Skip to content

fix: validate gossip aggregated attestations before storing#487

Merged
unnawut merged 8 commits intoleanEthereum:mainfrom
shaaibu7:fix/validate-aggregated-attestation
Mar 28, 2026
Merged

fix: validate gossip aggregated attestations before storing#487
unnawut merged 8 commits intoleanEthereum:mainfrom
shaaibu7:fix/validate-aggregated-attestation

Conversation

@shaaibu7
Copy link
Copy Markdown
Contributor

@shaaibu7 shaaibu7 commented Mar 26, 2026

🗒️ Description

  • on_gossip_aggregated_attestation() now validates the aggregated data via validate_attestation() before validator lookup, leanVM proof verification, or payload storage, ensuring the gossip aggregate path enforces the same availability/topology/time invariants as individual attestations.

  • Added test_invalid_attestation_data_rejected to prove aggregated attestations that violate validate_attestation() (e.g., source.slot > target.slot) raise before latest_new_aggregated_payloads is mutated.

✅ Checklist

  • Considered adding appropriate tests for the changes.

fixes #473

Copy link
Copy Markdown
Collaborator

@unnawut unnawut left a comment

Choose a reason for hiding this comment

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

Looking pretty good!

One extra ask in addition to the 2 comments: The test you added is a unit test used for internal testing. It'd be great if you could add test vectors (the generated test vectors that are used by clients) as well. You can check out examples at https://github.com/leanEthereum/leanSpec/tree/main/tests/consensus/devnet. There should be 1 test vector per each of the validation rule.

Thanks a lot!

data = signed_attestation.data
proof = signed_attestation.proof

self.validate_attestation(Attestation(validator_id=ValidatorIndex(0), data=data))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We shouldn't be assuming the validator_id value in the spec here.

We can edit validate_attestation() so that it takes in AttestationData instead of Attestation since it's not using the validator_id anyway.

@unnawut unnawut added specs Scope: Changes to the specifications tests Scope: Changes to the spec tests labels Mar 26, 2026
@shaaibu7
Copy link
Copy Markdown
Contributor Author

@unnawut kindly review the implemented changes

Comment on lines +20 to +30
def _base_blocks() -> list[BlockStep]:
return [
BlockStep(
block=BlockSpec(slot=Slot(1), label="block_1"),
checks=StoreChecks(head_slot=Slot(1)),
),
BlockStep(
block=BlockSpec(slot=Slot(2), label="block_2"),
checks=StoreChecks(head_slot=Slot(2)),
),
]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is more readable for the reader is you put this directly into each test without a util function like this, even if this is more verbose, we love readability for the tests.

@shaaibu7
Copy link
Copy Markdown
Contributor Author

shaaibu7 commented Mar 26, 2026

@tcoratger kindly review the updated changes

Copy link
Copy Markdown
Collaborator

@tcoratger tcoratger left a comment

Choose a reason for hiding this comment

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

LGTM

@unnawut Feel free to merge when this is ok on your side :)

@unnawut
Copy link
Copy Markdown
Collaborator

unnawut commented Mar 27, 2026

@shaaibu7 Just one error from the newly added test and I think we're good to go!

@shaaibu7
Copy link
Copy Markdown
Contributor Author

@unnawut made the fix kindly review

@unnawut
Copy link
Copy Markdown
Collaborator

unnawut commented Mar 28, 2026

thank you!

@unnawut unnawut merged commit ae0c10d into leanEthereum:main Mar 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

specs Scope: Changes to the specifications tests Scope: Changes to the spec tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

on_gossip_aggregated_attestation() is not validating attestation rules?

3 participants