mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
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.
This commit is contained in:
@@ -18,11 +18,13 @@ type Block struct {
|
||||
// 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
|
||||
Vars *RollupVariables
|
||||
L1UserTxs []L1Tx
|
||||
Batches []BatchData
|
||||
AddedTokens []Token
|
||||
Withdrawals []WithdrawInfo
|
||||
UpdateBucketWithdraw []BucketUpdate
|
||||
TokenExchanges []TokenExchange
|
||||
Vars *RollupVariables
|
||||
}
|
||||
|
||||
// NewRollupData creates an empty RollupData with the slices initialized.
|
||||
@@ -66,8 +68,9 @@ 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
|
||||
DepositsByTxHash map[ethCommon.Hash][]*WDelayerTransfer
|
||||
Withdrawals []WDelayerTransfer
|
||||
EscapeHatchWithdrawals []WDelayerEscapeHatchWithdrawal
|
||||
}
|
||||
|
||||
// NewWDelayerData creates an empty WDelayerData.
|
||||
|
||||
@@ -146,22 +146,40 @@ type RollupConstants struct {
|
||||
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
||||
}
|
||||
|
||||
// Bucket are the variables of each Bucket of Rollup Smart Contract
|
||||
type Bucket struct {
|
||||
CeilUSD uint64 `json:"ceilUSD"`
|
||||
BlockStamp uint64 `json:"blockStamp"`
|
||||
Withdrawals uint64 `json:"withdrawals"`
|
||||
BlockWithdrawalRate uint64 `json:"blockWithdrawalRate"`
|
||||
MaxWithdrawals uint64 `json:"maxWithdrawals"`
|
||||
// BucketParams are the parameter variables of each Bucket of Rollup Smart
|
||||
// Contract
|
||||
type BucketParams struct {
|
||||
CeilUSD *big.Int `json:"ceilUSD"`
|
||||
Withdrawals *big.Int `json:"withdrawals"`
|
||||
BlockWithdrawalRate *big.Int `json:"blockWithdrawalRate"`
|
||||
MaxWithdrawals *big.Int `json:"maxWithdrawals"`
|
||||
}
|
||||
|
||||
// BucketUpdate are the bucket updates (tracking the withdrawals value changes)
|
||||
// in Rollup Smart Contract
|
||||
type BucketUpdate struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
NumBucket int `json:"numBucket" meddler:"num_bucket"`
|
||||
BlockStamp int64 `json:"blockStamp" meddler:"block_stamp"`
|
||||
Withdrawals *big.Int `json:"withdrawals" meddler:"withdrawals,bigint"`
|
||||
}
|
||||
|
||||
// TokenExchange are the exchange value for tokens registered in the Rollup
|
||||
// Smart Contract
|
||||
type TokenExchange struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
Address ethCommon.Address `json:"address" meddler:"eth_addr"`
|
||||
ValueUSD int64 `json:"valueUSD" meddler:"value_usd"`
|
||||
}
|
||||
|
||||
// RollupVariables are the variables of the Rollup Smart Contract
|
||||
type RollupVariables struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
FeeAddToken *big.Int `json:"feeAddToken" meddler:"fee_add_token,bigint" validate:"required"`
|
||||
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||
Buckets [RollupConstNumBuckets]Bucket `json:"buckets" meddler:"buckets,json"`
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
FeeAddToken *big.Int `json:"feeAddToken" meddler:"fee_add_token,bigint" validate:"required"`
|
||||
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||
Buckets [RollupConstNumBuckets]BucketParams `json:"buckets" meddler:"buckets,json"`
|
||||
SafeMode bool `json:"safeMode" meddler:"safe_mode"`
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the Variables
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package common
|
||||
|
||||
import ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// WDelayerConstants are the constants of the Withdrawal Delayer Smart Contract
|
||||
type WDelayerConstants struct {
|
||||
@@ -12,6 +16,16 @@ type WDelayerConstants struct {
|
||||
HermezRollup ethCommon.Address `json:"hermezRollup"`
|
||||
}
|
||||
|
||||
// WDelayerEscapeHatchWithdrawal is an escape hatch withdrawal of the
|
||||
// Withdrawal Delayer Smart Contract
|
||||
type WDelayerEscapeHatchWithdrawal struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
Who ethCommon.Address `json:"who" meddler:"who_addr"`
|
||||
To ethCommon.Address `json:"to" meddler:"to_addr"`
|
||||
TokenAddr ethCommon.Address `json:"tokenAddr" meddler:"token_addr"`
|
||||
Amount *big.Int `json:"amount" meddler:"amount,bigint"`
|
||||
}
|
||||
|
||||
// WDelayerVariables are the variables of the Withdrawal Delayer Smart Contract
|
||||
type WDelayerVariables struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
|
||||
@@ -228,12 +228,12 @@ func L1TxFromDataAvailability(b []byte, nLevels uint32) (*L1Tx, error) {
|
||||
l1tx := L1Tx{}
|
||||
fromIdx, err := IdxFromBytes(ethCommon.LeftPadBytes(fromIdxBytes, 6))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
l1tx.FromIdx = fromIdx
|
||||
toIdx, err := IdxFromBytes(ethCommon.LeftPadBytes(toIdxBytes, 6))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
l1tx.ToIdx = toIdx
|
||||
l1tx.EffectiveAmount = Float16FromBytes(amountBytes).BigInt()
|
||||
|
||||
Reference in New Issue
Block a user