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

Revert "chore(consensus): add ContextConfig to SequencerConcensusContext" #3622

Closed
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: 0 additions & 15 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,21 +709,6 @@
"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",
Expand Down
4 changes: 1 addition & 3 deletions crates/papyrus_node/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ fn spawn_consensus(
};
let consensus_config = consensus_config.clone();
let context_config = context_config.clone();
debug!(
"Consensus configuration: {consensus_config:?}, Context configuration: {context_config:?}"
);
debug!("Consensus configuration: {consensus_config:?}");

let network_channels = network_manager.register_broadcast_topic(
Topic::new(consensus_config.network_topic.clone()),
Expand Down
3 changes: 0 additions & 3 deletions crates/starknet_consensus_manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use papyrus_config::dumping::{append_sub_config_name, SerializeConfig};
use papyrus_config::{ParamPath, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_consensus::config::ConsensusConfig;
use starknet_consensus::types::ContextConfig;
use starknet_consensus_orchestrator::cende::CendeConfig;
use validator::Validate;

Expand All @@ -13,15 +12,13 @@ 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,
}

impl SerializeConfig for ConsensusManagerConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
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"),
];

Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_consensus_manager/src/consensus_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ 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())),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ use starknet_batcher_types::communication::BatcherClient;
use starknet_consensus::types::{
ConsensusContext,
ConsensusError,
ContextConfig,
ProposalContentId,
Round,
ValidatorId,
Expand Down Expand Up @@ -112,7 +111,6 @@ 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<dyn BatcherClient>,
validators: Vec<ValidatorId>,
Expand All @@ -137,6 +135,8 @@ pub struct SequencerConsensusContext {
outbound_proposal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver<ProposalPart>)>,
// Used to broadcast votes to other consensus nodes.
vote_broadcast_client: BroadcastTopicClient<Vote>,
// Used to convert Transaction to ExecutableTransaction.
chain_id: ChainId,
cende_ambassador: Arc<dyn CendeContext>,
// The next block's l2 gas price, calculated based on EIP-1559, used for building and
// validating proposals.
Expand All @@ -145,16 +145,15 @@ pub struct SequencerConsensusContext {

impl SequencerConsensusContext {
pub fn new(
config: ContextConfig,
state_sync_client: SharedStateSyncClient,
batcher: Arc<dyn BatcherClient>,
outbound_proposal_sender: mpsc::Sender<(HeightAndRound, mpsc::Receiver<ProposalPart>)>,
vote_broadcast_client: BroadcastTopicClient<Vote>,
num_validators: u64,
chain_id: ChainId,
cende_ambassador: Arc<dyn CendeContext>,
) -> Self {
let num_validators = config.num_validators;
Self {
config,
state_sync_client,
batcher,
outbound_proposal_sender,
Expand All @@ -169,6 +168,7 @@ impl SequencerConsensusContext {
current_round: 0,
active_proposal: None,
queued_proposals: BTreeMap::new(),
chain_id,
cende_ambassador,
l2_gas_price: VersionedConstants::latest_constants().min_gas_price,
}
Expand Down Expand Up @@ -463,7 +463,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.config.chain_id.clone();
let chain_id = self.chain_id.clone();
let proposal_id = ProposalId(self.proposal_id);
self.proposal_id += 1;
let gas_prices = self.gas_prices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use starknet_batcher_types::batcher_types::{
};
use starknet_batcher_types::communication::MockBatcherClient;
use starknet_consensus::stream_handler::StreamHandler;
use starknet_consensus::types::{ConsensusContext, ContextConfig};
use starknet_consensus::types::ConsensusContext;
use starknet_state_sync_types::communication::MockStateSyncClient;
use starknet_types_core::felt::Felt;

Expand Down Expand Up @@ -95,11 +95,12 @@ 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),
);

Expand Down
9 changes: 2 additions & 7 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use starknet_api::transaction::TransactionHash;
use starknet_batcher::block_builder::BlockBuilderConfig;
use starknet_batcher::config::BatcherConfig;
use starknet_consensus::config::{ConsensusConfig, TimeoutsConfig};
use starknet_consensus::types::{ContextConfig, ValidatorId};
use starknet_consensus::types::ValidatorId;
use starknet_consensus_manager::config::ConsensusManagerConfig;
use starknet_consensus_orchestrator::cende::{CendeConfig, RECORDER_WRITE_BLOB_PATH};
use starknet_gateway::config::{
Expand Down Expand Up @@ -144,12 +144,7 @@ pub(crate) fn create_consensus_manager_configs_from_network_configs(
cende_config: CendeConfig{
skip_write_height: Some(BlockNumber(1)),
..Default::default()
},
context_config: ContextConfig {
num_validators,
chain_id: papyrus_storage::test_utils::CHAIN_ID_FOR_TESTS.clone(),
..Default::default()
},
}
})
.collect()
}
Expand Down
1 change: 0 additions & 1 deletion crates/starknet_sequencer_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = 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",
Expand Down
Loading