diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index dc7394cce9..851114d499 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -639,6 +639,21 @@ "pointer_target": "validator_id", "privacy": "Public" }, + "consensus_manager_config.context_config.batcher_build_buffer": { + "description": "The buffer size for the batcher when building proposals.", + "privacy": "Public", + "value": 100 + }, + "consensus_manager_config.context_config.chain_id": { + "description": "The chain id of the Starknet chain.", + "pointer_target": "chain_id", + "privacy": "Public" + }, + "consensus_manager_config.context_config.num_validators": { + "description": "The number of validators.", + "privacy": "Public", + "value": 1 + }, "eth_fee_token_address": { "description": "A required param! Address of the ETH fee token.", "param_type": "String", diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs index 1098ae7169..b658c5ed1a 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -15,6 +15,7 @@ use futures::{FutureExt, SinkExt, StreamExt}; use papyrus_consensus::types::{ ConsensusContext, ConsensusError, + ContextConfig, ProposalContentId, Round, ValidatorId, @@ -110,6 +111,7 @@ const BUILD_PROPOSAL_MARGIN: Duration = Duration::from_millis(1000); const VALIDATE_PROPOSAL_MARGIN: Duration = Duration::from_secs(10); pub struct SequencerConsensusContext { + config: ContextConfig, state_sync_client: SharedStateSyncClient, batcher: Arc, validators: Vec, @@ -134,8 +136,6 @@ pub struct SequencerConsensusContext { outbound_proposal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver)>, // Used to broadcast votes to other consensus nodes. vote_broadcast_client: BroadcastTopicClient, - // Used to convert Transaction to ExecutableTransaction. - chain_id: ChainId, cende_ambassador: Arc, // The next block's l2 gas price, calculated based on EIP-1559, used for building and // validating proposals. @@ -144,15 +144,16 @@ pub struct SequencerConsensusContext { impl SequencerConsensusContext { pub fn new( + config: ContextConfig, state_sync_client: SharedStateSyncClient, batcher: Arc, outbound_proposal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver)>, vote_broadcast_client: BroadcastTopicClient, - num_validators: u64, - chain_id: ChainId, cende_ambassador: Arc, ) -> Self { + let num_validators = config.num_validators; Self { + config, state_sync_client, batcher, outbound_proposal_sender, @@ -167,7 +168,6 @@ impl SequencerConsensusContext { current_round: 0, active_proposal: None, queued_proposals: BTreeMap::new(), - chain_id, cende_ambassador, l2_gas_price: MIN_GAS_PRICE, } @@ -457,7 +457,7 @@ impl SequencerConsensusContext { let cancel_token_clone = cancel_token.clone(); let batcher = Arc::clone(&self.batcher); let valid_proposals = Arc::clone(&self.valid_proposals); - let chain_id = self.chain_id.clone(); + let chain_id = self.config.chain_id.clone(); let proposal_id = ProposalId(self.proposal_id); self.proposal_id += 1; let gas_prices = self.gas_prices(); diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs index 84b7101721..8d9e6a09e9 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs @@ -8,7 +8,7 @@ use futures::future::pending; use futures::{FutureExt, SinkExt}; use lazy_static::lazy_static; use papyrus_consensus::stream_handler::StreamHandler; -use papyrus_consensus::types::ConsensusContext; +use papyrus_consensus::types::{ConsensusContext, ContextConfig}; use papyrus_network::network_manager::test_utils::{ mock_register_broadcast_topic, BroadcastNetworkMock, @@ -95,12 +95,11 @@ fn setup( let state_sync_client = MockStateSyncClient::new(); let context = SequencerConsensusContext::new( + ContextConfig { num_validators: NUM_VALIDATORS, chain_id: CHAIN_ID, ..Default::default() }, Arc::new(state_sync_client), Arc::new(batcher), outbound_proposal_stream_sender, votes_topic_client, - NUM_VALIDATORS, - CHAIN_ID, Arc::new(cende_ambassador), ); diff --git a/crates/starknet_consensus_manager/src/config.rs b/crates/starknet_consensus_manager/src/config.rs index 58c1ceafbb..60ec2c8e53 100644 --- a/crates/starknet_consensus_manager/src/config.rs +++ b/crates/starknet_consensus_manager/src/config.rs @@ -3,6 +3,7 @@ use std::collections::BTreeMap; use papyrus_config::dumping::{append_sub_config_name, SerializeConfig}; use papyrus_config::{ParamPath, SerializedParam}; use papyrus_consensus::config::ConsensusConfig; +use papyrus_consensus::types::ContextConfig; use papyrus_consensus_orchestrator::cende::CendeConfig; use serde::{Deserialize, Serialize}; use validator::Validate; @@ -12,6 +13,7 @@ use validator::Validate; #[derive(Clone, Default, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct ConsensusManagerConfig { pub consensus_config: ConsensusConfig, + pub context_config: ContextConfig, pub cende_config: CendeConfig, } @@ -19,6 +21,7 @@ impl SerializeConfig for ConsensusManagerConfig { fn dump(&self) -> BTreeMap { let sub_configs = vec![ append_sub_config_name(self.consensus_config.dump(), "consensus_config"), + append_sub_config_name(self.context_config.dump(), "context_config"), append_sub_config_name(self.cende_config.dump(), "cende_config"), ]; diff --git a/crates/starknet_consensus_manager/src/consensus_manager.rs b/crates/starknet_consensus_manager/src/consensus_manager.rs index 2c21e6e230..04a510cd8a 100644 --- a/crates/starknet_consensus_manager/src/consensus_manager.rs +++ b/crates/starknet_consensus_manager/src/consensus_manager.rs @@ -81,12 +81,11 @@ impl ConsensusManager { }; let context = SequencerConsensusContext::new( + self.config.context_config.clone(), Arc::clone(&self.state_sync_client), Arc::clone(&self.batcher_client), outbound_internal_sender, votes_broadcast_channels.broadcast_topic_client.clone(), - self.config.consensus_config.num_validators, - self.config.consensus_config.chain_id.clone(), Arc::new(CendeAmbassador::new(self.config.cende_config.clone())), ); diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index 6ca4b9332a..ef64d486c1 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -15,7 +15,7 @@ use mempool_test_utils::starknet_api_test_utils::{ MultiAccountTransactionGenerator, }; use papyrus_consensus::config::{ConsensusConfig, TimeoutsConfig}; -use papyrus_consensus::types::ValidatorId; +use papyrus_consensus::types::{ContextConfig, ValidatorId}; use papyrus_consensus_orchestrator::cende::RECORDER_WRITE_BLOB_PATH; use papyrus_network::network_manager::test_utils::create_connected_network_configs; use papyrus_network::NetworkConfig; @@ -140,6 +140,11 @@ pub(crate) fn create_consensus_manager_configs_from_network_configs( timeouts: timeouts.clone(), ..Default::default() }, + context_config: ContextConfig { + num_validators, + chain_id: papyrus_storage::test_utils::CHAIN_ID_FOR_TESTS.clone(), + ..Default::default() + }, ..Default::default() }) .collect() diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index 057d32aca3..5da3e75757 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -52,6 +52,7 @@ pub static CONFIG_POINTERS: LazyLock = LazyLock::new(|| { "batcher_config.block_builder_config.chain_info.chain_id", "batcher_config.storage.db_config.chain_id", "consensus_manager_config.consensus_config.chain_id", + "consensus_manager_config.context_config.chain_id", "consensus_manager_config.consensus_config.network_config.chain_id", "gateway_config.chain_info.chain_id", "l1_scraper_config.chain_id",