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

Refactor beacon attestation validation #6446

Open
wemeetagain opened this issue Feb 17, 2024 · 5 comments
Open

Refactor beacon attestation validation #6446

wemeetagain opened this issue Feb 17, 2024 · 5 comments
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. meta-technical-debt Issues introducing or resolving technical debts. prio-low This is nice to have.

Comments

@wemeetagain
Copy link
Member

Should we move this into a function somewhere and be re-used in gossip + here + state transition? In a way to signal that this logic must be consistent between those three places

Originally posted by @dapplion in #6198 (comment)

We should.

@ensi321 ensi321 added the good first issue Issues that are suitable for first-time contributors. label Feb 19, 2024
@HiroyukiNaito
Copy link
Contributor

I pick the issue as a good first issue.

@HiroyukiNaito
Copy link
Contributor

HiroyukiNaito commented Mar 5, 2024

I'm locating where should I change.

Should we move this into a function somewhere and be re-used in gossip + here + state transition? In a way to signal that this logic must be consistent between those three places

Is this right place?
https://github.com/ChainSafe/lodestar/blob/unstable/packages/beacon-node/src/chain/validation/attestation.ts#L478

@HiroyukiNaito
Copy link
Contributor

Shamely, I could not find where should I change the state-transition code.
Do you mind if you give me some hints?

@ensi321
Copy link
Contributor

ensi321 commented Mar 6, 2024

@HiroyukiNaito Hey! Thanks for picking this up.

Just want to share some background about this issue. Feel free to skip to tldr.

The related change is for implementing Deneb EIP EIP-7045, which is to extend the admissible range of attestation from [n - 32, n] slots to [(Math.floor(n / 32) - 1) * 32, n] slots. You can check out our implementation #5731 and also the consensus spec here.

The attestation validation logic in p2p we want to refactoring in Lodestar is to limit to lower bound of the slot in attestation by calculating earliestPermissableSlot. However, during state-transition, specifically during process_attestation, there is already an assertion in the spec and lodestar to limit the attestation to be within current or previous epoch, which has the same effect as setting lower (and upper) bound of the attestation slot. Therefore, the attestation validation logic in p2p is not needed in state-transition.

Shamely, I could not find where should I change the state-transition code.
Do you mind if you give me some hints?

tldr; The original comment is not quite accurate about state-transition. No refactoring needs to be made for state-transition. Only beacon_aggregate_and_proof and beacon_attestation_{subnet_id}

Is this right place?
https://github.com/ChainSafe/lodestar/blob/unstable/packages/beacon-node/src/chain/validation/attestation.ts#L478

Yes. Should be a straightforward change. Let me know if you have further questions

@HiroyukiNaito
Copy link
Contributor

HiroyukiNaito commented Mar 6, 2024

@ensi321 Thank you for describing the technical context of this.
So, I try to crop the codes and functionalize them, and apply the 2 points you suggested.

@philknows philknows added prio-low This is nice to have. help wanted The author indicates that additional help is wanted. meta-technical-debt Issues introducing or resolving technical debts. labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. meta-technical-debt Issues introducing or resolving technical debts. prio-low This is nice to have.
Projects
None yet
Development

No branches or pull requests

4 participants