From cabd73a04e7f5a910e5b7df8c47f012a7608cd29 Mon Sep 17 00:00:00 2001 From: toni-calvin Date: Thu, 22 Feb 2024 18:28:39 +0100 Subject: [PATCH 1/4] set BatchCommitDataGenerator in external node init --- core/bin/external_node/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/bin/external_node/src/main.rs b/core/bin/external_node/src/main.rs index a5b5a2473e2..a2a96dfc688 100644 --- a/core/bin/external_node/src/main.rs +++ b/core/bin/external_node/src/main.rs @@ -240,8 +240,14 @@ 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 + .l1_batch_commit_data_generator_mode + { + L1BatchCommitDataGeneratorMode::Rollup => Arc::new(RollupModeL1BatchCommitDataGenerator {}), + L1BatchCommitDataGeneratorMode::Validium => { + Arc::new(ValidiumModeL1BatchCommitDataGenerator {}) + } + }; let consistency_checker = ConsistencyChecker::new( &config .required From ce6247effa87286e1fe13249d861f3011a10f3b5 Mon Sep 17 00:00:00 2001 From: toni-calvin Date: Fri, 23 Feb 2024 16:24:23 +0100 Subject: [PATCH 2/4] add support for validium in external mode --- core/bin/external_node/src/config/mod.rs | 12 +++++++++++- core/bin/external_node/src/main.rs | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index e37a71d79c6..ed0ea50cdc0 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -4,7 +4,6 @@ use anyhow::Context; use serde::Deserialize; use url::Url; use zksync_basic_types::{Address, L1ChainId, L2ChainId}; -use zksync_config::ObjectStoreConfig; use zksync_consensus_roles::node; use zksync_core::{ api_server::{ @@ -20,6 +19,8 @@ use zksync_web3_decl::{ namespaces::{EthNamespaceClient, ZksNamespaceClient}, }; +use zksync_config::{configs::chain::L1BatchCommitDataGeneratorMode, ObjectStoreConfig}; + #[cfg(test)] mod tests; @@ -200,6 +201,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 +310,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) } @@ -384,6 +392,8 @@ pub struct RequiredENConfig { pub state_cache_path: String, /// Fast SSD path. Used as a RocksDB dir for the Merkle tree (*new* implementation). pub merkle_tree_path: String, + /// External node mode. Same as in the main node. + pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode, } impl RequiredENConfig { diff --git a/core/bin/external_node/src/main.rs b/core/bin/external_node/src/main.rs index a2a96dfc688..85fa1c9a0ea 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::{ @@ -241,6 +244,7 @@ async fn init_tasks( healthchecks.push(Box::new(metadata_calculator.tree_health_check())); let l1_batch_commit_data_generator: Arc = match config + .optional .l1_batch_commit_data_generator_mode { L1BatchCommitDataGeneratorMode::Rollup => Arc::new(RollupModeL1BatchCommitDataGenerator {}), From 57f4bbef96db387ebd438cb5ccafe4fae78df898 Mon Sep 17 00:00:00 2001 From: toni-calvin Date: Fri, 23 Feb 2024 16:37:18 +0100 Subject: [PATCH 3/4] update tests --- core/bin/external_node/src/config/mod.rs | 3 +-- core/bin/external_node/src/config/tests.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index ed0ea50cdc0..46b97550483 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -4,6 +4,7 @@ use anyhow::Context; use serde::Deserialize; use url::Url; use zksync_basic_types::{Address, L1ChainId, L2ChainId}; +use zksync_config::{configs::chain::L1BatchCommitDataGeneratorMode, ObjectStoreConfig}; use zksync_consensus_roles::node; use zksync_core::{ api_server::{ @@ -19,8 +20,6 @@ use zksync_web3_decl::{ namespaces::{EthNamespaceClient, ZksNamespaceClient}, }; -use zksync_config::{configs::chain::L1BatchCommitDataGeneratorMode, ObjectStoreConfig}; - #[cfg(test)] mod tests; diff --git a/core/bin/external_node/src/config/tests.rs b/core/bin/external_node/src/config/tests.rs index 243be39a113..8eb9792b8ee 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 + ); } From ba00a148970b9dff5540e6eb4534c50cdd17ea00 Mon Sep 17 00:00:00 2001 From: toni-calvin Date: Fri, 23 Feb 2024 19:29:29 +0100 Subject: [PATCH 4/4] remove unused parameter --- core/bin/external_node/src/config/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index 46b97550483..88c48e39394 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -391,8 +391,6 @@ pub struct RequiredENConfig { pub state_cache_path: String, /// Fast SSD path. Used as a RocksDB dir for the Merkle tree (*new* implementation). pub merkle_tree_path: String, - /// External node mode. Same as in the main node. - pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode, } impl RequiredENConfig {