diff --git a/code/crates/network/src/channel.rs b/code/crates/network/src/channel.rs index 97b7f4c30..86d984643 100644 --- a/code/crates/network/src/channel.rs +++ b/code/crates/network/src/channel.rs @@ -30,8 +30,8 @@ impl Channel { pub fn as_str(&self) -> &'static str { match self { - Channel::Consensus => "/consensus", - Channel::ProposalParts => "/proposal_parts", + Channel::Consensus => "/consensus_votes", + Channel::ProposalParts => "/consensus_proposals", Channel::Sync => "/sync", } } @@ -50,8 +50,8 @@ impl Channel { pub fn from_gossipsub_topic_hash(topic: &gossipsub::TopicHash) -> Option { match topic.as_str() { - "/consensus" => Some(Channel::Consensus), - "/proposal_parts" => Some(Channel::ProposalParts), + "/consensus_votes" => Some(Channel::Consensus), + "/consensus_proposals" => Some(Channel::ProposalParts), "/sync" => Some(Channel::Sync), _ => None, } @@ -59,8 +59,8 @@ impl Channel { pub fn from_broadcast_topic(topic: &broadcast::Topic) -> Option { match topic.as_ref() { - b"/consensus" => Some(Channel::Consensus), - b"/proposal_parts" => Some(Channel::ProposalParts), + b"/consensus_votes" => Some(Channel::Consensus), + b"/consensus_proposals" => Some(Channel::ProposalParts), b"/sync" => Some(Channel::Sync), _ => None, } diff --git a/code/crates/starknet/host/src/actor.rs b/code/crates/starknet/host/src/actor.rs index eb12bedfb..7c067571c 100644 --- a/code/crates/starknet/host/src/actor.rs +++ b/code/crates/starknet/host/src/actor.rs @@ -217,9 +217,11 @@ async fn on_consensus_ready( state: &mut HostState, consensus: ConsensusRef, ) -> Result<(), ActorProcessingErr> { - let latest_block_height = state.block_store.last_height().unwrap_or_default(); - let start_height = latest_block_height.increment(); - + let mut start_height = malachitebft_core_types::Height::INITIAL; + if state.block_store.last_height().is_some() { + let latest_block_height = state.block_store.last_height().unwrap_or_default(); + start_height = latest_block_height.increment(); + } state.consensus = Some(consensus.clone()); tokio::time::sleep(Duration::from_millis(200)).await; diff --git a/code/crates/starknet/p2p-types/src/context.rs b/code/crates/starknet/p2p-types/src/context.rs index 3ee31ea0c..d628a1cbc 100644 --- a/code/crates/starknet/p2p-types/src/context.rs +++ b/code/crates/starknet/p2p-types/src/context.rs @@ -42,7 +42,7 @@ impl Context for MockContext { let height = height.as_u64() as usize; let round = round.as_i64() as usize; - (height - 1 + round) % validator_set.count() + (height + round) % validator_set.count() }; validator_set diff --git a/code/crates/starknet/p2p-types/src/height.rs b/code/crates/starknet/p2p-types/src/height.rs index 62b4c8c70..adf1bdcf9 100644 --- a/code/crates/starknet/p2p-types/src/height.rs +++ b/code/crates/starknet/p2p-types/src/height.rs @@ -46,7 +46,7 @@ impl fmt::Display for Height { impl malachitebft_core_types::Height for Height { const ZERO: Self = Self::new(0, 0); - const INITIAL: Self = Self::new(1, 0); + const INITIAL: Self = Self::new(0, 0); fn increment_by(&self, n: u64) -> Self { Self { diff --git a/code/crates/starknet/test/src/tests/n3f0.rs b/code/crates/starknet/test/src/tests/n3f0.rs index 1d6d75601..faf3b8d9c 100644 --- a/code/crates/starknet/test/src/tests/n3f0.rs +++ b/code/crates/starknet/test/src/tests/n3f0.rs @@ -1,5 +1,7 @@ use std::time::Duration; +use malachitebft_test_framework::TestParams; + use crate::TestBuilder; #[tokio::test] @@ -12,5 +14,10 @@ pub async fn all_correct_nodes() { test.add_node().start().wait_until(HEIGHT).success(); test.add_node().start().wait_until(HEIGHT).success(); - test.build().run(Duration::from_secs(30)).await + test.build() + .run_with_params( + Duration::from_secs(30), // Timeout for the whole test + TestParams::default(), + ) + .await }