diff --git a/cmd/run.go b/cmd/run.go index e3043558b7..24fa2861ab 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -119,15 +119,8 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } - st := newState(cliCtx.Context, c, l2ChainID, []state.ForkIDInterval{}, stateSqlDB, eventLog, needsExecutor, needsStateTree) - forkIDIntervals, err := forkIDIntervals(cliCtx.Context, st, etherman, c.NetworkConfig.Genesis.BlockNumber) - if err != nil { - log.Fatal("error getting forkIDs. Error: ", err) - } - st.UpdateForkIDIntervalsInMemory(forkIDIntervals) + st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false) - currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId - log.Infof("Fork ID read from POE SC = %v", forkIDIntervals[len(forkIDIntervals)-1].ForkId) c.Aggregator.ChainID = l2ChainID c.Sequencer.StreamServer.ChainID = l2ChainID log.Infof("Chain ID read from POE SC = %v", l2ChainID) @@ -212,6 +205,7 @@ func start(cliCtx *cli.Context) error { for _, a := range cliCtx.StringSlice(config.FlagHTTPAPI) { apis[a] = true } + st, _ := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, true) go runJSONRPCServer(*c, etherman, l2ChainID, poolInstance, st, apis) case SYNCHRONIZER: ev.Component = event.Component_Synchronizer @@ -459,7 +453,7 @@ func waitSignal(cancelFuncs []context.CancelFunc) { } } -func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDIntervals []state.ForkIDInterval, sqlDB *pgxpool.Pool, eventLog *event.EventLog, needsExecutor, needsStateTree bool) *state.State { +func newState(ctx context.Context, c *config.Config, etherman *etherman.Client, l2ChainID uint64, sqlDB *pgxpool.Pool, eventLog *event.EventLog, needsExecutor, needsStateTree, avoidForkIDInMemory bool) (*state.State, uint64) { stateDb := pgstatestorage.NewPostgresStorage(c.State, sqlDB) // Executor @@ -478,7 +472,7 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDInt stateCfg := state.Config{ MaxCumulativeGasUsed: c.State.Batch.Constraints.MaxCumulativeGasUsed, ChainID: l2ChainID, - ForkIDIntervals: forkIDIntervals, + ForkIDIntervals: []state.ForkIDInterval{}, MaxResourceExhaustedAttempts: c.Executor.MaxResourceExhaustedAttempts, WaitOnResourceExhaustion: c.Executor.WaitOnResourceExhaustion, ForkUpgradeBatchNumber: c.ForkUpgradeBatchNumber, @@ -486,6 +480,7 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDInt MaxLogsCount: c.RPC.MaxLogsCount, MaxLogsBlockRange: c.RPC.MaxLogsBlockRange, MaxNativeBlockHashBlockRange: c.RPC.MaxNativeBlockHashBlockRange, + AvoidForkIDInMemory: avoidForkIDInMemory, } allLeaves, err := stateDb.GetAllL1InfoRootEntries(ctx, nil) if err != nil { @@ -501,7 +496,17 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDInt } st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, mt) - return st + + forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.BlockNumber) + if err != nil { + log.Fatal("error getting forkIDs. Error: ", err) + } + st.UpdateForkIDIntervalsInMemory(forkIDIntervals) + + currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId + log.Infof("Fork ID read from POE SC = %v", forkIDIntervals[len(forkIDIntervals)-1].ForkId) + + return st, currentForkID } func createPool(cfgPool pool.Config, constraintsCfg state.BatchConstraintsCfg, l2ChainID uint64, st *state.State, eventLog *event.EventLog) *pool.Pool { diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 33c937c2dd..111fb8018b 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -76,4 +76,4 @@
"300ms"
URI is the server URI.
Host is the address to bind the metrics server
Port is the port to bind the metrics server
Enabled is the flag to enable/disable the metrics server
ProfilingHost is the address to bind the profiling server
ProfilingPort is the port to bind the profiling server
ProfilingEnabled is the flag to enable/disable the profiling server
Database name
Database User name
Database Password of the user
Host address of database
Port Number of database
EnableLog
MaxConns is the maximum number of connections in the pool.
Database name
Database User name
Database Password of the user
Host address of database
Port Number of database
EnableLog
MaxConns is the maximum number of connections in the pool.
MaxCumulativeGasUsed is the max gas allowed per batch
ChainID is the L2 ChainID provided by the Network Config
ForkIdIntervals is the list of fork id intervals
MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion
WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion
"1m"
"300ms"
-
Batch number from which there is a forkid change (fork upgrade)
New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade)
Database name
Database User name
Database Password of the user
Host address of database
Port Number of database
EnableLog
MaxConns is the maximum number of connections in the pool.
MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit
MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit
MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit