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.

58 lines
1.6 KiB

Update missing parts, improve til, and more - Node - Updated configuration to initialize the interface to all the smart contracts - Common - Moved BlockData and BatchData types to common so that they can be shared among: historydb, til and synchronizer - Remove hash.go (it was never used) - Remove slot.go (it was never used) - Remove smartcontractparams.go (it was never used, and appropriate structs are defined in `eth/`) - Comment state / status method until requirements of this method are properly defined, and move it to Synchronizer - Synchronizer - Simplify `Sync` routine to only sync one block per call, and return useful information. - Use BlockData and BatchData from common - Check that events belong to the expected block hash - In L1Batch, query L1UserTxs from HistoryDB - Fill ERC20 token information - Test AddTokens with test.Client - HistryDB - Use BlockData and BatchData from common - Add `GetAllTokens` method - Uncomment and update GetL1UserTxs (with corresponding tests) - Til - Rename all instances of RegisterToken to AddToken (to follow the smart contract implementation naming) - Use BlockData and BatchData from common - Move testL1CoordinatorTxs and testL2Txs to a separate struct from BatchData in Context - Start Context with BatchNum = 1 (which the protocol defines to be the first batchNum) - In every Batch, set StateRoot and ExitRoot to a non-nil big.Int (zero). - In all L1Txs, if LoadAmount is not used, set it to 0; if Amount is not used, set it to 0; so that no *big.Int is nil. - In L1UserTx, don't set BatchNum, because when L1UserTxs are created and obtained by the synchronizer, the BatchNum is not known yet (it's a synchronizer job to set it) - In L1UserTxs, set `UserOrigin` and set `ToForgeL1TxsNum`.
4 years ago
  1. package common
  2. import (
  3. "time"
  4. ethCommon "github.com/ethereum/go-ethereum/common"
  5. )
  6. // Block represents of an Ethereum block
  7. type Block struct {
  8. EthBlockNum int64 `meddler:"eth_block_num"`
  9. Timestamp time.Time `meddler:"timestamp,utctime"`
  10. Hash ethCommon.Hash `meddler:"hash"`
  11. ParentHash ethCommon.Hash `meddler:"-"`
  12. }
  13. // BlockData contains the information of a Block
  14. type BlockData struct {
  15. Block Block
  16. // Rollup
  17. // L1UserTxs that were submitted in the block
  18. L1UserTxs []L1Tx
  19. Batches []BatchData
  20. AddedTokens []Token
  21. RollupVars *RollupVars
  22. // Auction
  23. Bids []Bid
  24. Coordinators []Coordinator
  25. AuctionVars *AuctionVars
  26. WithdrawDelayerVars *WithdrawDelayerVars
  27. // TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
  28. // WithdrawalDelayerVars *common.WithdrawalDelayerVars
  29. }
  30. // BatchData contains the information of a Batch
  31. type BatchData struct {
  32. // L1UserTxs that were forged in the batch
  33. L1Batch bool // TODO: Remove once Batch.ForgeL1TxsNum is a pointer
  34. // L1UserTxs []common.L1Tx
  35. L1CoordinatorTxs []L1Tx
  36. L2Txs []L2Tx
  37. CreatedAccounts []Account
  38. ExitTree []ExitInfo
  39. Batch Batch
  40. }
  41. // NewBatchData creates an empty BatchData with the slices initialized.
  42. func NewBatchData() *BatchData {
  43. return &BatchData{
  44. L1Batch: false,
  45. // L1UserTxs: make([]common.L1Tx, 0),
  46. L1CoordinatorTxs: make([]L1Tx, 0),
  47. L2Txs: make([]L2Tx, 0),
  48. CreatedAccounts: make([]Account, 0),
  49. ExitTree: make([]ExitInfo, 0),
  50. Batch: Batch{},
  51. }
  52. }