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

Add randomized Membership impls for testing #3863

Merged
merged 10 commits into from
Dec 2, 2024
47 changes: 44 additions & 3 deletions crates/example-types/src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
// You should have received a copy of the MIT License
// along with the HotShot repository. If not, see <https://mit-license.org/>.

use std::marker::PhantomData;

pub use hotshot::traits::election::helpers::{
RandomOverlapQuorumFilterConfig, StableQuorumFilterConfig,
};
use hotshot::traits::{
election::{
randomized_committee::RandomizedCommittee, static_committee::StaticCommittee,
helpers::QuorumFilterConfig, randomized_committee::RandomizedCommittee,
randomized_committee_members::RandomizedCommitteeMembers,
static_committee::StaticCommittee,
static_committee_leader_two_views::StaticCommitteeLeaderForTwoViews,
},
implementations::{CombinedNetworks, Libp2pNetwork, MemoryNetwork, PushCdnNetwork},
Expand Down Expand Up @@ -87,6 +94,40 @@ impl NodeType for TestTypesRandomizedLeader {
type BuilderSignatureKey = BuilderKey;
}

#[derive(
Copy,
Clone,
Debug,
Default,
Hash,
PartialEq,
Eq,
PartialOrd,
Ord,
serde::Serialize,
serde::Deserialize,
)]
/// filler struct to implement node type and allow us
/// to select our traits
pub struct TestTypesRandomizedCommitteeMembers<CONFIG: QuorumFilterConfig> {
_pd: PhantomData<CONFIG>,
}

impl<CONFIG: QuorumFilterConfig> NodeType for TestTypesRandomizedCommitteeMembers<CONFIG> {
type AuctionResult = TestAuctionResult;
type View = ViewNumber;
type Epoch = EpochNumber;
type BlockHeader = TestBlockHeader;
type BlockPayload = TestBlockPayload;
type SignatureKey = BLSPubKey;
type Transaction = TestTransaction;
type ValidatedState = TestValidatedState;
type InstanceState = TestInstanceState;
type Membership =
RandomizedCommitteeMembers<TestTypesRandomizedCommitteeMembers<CONFIG>, CONFIG>;
type BuilderSignatureKey = BuilderKey;
}

#[derive(
Copy,
Clone,
Expand Down Expand Up @@ -133,7 +174,7 @@ pub struct Libp2pImpl;
#[derive(Clone, Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
pub struct WebImpl;

/// Combined Network implementation (libp2p + web sever)
/// Combined Network implementation (libp2p + web server)
#[derive(Clone, Debug, Deserialize, Serialize, Hash, Eq, PartialEq)]
pub struct CombinedImpl;

Expand Down Expand Up @@ -223,7 +264,7 @@ impl Versions for EpochsTestVersions {
0, 0,
];

type Marketplace = StaticVersion<0, 3>;
type Marketplace = StaticVersion<0, 99>;

type Epochs = StaticVersion<0, 4>;
}
Expand Down
Loading
Loading