diff --git a/cmd/dumpstate.go b/cmd/dumpstate.go index 05b0bbea4e..6fc3b3156c 100644 --- a/cmd/dumpstate.go +++ b/cmd/dumpstate.go @@ -109,7 +109,7 @@ func dumpState(ctx *cli.Context) error { } // Connect to SQL - stateSqlDB, err := db.NewSQLDB(c.StateDB) + stateSqlDB, err := db.NewSQLDB(c.State.DB) if err != nil { return err } diff --git a/cmd/restore.go b/cmd/restore.go index 10e364338c..b31abbdf9a 100644 --- a/cmd/restore.go +++ b/cmd/restore.go @@ -46,25 +46,25 @@ func restore(ctx *cli.Context) error { } // Run migrations to create schemas and tables - runStateMigrations(c.StateDB) + runStateMigrations(c.State.DB) - port, err := strconv.Atoi(c.StateDB.Port) + port, err := strconv.Atoi(c.State.DB.Port) if err != nil { log.Error("error converting port to int. Error: ", err) return err } restore, err := pg.NewRestore(&pg.Postgres{ - Host: c.StateDB.Host, + Host: c.State.DB.Host, Port: port, - DB: c.StateDB.Name, - Username: c.StateDB.User, - Password: c.StateDB.Password, + DB: c.State.DB.Name, + Username: c.State.DB.User, + Password: c.State.DB.Password, }) if err != nil { log.Error("error: ", err) return err } - restore.Role = c.StateDB.User + restore.Role = c.State.DB.User restore.Schemas = append(restore.Schemas, "state") log.Info("Restore stateDB snapshot started, please wait...") restoreExec := restore.Exec(inputFileStateDB, pg.ExecOptions{StreamPrint: false}) diff --git a/cmd/run.go b/cmd/run.go index fd184cc665..0261335ea2 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -61,11 +61,11 @@ func start(cliCtx *cli.Context) error { if !cliCtx.Bool(config.FlagMigrations) { for _, comp := range components { if comp == SYNCHRONIZER { - runStateMigrations(c.StateDB) + runStateMigrations(c.State.DB) } } } - checkStateMigrations(c.StateDB) + checkStateMigrations(c.State.DB) // Decide if this node instance needs an executor and/or a state tree var needsExecutor, needsStateTree bool @@ -96,7 +96,7 @@ func start(cliCtx *cli.Context) error { eventLog = event.NewEventLog(c.EventLog, eventStorage) // Core State DB - stateSqlDB, err := db.NewSQLDB(c.StateDB) + stateSqlDB, err := db.NewSQLDB(c.State.DB) if err != nil { log.Fatal(err) } @@ -133,7 +133,7 @@ func start(cliCtx *cli.Context) error { ctx := context.Background() st := newState(ctx, c, l2ChainID, forkIDIntervals, stateSqlDB, eventLog, needsExecutor, needsStateTree) - ethTxManagerStorage, err := ethtxmanager.NewPostgresStorage(c.StateDB) + ethTxManagerStorage, err := ethtxmanager.NewPostgresStorage(c.State.DB) if err != nil { log.Fatal(err) } @@ -170,7 +170,7 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } if poolInstance == nil { - poolInstance = createPool(c.Pool, l2ChainID, st, eventLog) + poolInstance = createPool(c.Pool, c.State.Batch.Constraints, l2ChainID, st, eventLog) } seq := createSequencer(*c, poolInstance, ethTxManagerStorage, st, eventLog) go seq.Start(ctx) @@ -182,7 +182,7 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } if poolInstance == nil { - poolInstance = createPool(c.Pool, l2ChainID, st, eventLog) + poolInstance = createPool(c.Pool, c.State.Batch.Constraints, l2ChainID, st, eventLog) } seqSender := createSequenceSender(*c, poolInstance, ethTxManagerStorage, st, eventLog) go seqSender.Start(ctx) @@ -194,7 +194,7 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } if poolInstance == nil { - poolInstance = createPool(c.Pool, l2ChainID, st, eventLog) + poolInstance = createPool(c.Pool, c.State.Batch.Constraints, l2ChainID, st, eventLog) } if c.RPC.EnableL2SuggestedGasPricePolling { // Needed for rejecting transactions with too low gas price @@ -213,7 +213,7 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } if poolInstance == nil { - poolInstance = createPool(c.Pool, l2ChainID, st, eventLog) + poolInstance = createPool(c.Pool, c.State.Batch.Constraints, l2ChainID, st, eventLog) } go runSynchronizer(*c, etherman, etm, st, poolInstance, eventLog) case ETHTXMANAGER: @@ -233,7 +233,7 @@ func start(cliCtx *cli.Context) error { log.Fatal(err) } if poolInstance == nil { - poolInstance = createPool(c.Pool, l2ChainID, st, eventLog) + poolInstance = createPool(c.Pool, c.State.Batch.Constraints, l2ChainID, st, eventLog) } go runL2GasPriceSuggester(c.L2GasPriceSuggester, st, poolInstance, etherman) } @@ -315,7 +315,7 @@ func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManager func runJSONRPCServer(c config.Config, etherman *etherman.Client, chainID uint64, pool *pool.Pool, st *state.State, apis map[string]bool) { var err error storage := jsonrpc.NewStorage() - c.RPC.MaxCumulativeGasUsed = c.Sequencer.MaxCumulativeGasUsed + c.RPC.MaxCumulativeGasUsed = c.State.Batch.Constraints.MaxCumulativeGasUsed if !c.IsTrustedSequencer { if c.RPC.SequencerNodeURI == "" { log.Debug("getting trusted sequencer URL from smc") @@ -383,7 +383,7 @@ func createSequencer(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanage ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st) - seq, err := sequencer.New(cfg.Sequencer, pool, st, etherman, ethTxManager, eventLog) + seq, err := sequencer.New(cfg.Sequencer, cfg.State.Batch, pool, st, etherman, ethTxManager, eventLog) if err != nil { log.Fatal(err) } @@ -466,7 +466,7 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDInt } stateCfg := state.Config{ - MaxCumulativeGasUsed: c.Sequencer.MaxCumulativeGasUsed, + MaxCumulativeGasUsed: c.State.Batch.Constraints.MaxCumulativeGasUsed, ChainID: l2ChainID, ForkIDIntervals: forkIDIntervals, MaxResourceExhaustedAttempts: c.Executor.MaxResourceExhaustedAttempts, @@ -479,13 +479,13 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, forkIDInt return st } -func createPool(cfgPool pool.Config, l2ChainID uint64, st *state.State, eventLog *event.EventLog) *pool.Pool { +func createPool(cfgPool pool.Config, constraintsCfg state.BatchConstraintsCfg, l2ChainID uint64, st *state.State, eventLog *event.EventLog) *pool.Pool { runPoolMigrations(cfgPool.DB) poolStorage, err := pgpoolstorage.NewPostgresPoolStorage(cfgPool.DB) if err != nil { log.Fatal(err) } - poolInstance := pool.NewPool(cfgPool, poolStorage, st, l2ChainID, eventLog) + poolInstance := pool.NewPool(cfgPool, constraintsCfg, poolStorage, st, l2ChainID, eventLog) return poolInstance } diff --git a/cmd/snapshot.go b/cmd/snapshot.go index 4605772e12..01d7562654 100644 --- a/cmd/snapshot.go +++ b/cmd/snapshot.go @@ -25,17 +25,17 @@ func snapshot(ctx *cli.Context) error { } setupLog(c.Log) - port, err := strconv.Atoi(c.StateDB.Port) + port, err := strconv.Atoi(c.State.DB.Port) if err != nil { log.Error("error converting port to int. Error: ", err) return err } dump, err := pg.NewDump(&pg.Postgres{ - Host: c.StateDB.Host, + Host: c.State.DB.Host, Port: port, - DB: c.StateDB.Name, - Username: c.StateDB.User, - Password: c.StateDB.Password, + DB: c.State.DB.Name, + Username: c.State.DB.User, + Password: c.State.DB.Password, }) if err != nil { log.Error("error: ", err) diff --git a/config/config.go b/config/config.go index 9660faac75..acfb2186f8 100644 --- a/config/config.go +++ b/config/config.go @@ -18,6 +18,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/sequencer" "github.com/0xPolygonHermez/zkevm-node/sequencesender" + "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" "github.com/0xPolygonHermez/zkevm-node/synchronizer" "github.com/mitchellh/mapstructure" @@ -108,14 +109,14 @@ type Config struct { Executor executor.Config // Configuration of the merkle tree client service. Not use in the node, only for testing MTClient merkletree.Config - // Configuration of the state database connection - StateDB db.Config // Configuration of the metrics service, basically is where is going to publish the metrics Metrics metrics.Config // Configuration of the event database connection EventLog event.Config // Configuration of the hash database connection HashDB db.Config + // State service configuration + State state.Config } // Default parses the default configuration values. diff --git a/config/config_test.go b/config/config_test.go index 58f0a8dfb5..46e84d4a42 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -44,14 +44,6 @@ func Test_Defaults(t *testing.T) { path: "Sequencer.WaitPeriodPoolIsEmpty", expectedValue: types.NewDuration(1 * time.Second), }, - { - path: "Sequencer.MaxTxsPerBatch", - expectedValue: uint64(300), - }, - { - path: "Sequencer.MaxBatchBytesSize", - expectedValue: uint64(120000), - }, { path: "Sequencer.BlocksAmountForTxsToBeDeleted", expectedValue: uint64(100), @@ -60,38 +52,6 @@ func Test_Defaults(t *testing.T) { path: "Sequencer.FrequencyToCheckTxsForDelete", expectedValue: types.NewDuration(12 * time.Hour), }, - { - path: "Sequencer.MaxCumulativeGasUsed", - expectedValue: uint64(30000000), - }, - { - path: "Sequencer.MaxKeccakHashes", - expectedValue: uint32(2145), - }, - { - path: "Sequencer.MaxPoseidonHashes", - expectedValue: uint32(252357), - }, - { - path: "Sequencer.MaxPoseidonPaddings", - expectedValue: uint32(135191), - }, - { - path: "Sequencer.MaxMemAligns", - expectedValue: uint32(236585), - }, - { - path: "Sequencer.MaxArithmetics", - expectedValue: uint32(236585), - }, - { - path: "Sequencer.MaxBinaries", - expectedValue: uint32(473170), - }, - { - path: "Sequencer.MaxSteps", - expectedValue: uint32(7570538), - }, { path: "Sequencer.TxLifetimeCheckTimeout", expectedValue: types.NewDuration(10 * time.Minute), @@ -245,31 +205,31 @@ func Test_Defaults(t *testing.T) { expectedValue: "zkevm-prover:50061", }, { - path: "StateDB.User", + path: "State.DB.User", expectedValue: "state_user", }, { - path: "StateDB.Password", + path: "State.DB.Password", expectedValue: "state_password", }, { - path: "StateDB.Name", + path: "State.DB.Name", expectedValue: "state_db", }, { - path: "StateDB.Host", + path: "State.DB.Host", expectedValue: "zkevm-state-db", }, { - path: "StateDB.Port", + path: "State.DB.Port", expectedValue: "5432", }, { - path: "StateDB.EnableLog", + path: "State.DB.EnableLog", expectedValue: false, }, { - path: "StateDB.MaxConns", + path: "State.DB.MaxConns", expectedValue: 200, }, { @@ -437,6 +397,83 @@ func Test_Defaults(t *testing.T) { path: "Aggregator.GeneratingProofCleanupThreshold", expectedValue: "10m", }, + + { + path: "State.Batch.Constraints.MaxTxsPerBatch", + expectedValue: uint64(300), + }, + { + path: "State.Batch.Constraints.MaxBatchBytesSize", + expectedValue: uint64(120000), + }, + { + path: "State.Batch.Constraints.MaxCumulativeGasUsed", + expectedValue: uint64(30000000), + }, + { + path: "State.Batch.Constraints.MaxKeccakHashes", + expectedValue: uint32(2145), + }, + { + path: "State.Batch.Constraints.MaxPoseidonHashes", + expectedValue: uint32(252357), + }, + { + path: "State.Batch.Constraints.MaxPoseidonPaddings", + expectedValue: uint32(135191), + }, + { + path: "State.Batch.Constraints.MaxMemAligns", + expectedValue: uint32(236585), + }, + { + path: "State.Batch.Constraints.MaxArithmetics", + expectedValue: uint32(236585), + }, + { + path: "State.Batch.Constraints.MaxBinaries", + expectedValue: uint32(473170), + }, + { + path: "State.Batch.Constraints.MaxSteps", + expectedValue: uint32(7570538), + }, + { + path: "State.Batch.ResourceWeights.WeightBatchBytesSize", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightCumulativeGasUsed", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightKeccakHashes", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightPoseidonHashes", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightPoseidonPaddings", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightMemAligns", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightArithmetics", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightBinaries", + expectedValue: 1, + }, + { + path: "State.Batch.ResourceWeights.WeightSteps", + expectedValue: 1, + }, } file, err := os.CreateTemp("", "genesisConfig") require.NoError(t, err) diff --git a/config/default.go b/config/default.go index d4a23b00d1..b20c379a80 100644 --- a/config/default.go +++ b/config/default.go @@ -11,14 +11,38 @@ Environment = "development" # "production" or "development" Level = "info" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "zkevm-state-db" -Port = "5432" -EnableLog = false -MaxConns = 200 +[State] +AccountQueue = 64 + [State.DB] + User = "state_user" + Password = "state_password" + Name = "state_db" + Host = "zkevm-state-db" + Port = "5432" + EnableLog = false + MaxConns = 200 + [State.Batch] + [State.Batch.Constraints] + MaxTxsPerBatch = 300 + MaxBatchBytesSize = 120000 + MaxCumulativeGasUsed = 30000000 + MaxKeccakHashes = 2145 + MaxPoseidonHashes = 252357 + MaxPoseidonPaddings = 135191 + MaxMemAligns = 236585 + MaxArithmetics = 236585 + MaxBinaries = 473170 + MaxSteps = 7570538 + [State.Batch.ResourceWeights] + WeightBatchBytesSize = 1 + WeightCumulativeGasUsed = 1 + WeightKeccakHashes = 1 + WeightPoseidonHashes = 1 + WeightPoseidonPaddings = 1 + WeightMemAligns = 1 + WeightArithmetics = 1 + WeightBinaries = 1 + WeightSteps = 1 [Pool] IntervalToRefreshBlockedAddresses = "5m" @@ -75,16 +99,6 @@ TrustedSequencerURL = "" # If it is empty or not specified, then the value is re WaitPeriodPoolIsEmpty = "1s" BlocksAmountForTxsToBeDeleted = 100 FrequencyToCheckTxsForDelete = "12h" -MaxTxsPerBatch = 300 -MaxBatchBytesSize = 120000 -MaxCumulativeGasUsed = 30000000 -MaxKeccakHashes = 2145 -MaxPoseidonHashes = 252357 -MaxPoseidonPaddings = 135191 -MaxMemAligns = 236585 -MaxArithmetics = 236585 -MaxBinaries = 473170 -MaxSteps = 7570538 TxLifetimeCheckTimeout = "10m" MaxTxLifetime = "3h" [Sequencer.Finalizer] diff --git a/config/environments/local/local.node.config.toml b/config/environments/local/local.node.config.toml index 3e0112cab5..34e3b12f60 100644 --- a/config/environments/local/local.node.config.toml +++ b/config/environments/local/local.node.config.toml @@ -6,15 +6,6 @@ Environment = "development" # "production" or "development" Level = "debug" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "zkevm-state-db" -Port = "5432" -EnableLog = false -MaxConns = 200 - [Pool] IntervalToRefreshBlockedAddresses = "5m" IntervalToRefreshGasPrices = "5s" @@ -59,16 +50,6 @@ TrustedSequencerURL = "" # If it is empty or not specified, then the value is re WaitPeriodPoolIsEmpty = "1s" BlocksAmountForTxsToBeDeleted = 100 FrequencyToCheckTxsForDelete = "12h" -MaxTxsPerBatch = 300 -MaxBatchBytesSize = 120000 -MaxCumulativeGasUsed = 30000000 -MaxKeccakHashes = 2145 -MaxPoseidonHashes = 252357 -MaxPoseidonPaddings = 135191 -MaxMemAligns = 236585 -MaxArithmetics = 236585 -MaxBinaries = 473170 -MaxSteps = 7570538 TxLifetimeCheckTimeout = "10m" MaxTxLifetime = "3h" [Sequencer.Finalizer] diff --git a/config/environments/mainnet/example.env b/config/environments/mainnet/example.env index 95557a442c..05b13e5e79 100644 --- a/config/environments/mainnet/example.env +++ b/config/environments/mainnet/example.env @@ -2,7 +2,7 @@ ZKEVM_NETWORK = "mainnet" # URL of a JSON RPC for Ethereum mainnet ZKEVM_NODE_ETHERMAN_URL = "http://your.L1node.url" # PATH WHERE THE STATEDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA -ZKEVM_NODE_STATEDB_DATA_DIR = "/path/to/persistent/data/statedb" +ZKEVM_NODE_STATE_DB_DATA_DIR = "/path/to/persistent/data/statedb" # PATH WHERE THE POOLDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA ZKEVM_NODE_POOLDB_DATA_DIR = "/path/to/persistent/data/pooldb" # OPTIONAL, UNCOMENT IF YOU WANT TO DO ADVANCED CONFIG diff --git a/config/environments/mainnet/node.config.toml b/config/environments/mainnet/node.config.toml index 145a433ecb..ab12e064ac 100644 --- a/config/environments/mainnet/node.config.toml +++ b/config/environments/mainnet/node.config.toml @@ -3,15 +3,6 @@ Environment = "development" # "production" or "development" Level = "info" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "zkevm-state-db" -Port = "5432" -EnableLog = false -MaxConns = 200 - [Pool] MaxTxBytesSize=100132 MaxTxDataBytesSize=100000 diff --git a/config/environments/testnet/example.env b/config/environments/testnet/example.env index bf0db2e035..fe13decc82 100644 --- a/config/environments/testnet/example.env +++ b/config/environments/testnet/example.env @@ -2,7 +2,7 @@ ZKEVM_NETWORK = "testnet" # URL of a JSON RPC for Goerli ZKEVM_NODE_ETHERMAN_URL = "http://your.L1node.url" # PATH WHERE THE STATEDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA -ZKEVM_NODE_STATEDB_DATA_DIR = "/path/to/persistent/data/statedb" +ZKEVM_NODE_STATE_DB_DATA_DIR = "/path/to/persistent/data/statedb" # PATH WHERE THE POOLDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA ZKEVM_NODE_POOLDB_DATA_DIR = "/path/to/persistent/data/pooldb" # OPTIONAL, UNCOMENT IF YOU WANT TO DO ADVANCED CONFIG diff --git a/config/environments/testnet/node.config.toml b/config/environments/testnet/node.config.toml index 4566baa5f6..25c2028b4a 100644 --- a/config/environments/testnet/node.config.toml +++ b/config/environments/testnet/node.config.toml @@ -3,15 +3,6 @@ Environment = "development" # "production" or "development" Level = "info" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "zkevm-state-db" -Port = "5432" -EnableLog = false -MaxConns = 200 - [Pool] IntervalToRefreshBlockedAddresses = "5m" IntervalToRefreshGasPrices = "5s" diff --git a/docker-compose.yml b/docker-compose.yml index d3e6d17ffe..6b0693d65a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,7 +69,7 @@ services: - 5432:5432 volumes: - ./db/scripts/init_prover_db.sql:/docker-entrypoint-initdb.d/init.sql - - ${ZKEVM_NODE_STATEDB_DATA_DIR}:/var/lib/postgresql/data + - ${ZKEVM_NODE_STATE_DB_DATA_DIR}:/var/lib/postgresql/data - ${ZKEVM_ADVANCED_CONFIG_DIR:-./config/environments/testnet}/postgresql.conf:/etc/postgresql.conf environment: - POSTGRES_USER=state_user diff --git a/docs/components/aggregator.md b/docs/components/aggregator.md index a1c314a22e..35b4031c49 100644 --- a/docs/components/aggregator.md +++ b/docs/components/aggregator.md @@ -38,7 +38,7 @@ The container alone needs some parameters configured, access to certain configur - `your genesis.json file`: /app/genesis.json - environment: Env variables that supersede the config file - - `ZKEVM_NODE_STATEDB_HOST`: Name of StateDB Database Host + - `ZKEVM_NODE_STATE_DB_HOST`: Name of StateDB Database Host ### The Account Keystore file: diff --git a/docs/components/rpc.md b/docs/components/rpc.md index 3725ed0436..60e2f2aac7 100644 --- a/docs/components/rpc.md +++ b/docs/components/rpc.md @@ -37,7 +37,7 @@ The container alone needs some parameters configured, access to certain configur - `8545:8545`: RPC Port - `9091:9091`: Needed if Prometheus metrics are enabled - environment: Env variables that supersede the config file - - `ZKEVM_NODE_STATEDB_HOST`: Name of StateDB Database Host + - `ZKEVM_NODE_STATE_DB_HOST`: Name of StateDB Database Host - `ZKEVM_NODE_POOL_HOST`: Name of PoolDB Database Host - `ZKEVM_NODE_RPC_DB_HOST`: Name of RPCDB Database Host - volumes: diff --git a/docs/components/sequencer.md b/docs/components/sequencer.md index 3490494de7..4a434a591c 100644 --- a/docs/components/sequencer.md +++ b/docs/components/sequencer.md @@ -28,7 +28,7 @@ The container alone needs some parameters configured, access to certain configur - environment: Env variables that supersede the config file - `ZKEVM_NODE_POOLDB_HOST`: Name of PoolDB Database Host - - `ZKEVM_NODE_STATEDB_HOST`: Name of StateDB Database Host + - `ZKEVM_NODE_STATE_DB_HOST`: Name of StateDB Database Host - volumes: - `your Account Keystore file`: /pk/keystore (note, this `/pk/keystore` value is the default path that's written in the Public Configuration files on this repo, meant to expedite deployments, it can be superseded via an env flag `ZKEVM_NODE_ETHERMAN_PRIVATEKEYPATH`.) - `your config.toml file`: /app/config.toml diff --git a/docs/components/synchronizer.md b/docs/components/synchronizer.md index 0e79e52a37..1f289c208b 100644 --- a/docs/components/synchronizer.md +++ b/docs/components/synchronizer.md @@ -31,7 +31,7 @@ To orchestrate multiple deployments of the different ZKEVM Node components, a `d The container alone needs some parameters configured, access to certain configuration files and the appropriate ports exposed. - environment: Env variables that supersede the config file - - `ZKEVM_NODE_STATEDB_HOST`: Name of StateDB Database Host + - `ZKEVM_NODE_STATE_DB_HOST`: Name of StateDB Database Host - volumes: - `your config.toml file`: /app/config.toml - `your genesis.json file`: /app/genesis.json diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 2d45fdecc2..3bad482c56 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -20,7 +20,7 @@
"300ms"
 

Default: 100Type: integer

BlocksAmountForTxsToBeDeleted is blocks amount after which txs will be deleted from the pool


Default: "12h0m0s"Type: string

FrequencyToCheckTxsForDelete is frequency with which txs will be checked for deleting


Examples:

"1m"
 
"300ms"
-

Default: 300Type: integer

MaxTxsPerBatch is the maximum amount of transactions in the batch


Default: 120000Type: integer

MaxBatchBytesSize is the maximum batch size in bytes
(subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1)


Default: 30000000Type: integer

MaxCumulativeGasUsed is max gas amount used by batch


Default: 2145Type: integer

MaxKeccakHashes is max keccak hashes used by batch


Default: 252357Type: integer

MaxPoseidonHashes is max poseidon hashes batch can handle


Default: 135191Type: integer

MaxPoseidonPaddings is max poseidon paddings batch can handle


Default: 236585Type: integer

MaxMemAligns is max mem aligns batch can handle


Default: 236585Type: integer

MaxArithmetics is max arithmetics batch can handle


Default: 473170Type: integer

MaxBinaries is max binaries batch can handle


Default: 7570538Type: integer

MaxSteps is max steps batch can handle


Default: "10m0s"Type: string

TxLifetimeCheckTimeout is the time the sequencer waits to check txs lifetime


Examples:

"1m"
+

Default: "10m0s"Type: string

TxLifetimeCheckTimeout is the time the sequencer waits to check txs lifetime


Examples:

"1m"
 
"300ms"
 

Default: "3h0m0s"Type: string

MaxTxLifetime is the time a tx can be in the sequencer memory


Examples:

"1m"
 
"300ms"
@@ -64,4 +64,6 @@
 
"300ms"
 

Default: 0.15Type: number

Configuration of the executor service
Default: "zkevm-prover:50071"Type: string

Default: 3Type: integer

MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion


Default: "1s"Type: string

WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion


Examples:

"1m"
 
"300ms"
-

Default: 100000000Type: integer

Configuration of the merkle tree client service. Not use in the node, only for testing
Default: "zkevm-prover:50061"Type: string

URI is the server URI.


Configuration of the state database connection
Default: "state_db"Type: string

Database name


Default: "state_user"Type: string

Database User name


Default: "state_password"Type: string

Database Password of the user


Default: "zkevm-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration of the metrics service, basically is where is going to publish the metrics
Default: "0.0.0.0"Type: string

Host is the address to bind the metrics server


Default: 9091Type: integer

Port is the port to bind the metrics server


Default: falseType: boolean

Enabled is the flag to enable/disable the metrics server


Default: ""Type: string

ProfilingHost is the address to bind the profiling server


Default: 0Type: integer

ProfilingPort is the port to bind the profiling server


Default: falseType: boolean

ProfilingEnabled is the flag to enable/disable the profiling server


Configuration of the event database connection

DB is the database configuration
Default: ""Type: string

Database name


Default: ""Type: string

Database User name


Default: ""Type: string

Database Password of the user


Default: ""Type: string

Host address of database


Default: ""Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 0Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration of the hash database connection
Default: "prover_db"Type: string

Database name


Default: "prover_user"Type: string

Database User name


Default: "prover_pass"Type: string

Database Password of the user


Default: "zkevm-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


\ No newline at end of file +
Default: 100000000Type: integer

Configuration of the merkle tree client service. Not use in the node, only for testing
Default: "zkevm-prover:50061"Type: string

URI is the server URI.


Configuration of the metrics service, basically is where is going to publish the metrics
Default: "0.0.0.0"Type: string

Host is the address to bind the metrics server


Default: 9091Type: integer

Port is the port to bind the metrics server


Default: falseType: boolean

Enabled is the flag to enable/disable the metrics server


Default: ""Type: string

ProfilingHost is the address to bind the profiling server


Default: 0Type: integer

ProfilingPort is the port to bind the profiling server


Default: falseType: boolean

ProfilingEnabled is the flag to enable/disable the profiling server


Configuration of the event database connection

DB is the database configuration
Default: ""Type: string

Database name


Default: ""Type: string

Database User name


Default: ""Type: string

Database Password of the user


Default: ""Type: string

Host address of database


Default: ""Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 0Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration of the hash database connection
Default: "prover_db"Type: string

Database name


Default: "prover_user"Type: string

Database User name


Default: "prover_pass"Type: string

Database Password of the user


Default: "zkevm-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


State service configuration
Default: 0Type: integer

MaxCumulativeGasUsed is the max gas allowed per batch


Default: 0Type: integer

ChainID is the L2 ChainID provided by the Network Config


Type: array of object

ForkIdIntervals is the list of fork id intervals

Each item of this array must be:


Default: 0Type: integer

MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion


Default: "0s"Type: string

WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion


Examples:

"1m"
+
"300ms"
+

Default: 0Type: integer

Batch number from which there is a forkid change (fork upgrade)


Default: 0Type: integer

New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade)


DB is the database configuration
Default: "state_db"Type: string

Database name


Default: "state_user"Type: string

Database User name


Default: "state_password"Type: string

Database Password of the user


Default: "zkevm-state-db"Type: string

Host address of database


Default: "5432"Type: string

Port Number of database


Default: falseType: boolean

EnableLog


Default: 200Type: integer

MaxConns is the maximum number of connections in the pool.


Configuration for the batch constraints
\ No newline at end of file diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md index cb6cbe228a..27c9bbd404 100644 --- a/docs/config-file/node-config-doc.md +++ b/docs/config-file/node-config-doc.md @@ -23,10 +23,10 @@ | - [L2GasPriceSuggester](#L2GasPriceSuggester ) | No | object | No | - | Configuration of the gas price suggester service | | - [Executor](#Executor ) | No | object | No | - | Configuration of the executor service | | - [MTClient](#MTClient ) | No | object | No | - | Configuration of the merkle tree client service. Not use in the node, only for testing | -| - [StateDB](#StateDB ) | No | object | No | - | Configuration of the state database connection | | - [Metrics](#Metrics ) | No | object | No | - | Configuration of the metrics service, basically is where is going to publish the metrics | | - [EventLog](#EventLog ) | No | object | No | - | Configuration of the event database connection | | - [HashDB](#HashDB ) | No | object | No | - | Configuration of the hash database connection | +| - [State](#State ) | No | object | No | - | State service configuration | ## 1. `IsTrustedSequencer` @@ -995,26 +995,16 @@ TrustedSequencerURL="" **Type:** : `object` **Description:** Configuration of the sequencer service -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| - [WaitPeriodPoolIsEmpty](#Sequencer_WaitPeriodPoolIsEmpty ) | No | string | No | - | Duration | -| - [BlocksAmountForTxsToBeDeleted](#Sequencer_BlocksAmountForTxsToBeDeleted ) | No | integer | No | - | BlocksAmountForTxsToBeDeleted is blocks amount after which txs will be deleted from the pool | -| - [FrequencyToCheckTxsForDelete](#Sequencer_FrequencyToCheckTxsForDelete ) | No | string | No | - | Duration | -| - [MaxTxsPerBatch](#Sequencer_MaxTxsPerBatch ) | No | integer | No | - | MaxTxsPerBatch is the maximum amount of transactions in the batch | -| - [MaxBatchBytesSize](#Sequencer_MaxBatchBytesSize ) | No | integer | No | - | MaxBatchBytesSize is the maximum batch size in bytes
(subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1) | -| - [MaxCumulativeGasUsed](#Sequencer_MaxCumulativeGasUsed ) | No | integer | No | - | MaxCumulativeGasUsed is max gas amount used by batch | -| - [MaxKeccakHashes](#Sequencer_MaxKeccakHashes ) | No | integer | No | - | MaxKeccakHashes is max keccak hashes used by batch | -| - [MaxPoseidonHashes](#Sequencer_MaxPoseidonHashes ) | No | integer | No | - | MaxPoseidonHashes is max poseidon hashes batch can handle | -| - [MaxPoseidonPaddings](#Sequencer_MaxPoseidonPaddings ) | No | integer | No | - | MaxPoseidonPaddings is max poseidon paddings batch can handle | -| - [MaxMemAligns](#Sequencer_MaxMemAligns ) | No | integer | No | - | MaxMemAligns is max mem aligns batch can handle | -| - [MaxArithmetics](#Sequencer_MaxArithmetics ) | No | integer | No | - | MaxArithmetics is max arithmetics batch can handle | -| - [MaxBinaries](#Sequencer_MaxBinaries ) | No | integer | No | - | MaxBinaries is max binaries batch can handle | -| - [MaxSteps](#Sequencer_MaxSteps ) | No | integer | No | - | MaxSteps is max steps batch can handle | -| - [TxLifetimeCheckTimeout](#Sequencer_TxLifetimeCheckTimeout ) | No | string | No | - | Duration | -| - [MaxTxLifetime](#Sequencer_MaxTxLifetime ) | No | string | No | - | Duration | -| - [Finalizer](#Sequencer_Finalizer ) | No | object | No | - | Finalizer's specific config properties | -| - [DBManager](#Sequencer_DBManager ) | No | object | No | - | DBManager's specific config properties | -| - [EffectiveGasPrice](#Sequencer_EffectiveGasPrice ) | No | object | No | - | EffectiveGasPrice is the config for the gas price | +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ---------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | -------------------------------------------------------------------------------------------- | +| - [WaitPeriodPoolIsEmpty](#Sequencer_WaitPeriodPoolIsEmpty ) | No | string | No | - | Duration | +| - [BlocksAmountForTxsToBeDeleted](#Sequencer_BlocksAmountForTxsToBeDeleted ) | No | integer | No | - | BlocksAmountForTxsToBeDeleted is blocks amount after which txs will be deleted from the pool | +| - [FrequencyToCheckTxsForDelete](#Sequencer_FrequencyToCheckTxsForDelete ) | No | string | No | - | Duration | +| - [TxLifetimeCheckTimeout](#Sequencer_TxLifetimeCheckTimeout ) | No | string | No | - | Duration | +| - [MaxTxLifetime](#Sequencer_MaxTxLifetime ) | No | string | No | - | Duration | +| - [Finalizer](#Sequencer_Finalizer ) | No | object | No | - | Finalizer's specific config properties | +| - [DBManager](#Sequencer_DBManager ) | No | object | No | - | DBManager's specific config properties | +| - [EffectiveGasPrice](#Sequencer_EffectiveGasPrice ) | No | object | No | - | EffectiveGasPrice is the config for the gas price | ### 10.1. `Sequencer.WaitPeriodPoolIsEmpty` @@ -1083,148 +1073,7 @@ BlocksAmountForTxsToBeDeleted=100 FrequencyToCheckTxsForDelete="12h0m0s" ``` -### 10.4. `Sequencer.MaxTxsPerBatch` - -**Type:** : `integer` - -**Default:** `300` - -**Description:** MaxTxsPerBatch is the maximum amount of transactions in the batch - -**Example setting the default value** (300): -``` -[Sequencer] -MaxTxsPerBatch=300 -``` - -### 10.5. `Sequencer.MaxBatchBytesSize` - -**Type:** : `integer` - -**Default:** `120000` - -**Description:** MaxBatchBytesSize is the maximum batch size in bytes -(subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1) - -**Example setting the default value** (120000): -``` -[Sequencer] -MaxBatchBytesSize=120000 -``` - -### 10.6. `Sequencer.MaxCumulativeGasUsed` - -**Type:** : `integer` - -**Default:** `30000000` - -**Description:** MaxCumulativeGasUsed is max gas amount used by batch - -**Example setting the default value** (30000000): -``` -[Sequencer] -MaxCumulativeGasUsed=30000000 -``` - -### 10.7. `Sequencer.MaxKeccakHashes` - -**Type:** : `integer` - -**Default:** `2145` - -**Description:** MaxKeccakHashes is max keccak hashes used by batch - -**Example setting the default value** (2145): -``` -[Sequencer] -MaxKeccakHashes=2145 -``` - -### 10.8. `Sequencer.MaxPoseidonHashes` - -**Type:** : `integer` - -**Default:** `252357` - -**Description:** MaxPoseidonHashes is max poseidon hashes batch can handle - -**Example setting the default value** (252357): -``` -[Sequencer] -MaxPoseidonHashes=252357 -``` - -### 10.9. `Sequencer.MaxPoseidonPaddings` - -**Type:** : `integer` - -**Default:** `135191` - -**Description:** MaxPoseidonPaddings is max poseidon paddings batch can handle - -**Example setting the default value** (135191): -``` -[Sequencer] -MaxPoseidonPaddings=135191 -``` - -### 10.10. `Sequencer.MaxMemAligns` - -**Type:** : `integer` - -**Default:** `236585` - -**Description:** MaxMemAligns is max mem aligns batch can handle - -**Example setting the default value** (236585): -``` -[Sequencer] -MaxMemAligns=236585 -``` - -### 10.11. `Sequencer.MaxArithmetics` - -**Type:** : `integer` - -**Default:** `236585` - -**Description:** MaxArithmetics is max arithmetics batch can handle - -**Example setting the default value** (236585): -``` -[Sequencer] -MaxArithmetics=236585 -``` - -### 10.12. `Sequencer.MaxBinaries` - -**Type:** : `integer` - -**Default:** `473170` - -**Description:** MaxBinaries is max binaries batch can handle - -**Example setting the default value** (473170): -``` -[Sequencer] -MaxBinaries=473170 -``` - -### 10.13. `Sequencer.MaxSteps` - -**Type:** : `integer` - -**Default:** `7570538` - -**Description:** MaxSteps is max steps batch can handle - -**Example setting the default value** (7570538): -``` -[Sequencer] -MaxSteps=7570538 -``` - -### 10.14. `Sequencer.TxLifetimeCheckTimeout` +### 10.4. `Sequencer.TxLifetimeCheckTimeout` **Title:** Duration @@ -1250,7 +1099,7 @@ MaxSteps=7570538 TxLifetimeCheckTimeout="10m0s" ``` -### 10.15. `Sequencer.MaxTxLifetime` +### 10.5. `Sequencer.MaxTxLifetime` **Title:** Duration @@ -1276,7 +1125,7 @@ TxLifetimeCheckTimeout="10m0s" MaxTxLifetime="3h0m0s" ``` -### 10.16. `[Sequencer.Finalizer]` +### 10.6. `[Sequencer.Finalizer]` **Type:** : `object` **Description:** Finalizer's specific config properties @@ -1295,7 +1144,7 @@ MaxTxLifetime="3h0m0s" | - [TimestampResolution](#Sequencer_Finalizer_TimestampResolution ) | No | string | No | - | Duration | | - [StopSequencerOnBatchNum](#Sequencer_Finalizer_StopSequencerOnBatchNum ) | No | integer | No | - | StopSequencerOnBatchNum specifies the batch number where the Sequencer will stop to process more transactions and generate new batches. The Sequencer will halt after it closes the batch equal to this number | -#### 10.16.1. `Sequencer.Finalizer.GERDeadlineTimeout` +#### 10.6.1. `Sequencer.Finalizer.GERDeadlineTimeout` **Title:** Duration @@ -1321,7 +1170,7 @@ MaxTxLifetime="3h0m0s" GERDeadlineTimeout="5s" ``` -#### 10.16.2. `Sequencer.Finalizer.ForcedBatchDeadlineTimeout` +#### 10.6.2. `Sequencer.Finalizer.ForcedBatchDeadlineTimeout` **Title:** Duration @@ -1347,7 +1196,7 @@ GERDeadlineTimeout="5s" ForcedBatchDeadlineTimeout="1m0s" ``` -#### 10.16.3. `Sequencer.Finalizer.SleepDuration` +#### 10.6.3. `Sequencer.Finalizer.SleepDuration` **Title:** Duration @@ -1373,7 +1222,7 @@ ForcedBatchDeadlineTimeout="1m0s" SleepDuration="100ms" ``` -#### 10.16.4. `Sequencer.Finalizer.ResourcePercentageToCloseBatch` +#### 10.6.4. `Sequencer.Finalizer.ResourcePercentageToCloseBatch` **Type:** : `integer` @@ -1387,7 +1236,7 @@ SleepDuration="100ms" ResourcePercentageToCloseBatch=10 ``` -#### 10.16.5. `Sequencer.Finalizer.GERFinalityNumberOfBlocks` +#### 10.6.5. `Sequencer.Finalizer.GERFinalityNumberOfBlocks` **Type:** : `integer` @@ -1401,7 +1250,7 @@ ResourcePercentageToCloseBatch=10 GERFinalityNumberOfBlocks=64 ``` -#### 10.16.6. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingL1Timeout` +#### 10.6.6. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingL1Timeout` **Title:** Duration @@ -1427,7 +1276,7 @@ GERFinalityNumberOfBlocks=64 ClosingSignalsManagerWaitForCheckingL1Timeout="10s" ``` -#### 10.16.7. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingGER` +#### 10.6.7. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingGER` **Title:** Duration @@ -1453,7 +1302,7 @@ ClosingSignalsManagerWaitForCheckingL1Timeout="10s" ClosingSignalsManagerWaitForCheckingGER="10s" ``` -#### 10.16.8. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingForcedBatches` +#### 10.6.8. `Sequencer.Finalizer.ClosingSignalsManagerWaitForCheckingForcedBatches` **Title:** Duration @@ -1479,7 +1328,7 @@ ClosingSignalsManagerWaitForCheckingGER="10s" ClosingSignalsManagerWaitForCheckingForcedBatches="10s" ``` -#### 10.16.9. `Sequencer.Finalizer.ForcedBatchesFinalityNumberOfBlocks` +#### 10.6.9. `Sequencer.Finalizer.ForcedBatchesFinalityNumberOfBlocks` **Type:** : `integer` @@ -1493,7 +1342,7 @@ ClosingSignalsManagerWaitForCheckingForcedBatches="10s" ForcedBatchesFinalityNumberOfBlocks=64 ``` -#### 10.16.10. `Sequencer.Finalizer.TimestampResolution` +#### 10.6.10. `Sequencer.Finalizer.TimestampResolution` **Title:** Duration @@ -1519,7 +1368,7 @@ ForcedBatchesFinalityNumberOfBlocks=64 TimestampResolution="10s" ``` -#### 10.16.11. `Sequencer.Finalizer.StopSequencerOnBatchNum` +#### 10.6.11. `Sequencer.Finalizer.StopSequencerOnBatchNum` **Type:** : `integer` @@ -1533,7 +1382,7 @@ TimestampResolution="10s" StopSequencerOnBatchNum=0 ``` -### 10.17. `[Sequencer.DBManager]` +### 10.7. `[Sequencer.DBManager]` **Type:** : `object` **Description:** DBManager's specific config properties @@ -1543,7 +1392,7 @@ StopSequencerOnBatchNum=0 | - [PoolRetrievalInterval](#Sequencer_DBManager_PoolRetrievalInterval ) | No | string | No | - | Duration | | - [L2ReorgRetrievalInterval](#Sequencer_DBManager_L2ReorgRetrievalInterval ) | No | string | No | - | Duration | -#### 10.17.1. `Sequencer.DBManager.PoolRetrievalInterval` +#### 10.7.1. `Sequencer.DBManager.PoolRetrievalInterval` **Title:** Duration @@ -1567,7 +1416,7 @@ StopSequencerOnBatchNum=0 PoolRetrievalInterval="500ms" ``` -#### 10.17.2. `Sequencer.DBManager.L2ReorgRetrievalInterval` +#### 10.7.2. `Sequencer.DBManager.L2ReorgRetrievalInterval` **Title:** Duration @@ -1591,7 +1440,7 @@ PoolRetrievalInterval="500ms" L2ReorgRetrievalInterval="5s" ``` -### 10.18. `[Sequencer.EffectiveGasPrice]` +### 10.8. `[Sequencer.EffectiveGasPrice]` **Type:** : `object` **Description:** EffectiveGasPrice is the config for the gas price @@ -1605,7 +1454,7 @@ L2ReorgRetrievalInterval="5s" | - [Enabled](#Sequencer_EffectiveGasPrice_Enabled ) | No | boolean | No | - | Enabled is a flag to enable/disable the effective gas price | | - [DefaultMinGasPriceAllowed](#Sequencer_EffectiveGasPrice_DefaultMinGasPriceAllowed ) | No | integer | No | - | DefaultMinGasPriceAllowed is the default min gas price to suggest
This value is assigned from [Pool].DefaultMinGasPriceAllowed | -#### 10.18.1. `Sequencer.EffectiveGasPrice.MaxBreakEvenGasPriceDeviationPercentage` +#### 10.8.1. `Sequencer.EffectiveGasPrice.MaxBreakEvenGasPriceDeviationPercentage` **Type:** : `integer` @@ -1619,7 +1468,7 @@ L2ReorgRetrievalInterval="5s" MaxBreakEvenGasPriceDeviationPercentage=10 ``` -#### 10.18.2. `Sequencer.EffectiveGasPrice.L1GasPriceFactor` +#### 10.8.2. `Sequencer.EffectiveGasPrice.L1GasPriceFactor` **Type:** : `number` @@ -1633,7 +1482,7 @@ MaxBreakEvenGasPriceDeviationPercentage=10 L1GasPriceFactor=0.25 ``` -#### 10.18.3. `Sequencer.EffectiveGasPrice.ByteGasCost` +#### 10.8.3. `Sequencer.EffectiveGasPrice.ByteGasCost` **Type:** : `integer` @@ -1647,7 +1496,7 @@ L1GasPriceFactor=0.25 ByteGasCost=16 ``` -#### 10.18.4. `Sequencer.EffectiveGasPrice.MarginFactor` +#### 10.8.4. `Sequencer.EffectiveGasPrice.MarginFactor` **Type:** : `number` @@ -1661,7 +1510,7 @@ ByteGasCost=16 MarginFactor=1 ``` -#### 10.18.5. `Sequencer.EffectiveGasPrice.Enabled` +#### 10.8.5. `Sequencer.EffectiveGasPrice.Enabled` **Type:** : `boolean` @@ -1675,7 +1524,7 @@ MarginFactor=1 Enabled=false ``` -#### 10.18.6. `Sequencer.EffectiveGasPrice.DefaultMinGasPriceAllowed` +#### 10.8.6. `Sequencer.EffectiveGasPrice.DefaultMinGasPriceAllowed` **Type:** : `integer` @@ -2535,120 +2384,7 @@ MaxGRPCMessageSize=100000000 URI="zkevm-prover:50061" ``` -## 17. `[StateDB]` - -**Type:** : `object` -**Description:** Configuration of the state database connection - -| Property | Pattern | Type | Deprecated | Definition | Title/Description | -| ---------------------------------- | ------- | ------- | ---------- | ---------- | ---------------------------------------------------------- | -| - [Name](#StateDB_Name ) | No | string | No | - | Database name | -| - [User](#StateDB_User ) | No | string | No | - | Database User name | -| - [Password](#StateDB_Password ) | No | string | No | - | Database Password of the user | -| - [Host](#StateDB_Host ) | No | string | No | - | Host address of database | -| - [Port](#StateDB_Port ) | No | string | No | - | Port Number of database | -| - [EnableLog](#StateDB_EnableLog ) | No | boolean | No | - | EnableLog | -| - [MaxConns](#StateDB_MaxConns ) | No | integer | No | - | MaxConns is the maximum number of connections in the pool. | - -### 17.1. `StateDB.Name` - -**Type:** : `string` - -**Default:** `"state_db"` - -**Description:** Database name - -**Example setting the default value** ("state_db"): -``` -[StateDB] -Name="state_db" -``` - -### 17.2. `StateDB.User` - -**Type:** : `string` - -**Default:** `"state_user"` - -**Description:** Database User name - -**Example setting the default value** ("state_user"): -``` -[StateDB] -User="state_user" -``` - -### 17.3. `StateDB.Password` - -**Type:** : `string` - -**Default:** `"state_password"` - -**Description:** Database Password of the user - -**Example setting the default value** ("state_password"): -``` -[StateDB] -Password="state_password" -``` - -### 17.4. `StateDB.Host` - -**Type:** : `string` - -**Default:** `"zkevm-state-db"` - -**Description:** Host address of database - -**Example setting the default value** ("zkevm-state-db"): -``` -[StateDB] -Host="zkevm-state-db" -``` - -### 17.5. `StateDB.Port` - -**Type:** : `string` - -**Default:** `"5432"` - -**Description:** Port Number of database - -**Example setting the default value** ("5432"): -``` -[StateDB] -Port="5432" -``` - -### 17.6. `StateDB.EnableLog` - -**Type:** : `boolean` - -**Default:** `false` - -**Description:** EnableLog - -**Example setting the default value** (false): -``` -[StateDB] -EnableLog=false -``` - -### 17.7. `StateDB.MaxConns` - -**Type:** : `integer` - -**Default:** `200` - -**Description:** MaxConns is the maximum number of connections in the pool. - -**Example setting the default value** (200): -``` -[StateDB] -MaxConns=200 -``` - -## 18. `[Metrics]` +## 17. `[Metrics]` **Type:** : `object` **Description:** Configuration of the metrics service, basically is where is going to publish the metrics @@ -2662,7 +2398,7 @@ MaxConns=200 | - [ProfilingPort](#Metrics_ProfilingPort ) | No | integer | No | - | ProfilingPort is the port to bind the profiling server | | - [ProfilingEnabled](#Metrics_ProfilingEnabled ) | No | boolean | No | - | ProfilingEnabled is the flag to enable/disable the profiling server | -### 18.1. `Metrics.Host` +### 17.1. `Metrics.Host` **Type:** : `string` @@ -2676,7 +2412,7 @@ MaxConns=200 Host="0.0.0.0" ``` -### 18.2. `Metrics.Port` +### 17.2. `Metrics.Port` **Type:** : `integer` @@ -2690,7 +2426,7 @@ Host="0.0.0.0" Port=9091 ``` -### 18.3. `Metrics.Enabled` +### 17.3. `Metrics.Enabled` **Type:** : `boolean` @@ -2704,7 +2440,7 @@ Port=9091 Enabled=false ``` -### 18.4. `Metrics.ProfilingHost` +### 17.4. `Metrics.ProfilingHost` **Type:** : `string` @@ -2718,7 +2454,7 @@ Enabled=false ProfilingHost="" ``` -### 18.5. `Metrics.ProfilingPort` +### 17.5. `Metrics.ProfilingPort` **Type:** : `integer` @@ -2732,7 +2468,7 @@ ProfilingHost="" ProfilingPort=0 ``` -### 18.6. `Metrics.ProfilingEnabled` +### 17.6. `Metrics.ProfilingEnabled` **Type:** : `boolean` @@ -2746,7 +2482,7 @@ ProfilingPort=0 ProfilingEnabled=false ``` -## 19. `[EventLog]` +## 18. `[EventLog]` **Type:** : `object` **Description:** Configuration of the event database connection @@ -2755,7 +2491,7 @@ ProfilingEnabled=false | --------------------- | ------- | ------ | ---------- | ---------- | -------------------------------- | | - [DB](#EventLog_DB ) | No | object | No | - | DB is the database configuration | -### 19.1. `[EventLog.DB]` +### 18.1. `[EventLog.DB]` **Type:** : `object` **Description:** DB is the database configuration @@ -2770,7 +2506,7 @@ ProfilingEnabled=false | - [EnableLog](#EventLog_DB_EnableLog ) | No | boolean | No | - | EnableLog | | - [MaxConns](#EventLog_DB_MaxConns ) | No | integer | No | - | MaxConns is the maximum number of connections in the pool. | -#### 19.1.1. `EventLog.DB.Name` +#### 18.1.1. `EventLog.DB.Name` **Type:** : `string` @@ -2784,7 +2520,7 @@ ProfilingEnabled=false Name="" ``` -#### 19.1.2. `EventLog.DB.User` +#### 18.1.2. `EventLog.DB.User` **Type:** : `string` @@ -2798,7 +2534,7 @@ Name="" User="" ``` -#### 19.1.3. `EventLog.DB.Password` +#### 18.1.3. `EventLog.DB.Password` **Type:** : `string` @@ -2812,7 +2548,7 @@ User="" Password="" ``` -#### 19.1.4. `EventLog.DB.Host` +#### 18.1.4. `EventLog.DB.Host` **Type:** : `string` @@ -2826,7 +2562,7 @@ Password="" Host="" ``` -#### 19.1.5. `EventLog.DB.Port` +#### 18.1.5. `EventLog.DB.Port` **Type:** : `string` @@ -2840,7 +2576,7 @@ Host="" Port="" ``` -#### 19.1.6. `EventLog.DB.EnableLog` +#### 18.1.6. `EventLog.DB.EnableLog` **Type:** : `boolean` @@ -2854,7 +2590,7 @@ Port="" EnableLog=false ``` -#### 19.1.7. `EventLog.DB.MaxConns` +#### 18.1.7. `EventLog.DB.MaxConns` **Type:** : `integer` @@ -2868,7 +2604,7 @@ EnableLog=false MaxConns=0 ``` -## 20. `[HashDB]` +## 19. `[HashDB]` **Type:** : `object` **Description:** Configuration of the hash database connection @@ -2883,7 +2619,7 @@ MaxConns=0 | - [EnableLog](#HashDB_EnableLog ) | No | boolean | No | - | EnableLog | | - [MaxConns](#HashDB_MaxConns ) | No | integer | No | - | MaxConns is the maximum number of connections in the pool. | -### 20.1. `HashDB.Name` +### 19.1. `HashDB.Name` **Type:** : `string` @@ -2897,7 +2633,7 @@ MaxConns=0 Name="prover_db" ``` -### 20.2. `HashDB.User` +### 19.2. `HashDB.User` **Type:** : `string` @@ -2911,7 +2647,7 @@ Name="prover_db" User="prover_user" ``` -### 20.3. `HashDB.Password` +### 19.3. `HashDB.Password` **Type:** : `string` @@ -2925,7 +2661,7 @@ User="prover_user" Password="prover_pass" ``` -### 20.4. `HashDB.Host` +### 19.4. `HashDB.Host` **Type:** : `string` @@ -2939,7 +2675,7 @@ Password="prover_pass" Host="zkevm-state-db" ``` -### 20.5. `HashDB.Port` +### 19.5. `HashDB.Port` **Type:** : `string` @@ -2953,7 +2689,7 @@ Host="zkevm-state-db" Port="5432" ``` -### 20.6. `HashDB.EnableLog` +### 19.6. `HashDB.EnableLog` **Type:** : `boolean` @@ -2967,7 +2703,7 @@ Port="5432" EnableLog=false ``` -### 20.7. `HashDB.MaxConns` +### 19.7. `HashDB.MaxConns` **Type:** : `integer` @@ -2981,5 +2717,547 @@ EnableLog=false MaxConns=200 ``` +## 20. `[State]` + +**Type:** : `object` +**Description:** State service configuration + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ---------------------------------------------------------------------- | ------- | --------------- | ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------- | +| - [MaxCumulativeGasUsed](#State_MaxCumulativeGasUsed ) | No | integer | No | - | MaxCumulativeGasUsed is the max gas allowed per batch | +| - [ChainID](#State_ChainID ) | No | integer | No | - | ChainID is the L2 ChainID provided by the Network Config | +| - [ForkIDIntervals](#State_ForkIDIntervals ) | No | array of object | No | - | ForkIdIntervals is the list of fork id intervals | +| - [MaxResourceExhaustedAttempts](#State_MaxResourceExhaustedAttempts ) | No | integer | No | - | MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion | +| - [WaitOnResourceExhaustion](#State_WaitOnResourceExhaustion ) | No | string | No | - | Duration | +| - [ForkUpgradeBatchNumber](#State_ForkUpgradeBatchNumber ) | No | integer | No | - | Batch number from which there is a forkid change (fork upgrade) | +| - [ForkUpgradeNewForkId](#State_ForkUpgradeNewForkId ) | No | integer | No | - | New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade) | +| - [DB](#State_DB ) | No | object | No | - | DB is the database configuration | +| - [Batch](#State_Batch ) | No | object | No | - | Configuration for the batch constraints | + +### 20.1. `State.MaxCumulativeGasUsed` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** MaxCumulativeGasUsed is the max gas allowed per batch + +**Example setting the default value** (0): +``` +[State] +MaxCumulativeGasUsed=0 +``` + +### 20.2. `State.ChainID` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** ChainID is the L2 ChainID provided by the Network Config + +**Example setting the default value** (0): +``` +[State] +ChainID=0 +``` + +### 20.3. `State.ForkIDIntervals` + +**Type:** : `array of object` +**Description:** ForkIdIntervals is the list of fork id intervals + +| | Array restrictions | +| -------------------- | ------------------ | +| **Min items** | N/A | +| **Max items** | N/A | +| **Items unicity** | False | +| **Additional items** | False | +| **Tuple validation** | See below | + +| Each item of this array must be | Description | +| ----------------------------------------------------- | ------------------------------------ | +| [ForkIDIntervals items](#State_ForkIDIntervals_items) | ForkIDInterval is a fork id interval | + +#### 20.3.1. [State.ForkIDIntervals.ForkIDIntervals items] + +**Type:** : `object` +**Description:** ForkIDInterval is a fork id interval + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ----------------- | +| - [FromBatchNumber](#State_ForkIDIntervals_items_FromBatchNumber ) | No | integer | No | - | - | +| - [ToBatchNumber](#State_ForkIDIntervals_items_ToBatchNumber ) | No | integer | No | - | - | +| - [ForkId](#State_ForkIDIntervals_items_ForkId ) | No | integer | No | - | - | +| - [Version](#State_ForkIDIntervals_items_Version ) | No | string | No | - | - | + +##### 20.3.1.1. `State.ForkIDIntervals.ForkIDIntervals items.FromBatchNumber` + +**Type:** : `integer` + +##### 20.3.1.2. `State.ForkIDIntervals.ForkIDIntervals items.ToBatchNumber` + +**Type:** : `integer` + +##### 20.3.1.3. `State.ForkIDIntervals.ForkIDIntervals items.ForkId` + +**Type:** : `integer` + +##### 20.3.1.4. `State.ForkIDIntervals.ForkIDIntervals items.Version` + +**Type:** : `string` + +### 20.4. `State.MaxResourceExhaustedAttempts` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion + +**Example setting the default value** (0): +``` +[State] +MaxResourceExhaustedAttempts=0 +``` + +### 20.5. `State.WaitOnResourceExhaustion` + +**Title:** Duration + +**Type:** : `string` + +**Default:** `"0s"` + +**Description:** WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion + +**Examples:** + +```json +"1m" +``` + +```json +"300ms" +``` + +**Example setting the default value** ("0s"): +``` +[State] +WaitOnResourceExhaustion="0s" +``` + +### 20.6. `State.ForkUpgradeBatchNumber` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** Batch number from which there is a forkid change (fork upgrade) + +**Example setting the default value** (0): +``` +[State] +ForkUpgradeBatchNumber=0 +``` + +### 20.7. `State.ForkUpgradeNewForkId` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade) + +**Example setting the default value** (0): +``` +[State] +ForkUpgradeNewForkId=0 +``` + +### 20.8. `[State.DB]` + +**Type:** : `object` +**Description:** DB is the database configuration + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ----------------------------------- | ------- | ------- | ---------- | ---------- | ---------------------------------------------------------- | +| - [Name](#State_DB_Name ) | No | string | No | - | Database name | +| - [User](#State_DB_User ) | No | string | No | - | Database User name | +| - [Password](#State_DB_Password ) | No | string | No | - | Database Password of the user | +| - [Host](#State_DB_Host ) | No | string | No | - | Host address of database | +| - [Port](#State_DB_Port ) | No | string | No | - | Port Number of database | +| - [EnableLog](#State_DB_EnableLog ) | No | boolean | No | - | EnableLog | +| - [MaxConns](#State_DB_MaxConns ) | No | integer | No | - | MaxConns is the maximum number of connections in the pool. | + +#### 20.8.1. `State.DB.Name` + +**Type:** : `string` + +**Default:** `"state_db"` + +**Description:** Database name + +**Example setting the default value** ("state_db"): +``` +[State.DB] +Name="state_db" +``` + +#### 20.8.2. `State.DB.User` + +**Type:** : `string` + +**Default:** `"state_user"` + +**Description:** Database User name + +**Example setting the default value** ("state_user"): +``` +[State.DB] +User="state_user" +``` + +#### 20.8.3. `State.DB.Password` + +**Type:** : `string` + +**Default:** `"state_password"` + +**Description:** Database Password of the user + +**Example setting the default value** ("state_password"): +``` +[State.DB] +Password="state_password" +``` + +#### 20.8.4. `State.DB.Host` + +**Type:** : `string` + +**Default:** `"zkevm-state-db"` + +**Description:** Host address of database + +**Example setting the default value** ("zkevm-state-db"): +``` +[State.DB] +Host="zkevm-state-db" +``` + +#### 20.8.5. `State.DB.Port` + +**Type:** : `string` + +**Default:** `"5432"` + +**Description:** Port Number of database + +**Example setting the default value** ("5432"): +``` +[State.DB] +Port="5432" +``` + +#### 20.8.6. `State.DB.EnableLog` + +**Type:** : `boolean` + +**Default:** `false` + +**Description:** EnableLog + +**Example setting the default value** (false): +``` +[State.DB] +EnableLog=false +``` + +#### 20.8.7. `State.DB.MaxConns` + +**Type:** : `integer` + +**Default:** `200` + +**Description:** MaxConns is the maximum number of connections in the pool. + +**Example setting the default value** (200): +``` +[State.DB] +MaxConns=200 +``` + +### 20.9. `[State.Batch]` + +**Type:** : `object` +**Description:** Configuration for the batch constraints + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| -------------------------------------------------- | ------- | ------ | ---------- | ---------- | ----------------- | +| - [Constraints](#State_Batch_Constraints ) | No | object | No | - | - | +| - [ResourceWeights](#State_Batch_ResourceWeights ) | No | object | No | - | - | + +#### 20.9.1. `[State.Batch.Constraints]` + +**Type:** : `object` + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ------------------------------------------------------------------------ | ------- | ------- | ---------- | ---------- | ----------------- | +| - [MaxTxsPerBatch](#State_Batch_Constraints_MaxTxsPerBatch ) | No | integer | No | - | - | +| - [MaxBatchBytesSize](#State_Batch_Constraints_MaxBatchBytesSize ) | No | integer | No | - | - | +| - [MaxCumulativeGasUsed](#State_Batch_Constraints_MaxCumulativeGasUsed ) | No | integer | No | - | - | +| - [MaxKeccakHashes](#State_Batch_Constraints_MaxKeccakHashes ) | No | integer | No | - | - | +| - [MaxPoseidonHashes](#State_Batch_Constraints_MaxPoseidonHashes ) | No | integer | No | - | - | +| - [MaxPoseidonPaddings](#State_Batch_Constraints_MaxPoseidonPaddings ) | No | integer | No | - | - | +| - [MaxMemAligns](#State_Batch_Constraints_MaxMemAligns ) | No | integer | No | - | - | +| - [MaxArithmetics](#State_Batch_Constraints_MaxArithmetics ) | No | integer | No | - | - | +| - [MaxBinaries](#State_Batch_Constraints_MaxBinaries ) | No | integer | No | - | - | +| - [MaxSteps](#State_Batch_Constraints_MaxSteps ) | No | integer | No | - | - | + +##### 20.9.1.1. `State.Batch.Constraints.MaxTxsPerBatch` + +**Type:** : `integer` + +**Default:** `300` + +**Example setting the default value** (300): +``` +[State.Batch.Constraints] +MaxTxsPerBatch=300 +``` + +##### 20.9.1.2. `State.Batch.Constraints.MaxBatchBytesSize` + +**Type:** : `integer` + +**Default:** `120000` + +**Example setting the default value** (120000): +``` +[State.Batch.Constraints] +MaxBatchBytesSize=120000 +``` + +##### 20.9.1.3. `State.Batch.Constraints.MaxCumulativeGasUsed` + +**Type:** : `integer` + +**Default:** `30000000` + +**Example setting the default value** (30000000): +``` +[State.Batch.Constraints] +MaxCumulativeGasUsed=30000000 +``` + +##### 20.9.1.4. `State.Batch.Constraints.MaxKeccakHashes` + +**Type:** : `integer` + +**Default:** `2145` + +**Example setting the default value** (2145): +``` +[State.Batch.Constraints] +MaxKeccakHashes=2145 +``` + +##### 20.9.1.5. `State.Batch.Constraints.MaxPoseidonHashes` + +**Type:** : `integer` + +**Default:** `252357` + +**Example setting the default value** (252357): +``` +[State.Batch.Constraints] +MaxPoseidonHashes=252357 +``` + +##### 20.9.1.6. `State.Batch.Constraints.MaxPoseidonPaddings` + +**Type:** : `integer` + +**Default:** `135191` + +**Example setting the default value** (135191): +``` +[State.Batch.Constraints] +MaxPoseidonPaddings=135191 +``` + +##### 20.9.1.7. `State.Batch.Constraints.MaxMemAligns` + +**Type:** : `integer` + +**Default:** `236585` + +**Example setting the default value** (236585): +``` +[State.Batch.Constraints] +MaxMemAligns=236585 +``` + +##### 20.9.1.8. `State.Batch.Constraints.MaxArithmetics` + +**Type:** : `integer` + +**Default:** `236585` + +**Example setting the default value** (236585): +``` +[State.Batch.Constraints] +MaxArithmetics=236585 +``` + +##### 20.9.1.9. `State.Batch.Constraints.MaxBinaries` + +**Type:** : `integer` + +**Default:** `473170` + +**Example setting the default value** (473170): +``` +[State.Batch.Constraints] +MaxBinaries=473170 +``` + +##### 20.9.1.10. `State.Batch.Constraints.MaxSteps` + +**Type:** : `integer` + +**Default:** `7570538` + +**Example setting the default value** (7570538): +``` +[State.Batch.Constraints] +MaxSteps=7570538 +``` + +#### 20.9.2. `[State.Batch.ResourceWeights]` + +**Type:** : `object` + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ---------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- | +| - [WeightBatchBytesSize](#State_Batch_ResourceWeights_WeightBatchBytesSize ) | No | integer | No | - | - | +| - [WeightCumulativeGasUsed](#State_Batch_ResourceWeights_WeightCumulativeGasUsed ) | No | integer | No | - | - | +| - [WeightKeccakHashes](#State_Batch_ResourceWeights_WeightKeccakHashes ) | No | integer | No | - | - | +| - [WeightPoseidonHashes](#State_Batch_ResourceWeights_WeightPoseidonHashes ) | No | integer | No | - | - | +| - [WeightPoseidonPaddings](#State_Batch_ResourceWeights_WeightPoseidonPaddings ) | No | integer | No | - | - | +| - [WeightMemAligns](#State_Batch_ResourceWeights_WeightMemAligns ) | No | integer | No | - | - | +| - [WeightArithmetics](#State_Batch_ResourceWeights_WeightArithmetics ) | No | integer | No | - | - | +| - [WeightBinaries](#State_Batch_ResourceWeights_WeightBinaries ) | No | integer | No | - | - | +| - [WeightSteps](#State_Batch_ResourceWeights_WeightSteps ) | No | integer | No | - | - | + +##### 20.9.2.1. `State.Batch.ResourceWeights.WeightBatchBytesSize` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightBatchBytesSize=1 +``` + +##### 20.9.2.2. `State.Batch.ResourceWeights.WeightCumulativeGasUsed` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightCumulativeGasUsed=1 +``` + +##### 20.9.2.3. `State.Batch.ResourceWeights.WeightKeccakHashes` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightKeccakHashes=1 +``` + +##### 20.9.2.4. `State.Batch.ResourceWeights.WeightPoseidonHashes` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightPoseidonHashes=1 +``` + +##### 20.9.2.5. `State.Batch.ResourceWeights.WeightPoseidonPaddings` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightPoseidonPaddings=1 +``` + +##### 20.9.2.6. `State.Batch.ResourceWeights.WeightMemAligns` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightMemAligns=1 +``` + +##### 20.9.2.7. `State.Batch.ResourceWeights.WeightArithmetics` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightArithmetics=1 +``` + +##### 20.9.2.8. `State.Batch.ResourceWeights.WeightBinaries` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightBinaries=1 +``` + +##### 20.9.2.9. `State.Batch.ResourceWeights.WeightSteps` + +**Type:** : `integer` + +**Default:** `1` + +**Example setting the default value** (1): +``` +[State.Batch.ResourceWeights] +WeightSteps=1 +``` + ---------------------------------------------------------------------------------------------------------------------------- Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index dd1f84a973..bf837b443f 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -404,56 +404,6 @@ "300ms" ] }, - "MaxTxsPerBatch": { - "type": "integer", - "description": "MaxTxsPerBatch is the maximum amount of transactions in the batch", - "default": 300 - }, - "MaxBatchBytesSize": { - "type": "integer", - "description": "MaxBatchBytesSize is the maximum batch size in bytes\n(subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1)", - "default": 120000 - }, - "MaxCumulativeGasUsed": { - "type": "integer", - "description": "MaxCumulativeGasUsed is max gas amount used by batch", - "default": 30000000 - }, - "MaxKeccakHashes": { - "type": "integer", - "description": "MaxKeccakHashes is max keccak hashes used by batch", - "default": 2145 - }, - "MaxPoseidonHashes": { - "type": "integer", - "description": "MaxPoseidonHashes is max poseidon hashes batch can handle", - "default": 252357 - }, - "MaxPoseidonPaddings": { - "type": "integer", - "description": "MaxPoseidonPaddings is max poseidon paddings batch can handle", - "default": 135191 - }, - "MaxMemAligns": { - "type": "integer", - "description": "MaxMemAligns is max mem aligns batch can handle", - "default": 236585 - }, - "MaxArithmetics": { - "type": "integer", - "description": "MaxArithmetics is max arithmetics batch can handle", - "default": 236585 - }, - "MaxBinaries": { - "type": "integer", - "description": "MaxBinaries is max binaries batch can handle", - "default": 473170 - }, - "MaxSteps": { - "type": "integer", - "description": "MaxSteps is max steps batch can handle", - "default": 7570538 - }, "TxLifetimeCheckTimeout": { "type": "string", "title": "Duration", @@ -1038,48 +988,6 @@ "type": "object", "description": "Configuration of the merkle tree client service. Not use in the node, only for testing" }, - "StateDB": { - "properties": { - "Name": { - "type": "string", - "description": "Database name", - "default": "state_db" - }, - "User": { - "type": "string", - "description": "Database User name", - "default": "state_user" - }, - "Password": { - "type": "string", - "description": "Database Password of the user", - "default": "state_password" - }, - "Host": { - "type": "string", - "description": "Host address of database", - "default": "zkevm-state-db" - }, - "Port": { - "type": "string", - "description": "Port Number of database", - "default": "5432" - }, - "EnableLog": { - "type": "boolean", - "description": "EnableLog", - "default": false - }, - "MaxConns": { - "type": "integer", - "description": "MaxConns is the maximum number of connections in the pool.", - "default": 200 - } - }, - "additionalProperties": false, - "type": "object", - "description": "Configuration of the state database connection" - }, "Metrics": { "properties": { "Host": { @@ -1207,6 +1115,208 @@ "additionalProperties": false, "type": "object", "description": "Configuration of the hash database connection" + }, + "State": { + "properties": { + "MaxCumulativeGasUsed": { + "type": "integer", + "description": "MaxCumulativeGasUsed is the max gas allowed per batch", + "default": 0 + }, + "ChainID": { + "type": "integer", + "description": "ChainID is the L2 ChainID provided by the Network Config", + "default": 0 + }, + "ForkIDIntervals": { + "items": { + "properties": { + "FromBatchNumber": { + "type": "integer" + }, + "ToBatchNumber": { + "type": "integer" + }, + "ForkId": { + "type": "integer" + }, + "Version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "description": "ForkIDInterval is a fork id interval" + }, + "type": "array", + "description": "ForkIdIntervals is the list of fork id intervals" + }, + "MaxResourceExhaustedAttempts": { + "type": "integer", + "description": "MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion", + "default": 0 + }, + "WaitOnResourceExhaustion": { + "type": "string", + "title": "Duration", + "description": "WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion", + "default": "0s", + "examples": [ + "1m", + "300ms" + ] + }, + "ForkUpgradeBatchNumber": { + "type": "integer", + "description": "Batch number from which there is a forkid change (fork upgrade)", + "default": 0 + }, + "ForkUpgradeNewForkId": { + "type": "integer", + "description": "New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade)", + "default": 0 + }, + "DB": { + "properties": { + "Name": { + "type": "string", + "description": "Database name", + "default": "state_db" + }, + "User": { + "type": "string", + "description": "Database User name", + "default": "state_user" + }, + "Password": { + "type": "string", + "description": "Database Password of the user", + "default": "state_password" + }, + "Host": { + "type": "string", + "description": "Host address of database", + "default": "zkevm-state-db" + }, + "Port": { + "type": "string", + "description": "Port Number of database", + "default": "5432" + }, + "EnableLog": { + "type": "boolean", + "description": "EnableLog", + "default": false + }, + "MaxConns": { + "type": "integer", + "description": "MaxConns is the maximum number of connections in the pool.", + "default": 200 + } + }, + "additionalProperties": false, + "type": "object", + "description": "DB is the database configuration" + }, + "Batch": { + "properties": { + "Constraints": { + "properties": { + "MaxTxsPerBatch": { + "type": "integer", + "default": 300 + }, + "MaxBatchBytesSize": { + "type": "integer", + "default": 120000 + }, + "MaxCumulativeGasUsed": { + "type": "integer", + "default": 30000000 + }, + "MaxKeccakHashes": { + "type": "integer", + "default": 2145 + }, + "MaxPoseidonHashes": { + "type": "integer", + "default": 252357 + }, + "MaxPoseidonPaddings": { + "type": "integer", + "default": 135191 + }, + "MaxMemAligns": { + "type": "integer", + "default": 236585 + }, + "MaxArithmetics": { + "type": "integer", + "default": 236585 + }, + "MaxBinaries": { + "type": "integer", + "default": 473170 + }, + "MaxSteps": { + "type": "integer", + "default": 7570538 + } + }, + "additionalProperties": false, + "type": "object" + }, + "ResourceWeights": { + "properties": { + "WeightBatchBytesSize": { + "type": "integer", + "default": 1 + }, + "WeightCumulativeGasUsed": { + "type": "integer", + "default": 1 + }, + "WeightKeccakHashes": { + "type": "integer", + "default": 1 + }, + "WeightPoseidonHashes": { + "type": "integer", + "default": 1 + }, + "WeightPoseidonPaddings": { + "type": "integer", + "default": 1 + }, + "WeightMemAligns": { + "type": "integer", + "default": 1 + }, + "WeightArithmetics": { + "type": "integer", + "default": 1 + }, + "WeightBinaries": { + "type": "integer", + "default": 1 + }, + "WeightSteps": { + "type": "integer", + "default": 1 + } + }, + "additionalProperties": false, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "description": "Configuration for the batch constraints" + } + }, + "additionalProperties": false, + "type": "object", + "description": "State service configuration" } }, "additionalProperties": false, diff --git a/docs/configuration.md b/docs/configuration.md index a61bcac3c8..64a3c04b34 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -21,7 +21,7 @@ This file is used for trusted and for permisionless nodes. In the case of permis `ZKEVM_NODE_`[
`_`]*` For example: -`ZKEVM_NODE_STATEDB_HOST="localhost"` override value of section `[StateDB]` key `Host` +`ZKEVM_NODE_STATE_DB_HOST="localhost"` override value of section `[StateDB]` key `Host` ### Network Genesis Config This file is a [JSON](https://en.wikipedia.org/wiki/JSON) formatted file. diff --git a/pool/config.go b/pool/config.go index c744fd6c82..ed7e22c401 100644 --- a/pool/config.go +++ b/pool/config.go @@ -38,3 +38,15 @@ type Config struct { // GlobalQueue represents the maximum number of non-executable transaction slots for all accounts GlobalQueue uint64 `mapstructure:"GlobalQueue"` } + +// EffectiveGasPrice has parameters for the effective gas price calculation. +type EffectiveGasPrice struct { + // L1GasPriceFactor is the percentage of the L1 gas price that will be used as the L2 min gas price + L1GasPriceFactor float64 `mapstructure:"L1GasPriceFactor"` + + // ByteGasCost is the gas cost per byte + ByteGasCost uint64 `mapstructure:"ByteGasCost"` + + // MarginFactor is the margin factor percentage to be added to the L2 min gas price + MarginFactor float64 `mapstructure:"MarginFactor"` +} diff --git a/pool/config_test.go b/pool/config_test.go new file mode 100644 index 0000000000..c37eb483fd --- /dev/null +++ b/pool/config_test.go @@ -0,0 +1,63 @@ +package pool + +import ( + "testing" + + "github.com/0xPolygonHermez/zkevm-node/state" +) + +func TestIsWithinConstraints(t *testing.T) { + cfg := state.BatchConstraintsCfg{ + MaxCumulativeGasUsed: 500, + MaxKeccakHashes: 100, + MaxPoseidonHashes: 200, + MaxPoseidonPaddings: 150, + MaxMemAligns: 1000, + MaxArithmetics: 2000, + MaxBinaries: 3000, + MaxSteps: 4000, + } + + testCases := []struct { + desc string + counters state.ZKCounters + expected bool + }{ + { + desc: "All constraints within limits", + counters: state.ZKCounters{ + CumulativeGasUsed: 300, + UsedKeccakHashes: 50, + UsedPoseidonHashes: 100, + UsedPoseidonPaddings: 75, + UsedMemAligns: 500, + UsedArithmetics: 1000, + UsedBinaries: 2000, + UsedSteps: 2000, + }, + expected: true, + }, + { + desc: "All constraints exceed limits", + counters: state.ZKCounters{ + CumulativeGasUsed: 600, + UsedKeccakHashes: 150, + UsedPoseidonHashes: 300, + UsedPoseidonPaddings: 200, + UsedMemAligns: 2000, + UsedArithmetics: 3000, + UsedBinaries: 4000, + UsedSteps: 5000, + }, + expected: false, + }, + } + + for _, tC := range testCases { + t.Run(tC.desc, func(t *testing.T) { + if got := cfg.IsWithinConstraints(tC.counters); got != tC.expected { + t.Errorf("Expected %v, got %v", tC.expected, got) + } + }) + } +} diff --git a/pool/errors.go b/pool/errors.go index 14bcb8b08e..3b90864470 100644 --- a/pool/errors.go +++ b/pool/errors.go @@ -64,4 +64,13 @@ var ( // ErrGasPrice is returned if the transaction has specified lower gas price than the minimum allowed. ErrGasPrice = errors.New("gas price too low") + + // ErrReceivedZeroL1GasPrice is returned if the L1 gas price is 0. + ErrReceivedZeroL1GasPrice = errors.New("received L1 gas price 0") + + // ErrInvalidIP is returned if the IP address is invalid. + ErrInvalidIP = errors.New("invalid IP address") + + // ErrOutOfCounters is returned if the pool is out of counters. + ErrOutOfCounters = errors.New("out of counters") ) diff --git a/pool/pool.go b/pool/pool.go index b2869c6e45..bccda0dc7f 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -38,6 +38,7 @@ type Pool struct { state stateInterface chainID uint64 cfg Config + batchConstraintsCfg state.BatchConstraintsCfg blockedAddresses sync.Map minSuggestedGasPrice *big.Int minSuggestedGasPriceMux *sync.RWMutex @@ -63,10 +64,11 @@ type GasPrices struct { } // NewPool creates and initializes an instance of Pool -func NewPool(cfg Config, s storage, st stateInterface, chainID uint64, eventLog *event.EventLog) *Pool { +func NewPool(cfg Config, batchConstraintsCfg state.BatchConstraintsCfg, s storage, st stateInterface, chainID uint64, eventLog *event.EventLog) *Pool { startTimestamp := time.Now() p := &Pool{ cfg: cfg, + batchConstraintsCfg: batchConstraintsCfg, startTimestamp: startTimestamp, storage: s, state: st, @@ -195,7 +197,7 @@ func (p *Pool) StoreTx(ctx context.Context, tx types.Transaction, ip string, isW log.Errorf("error adding event: %v", err) } // Do not add tx to the pool - return fmt.Errorf("out of counters") + return ErrOutOfCounters } else if preExecutionResponse.isOOG { event := &event.Event{ ReceivedAt: time.Now(), @@ -231,10 +233,18 @@ func (p *Pool) preExecuteTx(ctx context.Context, tx types.Transaction) (preExecu if processBatchResponse.Responses != nil && len(processBatchResponse.Responses) > 0 { errorToCheck := processBatchResponse.Responses[0].RomError - response.isReverted = errors.Is(errorToCheck, runtime.ErrExecutionReverted) response.isExecutorLevelError = processBatchResponse.IsExecutorLevelError - response.isOOC = executor.IsROMOutOfCountersError(executor.RomErrorCode(errorToCheck)) - response.isOOG = errors.Is(errorToCheck, runtime.ErrOutOfGas) + if errorToCheck != nil { + response.isReverted = errors.Is(errorToCheck, runtime.ErrExecutionReverted) + response.isOOC = executor.IsROMOutOfCountersError(executor.RomErrorCode(errorToCheck)) + response.isOOG = errors.Is(errorToCheck, runtime.ErrOutOfGas) + } else { + if !p.batchConstraintsCfg.IsWithinConstraints(processBatchResponse.UsedZkCounters) { + response.isOOC = true + log.Errorf("OutOfCounters Error (Node level) for tx: %s", tx.Hash().String()) + } + } + response.usedZkCounters = processBatchResponse.UsedZkCounters response.txResponse = processBatchResponse.Responses[0] } @@ -303,6 +313,11 @@ func (p *Pool) IsTxPending(ctx context.Context, hash common.Hash) (bool, error) } func (p *Pool) validateTx(ctx context.Context, poolTx Transaction) error { + // Make sure the IP is valid. + if poolTx.IP != "" && !IsValidIP(poolTx.IP) { + return ErrInvalidIP + } + // Make sure the transaction is signed properly. if err := state.CheckSignature(poolTx.Transaction); err != nil { return ErrInvalidSender diff --git a/pool/pool_test.go b/pool/pool_test.go index 7cfe3128a0..3ff62196cf 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -70,6 +70,19 @@ var ( l1GasPrice = big.NewInt(1000000000000) gasLimit = uint64(21000) chainID = big.NewInt(1337) + bc = state.BatchConstraintsCfg{ + MaxTxsPerBatch: 300, + MaxBatchBytesSize: 120000, + MaxCumulativeGasUsed: 30000000, + MaxKeccakHashes: 2145, + MaxPoseidonHashes: 252357, + MaxPoseidonPaddings: 135191, + MaxMemAligns: 236585, + MaxArithmetics: 236585, + MaxBinaries: 473170, + MaxSteps: 7570538, + } + ip = "101.1.50.20" ) func TestMain(m *testing.M) { @@ -119,7 +132,7 @@ func Test_AddTx(t *testing.T) { require.NoError(t, err) const chainID = 2576980377 - p := setupPool(t, cfg, s, st, chainID, ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID, ctx, eventLog) tx := new(ethTypes.Transaction) expectedTxEncoded := "0xf86880843b9aca008252089400000000000000000000000000000000000000008080850133333355a03ee24709870c8dbc67884c9c8acb864c1aceaaa7332b9a3db0d7a5d7c68eb8e4a0302980b070f5e3ffca3dc27b07daf69d66ab27d4df648e0b3ed059cf23aa168d" @@ -127,7 +140,7 @@ func Test_AddTx(t *testing.T) { require.NoError(t, err) tx.UnmarshalBinary(b) //nolint:gosec,errcheck - err = p.AddTx(ctx, *tx, "") + err = p.AddTx(ctx, *tx, ip) require.NoError(t, err) rows, err := poolSqlDB.Query(ctx, "SELECT hash, encoded, decoded, status, used_steps FROM pool.transaction") @@ -200,7 +213,7 @@ func Test_AddTx_OversizedData(t *testing.T) { require.NoError(t, err) const chainID = 2576980377 - p := pool.NewPool(cfg, s, st, chainID, eventLog) + p := pool.NewPool(cfg, bc, s, st, chainID, eventLog) b := make([]byte, cfg.MaxTxBytesSize+1) to := common.HexToAddress(operations.DefaultSequencerAddress) @@ -212,7 +225,7 @@ func Test_AddTx_OversizedData(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.EqualError(t, err, pool.ErrOversizedData.Error()) } @@ -266,7 +279,7 @@ func Test_AddPreEIP155Tx(t *testing.T) { require.NoError(t, err) const chainID = 2576980377 - p := setupPool(t, cfg, s, st, chainID, ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID, ctx, eventLog) batchL2Data := "0xe580843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae98808464fbb77c6b39bdc5f8e458aba689f2a1ff8c543a94e4817bda40f3fe34080c4ab26c1e3c2fc2cda93bc32f0a79940501fd505dcf48d94abfde932ebf1417f502cb0d9de81bff" b, err := hex.DecodeHex(batchL2Data) @@ -276,7 +289,7 @@ func Test_AddPreEIP155Tx(t *testing.T) { tx := txs[0] - err = p.AddTx(ctx, tx, "") + err = p.AddTx(ctx, tx, ip) require.NoError(t, err) rows, err := poolSqlDB.Query(ctx, "SELECT hash, encoded, decoded, status FROM pool.transaction") @@ -335,7 +348,7 @@ func Test_GetPendingTxs(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) const txsCount = 10 const limit = 5 @@ -351,7 +364,7 @@ func Test_GetPendingTxs(t *testing.T) { tx := ethTypes.NewTransaction(uint64(i), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) } @@ -395,7 +408,7 @@ func Test_GetPendingTxsZeroPassed(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) const txsCount = 10 const limit = 0 @@ -411,7 +424,7 @@ func Test_GetPendingTxsZeroPassed(t *testing.T) { tx := ethTypes.NewTransaction(uint64(i), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) } @@ -455,7 +468,7 @@ func Test_GetTopPendingTxByProfitabilityAndZkCounters(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) const txsCount = 10 @@ -470,7 +483,7 @@ func Test_GetTopPendingTxByProfitabilityAndZkCounters(t *testing.T) { tx := ethTypes.NewTransaction(uint64(i), common.Address{}, big.NewInt(10), gasLimit, big.NewInt(gasPrice.Int64()+int64(i)), []byte{}) signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) } @@ -515,7 +528,7 @@ func Test_UpdateTxsStatus(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -526,13 +539,13 @@ func Test_UpdateTxsStatus(t *testing.T) { tx1 := ethTypes.NewTransaction(uint64(0), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx1, err := auth.Signer(auth.From, tx1) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx1, "") + err = p.AddTx(ctx, *signedTx1, ip) require.NoError(t, err) tx2 := ethTypes.NewTransaction(uint64(1), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx2, err := auth.Signer(auth.From, tx2) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx2, "") + err = p.AddTx(ctx, *signedTx2, ip) require.NoError(t, err) expectedFailedReason := "failed" @@ -606,7 +619,7 @@ func Test_UpdateTxStatus(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -616,7 +629,7 @@ func Test_UpdateTxStatus(t *testing.T) { tx := ethTypes.NewTransaction(uint64(0), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - if err := p.AddTx(ctx, *signedTx, ""); err != nil { + if err := p.AddTx(ctx, *signedTx, ip); err != nil { t.Error(err) } expectedFailedReason := "failed" @@ -649,7 +662,7 @@ func Test_SetAndGetGasPrice(t *testing.T) { require.NoError(t, err) eventLog := event.NewEventLog(event.Config{}, eventStorage) - p := pool.NewPool(cfg, s, nil, chainID.Uint64(), eventLog) + p := pool.NewPool(cfg, bc, s, nil, chainID.Uint64(), eventLog) nBig, err := rand.Int(rand.Reader, big.NewInt(0).SetUint64(math.MaxUint64)) require.NoError(t, err) @@ -674,7 +687,7 @@ func TestDeleteGasPricesHistoryOlderThan(t *testing.T) { require.NoError(t, err) eventLog := event.NewEventLog(event.Config{}, eventStorage) - p := pool.NewPool(cfg, s, nil, chainID.Uint64(), eventLog) + p := pool.NewPool(cfg, bc, s, nil, chainID.Uint64(), eventLog) ctx := context.Background() @@ -743,7 +756,7 @@ func TestGetPendingTxSince(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) const txsCount = 10 @@ -763,7 +776,7 @@ func TestGetPendingTxSince(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) txsAddedTime = append(txsAddedTime, time.Now()) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) txsAddedHashes = append(txsAddedHashes, signedTx.Hash()) time.Sleep(1 * time.Second) @@ -835,7 +848,7 @@ func Test_DeleteTransactionsByHashes(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -846,13 +859,13 @@ func Test_DeleteTransactionsByHashes(t *testing.T) { tx1 := ethTypes.NewTransaction(uint64(0), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx1, err := auth.Signer(auth.From, tx1) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx1, "") + err = p.AddTx(ctx, *signedTx1, ip) require.NoError(t, err) tx2 := ethTypes.NewTransaction(uint64(1), common.Address{}, big.NewInt(10), gasLimit, gasPrice, []byte{}) signedTx2, err := auth.Signer(auth.From, tx2) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx2, "") + err = p.AddTx(ctx, *signedTx2, ip) require.NoError(t, err) err = p.DeleteTransactionsByHashes(ctx, []common.Hash{signedTx1.Hash(), signedTx2.Hash()}) @@ -985,8 +998,8 @@ func Test_TryAddIncompatibleTxs(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { incompatibleTx := testCase.createIncompatibleTx() - p := setupPool(t, cfg, s, st, incompatibleTx.ChainId().Uint64(), ctx, eventLog) - err = p.AddTx(ctx, incompatibleTx, "") + p := setupPool(t, cfg, bc, s, st, incompatibleTx.ChainId().Uint64(), ctx, eventLog) + err = p.AddTx(ctx, incompatibleTx, ip) assert.Equal(t, testCase.expectedError, err) }) } @@ -1050,7 +1063,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -1069,7 +1082,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err) assert.Equal(t, err.Error(), pool.ErrIntrinsicGas.Error()) @@ -1083,7 +1096,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err) assert.Equal(t, err.Error(), pool.ErrIntrinsicGas.Error()) @@ -1097,7 +1110,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) tx = ethTypes.NewTx(ðTypes.LegacyTx{ @@ -1110,7 +1123,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err) assert.Equal(t, err.Error(), pool.ErrIntrinsicGas.Error()) @@ -1124,7 +1137,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err) assert.Equal(t, err.Error(), pool.ErrIntrinsicGas.Error()) @@ -1138,7 +1151,7 @@ func Test_AddTxWithIntrinsicGasTooLow(t *testing.T) { }) signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) txs, err := p.GetPendingTxs(ctx, 0) @@ -1230,7 +1243,7 @@ func Test_AddTx_GasPriceErr(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) tx := ethTypes.NewTx(ðTypes.LegacyTx{ Nonce: tc.nonce, To: tc.to, @@ -1248,7 +1261,7 @@ func Test_AddTx_GasPriceErr(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) if tc.expectedError != nil { require.ErrorIs(t, err, tc.expectedError) } else { @@ -1287,9 +1300,9 @@ func Test_AddRevertedTx(t *testing.T) { require.NoError(t, dbTx.Commit(ctx)) s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) - require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -1309,7 +1322,7 @@ func Test_AddRevertedTx(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) txs, err := p.GetPendingTxs(ctx, 0) @@ -1382,7 +1395,7 @@ func Test_BlockedAddress(t *testing.T) { GlobalQueue: 1024, } - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) gasPrices, err := p.GetGasPrices(ctx) require.NoError(t, err) @@ -1398,7 +1411,7 @@ func Test_BlockedAddress(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) // block address @@ -1419,7 +1432,7 @@ func Test_BlockedAddress(t *testing.T) { signedTx, err = auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Equal(t, pool.ErrBlockedSender, err) // remove block @@ -1430,7 +1443,7 @@ func Test_BlockedAddress(t *testing.T) { time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration) // allowed to add tx again - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) } @@ -1504,7 +1517,7 @@ func Test_AddTx_GasOverBatchLimit(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) tx := ethTypes.NewTx(ðTypes.LegacyTx{ Nonce: tc.nonce, To: tc.to, @@ -1522,7 +1535,7 @@ func Test_AddTx_GasOverBatchLimit(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) if tc.expectedError != nil { require.ErrorIs(t, err, tc.expectedError) } else { @@ -1578,7 +1591,7 @@ func Test_AddTx_AccountQueueLimit(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) privateKey, err := crypto.HexToECDSA(strings.TrimPrefix(senderPrivateKey, "0x")) require.NoError(t, err) @@ -1598,7 +1611,7 @@ func Test_AddTx_AccountQueueLimit(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) nonce++ } @@ -1613,7 +1626,7 @@ func Test_AddTx_AccountQueueLimit(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err, pool.ErrNonceTooHigh) } @@ -1679,7 +1692,7 @@ func Test_AddTx_GlobalQueueLimit(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) for _, privateKey := range accounts { auth, err := bind.NewKeyedTransactorWithChainID(privateKey, chainID) @@ -1694,7 +1707,7 @@ func Test_AddTx_GlobalQueueLimit(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.NoError(t, err) } @@ -1714,7 +1727,7 @@ func Test_AddTx_GlobalQueueLimit(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err, pool.ErrTxPoolOverflow) } @@ -1765,7 +1778,7 @@ func Test_AddTx_NonceTooHigh(t *testing.T) { s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) require.NoError(t, err) - p := setupPool(t, cfg, s, st, chainID.Uint64(), ctx, eventLog) + p := setupPool(t, cfg, bc, s, st, chainID.Uint64(), ctx, eventLog) tx := ethTypes.NewTx(ðTypes.LegacyTx{ Nonce: cfg.AccountQueue, @@ -1783,12 +1796,80 @@ func Test_AddTx_NonceTooHigh(t *testing.T) { signedTx, err := auth.Signer(auth.From, tx) require.NoError(t, err) - err = p.AddTx(ctx, *signedTx, "") + err = p.AddTx(ctx, *signedTx, ip) require.Error(t, err, pool.ErrNonceTooHigh) } -func setupPool(t *testing.T, cfg pool.Config, s *pgpoolstorage.PostgresPoolStorage, st *state.State, chainID uint64, ctx context.Context, eventLog *event.EventLog) *pool.Pool { - p := pool.NewPool(cfg, s, st, chainID, eventLog) +func Test_AddTx_IPValidation(t *testing.T) { + var tests = []struct { + name string + ip string + expected error + }{ + {"Valid IPv4", "127.0.0.1", nil}, + {"Valid IPv6", "2001:db8:0:1:1:1:1:1", nil}, + {"Invalid IP", "300.0.0.1", pool.ErrInvalidIP}, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + initOrResetDB(t) + + stateSqlDB, err := db.NewSQLDB(stateDBCfg) + require.NoError(t, err) + defer stateSqlDB.Close() //nolint:gosec,errcheck + + poolSqlDB, err := db.NewSQLDB(poolDBCfg) + require.NoError(t, err) + + defer poolSqlDB.Close() //nolint:gosec,errcheck + + eventStorage, err := nileventstorage.NewNilEventStorage() + if err != nil { + log.Fatal(err) + } + eventLog := event.NewEventLog(event.Config{}, eventStorage) + + st := newState(stateSqlDB, eventLog) + + genesisBlock := state.Block{ + BlockNumber: 0, + BlockHash: state.ZeroHash, + ParentHash: state.ZeroHash, + ReceivedAt: time.Now(), + } + ctx := context.Background() + dbTx, err := st.BeginStateTransaction(ctx) + require.NoError(t, err) + _, err = st.SetGenesis(ctx, genesisBlock, genesis, dbTx) + require.NoError(t, err) + require.NoError(t, dbTx.Commit(ctx)) + + s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) + require.NoError(t, err) + + const chainID = 2576980377 + p := setupPool(t, cfg, bc, s, st, chainID, ctx, eventLog) + + tx := new(ethTypes.Transaction) + expectedTxEncoded := "0xf86880843b9aca008252089400000000000000000000000000000000000000008080850133333355a03ee24709870c8dbc67884c9c8acb864c1aceaaa7332b9a3db0d7a5d7c68eb8e4a0302980b070f5e3ffca3dc27b07daf69d66ab27d4df648e0b3ed059cf23aa168d" + b, err := hex.DecodeHex(expectedTxEncoded) + require.NoError(t, err) + tx.UnmarshalBinary(b) //nolint:gosec,errcheck + + err = p.AddTx(context.Background(), *tx, tc.ip) + + if tc.expected != nil { + assert.ErrorIs(t, err, tc.expected) + } else { + assert.NoError(t, err) + } + }) + } +} + +func setupPool(t *testing.T, cfg pool.Config, constraintsCfg state.BatchConstraintsCfg, s *pgpoolstorage.PostgresPoolStorage, st *state.State, chainID uint64, ctx context.Context, eventLog *event.EventLog) *pool.Pool { + p := pool.NewPool(cfg, constraintsCfg, s, st, chainID, eventLog) err := p.SetGasPrices(ctx, gasPrice.Uint64(), l1GasPrice.Uint64()) require.NoError(t, err) diff --git a/pool/validation.go b/pool/validation.go new file mode 100644 index 0000000000..daf1460115 --- /dev/null +++ b/pool/validation.go @@ -0,0 +1,8 @@ +package pool + +import "net" + +// IsValidIP returns true if the given string is a valid IP address +func IsValidIP(ip string) bool { + return ip != "" && net.ParseIP(ip) != nil +} diff --git a/pool/validation_test.go b/pool/validation_test.go new file mode 100644 index 0000000000..d03ee86fc1 --- /dev/null +++ b/pool/validation_test.go @@ -0,0 +1,27 @@ +package pool + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_IsValidIP(t *testing.T) { + var tests = []struct { + name string + ip string + expected bool + }{ + {"Valid IPv4", "127.0.0.1", true}, + {"Valid IPv6", "2001:db8:0:1:1:1:1:1", true}, + {"Invalid IP", "300.0.0.1", false}, + {"Empty IP", "", false}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := IsValidIP(tt.ip) + assert.Equal(t, tt.expected, result) + }) + } +} diff --git a/sequencer/closingsignalsmanager_test.go b/sequencer/closingsignalsmanager_test.go index e6eca56cef..2b6b8fc179 100644 --- a/sequencer/closingsignalsmanager_test.go +++ b/sequencer/closingsignalsmanager_test.go @@ -74,7 +74,7 @@ func setupTest(t *testing.T) { localStateTree := merkletree.NewStateTree(localMtDBServiceClient) localState = state.NewState(stateCfg, state.NewPostgresStorage(localStateDb), localExecutorClient, localStateTree, eventLog) - batchConstraints := batchConstraints{ + batchConstraints := state.BatchConstraintsCfg{ MaxTxsPerBatch: 300, MaxBatchBytesSize: 120000, MaxCumulativeGasUsed: 30000000, diff --git a/sequencer/config.go b/sequencer/config.go index 7a98925ca0..321c503943 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -16,37 +16,6 @@ type Config struct { // FrequencyToCheckTxsForDelete is frequency with which txs will be checked for deleting FrequencyToCheckTxsForDelete types.Duration `mapstructure:"FrequencyToCheckTxsForDelete"` - // MaxTxsPerBatch is the maximum amount of transactions in the batch - MaxTxsPerBatch uint64 `mapstructure:"MaxTxsPerBatch"` - - // MaxBatchBytesSize is the maximum batch size in bytes - // (subtracted bits of all types.Sequence fields excluding BatchL2Data from MaxTxSizeForL1) - MaxBatchBytesSize uint64 `mapstructure:"MaxBatchBytesSize"` - - // MaxCumulativeGasUsed is max gas amount used by batch - MaxCumulativeGasUsed uint64 `mapstructure:"MaxCumulativeGasUsed"` - - // MaxKeccakHashes is max keccak hashes used by batch - MaxKeccakHashes uint32 `mapstructure:"MaxKeccakHashes"` - - // MaxPoseidonHashes is max poseidon hashes batch can handle - MaxPoseidonHashes uint32 `mapstructure:"MaxPoseidonHashes"` - - // MaxPoseidonPaddings is max poseidon paddings batch can handle - MaxPoseidonPaddings uint32 `mapstructure:"MaxPoseidonPaddings"` - - // MaxMemAligns is max mem aligns batch can handle - MaxMemAligns uint32 `mapstructure:"MaxMemAligns"` - - // MaxArithmetics is max arithmetics batch can handle - MaxArithmetics uint32 `mapstructure:"MaxArithmetics"` - - // MaxBinaries is max binaries batch can handle - MaxBinaries uint32 `mapstructure:"MaxBinaries"` - - // MaxSteps is max steps batch can handle - MaxSteps uint32 `mapstructure:"MaxSteps"` - // TxLifetimeCheckTimeout is the time the sequencer waits to check txs lifetime TxLifetimeCheckTimeout types.Duration `mapstructure:"TxLifetimeCheckTimeout"` diff --git a/sequencer/dbmanager.go b/sequencer/dbmanager.go index b47de338ef..1af2f80420 100644 --- a/sequencer/dbmanager.go +++ b/sequencer/dbmanager.go @@ -21,7 +21,7 @@ type dbManager struct { worker workerInterface l2ReorgCh chan L2ReorgEvent ctx context.Context - batchConstraints batchConstraints + batchConstraints state.BatchConstraintsCfg numberOfReorgs uint64 } @@ -41,7 +41,7 @@ type ClosingBatchParameters struct { EffectivePercentages []uint8 } -func newDBManager(ctx context.Context, config DBManagerCfg, txPool txPool, state stateInterface, worker *Worker, closingSignalCh ClosingSignalCh, batchConstraints batchConstraints) *dbManager { +func newDBManager(ctx context.Context, config DBManagerCfg, txPool txPool, state stateInterface, worker *Worker, closingSignalCh ClosingSignalCh, batchConstraints state.BatchConstraintsCfg) *dbManager { numberOfReorgs, err := state.CountReorgs(ctx, nil) if err != nil { log.Error("failed to get number of reorgs: %v", err) @@ -270,7 +270,7 @@ func (d *dbManager) GetWIPBatch(ctx context.Context) (*WipBatch, error) { // Init counters to MAX values var totalBytes uint64 = d.batchConstraints.MaxBatchBytesSize - var batchZkCounters state.ZKCounters = state.ZKCounters{ + var batchZkCounters = state.ZKCounters{ CumulativeGasUsed: d.batchConstraints.MaxCumulativeGasUsed, UsedKeccakHashes: d.batchConstraints.MaxKeccakHashes, UsedPoseidonHashes: d.batchConstraints.MaxPoseidonHashes, diff --git a/sequencer/dbmanager_test.go b/sequencer/dbmanager_test.go index 0a8cf82c23..7cfa8d8ff1 100644 --- a/sequencer/dbmanager_test.go +++ b/sequencer/dbmanager_test.go @@ -73,7 +73,7 @@ func setupDBManager() { GERCh: make(chan common.Hash), L2ReorgCh: make(chan L2ReorgEvent), } - batchConstraints := batchConstraints{ + batchConstraints := state.BatchConstraintsCfg{ MaxTxsPerBatch: 300, MaxBatchBytesSize: 120000, MaxCumulativeGasUsed: 30000000, diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index d41f98c617..b83405e067 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -42,7 +42,7 @@ type finalizer struct { dbManager dbManagerInterface executor stateInterface batch *WipBatch - batchConstraints batchConstraints + batchConstraints state.BatchConstraintsCfg processRequest state.ProcessRequest sharedResourcesMux *sync.RWMutex lastGERHash common.Hash @@ -110,7 +110,7 @@ func newFinalizer( sequencerAddr common.Address, isSynced func(ctx context.Context) bool, closingSignalCh ClosingSignalCh, - batchConstraints batchConstraints, + batchConstraints state.BatchConstraintsCfg, eventLog *event.EventLog, ) *finalizer { return &finalizer{ @@ -1257,7 +1257,7 @@ func (f *finalizer) getConstraintThresholdUint32(input uint32) uint32 { } // getUsedBatchResources returns the used resources in the batch -func getUsedBatchResources(constraints batchConstraints, remainingResources state.BatchResources) state.BatchResources { +func getUsedBatchResources(constraints state.BatchConstraintsCfg, remainingResources state.BatchResources) state.BatchResources { return state.BatchResources{ ZKCounters: state.ZKCounters{ CumulativeGasUsed: constraints.MaxCumulativeGasUsed - remainingResources.ZKCounters.CumulativeGasUsed, diff --git a/sequencer/finalizer_test.go b/sequencer/finalizer_test.go index d205a97aae..48b6ded9c7 100644 --- a/sequencer/finalizer_test.go +++ b/sequencer/finalizer_test.go @@ -33,7 +33,7 @@ var ( executorMock = new(StateMock) workerMock = new(WorkerMock) dbTxMock = new(DbTxMock) - bc = batchConstraints{ + bc = state.BatchConstraintsCfg{ MaxTxsPerBatch: 300, MaxBatchBytesSize: 120000, MaxCumulativeGasUsed: 30000000, diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index 8644f7bdc7..28c1e784a4 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -17,7 +17,8 @@ import ( // Sequencer represents a sequencer type Sequencer struct { - cfg Config + cfg Config + batchCfg state.BatchConfig pool txPool state stateInterface @@ -28,20 +29,6 @@ type Sequencer struct { address common.Address } -// batchConstraints represents the constraints for a batch -type batchConstraints struct { - MaxTxsPerBatch uint64 - MaxBatchBytesSize uint64 - MaxCumulativeGasUsed uint64 - MaxKeccakHashes uint32 - MaxPoseidonHashes uint32 - MaxPoseidonPaddings uint32 - MaxMemAligns uint32 - MaxArithmetics uint32 - MaxBinaries uint32 - MaxSteps uint32 -} - // L2ReorgEvent is the event that is triggered when a reorg happens in the L2 type L2ReorgEvent struct { TxHashes []common.Hash @@ -55,7 +42,7 @@ type ClosingSignalCh struct { } // New init sequencer -func New(cfg Config, txPool txPool, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*Sequencer, error) { +func New(cfg Config, batchCfg state.BatchConfig, txPool txPool, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*Sequencer, error) { addr, err := etherman.TrustedSequencer() if err != nil { return nil, fmt.Errorf("failed to get trusted sequencer address, err: %v", err) @@ -63,6 +50,7 @@ func New(cfg Config, txPool txPool, state stateInterface, etherman etherman, man return &Sequencer{ cfg: cfg, + batchCfg: batchCfg, pool: txPool, state: state, etherman: etherman, @@ -86,29 +74,17 @@ func (s *Sequencer) Start(ctx context.Context) { L2ReorgCh: make(chan L2ReorgEvent), } - batchConstraints := batchConstraints{ - MaxTxsPerBatch: s.cfg.MaxTxsPerBatch, - MaxBatchBytesSize: s.cfg.MaxBatchBytesSize, - MaxCumulativeGasUsed: s.cfg.MaxCumulativeGasUsed, - MaxKeccakHashes: s.cfg.MaxKeccakHashes, - MaxPoseidonHashes: s.cfg.MaxPoseidonHashes, - MaxPoseidonPaddings: s.cfg.MaxPoseidonPaddings, - MaxMemAligns: s.cfg.MaxMemAligns, - MaxArithmetics: s.cfg.MaxArithmetics, - MaxBinaries: s.cfg.MaxBinaries, - MaxSteps: s.cfg.MaxSteps, - } - err := s.pool.MarkWIPTxsAsPending(ctx) if err != nil { log.Fatalf("failed to mark WIP txs as pending, err: %v", err) } - worker := NewWorker(s.state) - dbManager := newDBManager(ctx, s.cfg.DBManager, s.pool, s.state, worker, closingSignalCh, batchConstraints) + worker := NewWorker(s.state, s.batchCfg.Constraints) + dbManager := newDBManager(ctx, s.cfg.DBManager, s.pool, s.state, worker, closingSignalCh, s.batchCfg.Constraints) go dbManager.Start() - finalizer := newFinalizer(s.cfg.Finalizer, s.cfg.EffectiveGasPrice, worker, dbManager, s.state, s.address, s.isSynced, closingSignalCh, batchConstraints, s.eventLog) + finalizer := newFinalizer(s.cfg.Finalizer, s.cfg.EffectiveGasPrice, worker, dbManager, s.state, s.address, s.isSynced, closingSignalCh, s.batchCfg.Constraints, s.eventLog) + currBatch, processingReq := s.bootstrap(ctx, dbManager, finalizer) go finalizer.Start(ctx, currBatch, processingReq) @@ -250,7 +226,7 @@ func (s *Sequencer) isSynced(ctx context.Context) bool { return true } -func getMaxRemainingResources(constraints batchConstraints) state.BatchResources { +func getMaxRemainingResources(constraints state.BatchConstraintsCfg) state.BatchResources { return state.BatchResources{ ZKCounters: state.ZKCounters{ CumulativeGasUsed: constraints.MaxCumulativeGasUsed, diff --git a/sequencer/worker.go b/sequencer/worker.go index f6abbe6b0e..124f6af535 100644 --- a/sequencer/worker.go +++ b/sequencer/worker.go @@ -9,6 +9,7 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -16,18 +17,20 @@ import ( // Worker represents the worker component of the sequencer type Worker struct { - pool map[string]*addrQueue - txSortedList *txSortedList - workerMutex sync.Mutex - state stateInterface + pool map[string]*addrQueue + txSortedList *txSortedList + workerMutex sync.Mutex + state stateInterface + batchConstraints state.BatchConstraintsCfg } // NewWorker creates an init a worker -func NewWorker(state stateInterface) *Worker { +func NewWorker(state stateInterface, constraints state.BatchConstraintsCfg) *Worker { w := Worker{ - pool: make(map[string]*addrQueue), - txSortedList: newTxSortedList(), - state: state, + pool: make(map[string]*addrQueue), + batchConstraints: constraints, + txSortedList: newTxSortedList(), + state: state, } return &w @@ -42,8 +45,20 @@ func (w *Worker) NewTxTracker(tx types.Transaction, counters state.ZKCounters, i func (w *Worker) AddTxTracker(ctx context.Context, tx *TxTracker) (replacedTx *TxTracker, dropReason error) { w.workerMutex.Lock() - addr, found := w.pool[tx.FromStr] + // Make sure the IP is valid. + if tx.IP != "" && !pool.IsValidIP(tx.IP) { + w.workerMutex.Unlock() + return nil, pool.ErrInvalidIP + } + // Make sure the transaction's batch resources are within the constraints. + if !w.batchConstraints.IsWithinConstraints(tx.BatchResources.ZKCounters) { + log.Errorf("OutOfCounters Error (Node level) for tx: %s", tx.Hash.String()) + w.workerMutex.Unlock() + return nil, pool.ErrOutOfCounters + } + + addr, found := w.pool[tx.FromStr] if !found { // Unlock the worker to let execute other worker functions while creating the new AddrQueue w.workerMutex.Unlock() diff --git a/sequencer/worker_test.go b/sequencer/worker_test.go index 98382898e5..837f59aeaf 100644 --- a/sequencer/worker_test.go +++ b/sequencer/worker_test.go @@ -5,11 +5,31 @@ import ( "math/big" "testing" + "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" ) +const ( + validIP = "10.23.100.1" +) + +var ( + // Init ZKEVM resourceCostMax values + rcMax = state.BatchConstraintsCfg{ + MaxCumulativeGasUsed: 10, + MaxArithmetics: 10, + MaxBinaries: 10, + MaxKeccakHashes: 10, + MaxMemAligns: 10, + MaxPoseidonHashes: 10, + MaxPoseidonPaddings: 10, + MaxSteps: 10, + MaxBatchBytesSize: 10, + } +) + type workerAddTxTestCase struct { name string from common.Address @@ -20,6 +40,8 @@ type workerAddTxTestCase struct { usedBytes uint64 gasPrice *big.Int expectedTxSortedList []common.Hash + ip string + expectedErr error } type workerAddrQueueInfo struct { @@ -42,10 +64,17 @@ func processWorkerAddTxTestCases(ctx context.Context, t *testing.T, worker *Work tx.BatchResources.Bytes = testCase.usedBytes tx.GasPrice = testCase.gasPrice tx.updateZKCounters(testCase.counters) + if testCase.ip == "" { + // A random valid IP Address + tx.IP = validIP + } else { + tx.IP = testCase.ip + } t.Logf("%s=%d", testCase.name, tx.GasPrice) _, err := worker.AddTxTracker(ctx, &tx) - if err != nil { + if err != nil && testCase.expectedErr != nil { + assert.ErrorIs(t, err, testCase.expectedErr) return } @@ -66,9 +95,9 @@ func TestWorkerAddTx(t *testing.T) { var nilErr error stateMock := NewStateMock(t) - worker := initWorker(stateMock) + worker := initWorker(stateMock, rcMax) - ctx := context.Background() + ctx = context.Background() stateMock.On("GetLastStateRoot", ctx, nil).Return(common.Hash{0}, nilErr) @@ -121,6 +150,31 @@ func TestWorkerAddTx(t *testing.T) { {3}, {2}, {1}, }, }, + { + name: "Invalid IP address", from: common.Address{5}, txHash: common.Hash{5}, nonce: 1, + counters: state.ZKCounters{CumulativeGasUsed: 1, UsedKeccakHashes: 1, UsedPoseidonHashes: 1, UsedPoseidonPaddings: 1, UsedMemAligns: 1, UsedArithmetics: 1, UsedBinaries: 1, UsedSteps: 1}, + usedBytes: 1, + ip: "invalid IP", + expectedErr: pool.ErrInvalidIP, + }, + { + name: "Out Of Counters Err", + from: common.Address{5}, txHash: common.Hash{5}, nonce: 1, + cost: new(big.Int).SetInt64(5), + // Here, we intentionally set the counters such that they violate the constraints + counters: state.ZKCounters{ + CumulativeGasUsed: worker.batchConstraints.MaxCumulativeGasUsed + 1, + UsedKeccakHashes: worker.batchConstraints.MaxKeccakHashes + 1, + UsedPoseidonHashes: worker.batchConstraints.MaxPoseidonHashes + 1, + UsedPoseidonPaddings: worker.batchConstraints.MaxPoseidonPaddings + 1, + UsedMemAligns: worker.batchConstraints.MaxMemAligns + 1, + UsedArithmetics: worker.batchConstraints.MaxArithmetics + 1, + UsedBinaries: worker.batchConstraints.MaxBinaries + 1, + UsedSteps: worker.batchConstraints.MaxSteps + 1, + }, + usedBytes: 1, + expectedErr: pool.ErrOutOfCounters, + }, { name: "Adding from:0x04, tx:0x04/gp:100", from: common.Address{4}, txHash: common.Hash{4}, nonce: 1, gasPrice: new(big.Int).SetInt64(100), cost: new(big.Int).SetInt64(5), @@ -144,7 +198,7 @@ func TestWorkerGetBestTx(t *testing.T) { } stateMock := NewStateMock(t) - worker := initWorker(stateMock) + worker := initWorker(stateMock, rcMax) ctx := context.Background() @@ -232,7 +286,7 @@ func TestWorkerGetBestTx(t *testing.T) { } } -func initWorker(stateMock *StateMock) *Worker { - worker := NewWorker(stateMock) +func initWorker(stateMock *StateMock, rcMax state.BatchConstraintsCfg) *Worker { + worker := NewWorker(stateMock, rcMax) return worker } diff --git a/state/config.go b/state/config.go index 62cae08c93..147eda30d7 100644 --- a/state/config.go +++ b/state/config.go @@ -1,6 +1,9 @@ package state -import "github.com/0xPolygonHermez/zkevm-node/config/types" +import ( + "github.com/0xPolygonHermez/zkevm-node/config/types" + "github.com/0xPolygonHermez/zkevm-node/db" +) // Config is state config type Config struct { @@ -24,4 +27,55 @@ type Config struct { // New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade) ForkUpgradeNewForkId uint64 + + // DB is the database configuration + DB db.Config `mapstructure:"DB"` + + // Configuration for the batch constraints + Batch BatchConfig `mapstructure:"Batch"` +} + +// BatchConfig represents the configuration of the batch constraints +type BatchConfig struct { + Constraints BatchConstraintsCfg `mapstructure:"Constraints"` + ResourceWeights BatchResourceWeightsCfg `mapstructure:"ResourceWeights"` +} + +// BatchConstraintsCfg represents the configuration of the batch constraints +type BatchConstraintsCfg struct { + MaxTxsPerBatch uint64 `mapstructure:"MaxTxsPerBatch"` + MaxBatchBytesSize uint64 `mapstructure:"MaxBatchBytesSize"` + MaxCumulativeGasUsed uint64 `mapstructure:"MaxCumulativeGasUsed"` + MaxKeccakHashes uint32 `mapstructure:"MaxKeccakHashes"` + MaxPoseidonHashes uint32 `mapstructure:"MaxPoseidonHashes"` + MaxPoseidonPaddings uint32 `mapstructure:"MaxPoseidonPaddings"` + MaxMemAligns uint32 `mapstructure:"MaxMemAligns"` + MaxArithmetics uint32 `mapstructure:"MaxArithmetics"` + MaxBinaries uint32 `mapstructure:"MaxBinaries"` + MaxSteps uint32 `mapstructure:"MaxSteps"` +} + +// IsWithinConstraints checks if the counters are within the batch constraints +func (c BatchConstraintsCfg) IsWithinConstraints(counters ZKCounters) bool { + return counters.CumulativeGasUsed <= c.MaxCumulativeGasUsed && + counters.UsedKeccakHashes <= c.MaxKeccakHashes && + counters.UsedPoseidonHashes <= c.MaxPoseidonHashes && + counters.UsedPoseidonPaddings <= c.MaxPoseidonPaddings && + counters.UsedMemAligns <= c.MaxMemAligns && + counters.UsedArithmetics <= c.MaxArithmetics && + counters.UsedBinaries <= c.MaxBinaries && + counters.UsedSteps <= c.MaxSteps +} + +// BatchResourceWeightsCfg represents the configuration of the batch resource weights +type BatchResourceWeightsCfg struct { + WeightBatchBytesSize int `mapstructure:"WeightBatchBytesSize"` + WeightCumulativeGasUsed int `mapstructure:"WeightCumulativeGasUsed"` + WeightKeccakHashes int `mapstructure:"WeightKeccakHashes"` + WeightPoseidonHashes int `mapstructure:"WeightPoseidonHashes"` + WeightPoseidonPaddings int `mapstructure:"WeightPoseidonPaddings"` + WeightMemAligns int `mapstructure:"WeightMemAligns"` + WeightArithmetics int `mapstructure:"WeightArithmetics"` + WeightBinaries int `mapstructure:"WeightBinaries"` + WeightSteps int `mapstructure:"WeightSteps"` } diff --git a/test/benchmarks/sequencer/common/setup/setup.go b/test/benchmarks/sequencer/common/setup/setup.go index 066514996b..a36c4021d0 100644 --- a/test/benchmarks/sequencer/common/setup/setup.go +++ b/test/benchmarks/sequencer/common/setup/setup.go @@ -12,6 +12,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/pool/pgpoolstorage" + "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/test/benchmarks/sequencer/common/params" "github.com/0xPolygonHermez/zkevm-node/test/operations" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -26,6 +27,21 @@ const ( defaultGasPrice = 1000000000 ) +var ( + bc = state.BatchConstraintsCfg{ + MaxTxsPerBatch: 300, + MaxBatchBytesSize: 120000, + MaxCumulativeGasUsed: 30000000, + MaxKeccakHashes: 2145, + MaxPoseidonHashes: 252357, + MaxPoseidonPaddings: 135191, + MaxMemAligns: 236585, + MaxArithmetics: 236585, + MaxBinaries: 473170, + MaxSteps: 7570538, + } +) + // Environment sets up the environment for the benchmark func Environment(ctx context.Context, b *testing.B) (*operations.Manager, *ethclient.Client, *pool.Pool, *bind.TransactOpts) { if testing.Short() { @@ -64,7 +80,7 @@ func Environment(ctx context.Context, b *testing.B) (*operations.Manager, *ethcl require.NoError(b, err) eventLog := event.NewEventLog(event.Config{}, eventStorage) - pl := pool.NewPool(config, s, st, params.ChainID, eventLog) + pl := pool.NewPool(config, bc, s, st, params.ChainID, eventLog) // Print Info before send senderBalance, err := client.BalanceAt(ctx, auth.From, nil) diff --git a/test/benchmarks/sequencer/e2e/eth-transfers/tx_sender.go b/test/benchmarks/sequencer/e2e/eth-transfers/tx_sender.go index 113bf5d380..0f94e0aea7 100644 --- a/test/benchmarks/sequencer/e2e/eth-transfers/tx_sender.go +++ b/test/benchmarks/sequencer/e2e/eth-transfers/tx_sender.go @@ -40,8 +40,8 @@ func TxSender(l2Client *ethclient.Client, gasPrice *big.Int, nonce uint64, auth } err = l2Client.SendTransaction(params.Ctx, signedTx) - if errors.Is(err, state.ErrStateNotSynchronized) { - for errors.Is(err, state.ErrStateNotSynchronized) { + if errors.Is(err, state.ErrStateNotSynchronized) || errors.Is(err, state.ErrInsufficientFunds) { + for errors.Is(err, state.ErrStateNotSynchronized) || errors.Is(err, state.ErrInsufficientFunds) { time.Sleep(sleepTime) err = l2Client.SendTransaction(params.Ctx, signedTx) } diff --git a/test/config/debug.node.config.toml b/test/config/debug.node.config.toml index a9507b3396..da0a63beaf 100644 --- a/test/config/debug.node.config.toml +++ b/test/config/debug.node.config.toml @@ -5,14 +5,15 @@ Environment = "development" # "production" or "development" Level = "debug" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "localhost" -Port = "5432" -EnableLog = true -MaxConns = 10 +[State] + [State.DB] + User = "state_user" + Password = "state_password" + Name = "state_db" + Host = "localhost" + Port = "5432" + EnableLog = true + MaxConns = 10 [Pool] FreeClaimGasLimit = 1500000 @@ -59,16 +60,6 @@ TrustedSequencerURL = "" WaitPeriodPoolIsEmpty = "1s" BlocksAmountForTxsToBeDeleted = 100 FrequencyToCheckTxsForDelete = "12h" -MaxTxsPerBatch = 300 -MaxBatchBytesSize = 120000 -MaxCumulativeGasUsed = 30000000 -MaxKeccakHashes = 2145 -MaxPoseidonHashes = 252357 -MaxPoseidonPaddings = 135191 -MaxMemAligns = 236585 -MaxArithmetics = 236585 -MaxBinaries = 473170 -MaxSteps = 7570538 TxLifetimeCheckTimeout = "10m" MaxTxLifetime = "3h" [Sequencer.Finalizer] diff --git a/test/config/test.node.config.toml b/test/config/test.node.config.toml index 36b655558a..d59bca3b4c 100644 --- a/test/config/test.node.config.toml +++ b/test/config/test.node.config.toml @@ -5,15 +5,6 @@ Environment = "development" # "production" or "development" Level = "debug" Outputs = ["stderr"] -[StateDB] -User = "state_user" -Password = "state_password" -Name = "state_db" -Host = "zkevm-state-db" -Port = "5432" -EnableLog = false -MaxConns = 200 - [Pool] FreeClaimGasLimit = 1500000 IntervalToRefreshBlockedAddresses = "5m" @@ -60,16 +51,6 @@ WaitPeriodPoolIsEmpty = "1s" LastBatchVirtualizationTimeMaxWaitPeriod = "10s" BlocksAmountForTxsToBeDeleted = 100 FrequencyToCheckTxsForDelete = "12h" -MaxTxsPerBatch = 300 -MaxBatchBytesSize = 120000 -MaxCumulativeGasUsed = 30000000 -MaxKeccakHashes = 2145 -MaxPoseidonHashes = 252357 -MaxPoseidonPaddings = 135191 -MaxMemAligns = 236585 -MaxArithmetics = 236585 -MaxBinaries = 473170 -MaxSteps = 7570538 TxLifetimeCheckTimeout = "10m" MaxTxLifetime = "3h" [Sequencer.Finalizer] @@ -160,3 +141,36 @@ Host = "zkevm-state-db" Port = "5432" EnableLog = false MaxConns = 200 + +[State] + AccountQueue = 64 + [State.DB] + User = "state_user" + Password = "state_password" + Name = "state_db" + Host = "zkevm-state-db" + Port = "5432" + EnableLog = false + MaxConns = 200 + [State.Batch] + [State.Batch.Constraints] + MaxTxsPerBatch = 300 + MaxBatchBytesSize = 120000 + MaxCumulativeGasUsed = 30000000 + MaxKeccakHashes = 2145 + MaxPoseidonHashes = 252357 + MaxPoseidonPaddings = 135191 + MaxMemAligns = 236585 + MaxArithmetics = 236585 + MaxBinaries = 473170 + MaxSteps = 7570538 + [State.Batch.ResourceWeights] + WeightBatchBytesSize = 1 + WeightCumulativeGasUsed = 1 + WeightKeccakHashes = 1 + WeightPoseidonHashes = 1 + WeightPoseidonPaddings = 1 + WeightMemAligns = 1 + WeightArithmetics = 1 + WeightBinaries = 1 + WeightSteps = 1 diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 598ed027f4..da482a6214 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -53,7 +53,7 @@ services: - 9092:9091 # needed if metrics enabled - 6060:6060 environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db volumes: - ./config/test.node.config.toml:/app/config.toml @@ -67,7 +67,7 @@ services: container_name: zkevm-sequence-sender image: zkevm-node environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db - ZKEVM_NODE_SEQUENCER_SENDER_ADDRESS=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 volumes: @@ -87,7 +87,7 @@ services: - 8133:8133 # needed if WebSockets enabled - 9091:9091 # needed if metrics enabled environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db volumes: - ./config/test.node.config.toml:/app/config.toml @@ -104,7 +104,7 @@ services: - 50081:50081 - 9093:9091 # needed if metrics enabled environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_AGGREGATOR_SENDER_ADDRESS=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 volumes: - ./config/test.node.config.toml:/app/config.toml @@ -120,7 +120,7 @@ services: ports: - 9095:9091 # needed if metrics enabled environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db volumes: - ./config/test.node.config.toml:/app/config.toml - ./config/test.genesis.config.json:/app/genesis.json @@ -135,7 +135,7 @@ services: ports: - 9094:9091 # needed if metrics enabled environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db volumes: - ./sequencer.keystore:/pk/sequencer.keystore - ./aggregator.keystore:/pk/aggregator.keystore @@ -285,7 +285,7 @@ services: - 8124:8124 - 8134:8134 # needed if WebSockets enabled environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db - ZKEVM_NODE_RPC_PORT=8124 - ZKEVM_NODE_RPC_WEBSOCKETS_PORT=8134 @@ -353,7 +353,7 @@ services: container_name: zkevm-approve image: zkevm-node environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db volumes: - ./sequencer.keystore:/pk/keystore - ./config/test.node.config.toml:/app/config.toml @@ -392,10 +392,10 @@ services: - 8125:8125 environment: - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false - - ZKEVM_NODE_STATEDB_USER=test_user - - ZKEVM_NODE_STATEDB_PASSWORD=test_password - - ZKEVM_NODE_STATEDB_NAME=state_db - - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db + - ZKEVM_NODE_STATE_DB_USER=test_user + - ZKEVM_NODE_STATE_DB_PASSWORD=test_password + - ZKEVM_NODE_STATE_DB_NAME=state_db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-permissionless-db - ZKEVM_NODE_POOL_DB_USER=test_user - ZKEVM_NODE_POOL_DB_PASSWORD=test_password - ZKEVM_NODE_POOL_DB_NAME=pool_db @@ -443,7 +443,7 @@ services: stdin_open: true tty: true environment: - - ZKEVM_NODE_STATEDB_HOST=zkevm-state-db + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db - ZKEVM_NODE_POOL_DB_HOST=zkevm-pool-db volumes: - ./config/test.node.config.toml:/app/config.toml diff --git a/test/e2e/uniswap_test.go b/test/e2e/uniswap_test.go index 73e69c4b6c..4abc6febfe 100644 --- a/test/e2e/uniswap_test.go +++ b/test/e2e/uniswap_test.go @@ -36,7 +36,7 @@ func TestUniswap(t *testing.T) { opsCfg := &operations.Config{ State: &state.Config{ - MaxCumulativeGasUsed: cfg.Sequencer.MaxCumulativeGasUsed, + MaxCumulativeGasUsed: cfg.State.Batch.Constraints.MaxCumulativeGasUsed, }, SequenceSender: &operations.SequenceSenderConfig{ SenderAddress: "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",