Skip to content

Single attestation "Full" implementation #7444

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

Open
wants to merge 26 commits into
base: unstable
Choose a base branch
from

Conversation

eserilev
Copy link
Member

Issue Addressed

#6970

Proposed Changes

This allows for us to receive SingleAttestation over gossip and process it without converting. There is still a conversion to Attestation as a final step in the attestation verification process, but by then the SingleAttestation is fully verified.

I've also fully removed the submitPoolAttestationsV1 endpoint as its been deprecated

I've also pre-emptively deprecated supporting Attestation in submitPoolAttestationsV2 endpoint. See here for more info: ethereum/beacon-APIs#531

I tried to the minimize the diff here by only making the "required" changes. There are some unnecessary complexities with the way we manage the different attestation verification wrapper types. We could probably consolidate this to one wrapper type and refactor this even further. We could leave that to a separate PR if we feel like cleaning things up in the future.

Note that I've also updated the test harness to always submit SingleAttestation regardless of fork variant. I don't see a problem in that approach and it allows us to delete more code :)

@eserilev eserilev requested a review from jxs as a code owner May 12, 2025 18:45
@eserilev eserilev added backwards-incompat Backwards-incompatible API change electra Required for the Electra/Prague fork optimization Something to make Lighthouse run more efficiently. v7.1.0 Post-Electra release labels May 12, 2025
Copy link

mergify bot commented May 15, 2025

Some required checks have failed. Could you please take a look @eserilev? 🙏

@mergify mergify bot added the waiting-on-author The reviewer has suggested changes and awaits thier implementation. label May 15, 2025
Copy link

mergify bot commented May 16, 2025

All required checks have passed and there are no merge conflicts. This pull request may now be ready for another review.

@mergify mergify bot added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels May 16, 2025
Copy link

mergify bot commented May 16, 2025

Some required checks have failed. Could you please take a look @eserilev? 🙏

@mergify mergify bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels May 16, 2025
Copy link

mergify bot commented May 16, 2025

This pull request has merge conflicts. Could you please resolve them @eserilev? 🙏

Copy link

mergify bot commented May 16, 2025

Some required checks have failed. Could you please take a look @eserilev? 🙏

@michaelsproul michaelsproul self-requested a review May 20, 2025 08:07
Copy link

mergify bot commented May 26, 2025

This pull request has merge conflicts. Could you please resolve them @eserilev? 🙏

@mergify mergify bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels May 26, 2025
@mergify mergify bot added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jun 2, 2025
Comment on lines -839 to -843
// Check to ensure that the attestation is "unaggregated". I.e., it has exactly one
// aggregation bit set.
let num_aggregation_bits = attestation.num_set_aggregation_bits();
if num_aggregation_bits != 1 {
return Err(Error::NotExactlyOneAggregationBitSet(num_aggregation_bits));
Copy link
Member Author

Choose a reason for hiding this comment

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

SingleAttestation objects are guaranteed to be unaggregated so this check is not needed

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines -846 to -848
// [New in Electra:EIP7549]
verify_committee_index(attestation)?;

Copy link
Member Author

Choose a reason for hiding this comment

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

SingleAttestation objects are guaranteed to be unaggregated so no need for this check

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 968 to 969
// Check that the attester is a member of the committee and return `committees_per_slot` which
// is used in `verify_middle_checks` to calculate the expected `subnet_id`
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

mergify bot commented Jun 8, 2025

Some required checks have failed. Could you please take a look @eserilev? 🙏

@mergify mergify bot added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Jun 8, 2025
Comment on lines 972 to +988
fn verify_late_checks(
attestation: AttestationRef<T::EthSpec>,
attestation: &'a SingleAttestation,
validator_index: u64,
subnet_id: Option<SubnetId>,
chain: &BeaconChain<T>,
) -> Result<(), Error> {
) -> Result<(Attestation<T::EthSpec>, SubnetId), Error> {
// Check that the attester is a member of the committee
let (committee_opt, committees_per_slot) = chain.with_committee_cache(
attestation.data.target.root,
attestation.data.slot.epoch(T::EthSpec::slots_per_epoch()),
|committee_cache, _| {
let committee_opt = committee_cache
.get_beacon_committee(attestation.data.slot, attestation.committee_index)
.map(|beacon_committee| beacon_committee.committee.to_vec());

Ok((committee_opt, committee_cache.committees_per_slot()))
},
Copy link
Member Author

Choose a reason for hiding this comment

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

In the spirit of the SingleAttestation changes, I've moved all checks that require access to the shuffling to after signature verification

Copy link
Member Author

Choose a reason for hiding this comment

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

These checks are

  • Committee exists for slot and index
  • Attester is in the committee
  • expected subnet id == provided subnet id

Comment on lines 998 to 1003
if committee.contains(&(attestation.attester_index as usize)) {
return Err(Error::AttesterNotInCommittee {
attester_index: attestation.attester_index,
committee_index: attestation.committee_index,
slot: attestation.data.slot,
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines -1027 to -1029
.inspect_unaggregate_err(
"attestation without any aggregation bits set",
|tester, mut a, _| {
Copy link
Member Author

Choose a reason for hiding this comment

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

not a valid test case for SingleAttestation

Comment on lines -1059 to -1063
)
.inspect_unaggregate_err(
"attestation with two aggregation bits set",
|tester, mut a, _| {
match &mut a {
Copy link
Member Author

Choose a reason for hiding this comment

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

not a valid test case for SingleAttestation

Comment on lines -1086 to -1092
* The number of aggregation bits matches the committee size -- i.e.
* `len(attestation.aggregation_bits) == len(get_beacon_committee(state, data.slot,
* data.index))`.
*/
.inspect_unaggregate_err(
"attestation with invalid bitfield",
|_, mut a, _| {
Copy link
Member Author

Choose a reason for hiding this comment

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

not a valid test case for SingleAttestation

@eserilev
Copy link
Member Author

eserilev commented Jun 8, 2025

We now move checks that require access to the shuffling to AFTER signature verification. This seems in line with the spirit of the SingleAttestation changes

ethereum/consensus-specs#3900

@eserilev eserilev added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-incompat Backwards-incompatible API change electra Required for the Electra/Prague fork optimization Something to make Lighthouse run more efficiently. ready-for-review The code is ready for review v7.1.0 Post-Electra release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant