Skip to content

Commit

Permalink
Merge pull request #1235 from lambdaclass/feat_add_validium_support_e…
Browse files Browse the repository at this point in the history
…xternal_node

feat(Validium): add validium support for external node
  • Loading branch information
ilitteri committed Feb 28, 2024
2 parents 4c6de9f + ba00a14 commit 6310305
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
9 changes: 8 additions & 1 deletion core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -214,6 +214,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 {
Expand Down Expand Up @@ -320,6 +323,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)
}
Expand Down
9 changes: 9 additions & 0 deletions core/bin/external_node/src/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -45,6 +49,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()
Expand Down Expand Up @@ -72,4 +77,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
);
}
18 changes: 14 additions & 4 deletions core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -37,7 +37,10 @@ use zksync_dal::{healthcheck::ConnectionPoolHealthCheck, ConnectionPool};
use zksync_health_check::{AppHealthCheck, 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 zksync_web3_decl::jsonrpsee::http_client::HttpClient;

Expand Down Expand Up @@ -230,8 +233,15 @@ async fn init_tasks(
.context("failed initializing metadata calculator")?;
app_health.insert_component(metadata_calculator.tree_health_check());

let l1_batch_commit_data_generator = Arc::new(RollupModeL1BatchCommitDataGenerator {});

let l1_batch_commit_data_generator: Arc<dyn L1BatchCommitDataGenerator> = 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
Expand Down

0 comments on commit 6310305

Please sign in to comment.