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.

99 lines
2.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
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
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. // RollupData contains information returned by the Rollup smart contract
  14. type RollupData struct {
  15. // L1UserTxs that were submitted in the block
  16. L1UserTxs []L1Tx
  17. Batches []BatchData
  18. AddedTokens []Token
  19. Withdrawals []WithdrawInfo
  20. Vars *RollupVariables
  21. }
  22. // NewRollupData creates an empty RollupData with the slices initialized.
  23. func NewRollupData() RollupData {
  24. return RollupData{
  25. L1UserTxs: make([]L1Tx, 0),
  26. Batches: make([]BatchData, 0),
  27. AddedTokens: make([]Token, 0),
  28. Withdrawals: make([]WithdrawInfo, 0),
  29. Vars: nil,
  30. }
  31. }
  32. // AuctionData contains information returned by the Action smart contract
  33. type AuctionData struct {
  34. Bids []Bid
  35. Coordinators []Coordinator
  36. Vars *AuctionVariables
  37. }
  38. // NewAuctionData creates an empty AuctionData with the slices initialized.
  39. func NewAuctionData() AuctionData {
  40. return AuctionData{
  41. Bids: make([]Bid, 0),
  42. Coordinators: make([]Coordinator, 0),
  43. Vars: nil,
  44. }
  45. }
  46. // WDelayerData contains information returned by the WDelayer smart contract
  47. type WDelayerData struct {
  48. Vars *WDelayerVariables
  49. }
  50. // NewWDelayerData creates an empty WDelayerData.
  51. func NewWDelayerData() WDelayerData {
  52. return WDelayerData{
  53. Vars: nil,
  54. }
  55. }
  56. // BlockData contains the information of a Block
  57. type BlockData struct {
  58. Block Block
  59. Rollup RollupData
  60. Auction AuctionData
  61. WDelayer WDelayerData
  62. // TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
  63. // WithdrawalDelayerVars *common.WithdrawalDelayerVars
  64. }
  65. // BatchData contains the information of a Batch
  66. type BatchData struct {
  67. // L1UserTxs that were forged in the batch
  68. L1Batch bool // TODO: Remove once Batch.ForgeL1TxsNum is a pointer
  69. // L1UserTxs []common.L1Tx
  70. L1CoordinatorTxs []L1Tx
  71. L2Txs []L2Tx
  72. CreatedAccounts []Account
  73. ExitTree []ExitInfo
  74. Batch Batch
  75. }
  76. // NewBatchData creates an empty BatchData with the slices initialized.
  77. func NewBatchData() *BatchData {
  78. return &BatchData{
  79. L1Batch: false,
  80. // L1UserTxs: make([]common.L1Tx, 0),
  81. L1CoordinatorTxs: make([]L1Tx, 0),
  82. L2Txs: make([]L2Tx, 0),
  83. CreatedAccounts: make([]Account, 0),
  84. ExitTree: make([]ExitInfo, 0),
  85. Batch: Batch{},
  86. }
  87. }