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.

90 lines
2.5 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. "math/big"
  4. "time"
  5. ethCommon "github.com/ethereum/go-ethereum/common"
  6. )
  7. // Block represents of an Ethereum block
  8. type Block struct {
  9. EthBlockNum int64 `meddler:"eth_block_num"`
  10. Timestamp time.Time `meddler:"timestamp,utctime"`
  11. Hash ethCommon.Hash `meddler:"hash"`
  12. ParentHash ethCommon.Hash `meddler:"-"`
  13. }
  14. // RollupData contains information returned by the Rollup smart contract
  15. type RollupData struct {
  16. // L1UserTxs that were submitted in the block
  17. L1UserTxs []L1Tx
  18. Batches []BatchData
  19. AddedTokens []Token
  20. Withdrawals []WithdrawInfo
  21. Vars *RollupVariables
  22. }
  23. // NewRollupData creates an empty RollupData with the slices initialized.
  24. func NewRollupData() RollupData {
  25. return RollupData{
  26. L1UserTxs: make([]L1Tx, 0),
  27. Batches: make([]BatchData, 0),
  28. AddedTokens: make([]Token, 0),
  29. Withdrawals: make([]WithdrawInfo, 0),
  30. Vars: nil,
  31. }
  32. }
  33. // AuctionData contains information returned by the Action smart contract
  34. type AuctionData struct {
  35. Bids []Bid
  36. Coordinators []Coordinator
  37. Vars *AuctionVariables
  38. }
  39. // NewAuctionData creates an empty AuctionData with the slices initialized.
  40. func NewAuctionData() AuctionData {
  41. return AuctionData{
  42. Bids: make([]Bid, 0),
  43. Coordinators: make([]Coordinator, 0),
  44. Vars: nil,
  45. }
  46. }
  47. // WDelayerTransfer represents a transfer (either deposit or withdrawal) in the
  48. // WDelayer smart contract
  49. type WDelayerTransfer struct {
  50. Owner ethCommon.Address
  51. Token ethCommon.Address
  52. Amount *big.Int
  53. // TxHash ethCommon.Hash // hash of the transaction in which the wdelayer transfer happened
  54. }
  55. // WDelayerData contains information returned by the WDelayer smart contract
  56. type WDelayerData struct {
  57. Vars *WDelayerVariables
  58. Deposits []WDelayerTransfer
  59. DepositsByTxHash map[ethCommon.Hash]*WDelayerTransfer
  60. Withdrawals []WDelayerTransfer
  61. }
  62. // NewWDelayerData creates an empty WDelayerData.
  63. func NewWDelayerData() WDelayerData {
  64. return WDelayerData{
  65. Vars: nil,
  66. Deposits: make([]WDelayerTransfer, 0),
  67. DepositsByTxHash: make(map[ethCommon.Hash]*WDelayerTransfer),
  68. Withdrawals: make([]WDelayerTransfer, 0),
  69. }
  70. }
  71. // BlockData contains the information of a Block
  72. type BlockData struct {
  73. Block Block
  74. Rollup RollupData
  75. Auction AuctionData
  76. WDelayer WDelayerData
  77. // TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
  78. // WithdrawalDelayerVars *common.WithdrawalDelayerVars
  79. }