Skip to content

Commit

Permalink
Add randomized Membership impls for testing (#3863)
Browse files Browse the repository at this point in the history
* replace calls to Memberships

Delete Memberships and replace functionality. Add some methods to
`Membership` trait to deal w/ collapsing into one type both kinds of
memberships (stake and DA).

  * avoid passing membership into `is_valid_cert
  * for DA, avoid proxying threshold through `Threshold` trait
  * remove `Topic` param from `Membership::new
  * Split cert impls by marker (#3891)
  * add membership methods to Cert trait
  * remove non-existent tests from justfile

* cleanup

* conflict resolution

* revert some unnecessary name changes

We can keep the old name where we only have one membership type to
keep the diff smaller.

* Leaders are Leaders

Always use quorum for leader selection

* Add randomized committees for testing

* add randomized overlap committee generator

* Add epoch to threshold functions to allow dynamically sized committees

* rework randomized_committee_members to work with flattened Membership

* fix lingering da_leader things

---------

Co-authored-by: tbro <[email protected]>
  • Loading branch information
pls148 and tbro authored Dec 2, 2024
1 parent 86ef57b commit 437d9c8
Show file tree
Hide file tree
Showing 28 changed files with 1,110 additions and 100 deletions.
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

0 comments on commit 437d9c8

Please sign in to comment.