Skip to content

Commit

Permalink
feat(consensus): rename proposal channels in preparation for adding v…
Browse files Browse the repository at this point in the history
…oting (#2392)
  • Loading branch information
matan-starkware authored Dec 2, 2024
1 parent 0dfa542 commit 88ff3ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const Configuration = {
'ci',
'committer',
'committer_cli',
'consensus',
'deployment',
'helm',
'infra_utils',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ pub struct SequencerConsensusContext {
proposal_id: u64,
current_height: Option<BlockNumber>,
current_round: Round,
network_broadcast_client: BroadcastTopicClient<ProposalPart>,
// Used to broadcast proposals to other consensus nodes.
// TODO(Guy) switch to the actual streaming struct.
proposal_streaming_client: BroadcastTopicClient<ProposalPart>,
// The active proposal refers to the proposal being validated at the current height/round.
// Building proposals are not tracked as active, as consensus can't move on to the next
// height/round until building is done. Context only works on proposals for the
Expand All @@ -80,12 +82,12 @@ pub struct SequencerConsensusContext {
impl SequencerConsensusContext {
pub fn new(
batcher: Arc<dyn BatcherClient>,
network_broadcast_client: BroadcastTopicClient<ProposalPart>,
proposal_streaming_client: BroadcastTopicClient<ProposalPart>,
num_validators: u64,
) -> Self {
Self {
batcher,
network_broadcast_client,
proposal_streaming_client,
validators: (0..num_validators).map(ValidatorId::from).collect(),
valid_proposals: Arc::new(Mutex::new(HeightToIdToContent::new())),
proposal_id: 0,
Expand Down Expand Up @@ -141,11 +143,11 @@ impl ConsensusContext for SequencerConsensusContext {
.await
.expect("Failed to initiate proposal build");
debug!("Broadcasting proposal init: {proposal_init:?}");
self.network_broadcast_client
self.proposal_streaming_client
.broadcast_message(ProposalPart::Init(proposal_init.clone()))
.await
.expect("Failed to broadcast proposal init");
let broadcast_client = self.network_broadcast_client.clone();
let broadcast_client = self.proposal_streaming_client.clone();
tokio::spawn(
async move {
stream_build_proposal(
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_consensus_manager/src/consensus_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::config::ConsensusManagerConfig;

// TODO(Dan, Guy): move to config.
pub const BROADCAST_BUFFER_SIZE: usize = 100;
pub const NETWORK_TOPIC: &str = "consensus_proposals";
pub const CONSENSUS_PROPOSALS_TOPIC: &str = "consensus_proposals";

#[derive(Clone)]
pub struct ConsensusManager {
Expand All @@ -39,7 +39,7 @@ impl ConsensusManager {
NetworkManager::new(self.config.consensus_config.network_config.clone(), None);
let mut proposals_broadcast_channels = network_manager
.register_broadcast_topic::<ProposalPart>(
Topic::new(NETWORK_TOPIC),
Topic::new(CONSENSUS_PROPOSALS_TOPIC),
BROADCAST_BUFFER_SIZE,
)
.expect("Failed to register broadcast topic");
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn create_consensus_manager_configs_and_channels(
create_network_configs_connected_to_broadcast_channels(
n_managers,
papyrus_network::gossipsub_impl::Topic::new(
starknet_consensus_manager::consensus_manager::NETWORK_TOPIC,
starknet_consensus_manager::consensus_manager::CONSENSUS_PROPOSALS_TOPIC,
),
);

Expand Down

0 comments on commit 88ff3ce

Please sign in to comment.