Skip to content

Commit

Permalink
#4045 re-enable epochs tests with dynamic quora (#4103)
Browse files Browse the repository at this point in the history
* #4045 re-enable epochs tests with dynamic quora

* Epoch 1 is genesis epoch (#4112)

* #4045 re-enable epochs tests with dynamic quora

* Remove Epoch 0

* 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.

* Adjust test_genesis_epoch_from_version

---------

Co-authored-by: pls148 <[email protected]>

---------

Co-authored-by: lukaszrzasik <[email protected]>
  • Loading branch information
pls148 and lukaszrzasik authored Feb 6, 2025
1 parent 27cb622 commit e4abb5c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion crates/example-types/src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,6 @@ mod tests {
assert_eq!(None, epoch);

let epoch = genesis_epoch_from_version::<EpochsTestVersions, TestTypes>();
assert_eq!(Some(<TestTypes as NodeType>::Epoch::new(0)), epoch);
assert_eq!(Some(<TestTypes as NodeType>::Epoch::new(1)), epoch);
}
}
51 changes: 30 additions & 21 deletions crates/testing/tests/tests_6/test_epochs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::{collections::HashMap, time::Duration};
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},
};
Expand Down Expand Up @@ -48,25 +49,33 @@ cross_tests!(
},
);

// cross_tests!(
// TestName: test_epoch_success,
// Impls: [MemoryImpl, Libp2pImpl, PushCdnImpl],
// Types: [TestTypes, TestTypesRandomizedLeader, TestTypesRandomizedCommitteeMembers<StableQuorumFilterConfig<123, 2>>, TestTypesRandomizedCommitteeMembers<RandomOverlapQuorumFilterConfig<123, 4, 5, 0, 2>>],
// 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<StableQuorumFilterConfig<123, 2>>, // Overlap = F
TestTypesRandomizedCommitteeMembers<StableQuorumFilterConfig<123, 3>>, // Overlap = F+1
TestTypesRandomizedCommitteeMembers<StableQuorumFilterConfig<123, 4>>, // Overlap = 2F
TestTypesRandomizedCommitteeMembers<StableQuorumFilterConfig<123, 5>>, // Overlap = 2F+1
TestTypesRandomizedCommitteeMembers<StableQuorumFilterConfig<123, 6>>, // Overlap = 3F
TestTypesRandomizedCommitteeMembers<RandomOverlapQuorumFilterConfig<123, 4, 7, 0, 2>>, // 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,
Expand Down
8 changes: 8 additions & 0 deletions crates/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ impl Committable for EpochNumber {

impl_u64_wrapper!(EpochNumber);

impl EpochNumber {
/// Create a genesis number (1)
#[allow(dead_code)]
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")]
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ pub fn option_epoch_from_block_number<TYPES: NodeType>(
/// Returns Some(0) if epochs are enabled by V::Base, otherwise returns None
#[must_use]
pub fn genesis_epoch_from_version<V: Versions, TYPES: NodeType>() -> Option<TYPES::Epoch> {
(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
Expand Down

0 comments on commit e4abb5c

Please sign in to comment.