Files
hermez-node/common/block.go
Eduard S 20b8d0561f Update synchronizer and DB with last contracts updates
- API
	- When updating network info, handle cases where no batches exists and
	  where no forgers exists
- cli/node
	- Update `cfg.buidler.toml` config file to a working version
- common
	- Add new smart contract structs and extend some existing ones to
	  reflect updates regarding events from the smart contracts
- SQL
	- Add new tables and extend existing ones to reflect updates regarding
	  events from the smart contracts
- db/historydb
	- Add functions to insert new smart contract events data
	- Fix unclosed rows that led to inconsistent sql driver state (replace
	  NamedQuery by NamedExec).  This fixes the error:
	  `pq: unexpected Parse response 'C'`
- db/l2db
	- Close rows after usage
- eth
	- In Rollup event, introduce a new UpdateBucketsParameter when there's a
	  SafeMode event, with `SafeMode = true`
- synchronizer
	- synchronize new events
	- avoid calling `auction.CanForge` before the genesisBlock to avoid
	  getting a revert.
2020-12-10 17:45:17 +01:00

93 lines
2.6 KiB
Go

package common
import (
"math/big"
"time"
ethCommon "github.com/ethereum/go-ethereum/common"
)
// Block represents of an Ethereum block
type Block struct {
Num int64 `meddler:"eth_block_num"`
Timestamp time.Time `meddler:"timestamp,utctime"`
Hash ethCommon.Hash `meddler:"hash"`
ParentHash ethCommon.Hash `meddler:"-" json:"-"`
}
// RollupData contains information returned by the Rollup smart contract
type RollupData struct {
// L1UserTxs that were submitted in the block
L1UserTxs []L1Tx
Batches []BatchData
AddedTokens []Token
Withdrawals []WithdrawInfo
UpdateBucketWithdraw []BucketUpdate
TokenExchanges []TokenExchange
Vars *RollupVariables
}
// NewRollupData creates an empty RollupData with the slices initialized.
func NewRollupData() RollupData {
return RollupData{
L1UserTxs: make([]L1Tx, 0),
Batches: make([]BatchData, 0),
AddedTokens: make([]Token, 0),
Withdrawals: make([]WithdrawInfo, 0),
Vars: nil,
}
}
// AuctionData contains information returned by the Action smart contract
type AuctionData struct {
Bids []Bid
Coordinators []Coordinator
Vars *AuctionVariables
}
// NewAuctionData creates an empty AuctionData with the slices initialized.
func NewAuctionData() AuctionData {
return AuctionData{
Bids: make([]Bid, 0),
Coordinators: make([]Coordinator, 0),
Vars: nil,
}
}
// WDelayerTransfer represents a transfer (either deposit or withdrawal) in the
// WDelayer smart contract
type WDelayerTransfer struct {
Owner ethCommon.Address
Token ethCommon.Address
Amount *big.Int
// TxHash ethCommon.Hash // hash of the transaction in which the wdelayer transfer happened
}
// WDelayerData contains information returned by the WDelayer smart contract
type WDelayerData struct {
Vars *WDelayerVariables
Deposits []WDelayerTransfer
// We use an array because there can be multiple deposits in a single eth transaction
DepositsByTxHash map[ethCommon.Hash][]*WDelayerTransfer
Withdrawals []WDelayerTransfer
EscapeHatchWithdrawals []WDelayerEscapeHatchWithdrawal
}
// NewWDelayerData creates an empty WDelayerData.
func NewWDelayerData() WDelayerData {
return WDelayerData{
Vars: nil,
Deposits: make([]WDelayerTransfer, 0),
DepositsByTxHash: make(map[ethCommon.Hash][]*WDelayerTransfer),
Withdrawals: make([]WDelayerTransfer, 0),
}
}
// BlockData contains the information of a Block
type BlockData struct {
Block Block
Rollup RollupData
Auction AuctionData
WDelayer WDelayerData
}