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/attester_slashings #14479

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

saolyn
Copy link
Contributor

@saolyn saolyn commented Sep 25, 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 /eth/v2/beacon/pool/attester_slashings.
As described in the spec https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getPoolAttesterSlashingsV2

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 /eth/v2/beacon/pool/attester_slashings Add GET /eth/v2/beacon/pool/attester_slashings Sep 25, 2024
@saolyn saolyn marked this pull request as ready for review September 25, 2024 15:00
@saolyn saolyn requested a review from a team as a code owner September 25, 2024 15:00
ss := make([]*eth.AttesterSlashingElectra, len(sourceSlashings))
for i, slashing := range sourceSlashings {
a, ok := slashing.(*eth.AttesterSlashingElectra)
if ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

you could do the reverse here and avoid the else

@@ -172,6 +172,11 @@ type GetAttesterSlashingsResponse struct {
Data []*AttesterSlashing `json:"data"`
}

type GetAttesterSlashingsV2Response struct {
Version string `json:"version"`
Data []json.RawMessage `json:"data"` // Accepts both `[]*AttesterSlashing` and `[]*AttesterSlashingElectra` types
Copy link
Contributor

Choose a reason for hiding this comment

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

Single json.RawMessage will make the code more compact

}
v := version.String(headState.Version())
Copy link
Contributor

Choose a reason for hiding this comment

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

The version should be based on the version of the slashing, not the state. This is because (1) the only possible slashing versions are Phase0 and Electra, and (2) the state here can be after a fork with the slashing being before the fork.

beacon-chain/rpc/eth/beacon/handlers_pool.go Outdated Show resolved Hide resolved
@@ -172,6 +172,11 @@ type GetAttesterSlashingsResponse struct {
Data []*AttesterSlashing `json:"data"`
}

type GetAttesterSlashingsV2Response struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants