-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 /eth/v2/beacon/blocks/{block_id}/attestations
#14478
Conversation
b3c929e
to
7ea8c9c
Compare
e9031c3
to
3f00b67
Compare
75a27c3
to
a6480ab
Compare
Version string `json:"version"` | ||
ExecutionOptimistic bool `json:"execution_optimistic"` | ||
Finalized bool `json:"finalized"` | ||
Data interface{} `json:"data"` // Accepts both `Attestation` and `AttestationElectra` types |
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.
Can we make this a json.RawMessage
?
beacon-chain/rpc/endpoints.go
Outdated
@@ -585,6 +585,15 @@ func (s *Service) beaconEndpoints( | |||
handler: server.GetBlockAttestations, | |||
methods: []string{http.MethodGet}, | |||
}, | |||
{ | |||
template: "/eth/v2/beacon/blocks/{block_id}/attestations", | |||
name: namespace + ".GetBlockAttestations", |
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.
name: namespace + ".GetBlockAttestations", | |
name: namespace + ".GetBlockAttestationsV2", |
@@ -515,7 +515,7 @@ func TestGetBlockAttestations(t *testing.T) { | |||
Blocker: mockBlockFetcher, | |||
} | |||
|
|||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v2/beacon/blocks/{block_id}/attestations", nil) | |||
request := httptest.NewRequest(http.MethodGet, "http://foo.example/eth/v1/beacon/blocks/{block_id}/attestations", nil) |
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 think it would be cleaner to organize tests like this:
t.Run("v1")
t.Run("v2")
t.Run("pre-Electra")
t.Run("post-Electra")
Blocks can be created at the top, before test runs.
if v >= version.Electra { | ||
for i, att := range consensusAtts { | ||
a, ok := att.(*eth.AttestationElectra) | ||
if ok { |
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.
similar feedback to another PR we can avoid the else statement by reversing this
Version string `json:"version"` | ||
ExecutionOptimistic bool `json:"execution_optimistic"` | ||
Finalized bool `json:"finalized"` | ||
Data []json.RawMessage `json:"data"` // Accepts both `Attestation` and `AttestationElectra` types |
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.
If you make this a single json.RawMessage
, you can call json.Marshal
just once on the entire slice.
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/blocks/{block_id}/attestations
.As described in the spec https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Beacon/getBlockAttestationsV2
Which issues(s) does this PR fix?
Part of #14476
Other notes for review
Acknowledgements