mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
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:
@@ -15,7 +15,7 @@ import (
|
||||
// Block0 represents Ethereum's genesis block,
|
||||
// which is stored by default at HistoryDB
|
||||
var Block0 common.Block = common.Block{
|
||||
EthBlockNum: 0,
|
||||
Num: 0,
|
||||
Hash: ethCommon.Hash([32]byte{
|
||||
212, 229, 103, 64, 248, 118, 174, 248,
|
||||
192, 16, 184, 106, 64, 213, 245, 103,
|
||||
@@ -44,7 +44,7 @@ func GenBlocks(from, to int64) []common.Block {
|
||||
var blocks []common.Block
|
||||
for i := from; i < to; i++ {
|
||||
blocks = append(blocks, common.Block{
|
||||
EthBlockNum: i,
|
||||
Num: i,
|
||||
//nolint:gomnd
|
||||
Timestamp: time.Now().Add(time.Second * 13).UTC(),
|
||||
Hash: ethCommon.BigToHash(big.NewInt(int64(i))),
|
||||
@@ -62,7 +62,7 @@ func GenTokens(nTokens int, blocks []common.Block) (tokensToAddInDB []common.Tok
|
||||
Name: "NAME" + fmt.Sprint(i),
|
||||
Symbol: fmt.Sprint(i),
|
||||
Decimals: uint64(i + 1),
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
EthAddr: ethCommon.BigToAddress(big.NewInt(int64(i))),
|
||||
}
|
||||
tokensToAddInDB = append(tokensToAddInDB, token)
|
||||
@@ -87,7 +87,7 @@ func GenBatches(nBatches int, blocks []common.Block) []common.Batch {
|
||||
for i := 0; i < nBatches; i++ {
|
||||
batch := common.Batch{
|
||||
BatchNum: common.BatchNum(i + 1),
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
//nolint:gomnd
|
||||
ForgerAddr: ethCommon.BigToAddress(big.NewInt(6886723)),
|
||||
CollectedFees: collectedFees,
|
||||
@@ -161,7 +161,7 @@ func GenL1Txs(
|
||||
TokenID: token.TokenID,
|
||||
Amount: amount,
|
||||
LoadAmount: amount,
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
}
|
||||
if tx.UserOrigin {
|
||||
n := nextTxsNum
|
||||
@@ -287,7 +287,7 @@ func GenL2Txs(
|
||||
Amount: amount,
|
||||
Fee: fee,
|
||||
Nonce: common.Nonce(i + 1),
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
Type: randomTxType(i),
|
||||
}
|
||||
if i < nUserTxs {
|
||||
@@ -341,7 +341,7 @@ func GenCoordinators(nCoords int, blocks []common.Block) []common.Coordinator {
|
||||
coords := []common.Coordinator{}
|
||||
for i := 0; i < nCoords; i++ {
|
||||
coords = append(coords, common.Coordinator{
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
Forger: ethCommon.BigToAddress(big.NewInt(int64(i))),
|
||||
Bidder: ethCommon.BigToAddress(big.NewInt(int64(i))),
|
||||
URL: "https://foo.bar",
|
||||
@@ -363,7 +363,7 @@ func GenBids(nBids int, blocks []common.Block, coords []common.Coordinator) []co
|
||||
bids = append(bids, common.Bid{
|
||||
SlotNum: slotNum,
|
||||
BidValue: big.NewInt(int64(i)),
|
||||
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
|
||||
EthBlockNum: blocks[i%len(blocks)].Num,
|
||||
Bidder: coords[i%len(blocks)].Bidder,
|
||||
})
|
||||
}
|
||||
@@ -397,13 +397,13 @@ func GenExitTree(n int, batches []common.Batch, accounts []common.Account, block
|
||||
Balance: big.NewInt(int64(i) * 1000),
|
||||
}
|
||||
if i%2 == 0 {
|
||||
instant := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
instant := int64(blocks[i%len(blocks)].Num)
|
||||
exitTree[i].InstantWithdrawn = &instant
|
||||
} else if i%3 == 0 {
|
||||
delayedReq := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
delayedReq := int64(blocks[i%len(blocks)].Num)
|
||||
exitTree[i].DelayedWithdrawRequest = &delayedReq
|
||||
if i%9 == 0 {
|
||||
delayed := int64(blocks[i%len(blocks)].EthBlockNum)
|
||||
delayed := int64(blocks[i%len(blocks)].Num)
|
||||
exitTree[i].DelayedWithdrawn = &delayed
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user