hermez-node/common/block.go
common/block.goRaw
1package common
2
3import (
4 "time"
5
6 ethCommon "github.com/ethereum/go-ethereum/common"
7)
8
9// Block represents of an Ethereum block
10type Block struct {
11 EthBlockNum int64 `meddler:"eth_block_num"`
12 Timestamp time.Time `meddler:"timestamp,utctime"`
13 Hash ethCommon.Hash `meddler:"hash"`
14 ParentHash ethCommon.Hash `meddler:"-"`
15}
16
17// RollupData contains information returned by the Rollup smart contract
18type RollupData struct {
19 // L1UserTxs that were submitted in the block
20 L1UserTxs []L1Tx
21 Batches []BatchData
22 AddedTokens []Token
23 Withdrawals []WithdrawInfo
24 Vars *RollupVariables
25}
26
27// NewRollupData creates an empty RollupData with the slices initialized.
28func NewRollupData() RollupData {
29 return RollupData{
30 L1UserTxs: make([]L1Tx, 0),
31 Batches: make([]BatchData, 0),
32 AddedTokens: make([]Token, 0),
33 Withdrawals: make([]WithdrawInfo, 0),
34 Vars: nil,
35 }
36}
37
38// AuctionData contains information returned by the Action smart contract
39type AuctionData struct {
40 Bids []Bid
41 Coordinators []Coordinator
42 Vars *AuctionVariables
43}
44
45// NewAuctionData creates an empty AuctionData with the slices initialized.
46func NewAuctionData() AuctionData {
47 return AuctionData{
48 Bids: make([]Bid, 0),
49 Coordinators: make([]Coordinator, 0),
50 Vars: nil,
51 }
52}
53
54// WDelayerData contains information returned by the WDelayer smart contract
55type WDelayerData struct {
56 Vars *WDelayerVariables
57}
58
59// NewWDelayerData creates an empty WDelayerData.
60func NewWDelayerData() WDelayerData {
61 return WDelayerData{
62 Vars: nil,
63 }
64}
65
66// BlockData contains the information of a Block
67type BlockData struct {
68 Block Block
69 Rollup RollupData
70 Auction AuctionData
71 WDelayer WDelayerData
72 // TODO: enable when common.WithdrawalDelayerVars is Merged from Synchronizer PR
73 // WithdrawalDelayerVars *common.WithdrawalDelayerVars
74}
75
76// BatchData contains the information of a Batch
77type BatchData struct {
78 // L1UserTxs that were forged in the batch
79 L1Batch bool // TODO: Remove once Batch.ForgeL1TxsNum is a pointer
80 // L1UserTxs []common.L1Tx
81 L1CoordinatorTxs []L1Tx
82 L2Txs []L2Tx
83 CreatedAccounts []Account
84 ExitTree []ExitInfo
85 Batch Batch
86}
87
88// NewBatchData creates an empty BatchData with the slices initialized.
89func NewBatchData() *BatchData {
90 return &BatchData{
91 L1Batch: false,
92 // L1UserTxs: make([]common.L1Tx, 0),
93 L1CoordinatorTxs: make([]L1Tx, 0),
94 L2Txs: make([]L2Tx, 0),
95 CreatedAccounts: make([]Account, 0),
96 ExitTree: make([]ExitInfo, 0),
97 Batch: Batch{},
98 }
99}