From 847fd7f1c952c6cdfadba8f5638243d8c9a31068 Mon Sep 17 00:00:00 2001 From: pls148 <184445976+pls148@users.noreply.github.com> Date: Mon, 3 Feb 2025 11:56:16 -0800 Subject: [PATCH 1/4] #4045 re-enable epochs tests with dynamic quora --- crates/task-impls/src/quorum_vote/handlers.rs | 22 ++++---- crates/testing/tests/tests_6/test_epochs.rs | 51 +++++++++++-------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/crates/task-impls/src/quorum_vote/handlers.rs b/crates/task-impls/src/quorum_vote/handlers.rs index 38b63fe4ea..1f8179a29d 100644 --- a/crates/task-impls/src/quorum_vote/handlers.rs +++ b/crates/task-impls/src/quorum_vote/handlers.rs @@ -6,27 +6,17 @@ use std::{collections::btree_map::Entry, sync::Arc}; -use super::QuorumVoteTaskState; -use crate::{ - events::HotShotEvent, - helpers::{ - broadcast_event, decide_from_proposal, decide_from_proposal_2, fetch_proposal, - LeafChainTraversalOutcome, - }, - quorum_vote::Versions, -}; use async_broadcast::{InactiveReceiver, Sender}; use async_lock::RwLock; use chrono::Utc; use committable::Committable; -use hotshot_types::simple_vote::HasEpoch; use hotshot_types::{ consensus::OuterConsensus, data::{Leaf2, QuorumProposalWrapper, VidDisperseShare}, drb::{compute_drb_result, DrbResult}, event::{Event, EventType}, message::{convert_proposal, Proposal, UpgradeLock}, - simple_vote::{QuorumData2, QuorumVote2}, + simple_vote::{HasEpoch, QuorumData2, QuorumVote2}, traits::{ block_contents::BlockHeader, election::Membership, @@ -46,6 +36,16 @@ use tracing::instrument; use utils::anytrace::*; use vbs::version::StaticVersionType; +use super::QuorumVoteTaskState; +use crate::{ + events::HotShotEvent, + helpers::{ + broadcast_event, decide_from_proposal, decide_from_proposal_2, fetch_proposal, + LeafChainTraversalOutcome, + }, + quorum_vote::Versions, +}; + /// Store the DRB result from the computation task to the shared `results` table. /// /// Returns the result if it exists. diff --git a/crates/testing/tests/tests_6/test_epochs.rs b/crates/testing/tests/tests_6/test_epochs.rs index ae2a6fdd3a..7f1119dedc 100644 --- a/crates/testing/tests/tests_6/test_epochs.rs +++ b/crates/testing/tests/tests_6/test_epochs.rs @@ -7,8 +7,9 @@ use hotshot_example_types::{ node_types::{ CombinedImpl, EpochUpgradeTestVersions, EpochsTestVersions, Libp2pImpl, MemoryImpl, - PushCdnImpl, TestConsecutiveLeaderTypes, TestTwoStakeTablesTypes, TestTypes, - TestTypesRandomizedLeader, + PushCdnImpl, RandomOverlapQuorumFilterConfig, StableQuorumFilterConfig, + TestConsecutiveLeaderTypes, TestTwoStakeTablesTypes, TestTypes, + TestTypesRandomizedCommitteeMembers, TestTypesRandomizedLeader, }, testable_delay::{DelayConfig, DelayOptions, DelaySettings, SupportedTraitTypesForAsyncDelay}, }; @@ -47,25 +48,33 @@ cross_tests!( }, ); -// cross_tests!( -// TestName: test_epoch_success, -// Impls: [MemoryImpl, Libp2pImpl, PushCdnImpl], -// Types: [TestTypes, TestTypesRandomizedLeader, TestTypesRandomizedCommitteeMembers>, TestTypesRandomizedCommitteeMembers>], -// Versions: [EpochsTestVersions], -// Ignore: false, -// Metadata: { -// TestDescription { -// // allow more time to pass in CI -// completion_task_description: CompletionTaskDescription::TimeBasedCompletionTaskBuilder( -// TimeBasedCompletionTaskDescription { -// duration: Duration::from_secs(60), -// }, -// ), -// epoch_height: 10, -// ..TestDescription::default() -// } -// }, -// ); +cross_tests!( + TestName: test_epoch_success, + Impls: [MemoryImpl, Libp2pImpl, PushCdnImpl], + Types: [ + TestTypes, + TestTypesRandomizedLeader, + TestTypesRandomizedCommitteeMembers>, // Overlap = F + TestTypesRandomizedCommitteeMembers>, // Overlap = F+1 + TestTypesRandomizedCommitteeMembers>, // Overlap = 2F + TestTypesRandomizedCommitteeMembers>, // Overlap = 2F+1 + TestTypesRandomizedCommitteeMembers>, // Overlap = 3F + TestTypesRandomizedCommitteeMembers>, // Overlap = Dynamic + ], + Versions: [EpochsTestVersions], + Ignore: false, + Metadata: { + TestDescription { + // allow more time to pass in CI + completion_task_description: CompletionTaskDescription::TimeBasedCompletionTaskBuilder( + TimeBasedCompletionTaskDescription { + duration: Duration::from_secs(60), + }, + ), + ..TestDescription::default().set_num_nodes(14, 14) + } + }, +); cross_tests!( TestName: test_success_with_async_delay_with_epochs, From 2b9c9370b637a8960e368de46b4999c1287d46a2 Mon Sep 17 00:00:00 2001 From: Lukasz Rzasik Date: Thu, 6 Feb 2025 17:19:53 +0100 Subject: [PATCH 2/4] Remove Epoch 0 --- crates/types/src/data.rs | 7 +++++++ crates/types/src/utils.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/types/src/data.rs b/crates/types/src/data.rs index 47fae4a823..fc21f28981 100644 --- a/crates/types/src/data.rs +++ b/crates/types/src/data.rs @@ -135,6 +135,13 @@ impl Committable for EpochNumber { impl_u64_wrapper!(EpochNumber); +impl EpochNumber { + /// Create a genesis number (1) + fn genesis() -> Self { + Self(1) + } +} + /// A proposal to start providing data availability for a block. #[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound = "TYPES: NodeType")] diff --git a/crates/types/src/utils.rs b/crates/types/src/utils.rs index 6d7dcd170e..b4f8c25ec0 100644 --- a/crates/types/src/utils.rs +++ b/crates/types/src/utils.rs @@ -295,7 +295,7 @@ pub fn option_epoch_from_block_number( /// Returns Some(0) if epochs are enabled by V::Base, otherwise returns None #[must_use] pub fn genesis_epoch_from_version() -> Option { - (V::Base::VERSION >= V::Epochs::VERSION).then(|| TYPES::Epoch::new(0)) + (V::Base::VERSION >= V::Epochs::VERSION).then(|| TYPES::Epoch::new(1)) } /// A function for generating a cute little user mnemonic from a hash From 1bbd1c6abbcb2bae9176258420b349150c06e6d4 Mon Sep 17 00:00:00 2001 From: Lukasz Rzasik Date: Thu, 6 Feb 2025 17:25:43 +0100 Subject: [PATCH 3/4] Allow dead code for genesis method for EpochNumber The method is not called at the moment but it's better to have it because otherwise the default genesis method returning 0 might be called by accident. --- crates/types/src/data.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/types/src/data.rs b/crates/types/src/data.rs index fc21f28981..3ee1fb5bd4 100644 --- a/crates/types/src/data.rs +++ b/crates/types/src/data.rs @@ -137,6 +137,7 @@ impl_u64_wrapper!(EpochNumber); impl EpochNumber { /// Create a genesis number (1) + #[allow(dead_code)] fn genesis() -> Self { Self(1) } From 8d781d305aa86f0e847c6b868f6ab2e9d93e5dc7 Mon Sep 17 00:00:00 2001 From: Lukasz Rzasik Date: Thu, 6 Feb 2025 17:46:38 +0100 Subject: [PATCH 4/4] Adjust test_genesis_epoch_from_version --- crates/example-types/src/node_types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/example-types/src/node_types.rs b/crates/example-types/src/node_types.rs index 5b2ffdf531..033feb514b 100644 --- a/crates/example-types/src/node_types.rs +++ b/crates/example-types/src/node_types.rs @@ -434,6 +434,6 @@ mod tests { assert_eq!(None, epoch); let epoch = genesis_epoch_from_version::(); - assert_eq!(Some(::Epoch::new(0)), epoch); + assert_eq!(Some(::Epoch::new(1)), epoch); } }