From c285715f9f475561b60474d6f4fb261a6fc68686 Mon Sep 17 00:00:00 2001 From: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:16:33 +0100 Subject: [PATCH] Add missing Eth-Consensus-Version headers (#14647) * add missing Eth-Consensus-Version headers * changelog * fix header return value --- CHANGELOG.md | 17 +++++++++-------- beacon-chain/rpc/eth/beacon/handlers_pool.go | 1 + beacon-chain/rpc/eth/validator/handlers.go | 8 +++++++- beacon-chain/rpc/eth/validator/handlers_test.go | 3 +++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98206ce591b1..a40746a167ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve ### Added -- Electra EIP6110: Queue deposit [pr](https://github.com/prysmaticlabs/prysm/pull/14430) +- Electra EIP6110: Queue deposit [pr](https://github.com/prysmaticlabs/prysm/pull/14430). - Add Bellatrix tests for light client functions. - Add Discovery Rebooter Feature. - Added GetBlockAttestationsV2 endpoint. @@ -19,13 +19,13 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Added ListAttestationsV2 endpoint. - Add ability to rollback node's internal state during processing. - Change how unsafe protobuf state is created to prevent unnecessary copies. -- Added benchmarks for process slots for Capella, Deneb, Electra +- Added benchmarks for process slots for Capella, Deneb, Electra. - Add helper to cast bytes to string without allocating memory. - Added GetAggregatedAttestationV2 endpoint. - Added SubmitAttestationsV2 endpoint. -- Validator REST mode Electra block support -- Added validator index label to `validator_statuses` metric -- Added Validator REST mode use of Attestation V2 endpoints and Electra attestations +- Validator REST mode Electra block support. +- Added validator index label to `validator_statuses` metric. +- Added Validator REST mode use of Attestation V2 endpoints and Electra attestations. ### Changed @@ -53,11 +53,12 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Only Build the Protobuf state once during serialization. - Capella blocks are execution. - Fixed panic when http request to subscribe to event stream fails. -- Return early for blob reconstructor during capella fork -- Updated block endpoint from V1 to V2 +- Return early for blob reconstructor during capella fork. +- Updated block endpoint from V1 to V2. - Rename instances of "deposit receipts" to "deposit requests". -- non-blocking payload attribute event handling in beacon api [pr](https://github.com/prysmaticlabs/prysm/pull/14644) +- Non-blocking payload attribute event handling in beacon api [pr](https://github.com/prysmaticlabs/prysm/pull/14644). - Updated light client protobufs. [PR](https://github.com/prysmaticlabs/prysm/pull/14650) +- Added `Eth-Consensus-Version` header to `ListAttestationsV2` and `GetAggregateAttestationV2` endpoints. ### Deprecated diff --git a/beacon-chain/rpc/eth/beacon/handlers_pool.go b/beacon-chain/rpc/eth/beacon/handlers_pool.go index e68b7d377659..f522e659b5a7 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_pool.go +++ b/beacon-chain/rpc/eth/beacon/handlers_pool.go @@ -149,6 +149,7 @@ func (s *Server) ListAttestationsV2(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set(api.VersionHeader, version.String(headState.Version())) httputil.WriteJson(w, &structs.ListAttestationsResponse{ Version: version.String(headState.Version()), Data: attsData, diff --git a/beacon-chain/rpc/eth/validator/handlers.go b/beacon-chain/rpc/eth/validator/handlers.go index 375558a8e7ca..1b56aba5360a 100644 --- a/beacon-chain/rpc/eth/validator/handlers.go +++ b/beacon-chain/rpc/eth/validator/handlers.go @@ -75,7 +75,7 @@ func (s *Server) GetAggregateAttestation(w http.ResponseWriter, r *http.Request) // GetAggregateAttestationV2 aggregates all attestations matching the given attestation data root and slot, returning the aggregated result. func (s *Server) GetAggregateAttestationV2(w http.ResponseWriter, r *http.Request) { - _, span := trace.StartSpan(r.Context(), "validator.GetAggregateAttestationV2") + ctx, span := trace.StartSpan(r.Context(), "validator.GetAggregateAttestationV2") defer span.End() _, attDataRoot, ok := shared.HexFromQuery(w, r, "attestation_data_root", fieldparams.RootLength, true) @@ -123,6 +123,12 @@ func (s *Server) GetAggregateAttestationV2(w http.ResponseWriter, r *http.Reques } resp.Data = data } + headState, err := s.ChainInfoFetcher.HeadStateReadOnly(ctx) + if err != nil { + httputil.HandleError(w, "Could not get head state: "+err.Error(), http.StatusInternalServerError) + return + } + w.Header().Set(api.VersionHeader, version.String(headState.Version())) httputil.WriteJson(w, resp) } diff --git a/beacon-chain/rpc/eth/validator/handlers_test.go b/beacon-chain/rpc/eth/validator/handlers_test.go index c9843d911337..ec4d7d8e2a16 100644 --- a/beacon-chain/rpc/eth/validator/handlers_test.go +++ b/beacon-chain/rpc/eth/validator/handlers_test.go @@ -262,7 +262,10 @@ func TestGetAggregateAttestation(t *testing.T) { require.NoError(t, pool.SaveAggregatedAttestations([]ethpbalpha.Att{aggSlot1_Root1_1, aggSlot1_Root1_2, aggSlot1_Root2, aggSlot2}), "Failed to save aggregated attestations") agg := pool.AggregatedAttestations() require.Equal(t, 4, len(agg), "Expected 4 aggregated attestations") + bs, err := util.NewBeaconState() + require.NoError(t, err) s := &Server{ + ChainInfoFetcher: &mockChain.ChainService{State: bs}, AttestationsPool: pool, } t.Run("non-matching attestation request", func(t *testing.T) {