mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Use init SC vars and start block from events
Previously the Synchronizer required the initial variables of the smart contracts to be passed as a configuration parameter (that the node took from the configuration file). The same applied to the blockNumber. The last update of the smart contracts introduced events for each smart contract constructor (initializer), which allows querying the initial variables as well as the initial block number for each smart contract. Now the synchronizer uses this information, and thus the initial variables and the starting block numbers have been removed from the configuration.
This commit is contained in:
@@ -59,6 +59,27 @@ type RollupEventInitialize struct {
|
||||
WithdrawalDelay uint64
|
||||
}
|
||||
|
||||
// RollupVariables returns the RollupVariables from the initialize event
|
||||
func (ei *RollupEventInitialize) RollupVariables() *common.RollupVariables {
|
||||
var buckets [common.RollupConstNumBuckets]common.BucketParams
|
||||
for i := range buckets {
|
||||
buckets[i] = common.BucketParams{
|
||||
CeilUSD: big.NewInt(0),
|
||||
Withdrawals: big.NewInt(0),
|
||||
BlockWithdrawalRate: big.NewInt(0),
|
||||
MaxWithdrawals: big.NewInt(0),
|
||||
}
|
||||
}
|
||||
return &common.RollupVariables{
|
||||
EthBlockNum: 0,
|
||||
FeeAddToken: ei.FeeAddToken,
|
||||
ForgeL1L2BatchTimeout: int64(ei.ForgeL1L2BatchTimeout),
|
||||
WithdrawalDelay: ei.WithdrawalDelay,
|
||||
Buckets: buckets,
|
||||
SafeMode: false,
|
||||
}
|
||||
}
|
||||
|
||||
// RollupEventL1UserTx is an event of the Rollup Smart Contract
|
||||
type RollupEventL1UserTx struct {
|
||||
// ToForgeL1TxsNum int64 // QueueIndex *big.Int
|
||||
@@ -245,6 +266,7 @@ type RollupInterface interface {
|
||||
RollupConstants() (*common.RollupConstants, error)
|
||||
RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethCommon.Hash, error)
|
||||
RollupForgeBatchArgs(ethCommon.Hash, uint16) (*RollupForgeBatchArgs, *ethCommon.Address, error)
|
||||
RollupEventInit() (*RollupEventInitialize, int64, error)
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user