diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index e37a71d79c6f..88c48e39394f 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -4,7 +4,7 @@ use anyhow::Context; use serde::Deserialize; use url::Url; use zksync_basic_types::{Address, L1ChainId, L2ChainId}; -use zksync_config::ObjectStoreConfig; +use zksync_config::{configs::chain::L1BatchCommitDataGeneratorMode, ObjectStoreConfig}; use zksync_consensus_roles::node; use zksync_core::{ api_server::{ @@ -200,6 +200,9 @@ pub struct OptionalENConfig { /// 0 means that sealing is synchronous; this is mostly useful for performance comparison, testing etc. #[serde(default = "OptionalENConfig::default_miniblock_seal_queue_capacity")] pub miniblock_seal_queue_capacity: usize, + + #[serde(default = "OptionalENConfig::default_l1_batch_commit_data_generator_mode")] + pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode, } impl OptionalENConfig { @@ -306,6 +309,10 @@ impl OptionalENConfig { 10 } + const fn default_l1_batch_commit_data_generator_mode() -> L1BatchCommitDataGeneratorMode { + L1BatchCommitDataGeneratorMode::Rollup + } + pub fn polling_interval(&self) -> Duration { Duration::from_millis(self.polling_interval) } diff --git a/core/bin/external_node/src/config/tests.rs b/core/bin/external_node/src/config/tests.rs index 243be39a1139..8eb9792b8eee 100644 --- a/core/bin/external_node/src/config/tests.rs +++ b/core/bin/external_node/src/config/tests.rs @@ -25,6 +25,10 @@ fn parsing_optional_config_from_empty_env() { 128 * BYTES_IN_MEGABYTE ); assert_eq!(config.max_response_body_size(), 10 * BYTES_IN_MEGABYTE); + assert_eq!( + config.l1_batch_commit_data_generator_mode, + L1BatchCommitDataGeneratorMode::Rollup + ); } #[test] @@ -44,6 +48,7 @@ fn parsing_optional_config_from_env() { ("EN_MERKLE_TREE_MULTI_GET_CHUNK_SIZE", "1000"), ("EN_MERKLE_TREE_BLOCK_CACHE_SIZE_MB", "32"), ("EN_MAX_RESPONSE_BODY_SIZE_MB", "1"), + ("EN_L1_BATCH_COMMIT_DATA_GENERATOR_MODE", "Validium"), ]; let env_vars = env_vars .into_iter() @@ -70,4 +75,8 @@ fn parsing_optional_config_from_env() { 32 * BYTES_IN_MEGABYTE ); assert_eq!(config.max_response_body_size(), BYTES_IN_MEGABYTE); + assert_eq!( + config.l1_batch_commit_data_generator_mode, + L1BatchCommitDataGeneratorMode::Validium + ); } diff --git a/core/bin/external_node/src/main.rs b/core/bin/external_node/src/main.rs index a5b5a2473e20..85fa1c9a0eac 100644 --- a/core/bin/external_node/src/main.rs +++ b/core/bin/external_node/src/main.rs @@ -8,7 +8,7 @@ use prometheus_exporter::PrometheusExporterConfig; use tokio::{sync::watch, task, time::sleep}; use zksync_basic_types::{Address, L2ChainId}; use zksync_concurrency::{ctx, scope}; -use zksync_config::configs::database::MerkleTreeMode; +use zksync_config::configs::{chain::L1BatchCommitDataGeneratorMode, database::MerkleTreeMode}; use zksync_core::{ api_server::{ execution_sandbox::VmConcurrencyLimiter, @@ -37,7 +37,10 @@ use zksync_dal::{healthcheck::ConnectionPoolHealthCheck, ConnectionPool}; use zksync_health_check::{CheckHealth, HealthStatus, ReactiveHealthCheck}; use zksync_state::PostgresStorageCaches; use zksync_storage::RocksDB; -use zksync_types::l1_batch_commit_data_generator::RollupModeL1BatchCommitDataGenerator; +use zksync_types::l1_batch_commit_data_generator::{ + L1BatchCommitDataGenerator, RollupModeL1BatchCommitDataGenerator, + ValidiumModeL1BatchCommitDataGenerator, +}; use zksync_utils::wait_for_tasks::wait_for_tasks; use crate::{ @@ -240,8 +243,15 @@ async fn init_tasks( .context("failed initializing metadata calculator")?; healthchecks.push(Box::new(metadata_calculator.tree_health_check())); - let l1_batch_commit_data_generator = Arc::new(RollupModeL1BatchCommitDataGenerator {}); - + let l1_batch_commit_data_generator: Arc = match config + .optional + .l1_batch_commit_data_generator_mode + { + L1BatchCommitDataGeneratorMode::Rollup => Arc::new(RollupModeL1BatchCommitDataGenerator {}), + L1BatchCommitDataGeneratorMode::Validium => { + Arc::new(ValidiumModeL1BatchCommitDataGenerator {}) + } + }; let consistency_checker = ConsistencyChecker::new( &config .required