Update coordinator, call all api update functions

- Common:
	- Rename Block.EthBlockNum to Block.Num to avoid unneeded repetition
- API:
	- Add UpdateNetworkInfoBlock to update just block information, to be
	  used when the node is not yet synchronized
- Node:
	- Call API.UpdateMetrics and UpdateRecommendedFee in a loop, with
	  configurable time intervals
- Synchronizer:
	- When mapping events by TxHash, use an array to support the possibility
	  of multiple calls of the same function happening in the same
	  transaction (for example, a smart contract in a single transaction
	  could call withdraw with delay twice, which would generate 2 withdraw
	  events, and 2 deposit events).
	- In Stats, keep entire LastBlock instead of just the blockNum
	- In Stats, add lastL1BatchBlock
	- Test Stats and SCVars
- Coordinator:
	- Enable writing the BatchInfo in every step of the pipeline to disk
	  (with JSON text files) for debugging purposes.
	- Move the Pipeline functionality from the Coordinator to its own struct
	  (Pipeline)
	- Implement shouldL1lL2Batch
	- In TxManager, implement logic to perform several attempts when doing
	  ethereum node RPC calls before considering the error. (Both for calls
	  to forgeBatch and transaction receipt)
	- In TxManager, reorganize the flow and note the specific points in
	  which actions are made when err != nil
- HistoryDB:
	- Implement GetLastL1BatchBlockNum: returns the blockNum of the latest
	  forged l1Batch, to help the coordinator decide when to forge an
	  L1Batch.
- EthereumClient and test.Client:
	- Update EthBlockByNumber to return the last block when the passed
	  number is -1.
This commit is contained in:
Eduard S
2020-11-20 14:46:01 +01:00
parent 58c9be3644
commit 8f1cf2f145
26 changed files with 1039 additions and 402 deletions

View File

@@ -33,7 +33,10 @@ type Slot struct {
BatchesLen int
BidValue *big.Int
BootCoord bool
Bidder ethCommon.Address
Forger ethCommon.Address
URL string
// Bidder, Forer and URL correspond to the winner of the slot (which is
// not always the highest bidder). These are the values of the
// coordinator that is able to forge exclusively before the deadline.
Bidder ethCommon.Address
Forger ethCommon.Address
URL string
}

View File

@@ -9,10 +9,10 @@ import (
// Block represents of an Ethereum block
type Block struct {
EthBlockNum int64 `meddler:"eth_block_num"`
Timestamp time.Time `meddler:"timestamp,utctime"`
Hash ethCommon.Hash `meddler:"hash"`
ParentHash ethCommon.Hash `meddler:"-"`
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
@@ -63,9 +63,10 @@ type WDelayerTransfer struct {
// WDelayerData contains information returned by the WDelayer smart contract
type WDelayerData struct {
Vars *WDelayerVariables
Deposits []WDelayerTransfer
DepositsByTxHash map[ethCommon.Hash]*WDelayerTransfer
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
}
@@ -74,7 +75,7 @@ func NewWDelayerData() WDelayerData {
return WDelayerData{
Vars: nil,
Deposits: make([]WDelayerTransfer, 0),
DepositsByTxHash: make(map[ethCommon.Hash]*WDelayerTransfer),
DepositsByTxHash: make(map[ethCommon.Hash][]*WDelayerTransfer),
Withdrawals: make([]WDelayerTransfer, 0),
}
}