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

Epoch 1 is genesis epoch #4112

Merged
merged 4 commits into from
Feb 6, 2025
Merged
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
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);
}
}
22 changes: 11 additions & 11 deletions crates/task-impls/src/quorum_vote/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
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 @@ -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},
};
Expand Down Expand Up @@ -47,25 +48,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