feat: add Electra attestation V2 endpoints - #6951
Conversation
nflaig
left a comment
There was a problem hiding this comment.
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.
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.
Honestly what we should do across the code base is type all arrays like this
(Attestation | undefined)[]instead of
Attestation[]|
|
||
| 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.
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.
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
| } | ||
|
|
||
| export type ForkPreElectra = ForkPreBlobs | ForkName.deneb; | ||
| export type ForkElectra = Exclude<ForkName, ForkPreElectra>; |
There was a problem hiding this comment.
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.
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.
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.
in favor of pre / post fork terminology, it seems most commonly used and the most concise
|
|
||
| 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.
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
| }; | ||
| try { | ||
| (await this.api.beacon.submitPoolAttestations({signedAttestations})).assertOk(); | ||
| // TODO Electra: Ensure calling V2 works in pre-electra |
There was a problem hiding this comment.
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
| res: undefined, | ||
| }, | ||
| submitPoolAttestationsV2: { | ||
| args: {signedAttestations: [ssz.phase0.Attestation.defaultValue()]}, |
There was a problem hiding this comment.
I opened an issue to test this with electra data #6987
nflaig
left a comment
There was a problem hiding this comment.
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.
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 <nflaig@protonmail.com>
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
c6e1cca to
c9394c6
Compare
wemeetagain
left a comment
There was a problem hiding this comment.
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 <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* 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 <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* 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 <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* 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 <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
* 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 <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update packages/api/src/beacon/routes/beacon/pool.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Address comment * Add api stub back * Add todos * Review PR * Fix rebase * Lint --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
|
馃帀 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_attestationGET /eth/v2/beacon/blocks/{block_id}/attestationsGET /eth/v2/beacon/pool/attestationsPOST /eth/v2/beacon/pool/attestationsGET /eth/v2/beacon/pool/attester_slashingsPOST /eth/v2/beacon/pool/attester_slashings(Only support pre-electra request)POST /eth/v2/validator/aggregate_and_proofsEndpoints modified:
GET /eth/v1/validator/aggregate_attestation(Broken)GET /eth/v1/beacon/blocks/{block_id}/attestationsGET /eth/v1/beacon/pool/attestationsGET /eth/v1/beacon/pool/attester_slashingsRemaining todos:
GET /eth/v1/validator/aggregate_attestation)submitPoolAttesterSlashingsflow to handleelectra.AttesterSlashing(Related toPOST /eth/v2/beacon/pool/attester_slashings)Passes oapi spec test with the latest master branch of
ethereum/beacon-APIsPartially closes #6895