-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
feat: add Electra attestation V2 endpoints #6951
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff in PR is kinda strange in a few places because we had the hacks previously.
I see two options
- either we remove the hacks separately and then rebase this branch on top
- or we merge this, do another review on electra branch, and submit fixes afterwards if any
I guess option (2) is favorable as (1) might be too much effort for what it's worth
|
||
async getPoolAttestationsV2({slot, committeeIndex}) { | ||
// Already filtered by slot | ||
let attestations = chain.aggregatedAttestationPool.getAll(slot); | ||
const fork = chain.config.getForkName(slot ?? attestations[0].data.slot) ?? ForkName.phase0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is unsafe and also incorrect, need to be careful with accessing items in array as typescript does not properly warn here
If array is empty, this will give an error attestations[0].data.slot
, need to do attestations[0]?.data.slot
I would also favor a logic like this
const fork = chain.config.getForkName(slot ?? attestations[0]?.data.slot ?? chain.clock.currentSlot);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly what we should do across the code base is type all arrays like this
(Attestation | undefined)[]
instead of
Attestation[]
@@ -258,7 +258,7 @@ export class AttestationService { | |||
} | |||
|
|||
this.logger.verbose("Aggregating attestations", logCtx); | |||
const res = await this.api.validator.getAggregatedAttestation({ | |||
const res = await this.api.validator.getAggregatedAttestationV2({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same to the above, vc
should follow the spec to call correct api depending on the clock slot. Note that lodestar vc
could call bn
from other clients as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do a kurtosis run before we merge electra branch to unstable, I have a config which tests interop will all other clients but we will need to use v1 apis pre-electra in any case becasue we don't know if users updated their clients, similar to how we transitioned to block v3 api
packages/params/src/forkName.ts
Outdated
@@ -47,3 +47,9 @@ export type ForkBlobs = Exclude<ForkName, ForkPreBlobs>; | |||
export function isForkBlobs(fork: ForkName): fork is ForkBlobs { | |||
return isForkWithdrawals(fork) && fork !== ForkName.capella; | |||
} | |||
|
|||
export type ForkPreElectra = ForkPreBlobs | ForkName.deneb; | |||
export type ForkElectra = Exclude<ForkName, ForkPreElectra>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyone has an idea for a fancy name here? Looks we like we usually don't use the fork name but rather a feature added in the fork
cc @g11tech
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ForkElectra is a little confusing here imo.
Maybe ForkPostElectra.
I'd also be in favor of using that same naming for the other forks (eg ForkPostBellatrix instead of ForkExecution)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also be in favor of using that same naming for the other forks (eg ForkPostBellatrix instead of ForkExecution)
Yea I guess back in the days, each hard fork has a single signature feature (or theme) that you can name after. For electra, there is a bunch of new features that are significant, so naming convention like ForkExecution
can't apply to electra.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForkElectraOnwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in favor of pre / post fork terminology, it seems most commonly used and the most concise
@@ -258,7 +258,7 @@ export class AttestationService { | |||
} | |||
|
|||
this.logger.verbose("Aggregating attestations", logCtx); | |||
const res = await this.api.validator.getAggregatedAttestation({ | |||
const res = await this.api.validator.getAggregatedAttestationV2({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do a kurtosis run before we merge electra branch to unstable, I have a config which tests interop will all other clients but we will need to use v1 apis pre-electra in any case becasue we don't know if users updated their clients, similar to how we transitioned to block v3 api
@@ -225,7 +225,8 @@ export class AttestationService { | |||
...(this.opts?.disableAttestationGrouping && {index: attestationNoCommittee.index}), | |||
}; | |||
try { | |||
(await this.api.beacon.submitPoolAttestations({signedAttestations})).assertOk(); | |||
// TODO Electra: Ensure calling V2 works in pre-electra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note here, while all apis should be backward compatible, i.e. work pre-electra, we still can't use them until the fork happens. After the electra fork, we can safely remove all v1 calls and only use v2
@@ -114,10 +129,18 @@ export const testData: GenericServerTestCases<Endpoints> = { | |||
args: {signedAttestations: [ssz.phase0.Attestation.defaultValue()]}, | |||
res: undefined, | |||
}, | |||
submitPoolAttestationsV2: { | |||
args: {signedAttestations: [ssz.phase0.Attestation.defaultValue()]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened an issue to test this with electra data #6987
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - can solve remaining todos separately to make it easier to review
req: { | ||
writeReqJson: ({signedAttestations}) => { | ||
const fork = config.getForkName(signedAttestations[0].data.slot); | ||
const fork = config.getForkName(signedAttestations[0]?.data.slot ?? 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice, we won't be calling this api with an empty array but it's possible based on the types and the spec does not explicitly state that the array is not allowed to be empty.
We don't have access to the clock here, so it's hard as far as I can see to determine the current fork but passing 0 (translating to phase0) should be fine as well since array is empty anyways.
Are we waiting on merging this until |
@wemeetagain Yes we will wait until the electra-fork branch is rebased |
Ok, can you base this PR on |
Co-authored-by: Nico Flaig <[email protected]>
Co-authored-by: Nico Flaig <[email protected]>
Co-authored-by: Nico Flaig <[email protected]>
Co-authored-by: Nico Flaig <[email protected]>
c6e1cca
to
c9394c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging, we can continue the next round of review there
* Initial commit * getAggregatedAttestationV2 * Lint * Fix minor flaw * Add publishAggregateAndProofsV2 * Fix spelling * Fix CI * Fix spec test * Clean up events api * Run against latest beacon api spec * Revert changes to emitted events * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <[email protected]>
* Initial commit * getAggregatedAttestationV2 * Lint * Fix minor flaw * Add publishAggregateAndProofsV2 * Fix spelling * Fix CI * Fix spec test * Clean up events api * Run against latest beacon api spec * Revert changes to emitted events * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <[email protected]>
* Initial commit * getAggregatedAttestationV2 * Lint * Fix minor flaw * Add publishAggregateAndProofsV2 * Fix spelling * Fix CI * Fix spec test * Clean up events api * Run against latest beacon api spec * Revert changes to emitted events * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <[email protected]>
* Initial commit * getAggregatedAttestationV2 * Lint * Fix minor flaw * Add publishAggregateAndProofsV2 * Fix spelling * Fix CI * Fix spec test * Clean up events api * Run against latest beacon api spec * Revert changes to emitted events * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <[email protected]>
* Initial commit * getAggregatedAttestationV2 * Lint * Fix minor flaw * Add publishAggregateAndProofsV2 * Fix spelling * Fix CI * Fix spec test * Clean up events api * Run against latest beacon api spec * Revert changes to emitted events * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <[email protected]> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <[email protected]>
🎉 This PR is included in v1.22.0 🎉 |
This PR adds definition of the new attestation related V2 endpoints in Electra. It also reverts some of the hacks we made to some V1 endpoints during devnet-0.
Note some of the V1 and V2 endpoints are not functioning properly. TODOs are added to ensure their functionalities
Endpoints added:
GET /eth/v2/validator/aggregate_attestation
GET /eth/v2/beacon/blocks/{block_id}/attestations
GET /eth/v2/beacon/pool/attestations
POST /eth/v2/beacon/pool/attestations
GET /eth/v2/beacon/pool/attester_slashings
POST /eth/v2/beacon/pool/attester_slashings
(Only support pre-electra request)POST /eth/v2/validator/aggregate_and_proofs
Endpoints modified:
GET /eth/v1/validator/aggregate_attestation
(Broken)GET /eth/v1/beacon/blocks/{block_id}/attestations
GET /eth/v1/beacon/pool/attestations
GET /eth/v1/beacon/pool/attester_slashings
Remaining todos:
GET /eth/v1/validator/aggregate_attestation
)submitPoolAttesterSlashings
flow to handleelectra.AttesterSlashing
(Related toPOST /eth/v2/beacon/pool/attester_slashings
)Passes oapi spec test with the latest master branch of
ethereum/beacon-APIs
Partially closes #6895