Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add validium support external node (Moved) #184

Open
wants to merge 4 commits into
base: feat_validium_pubdata_abstraction
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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 {
Expand Down Expand Up @@ -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)
}
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 @@ -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()
Expand All @@ -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
);
}
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::{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::{
Expand Down Expand Up @@ -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<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
Loading