diff --git a/core/lib/config/src/configs/chain.rs b/core/lib/config/src/configs/chain.rs index d35c6ed52b5..67845fcc2ae 100644 --- a/core/lib/config/src/configs/chain.rs +++ b/core/lib/config/src/configs/chain.rs @@ -45,6 +45,18 @@ impl Default for FeeModelVersion { } } +#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)] +pub enum L1BatchCommitDataGeneratorMode { + Rollup, + Validium, +} + +impl Default for L1BatchCommitDataGeneratorMode { + fn default() -> Self { + Self::Rollup + } +} + #[derive(Debug, Deserialize, Clone, PartialEq, Default)] pub struct StateKeeperConfig { /// The max number of slots for txs in a block before it should be sealed by the slots sealer. @@ -116,6 +128,8 @@ pub struct StateKeeperConfig { /// Number of keys that is processed by enum_index migration in State Keeper each L1 batch. pub enum_index_migration_chunk_size: Option, + + pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode, } impl StateKeeperConfig { @@ -150,6 +164,7 @@ impl StateKeeperConfig { virtual_blocks_per_miniblock: 1, upload_witness_inputs_to_gcs: false, enum_index_migration_chunk_size: None, + l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode::Rollup, } } diff --git a/core/lib/env_config/src/chain.rs b/core/lib/env_config/src/chain.rs index c258c5092e5..129b2b4adda 100644 --- a/core/lib/env_config/src/chain.rs +++ b/core/lib/env_config/src/chain.rs @@ -37,7 +37,7 @@ impl FromEnv for MempoolConfig { #[cfg(test)] mod tests { use zksync_basic_types::L2ChainId; - use zksync_config::configs::chain::FeeModelVersion; + use zksync_config::configs::chain::{FeeModelVersion, L1BatchCommitDataGeneratorMode}; use super::*; use crate::test_utils::{addr, EnvMutex}; @@ -94,6 +94,7 @@ mod tests { virtual_blocks_per_miniblock: 1, upload_witness_inputs_to_gcs: false, enum_index_migration_chunk_size: Some(2_000), + l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode::Rollup, } } diff --git a/core/lib/zksync_core/src/lib.rs b/core/lib/zksync_core/src/lib.rs index 9a537c73c32..d7275519992 100644 --- a/core/lib/zksync_core/src/lib.rs +++ b/core/lib/zksync_core/src/lib.rs @@ -16,8 +16,8 @@ use zksync_config::{ configs::{ api::{MerkleTreeApiConfig, Web3JsonRpcConfig}, chain::{ - CircuitBreakerConfig, MempoolConfig, NetworkConfig, OperationsManagerConfig, - StateKeeperConfig, + CircuitBreakerConfig, L1BatchCommitDataGeneratorMode, MempoolConfig, NetworkConfig, + OperationsManagerConfig, StateKeeperConfig, }, contracts::ProverAtGenesis, database::{MerkleTreeConfig, MerkleTreeMode}, @@ -554,11 +554,18 @@ pub async fn initialize_components( let eth_client = PKSigningClient::from_config(ð_sender, &contracts_config, ð_client_config); let nonce = eth_client.pending_nonce("eth_sender").await.unwrap(); + let state_keeper_config = configs + .state_keeper_config + .clone() + .context("state_keeper_config")?; let l1_batch_commit_data_generator: Arc = - if std::env::var("VALIDIUM_MODE") == Ok("true".to_owned()) { - Arc::new(ValidiumModeL1BatchCommitDataGenerator {}) - } else { - Arc::new(RollupModeL1BatchCommitDataGenerator {}) + match state_keeper_config.l1_batch_commit_data_generator_mode { + L1BatchCommitDataGeneratorMode::Rollup => { + Arc::new(RollupModeL1BatchCommitDataGenerator {}) + } + L1BatchCommitDataGeneratorMode::Validium => { + Arc::new(ValidiumModeL1BatchCommitDataGenerator {}) + } }; let eth_tx_aggregator_actor = EthTxAggregator::new( eth_sender.sender.clone(), diff --git a/etc/env/base/chain.toml b/etc/env/base/chain.toml index 4a385be905a..a47c5c498d2 100644 --- a/etc/env/base/chain.toml +++ b/etc/env/base/chain.toml @@ -93,6 +93,8 @@ virtual_blocks_per_miniblock=1 # This variable should not be set to true in any customer facing environment. upload_witness_inputs_to_gcs=false +l1_batch_commit_data_generator_mode="Validium" + [chain.operations_manager] # Sleep time when there is no new input data delay_interval=100