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

Flatten memberships into a single type #3867

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

tbro
Copy link
Contributor

@tbro tbro commented Nov 8, 2024

Needed for #3726

This PR:

Removes Memberships struct and updates Membership trait to support DA and Quorum w/ a single interface. Essentially, instead of having qourom_membership and committee_membership (DA) fields in most places we now have a single membership field. In some places, where only one of the membership types was previously used, the previous name is preserved. To obtain the correct data, we now have to call the correct method: membership.leader() for quorum membership.da_leader() for da.

This PR does not:

Shouldn't change behavior. It is only preparation for EspressoSystems/espresso-sequencer#2237

Key places to review:

The trait is used extensively and there are changes across many files.

  • The trait lives in crates/types/src/traits/election.rs
  • SimpleCert impls in crates/types/src/simple_certificate.rs

@tbro tbro requested a review from ss-es November 8, 2024 00:55
@tbro tbro changed the title Tb/pos/flatten members Flatten memberships into a single type Nov 8, 2024
@tbro tbro force-pushed the tb/pos/flatten-members branch 4 times, most recently from 0d9e849 to 859aa47 Compare November 11, 2024 22:39
@tbro tbro mentioned this pull request Nov 19, 2024
@tbro tbro force-pushed the tb/pos/flatten-members branch 2 times, most recently from dbd49cf to d4815f9 Compare November 19, 2024 20:21
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
We can keep the old name where we only have one membership type to
keep the diff smaller.
Copy link
Contributor

@ss-es ss-es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, but couldn't find the issue. I'll check a few more things

crates/examples/infra/mod.rs Outdated Show resolved Hide resolved
crates/examples/infra/mod.rs Outdated Show resolved Hide resolved
@@ -124,8 +125,8 @@ impl<TYPES: NodeType, V: Versions> ProposalDependencyHandle<TYPES, V> {
if let HotShotEvent::HighQcRecv(qc, _sender) = event.as_ref() {
if qc
.is_valid_cert(
self.quorum_membership.as_ref(),
TYPES::Epoch::new(0),
self.quorum_membership.stake_table(TYPES::Epoch::new(0)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use epoch 0 for now (since QC doesn't have an epoch number yet), but we should make an issue to come back and take the epoch number from the QC after #3893

can you add an issue to the board for this line?

crates/task-impls/src/request.rs Outdated Show resolved Hide resolved
>(
data: DATAType,
membership: &TYPES::Membership,
da_membership: &TYPES::Membership,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should take the stake table + threshold directly (and therefore build_assembled_sig should too)

this isn't used in the integration tests like libp2p::libp2p_network though, so shouldn't have anything to do with the failure


let da_data = DaData {
payload_commit: da_payload_commitment,
};

build_cert::<TYPES, V, DaData, DaVote<TYPES>, DaCertificate<TYPES>>(
da_data,
da_membership,
membership,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should pass the da stake table + threshold directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we always just pass in DA stake table and success_threshold? If so it isn't clear to me why we need a generic CERT.

&self,
stake_table: Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is immediately fixable (might require epoch numbers in the certs, which is being worked on separately), but I think is_valid_cert should actually just take the Memberships directly, rather than the stake table + threshold

we always know which stake table/threshold to use for each cert

can you make an issue for this and add it to the board

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR that was the logic. We changed it b/c is_valid_cert can't be generic of Membership b/c we have to call specific functions such stake_table or da_stake_table. This PR addresses this by passing in the stake table.

Always use quorum for leader selection
@tbro tbro marked this pull request as ready for review November 22, 2024 19:24
@tbro tbro requested a review from bfish713 as a code owner November 22, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants