You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

621 lines
21 KiB

  1. package test
  2. import (
  3. "context"
  4. "encoding/binary"
  5. "encoding/json"
  6. "fmt"
  7. "math/big"
  8. "time"
  9. ethCommon "github.com/ethereum/go-ethereum/common"
  10. "github.com/ethereum/go-ethereum/core/types"
  11. "github.com/hermeznetwork/hermez-node/common"
  12. "github.com/hermeznetwork/hermez-node/eth"
  13. "github.com/hermeznetwork/hermez-node/log"
  14. "github.com/hermeznetwork/hermez-node/utils"
  15. "github.com/iden3/go-iden3-crypto/babyjub"
  16. "github.com/mitchellh/copystructure"
  17. )
  18. // RollupBlock stores all the data related to the Rollup SC from an ethereum block
  19. type RollupBlock struct {
  20. State eth.RollupState
  21. Vars eth.RollupVariables
  22. Events eth.RollupEvents
  23. }
  24. // AuctionBlock stores all the data related to the Auction SC from an ethereum block
  25. type AuctionBlock struct {
  26. State eth.AuctionState
  27. Vars eth.AuctionVariables
  28. Events eth.AuctionEvents
  29. }
  30. // EthereumBlock stores all the generic data related to the an ethereum block
  31. type EthereumBlock struct {
  32. BlockNum int64
  33. Time int64
  34. Hash ethCommon.Hash
  35. ParentHash ethCommon.Hash
  36. // state ethState
  37. }
  38. // Block represents a ethereum block
  39. type Block struct {
  40. Rollup *RollupBlock
  41. Auction *AuctionBlock
  42. Eth *EthereumBlock
  43. }
  44. // type ethState struct {
  45. // blockNum int64
  46. // }
  47. // type state struct {
  48. // rollupState eth.RollupState
  49. // rollupVars eth.RollupVariables
  50. // auctionState eth.AuctionState
  51. // auctionVars eth.AuctionVariables
  52. // eth ethState
  53. // }
  54. // ClientSetup is used to initialize the constants of the Smart Contracts and
  55. // other details of the test Client
  56. type ClientSetup struct {
  57. RollupConstants *eth.RollupConstants
  58. RollupVariables *eth.RollupVariables
  59. AuctionConstants *eth.AuctionConstants
  60. AuctionVariables *eth.AuctionVariables
  61. VerifyProof bool
  62. }
  63. // Timer is an interface to simulate a source of time, useful to advance time
  64. // virtually.
  65. type Timer interface {
  66. Time() int64
  67. }
  68. // type forgeBatchArgs struct {
  69. // ethTx *types.Transaction
  70. // blockNum int64
  71. // blockHash ethCommon.Hash
  72. // }
  73. // Client implements the eth.ClientInterface interface, allowing to manipulate the
  74. // values for testing, working with deterministic results.
  75. type Client struct {
  76. log bool
  77. rollupConstants *eth.RollupConstants
  78. auctionConstants *eth.AuctionConstants
  79. blocks map[int64]*Block
  80. // state state
  81. blockNum int64 // last mined block num
  82. maxBlockNum int64 // highest block num calculated
  83. timer Timer
  84. hasher hasher
  85. forgeBatchArgsPending map[ethCommon.Hash]*eth.RollupForgeBatchArgs
  86. forgeBatchArgs map[ethCommon.Hash]*eth.RollupForgeBatchArgs
  87. }
  88. // NewClient returns a new test Client that implements the eth.IClient
  89. // interface, at the given initialBlockNumber.
  90. func NewClient(l bool, timer Timer, setup *ClientSetup) *Client {
  91. blocks := make(map[int64]*Block)
  92. blockNum := int64(0)
  93. hasher := hasher{}
  94. // Add ethereum genesis block
  95. mapL1TxQueue := make(map[int64]*eth.QueueStruct)
  96. mapL1TxQueue[0] = eth.NewQueueStruct()
  97. mapL1TxQueue[1] = eth.NewQueueStruct()
  98. blockCurrent := Block{
  99. Rollup: &RollupBlock{
  100. State: eth.RollupState{
  101. StateRoot: big.NewInt(0),
  102. ExitRoots: make([]*big.Int, 0),
  103. ExitNullifierMap: make(map[[256 / 8]byte]bool),
  104. TokenList: make([]ethCommon.Address, 0),
  105. TokenMap: make(map[ethCommon.Address]bool),
  106. MapL1TxQueue: mapL1TxQueue,
  107. LastL1L2Batch: 0,
  108. CurrentToForgeL1TxsNum: 0,
  109. LastToForgeL1TxsNum: 1,
  110. CurrentIdx: 0,
  111. },
  112. Vars: *setup.RollupVariables,
  113. Events: eth.NewRollupEvents(),
  114. },
  115. Auction: &AuctionBlock{
  116. State: eth.AuctionState{
  117. Slots: make(map[int64]eth.SlotState),
  118. PendingBalances: make(map[ethCommon.Address]*big.Int),
  119. Coordinators: make(map[ethCommon.Address]eth.Coordinator),
  120. },
  121. Vars: *setup.AuctionVariables,
  122. Events: eth.NewAuctionEvents(),
  123. },
  124. Eth: &EthereumBlock{
  125. BlockNum: blockNum,
  126. Time: timer.Time(),
  127. Hash: hasher.Next(),
  128. ParentHash: ethCommon.Hash{},
  129. },
  130. }
  131. blocks[blockNum] = &blockCurrent
  132. blockNextRaw, err := copystructure.Copy(&blockCurrent)
  133. if err != nil {
  134. panic(err)
  135. }
  136. blockNext := blockNextRaw.(*Block)
  137. blocks[blockNum+1] = blockNext
  138. return &Client{
  139. log: l,
  140. rollupConstants: setup.RollupConstants,
  141. auctionConstants: setup.AuctionConstants,
  142. blocks: blocks,
  143. timer: timer,
  144. hasher: hasher,
  145. forgeBatchArgsPending: make(map[ethCommon.Hash]*eth.RollupForgeBatchArgs),
  146. forgeBatchArgs: make(map[ethCommon.Hash]*eth.RollupForgeBatchArgs),
  147. }
  148. }
  149. //
  150. // Mock Control
  151. //
  152. // Debugf calls log.Debugf if c.log is true
  153. func (c *Client) Debugf(template string, args ...interface{}) {
  154. if c.log {
  155. log.Debugf(template, args...)
  156. }
  157. }
  158. // Debugw calls log.Debugw if c.log is true
  159. func (c *Client) Debugw(template string, kv ...interface{}) {
  160. if c.log {
  161. log.Debugw(template, kv...)
  162. }
  163. }
  164. type hasher struct {
  165. counter uint64
  166. }
  167. // Next returns the next hash
  168. func (h *hasher) Next() ethCommon.Hash {
  169. var hash ethCommon.Hash
  170. binary.LittleEndian.PutUint64(hash[:], h.counter)
  171. h.counter++
  172. return hash
  173. }
  174. func (c *Client) nextBlock() *Block {
  175. return c.blocks[c.blockNum+1]
  176. }
  177. // CtlMineBlock moves one block forward
  178. func (c *Client) CtlMineBlock() {
  179. blockCurrent := c.nextBlock()
  180. c.blockNum++
  181. c.maxBlockNum = c.blockNum
  182. blockCurrent.Eth = &EthereumBlock{
  183. BlockNum: c.blockNum,
  184. Time: c.timer.Time(),
  185. Hash: c.hasher.Next(),
  186. ParentHash: blockCurrent.Eth.Hash,
  187. }
  188. for ethTxHash, forgeBatchArgs := range c.forgeBatchArgsPending {
  189. c.forgeBatchArgs[ethTxHash] = forgeBatchArgs
  190. }
  191. c.forgeBatchArgsPending = make(map[ethCommon.Hash]*eth.RollupForgeBatchArgs)
  192. blockNextRaw, err := copystructure.Copy(blockCurrent)
  193. if err != nil {
  194. panic(err)
  195. }
  196. blockNext := blockNextRaw.(*Block)
  197. blockNext.Rollup.Events = eth.NewRollupEvents()
  198. blockNext.Auction.Events = eth.NewAuctionEvents()
  199. c.blocks[c.blockNum+1] = blockNext
  200. c.Debugw("TestClient mined block", "blockNum", c.blockNum)
  201. }
  202. // CtlRollback discards the last mined block. Use this to replace a mined
  203. // block to simulate reorgs.
  204. func (c *Client) CtlRollback() {
  205. if c.blockNum == 0 {
  206. panic("Can't rollback at blockNum = 0")
  207. }
  208. delete(c.blocks, c.blockNum+1) // delete next block
  209. delete(c.blocks, c.blockNum) // delete current block
  210. c.blockNum--
  211. blockCurrent := c.blocks[c.blockNum]
  212. blockNextRaw, err := copystructure.Copy(blockCurrent)
  213. if err != nil {
  214. panic(err)
  215. }
  216. blockNext := blockNextRaw.(*Block)
  217. blockNext.Rollup.Events = eth.NewRollupEvents()
  218. blockNext.Auction.Events = eth.NewAuctionEvents()
  219. c.blocks[c.blockNum+1] = blockNext
  220. }
  221. //
  222. // Ethereum
  223. //
  224. // EthCurrentBlock returns the current blockNum
  225. func (c *Client) EthCurrentBlock() (int64, error) {
  226. if c.blockNum < c.maxBlockNum {
  227. panic("blockNum has decreased. " +
  228. "After a rollback you must mine to reach the same or higher blockNum")
  229. }
  230. return c.blockNum, nil
  231. }
  232. // func newHeader(number *big.Int) *types.Header {
  233. // return &types.Header{
  234. // Number: number,
  235. // Time: uint64(number.Int64()),
  236. // }
  237. // }
  238. // EthHeaderByNumber returns the *types.Header for the given block number in a
  239. // deterministic way.
  240. // func (c *Client) EthHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) {
  241. // return newHeader(number), nil
  242. // }
  243. // EthBlockByNumber returns the *common.Block for the given block number in a
  244. // deterministic way.
  245. func (c *Client) EthBlockByNumber(ctx context.Context, blockNum int64) (*common.Block, error) {
  246. block, ok := c.blocks[blockNum]
  247. if !ok {
  248. return nil, fmt.Errorf("block not found")
  249. }
  250. return &common.Block{
  251. EthBlockNum: blockNum,
  252. Timestamp: time.Unix(block.Eth.Time, 0),
  253. Hash: block.Eth.Hash,
  254. ParentHash: block.Eth.ParentHash,
  255. }, nil
  256. }
  257. var errTODO = fmt.Errorf("TODO: Not implemented yet")
  258. //
  259. // Rollup
  260. //
  261. // CtlAddL1TxUser adds an L1TxUser to the L1UserTxs queue of the Rollup
  262. func (c *Client) CtlAddL1TxUser(l1Tx *common.L1Tx) {
  263. nextBlock := c.nextBlock()
  264. r := nextBlock.Rollup
  265. queue := r.State.MapL1TxQueue[r.State.LastToForgeL1TxsNum]
  266. if len(queue.L1TxQueue) >= c.rollupConstants.MaxL1UserTx {
  267. r.State.LastToForgeL1TxsNum++
  268. r.State.MapL1TxQueue[r.State.LastToForgeL1TxsNum] = eth.NewQueueStruct()
  269. queue = r.State.MapL1TxQueue[r.State.LastToForgeL1TxsNum]
  270. }
  271. if int64(l1Tx.FromIdx) > r.State.CurrentIdx {
  272. panic("l1Tx.FromIdx > r.State.CurrentIdx")
  273. }
  274. if int(l1Tx.TokenID)+1 > len(r.State.TokenList) {
  275. panic("l1Tx.TokenID + 1 > len(r.State.TokenList)")
  276. }
  277. queue.L1TxQueue = append(queue.L1TxQueue, *l1Tx)
  278. r.Events.L1UserTx = append(r.Events.L1UserTx, eth.RollupEventL1UserTx{L1Tx: *l1Tx})
  279. }
  280. func (c *Client) newTransaction(name string, value interface{}) *types.Transaction {
  281. data, err := json.Marshal(value)
  282. if err != nil {
  283. panic(err)
  284. }
  285. return types.NewTransaction(0, ethCommon.Address{}, nil, 0, nil,
  286. data)
  287. }
  288. // RollupForgeBatch is the interface to call the smart contract function
  289. func (c *Client) RollupForgeBatch(*eth.RollupForgeBatchArgs) (*types.Transaction, error) {
  290. return nil, errTODO
  291. }
  292. // CtlAddBatch adds forged batch to the Rollup, without checking any ZKProof
  293. func (c *Client) CtlAddBatch(args *eth.RollupForgeBatchArgs) {
  294. nextBlock := c.nextBlock()
  295. r := nextBlock.Rollup
  296. r.State.StateRoot = args.NewStRoot
  297. if args.NewLastIdx < r.State.CurrentIdx {
  298. panic("args.NewLastIdx < r.State.CurrentIdx")
  299. }
  300. r.State.CurrentIdx = args.NewLastIdx
  301. r.State.ExitRoots = append(r.State.ExitRoots, args.NewExitRoot)
  302. if args.L1Batch {
  303. r.State.CurrentToForgeL1TxsNum++
  304. if r.State.CurrentToForgeL1TxsNum == r.State.LastToForgeL1TxsNum {
  305. r.State.LastToForgeL1TxsNum++
  306. r.State.MapL1TxQueue[r.State.LastToForgeL1TxsNum] = eth.NewQueueStruct()
  307. }
  308. }
  309. ethTx := c.newTransaction("forgebatch", args)
  310. c.forgeBatchArgsPending[ethTx.Hash()] = args
  311. r.Events.ForgeBatch = append(r.Events.ForgeBatch, eth.RollupEventForgeBatch{
  312. BatchNum: int64(len(r.State.ExitRoots)),
  313. EthTxHash: ethTx.Hash(),
  314. })
  315. }
  316. // RollupAddToken is the interface to call the smart contract function
  317. func (c *Client) RollupAddToken(tokenAddress ethCommon.Address) (*types.Transaction, error) {
  318. nextBlock := c.nextBlock()
  319. r := nextBlock.Rollup
  320. if _, ok := r.State.TokenMap[tokenAddress]; ok {
  321. return nil, fmt.Errorf("Token %v already registered", tokenAddress)
  322. }
  323. r.State.TokenMap[tokenAddress] = true
  324. r.State.TokenList = append(r.State.TokenList, tokenAddress)
  325. r.Events.AddToken = append(r.Events.AddToken, eth.RollupEventAddToken{Address: tokenAddress,
  326. TokenID: uint32(len(r.State.TokenList) - 1)})
  327. return c.newTransaction("addtoken", tokenAddress), nil
  328. }
  329. // RollupWithdrawSNARK is the interface to call the smart contract function
  330. // func (c *Client) RollupWithdrawSNARK() (*types.Transaction, error) { // TODO (Not defined in Hermez.sol)
  331. // return nil, errTODO
  332. // }
  333. // RollupWithdrawMerkleProof is the interface to call the smart contract function
  334. func (c *Client) RollupWithdrawMerkleProof(tokenID int64, balance *big.Int, babyPubKey *babyjub.PublicKey, numExitRoot int64, siblings []*big.Int, idx int64, instantWithdraw bool) (*types.Transaction, error) {
  335. return nil, errTODO
  336. }
  337. // RollupForceExit is the interface to call the smart contract function
  338. func (c *Client) RollupForceExit(fromIdx int64, amountF utils.Float16, tokenID int64) (*types.Transaction, error) {
  339. return nil, errTODO
  340. }
  341. // RollupForceTransfer is the interface to call the smart contract function
  342. func (c *Client) RollupForceTransfer(fromIdx int64, amountF utils.Float16, tokenID, toIdx int64) (*types.Transaction, error) {
  343. return nil, errTODO
  344. }
  345. // RollupCreateAccountDepositTransfer is the interface to call the smart contract function
  346. func (c *Client) RollupCreateAccountDepositTransfer(babyPubKey babyjub.PublicKey, loadAmountF, amountF utils.Float16, tokenID int64, toIdx int64) (*types.Transaction, error) {
  347. return nil, errTODO
  348. }
  349. // RollupDepositTransfer is the interface to call the smart contract function
  350. func (c *Client) RollupDepositTransfer(fromIdx int64, loadAmountF, amountF utils.Float16, tokenID int64, toIdx int64) (*types.Transaction, error) {
  351. return nil, errTODO
  352. }
  353. // RollupDeposit is the interface to call the smart contract function
  354. func (c *Client) RollupDeposit(fromIdx int64, loadAmountF utils.Float16, tokenID int64) (*types.Transaction, error) {
  355. return nil, errTODO
  356. }
  357. // RollupCreateAccountDepositFromRelayer is the interface to call the smart contract function
  358. func (c *Client) RollupCreateAccountDepositFromRelayer(accountCreationAuthSig []byte, babyPubKey babyjub.PublicKey, loadAmountF utils.Float16) (*types.Transaction, error) {
  359. return nil, errTODO
  360. }
  361. // RollupCreateAccountDeposit is the interface to call the smart contract function
  362. func (c *Client) RollupCreateAccountDeposit(babyPubKey babyjub.PublicKey, loadAmountF utils.Float16, tokenID int64) (*types.Transaction, error) {
  363. return nil, errTODO
  364. }
  365. // RollupGetTokenAddress is the interface to call the smart contract function
  366. func (c *Client) RollupGetTokenAddress(tokenID int64) (*ethCommon.Address, error) {
  367. return nil, errTODO
  368. }
  369. // RollupGetL1TxFromQueue is the interface to call the smart contract function
  370. func (c *Client) RollupGetL1TxFromQueue(queue int64, position int64) ([]byte, error) {
  371. return nil, errTODO
  372. }
  373. // RollupGetQueue is the interface to call the smart contract function
  374. func (c *Client) RollupGetQueue(queue int64) ([]byte, error) {
  375. return nil, errTODO
  376. }
  377. // RollupUpdateForgeL1Timeout is the interface to call the smart contract function
  378. func (c *Client) RollupUpdateForgeL1Timeout(newForgeL1Timeout int64) (*types.Transaction, error) {
  379. return nil, errTODO
  380. }
  381. // RollupUpdateFeeL1UserTx is the interface to call the smart contract function
  382. func (c *Client) RollupUpdateFeeL1UserTx(newFeeL1UserTx *big.Int) (*types.Transaction, error) {
  383. return nil, errTODO
  384. }
  385. // RollupUpdateFeeAddToken is the interface to call the smart contract function
  386. func (c *Client) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (*types.Transaction, error) {
  387. return nil, errTODO
  388. }
  389. // RollupUpdateTokensHEZ is the interface to call the smart contract function
  390. func (c *Client) RollupUpdateTokensHEZ(newTokenHEZ ethCommon.Address) (*types.Transaction, error) {
  391. return nil, errTODO
  392. }
  393. // RollupUpdateGovernance is the interface to call the smart contract function
  394. // func (c *Client) RollupUpdateGovernance() (*types.Transaction, error) { // TODO (Not defined in Hermez.sol)
  395. // return nil, errTODO
  396. // }
  397. // RollupConstants returns the Constants of the Rollup Smart Contract
  398. func (c *Client) RollupConstants() (*eth.RollupConstants, error) {
  399. return nil, errTODO
  400. }
  401. // RollupEventsByBlock returns the events in a block that happened in the Rollup Smart Contract
  402. func (c *Client) RollupEventsByBlock(blockNum int64) (*eth.RollupEvents, *ethCommon.Hash, error) {
  403. block, ok := c.blocks[blockNum]
  404. if !ok {
  405. return nil, nil, fmt.Errorf("Block %v doesn't exist", blockNum)
  406. }
  407. return &block.Rollup.Events, &block.Eth.Hash, nil
  408. }
  409. // RollupForgeBatchArgs returns the arguments used in a ForgeBatch call in the Rollup Smart Contract in the given transaction
  410. func (c *Client) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*eth.RollupForgeBatchArgs, error) {
  411. forgeBatchArgs, ok := c.forgeBatchArgs[ethTxHash]
  412. if !ok {
  413. return nil, fmt.Errorf("transaction not found")
  414. }
  415. return forgeBatchArgs, nil
  416. }
  417. //
  418. // Auction
  419. //
  420. // AuctionSetSlotDeadline is the interface to call the smart contract function
  421. func (c *Client) AuctionSetSlotDeadline(newDeadline uint8) (*types.Transaction, error) {
  422. return nil, errTODO
  423. }
  424. // AuctionGetSlotDeadline is the interface to call the smart contract function
  425. func (c *Client) AuctionGetSlotDeadline() (uint8, error) {
  426. return 0, errTODO
  427. }
  428. // AuctionSetOpenAuctionSlots is the interface to call the smart contract function
  429. func (c *Client) AuctionSetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) {
  430. return nil, errTODO
  431. }
  432. // AuctionGetOpenAuctionSlots is the interface to call the smart contract function
  433. func (c *Client) AuctionGetOpenAuctionSlots() (uint16, error) { return 0, errTODO }
  434. // AuctionSetClosedAuctionSlots is the interface to call the smart contract function
  435. func (c *Client) AuctionSetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) {
  436. return nil, errTODO
  437. }
  438. // AuctionGetClosedAuctionSlots is the interface to call the smart contract function
  439. func (c *Client) AuctionGetClosedAuctionSlots() (uint16, error) {
  440. return 0, errTODO
  441. }
  442. // AuctionSetOutbidding is the interface to call the smart contract function
  443. func (c *Client) AuctionSetOutbidding(newOutbidding uint8) (*types.Transaction, error) {
  444. return nil, errTODO
  445. }
  446. // AuctionGetOutbidding is the interface to call the smart contract function
  447. func (c *Client) AuctionGetOutbidding() (uint8, error) {
  448. return 0, errTODO
  449. }
  450. // AuctionSetAllocationRatio is the interface to call the smart contract function
  451. func (c *Client) AuctionSetAllocationRatio(newAllocationRatio [3]uint8) (*types.Transaction, error) {
  452. return nil, errTODO
  453. }
  454. // AuctionGetAllocationRatio is the interface to call the smart contract function
  455. func (c *Client) AuctionGetAllocationRatio() ([3]uint8, error) {
  456. return [3]uint8{}, errTODO
  457. }
  458. // AuctionSetDonationAddress is the interface to call the smart contract function
  459. func (c *Client) AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error) {
  460. return nil, errTODO
  461. }
  462. // AuctionGetDonationAddress is the interface to call the smart contract function
  463. func (c *Client) AuctionGetDonationAddress() (*ethCommon.Address, error) {
  464. return nil, errTODO
  465. }
  466. // AuctionSetBootCoordinator is the interface to call the smart contract function
  467. func (c *Client) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (*types.Transaction, error) {
  468. return nil, errTODO
  469. }
  470. // AuctionGetBootCoordinator is the interface to call the smart contract function
  471. func (c *Client) AuctionGetBootCoordinator() (*ethCommon.Address, error) {
  472. return nil, errTODO
  473. }
  474. // AuctionChangeEpochMinBid is the interface to call the smart contract function
  475. func (c *Client) AuctionChangeEpochMinBid(slotEpoch int64, newInitialMinBid *big.Int) (*types.Transaction, error) {
  476. return nil, errTODO
  477. }
  478. // AuctionRegisterCoordinator is the interface to call the smart contract function
  479. func (c *Client) AuctionRegisterCoordinator(forgerAddress ethCommon.Address, URL string) (*types.Transaction, error) {
  480. return nil, errTODO
  481. }
  482. // AuctionIsRegisteredCoordinator is the interface to call the smart contract function
  483. func (c *Client) AuctionIsRegisteredCoordinator(forgerAddress ethCommon.Address) (bool, error) {
  484. return false, errTODO
  485. }
  486. // AuctionUpdateCoordinatorInfo is the interface to call the smart contract function
  487. func (c *Client) AuctionUpdateCoordinatorInfo(forgerAddress ethCommon.Address, newWithdrawAddress ethCommon.Address, newURL string) (*types.Transaction, error) {
  488. return nil, errTODO
  489. }
  490. // AuctionGetCurrentSlotNumber is the interface to call the smart contract function
  491. func (c *Client) AuctionGetCurrentSlotNumber() (int64, error) {
  492. return 0, errTODO
  493. }
  494. // AuctionGetMinBidBySlot is the interface to call the smart contract function
  495. func (c *Client) AuctionGetMinBidBySlot(slot int64) (*big.Int, error) {
  496. return nil, errTODO
  497. }
  498. // AuctionGetMinBidEpoch is the interface to call the smart contract function
  499. func (c *Client) AuctionGetMinBidEpoch(epoch uint8) (*big.Int, error) {
  500. return nil, errTODO
  501. }
  502. // AuctionTokensReceived is the interface to call the smart contract function
  503. // func (c *Client) AuctionTokensReceived(operator, from, to ethCommon.Address, amount *big.Int, userData, operatorData []byte) error {
  504. // return errTODO
  505. // }
  506. // AuctionBid is the interface to call the smart contract function
  507. func (c *Client) AuctionBid(slot int64, bidAmount *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
  508. return nil, errTODO
  509. }
  510. // AuctionMultiBid is the interface to call the smart contract function
  511. func (c *Client) AuctionMultiBid(startingSlot int64, endingSlot int64, slotEpoch [6]bool, maxBid, closedMinBid, budget *big.Int, forger ethCommon.Address) (*types.Transaction, error) {
  512. return nil, errTODO
  513. }
  514. // AuctionCanForge is the interface to call the smart contract function
  515. func (c *Client) AuctionCanForge(forger ethCommon.Address) (bool, error) {
  516. return false, errTODO
  517. }
  518. // AuctionForge is the interface to call the smart contract function
  519. // func (c *Client) AuctionForge(forger ethCommon.Address) (bool, error) {
  520. // return false, errTODO
  521. // }
  522. // AuctionClaimHEZ is the interface to call the smart contract function
  523. func (c *Client) AuctionClaimHEZ() (*types.Transaction, error) {
  524. return nil, errTODO
  525. }
  526. // AuctionConstants returns the Constants of the Auction Smart Contract
  527. func (c *Client) AuctionConstants() (*eth.AuctionConstants, error) {
  528. return nil, errTODO
  529. }
  530. // AuctionEventsByBlock returns the events in a block that happened in the Auction Smart Contract
  531. func (c *Client) AuctionEventsByBlock(blockNum int64) (*eth.AuctionEvents, *ethCommon.Hash, error) {
  532. return nil, nil, errTODO
  533. }