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: Abstract commit data generator initialization #94

Merged
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
15 changes: 15 additions & 0 deletions core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<usize>,

pub l1_batch_commit_data_generator_mode: L1BatchCommitDataGeneratorMode,
}

impl StateKeeperConfig {
Expand Down Expand Up @@ -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,
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/lib/env_config/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
}
}

Expand Down
19 changes: 13 additions & 6 deletions core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -554,11 +554,18 @@ pub async fn initialize_components(
let eth_client =
PKSigningClient::from_config(&eth_sender, &contracts_config, &eth_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<dyn L1BatchCommitDataGenerator> =
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(),
Expand Down
2 changes: 2 additions & 0 deletions etc/env/base/chain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading