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

Add GET /eth/v2/beacon/pool/attestations endpoint #14560

Merged
merged 12 commits into from
Oct 28, 2024
Merged

Conversation

saolyn
Copy link
Contributor

@saolyn saolyn commented Oct 21, 2024

What type of PR is this?

Other

What does this PR do? Why is it needed?

Beacon API Electra alignment, add missing endpoint for GET /eth/v2/beacon/pool/attestations.
As described in the spec https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getPoolAttestationsV2

Which issues(s) does this PR fix?

Part of #14476

Other notes for review

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have made an appropriate entry to CHANGELOG.md.
  • I have added a description to this PR with sufficient context for reviewers to understand this PR.

@saolyn saolyn changed the title add ListAttestationsV2 endpoint Add /eth/v2/beacon/pool/attestations endpoint Oct 21, 2024
@saolyn saolyn changed the title Add /eth/v2/beacon/pool/attestations endpoint Add GET /eth/v2/beacon/pool/attestations endpoint Oct 22, 2024
@saolyn saolyn marked this pull request as ready for review October 22, 2024 15:11
@saolyn saolyn requested a review from a team as a code owner October 22, 2024 15:11
@saolyn saolyn force-pushed the add-getAttestations branch from c43e5ba to 33a2948 Compare October 22, 2024 15:47
@saolyn saolyn added API Api related tasks Electra electra hardfork labels Oct 22, 2024
}
httputil.WriteJson(w, &structs.ListAttestationsResponse{Data: filteredAtts})
w.Header().Set(api.VersionHeader, version.String(firstVersion))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same idea as for slashings: we should use the head state or current slot to determine the version and only return attestations for that version.


for _, att := range attestations {
var includeAttestation bool
attOld, ok := att.(*eth.Attestation)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename to att since there is only one type of attestations in v1?

}
httputil.WriteJson(w, &structs.ListAttestationsResponse{Data: allAtts})
data := attOld.GetData()
attStruct := structs.AttFromConsensus(attOld)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should ideally be done inside if includeAttestation

return
}
data := attElectra.GetData()
attStruct := structs.AttElectraFromConsensus(attElectra)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should ideally be done inside if includeAttestation

return
}
data := attOld.GetData()
attStruct := structs.AttFromConsensus(attOld)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should ideally be done inside if includeAttestation

Comment on lines 173 to 174
if isEmptyReq {
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is not really needed. If both are empty, then return committeeIndexMatch && slotMatch will return true. Also you will be able to have one function argument less.

Comment on lines +167 to +168
ElectraForkVersion []byte `yaml:"ELECTRA_FORK_VERSION" spec:"true"` // ElectraForkVersion is used to represent the fork version for electra.
ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for electra.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@saolyn saolyn enabled auto-merge October 28, 2024 10:01
@saolyn saolyn added this pull request to the merge queue Oct 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 28, 2024
@saolyn saolyn added this pull request to the merge queue Oct 28, 2024
Merged via the queue into develop with commit 09accc7 Oct 28, 2024
17 of 18 checks passed
@saolyn saolyn deleted the add-getAttestations branch October 28, 2024 11:08
rkapka pushed a commit that referenced this pull request Nov 29, 2024
* add ListAttestationsV2 endpoint

* fix endpoint

* changelog

* add endpoint to tests

* add trailing comma

* add version header + lint fix

* all reviews

* modify v1 and comments

* fix linter

* Radek' review
@kasey kasey added the changelog/added Changelog Section: Added label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks changelog/added Changelog Section: Added Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants