From 5be1c9a1c6d0148790f0549f1ce4c70d7296150d Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Fri, 23 Aug 2024 01:40:13 +0530 Subject: [PATCH 01/34] feat: introduce Capella and Deneb `full-node.md` lc changes --- api/server/structs/endpoints_lightclient.go | 34 ++++++ beacon-chain/rpc/eth/light-client/handlers.go | 48 ++++++-- .../rpc/eth/light-client/handlers_test.go | 106 ++++++++++++++++- beacon-chain/rpc/eth/light-client/helpers.go | 110 ++++++++++++++++++ 4 files changed, 289 insertions(+), 9 deletions(-) diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index d7380073395b..b2ccd7edddd7 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -4,17 +4,51 @@ type LightClientHeader struct { Beacon *BeaconBlockHeader `json:"beacon"` } +type LightClientHeaderCapella struct { + Beacon *BeaconBlockHeader `json:"beacon"` + Execution *ExecutionPayloadHeaderCapella `json:"execution"` + ExecutionBranch [][]byte `json:"execution_branch"` +} + +type LightClientHeaderDeneb struct { + Beacon *BeaconBlockHeader `json:"beacon"` + Execution *ExecutionPayloadHeaderDeneb `json:"execution"` + ExecutionBranch [][]byte `json:"execution_branch"` +} + type LightClientBootstrapResponse struct { Version string `json:"version"` Data *LightClientBootstrap `json:"data"` } +type LightClientBootstrapResponseCapella struct { + Version string `json:"version"` + Data *LightClientBootstrapCapella `json:"data"` +} + +type LightClientBootstrapResponseDeneb struct { + Version string `json:"version"` + Data *LightClientBootstrapDeneb `json:"data"` +} + type LightClientBootstrap struct { Header *LightClientHeader `json:"header"` CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` } +type LightClientBootstrapCapella struct { + Header *LightClientHeaderCapella `json:"header"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` +} + +type LightClientBootstrapDeneb struct { + Header *LightClientHeaderDeneb `json:"header"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` +} + type LightClientUpdate struct { AttestedHeader *BeaconBlockHeader `json:"attested_header"` NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 74296f192e85..1c261d51102d 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -46,18 +46,52 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - bootstrap, err := createLightClientBootstrap(ctx, state) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + ver := blk.Version() + if ver >= version.Deneb { + bootstrap, err := createLightClientBootstrapDeneb(ctx, state) + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } + + response := &structs.LightClientBootstrapResponseDeneb{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + + httputil.WriteJson(w, response) return } - response := &structs.LightClientBootstrapResponse{ - Version: version.String(blk.Version()), - Data: bootstrap, + if ver >= version.Capella { + bootstrap, err := createLightClientBootstrapCapella(ctx, state) + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } + + response := &structs.LightClientBootstrapResponseCapella{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + httputil.WriteJson(w, response) + return } - httputil.WriteJson(w, response) + if ver >= version.Altair { + bootstrap, err := createLightClientBootstrap(ctx, state) + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } + + response := &structs.LightClientBootstrapResponse{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + httputil.WriteJson(w, response) + return + } } // GetLightClientUpdatesByRange - implements https://github.com/ethereum/beacon-APIs/blob/263f4ed6c263c967f13279c7a9f5629b51c5fc55/apis/beacon/light_client/updates.yaml diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index 59e34923948d..1ff09f8ea5c3 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -26,7 +26,58 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/util" ) -func TestLightClientHandler_GetLightClientBootstrap(t *testing.T) { +func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) { + helpers.ClearCache() + slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + + b := util.NewBeaconBlockAltair() + b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) + b.Block.Slot = slot + + signedBlock, err := blocks.NewSignedBeaconBlock(b) + + require.NoError(t, err) + header, err := signedBlock.Header() + require.NoError(t, err) + + r, err := b.Block.HashTreeRoot() + require.NoError(t, err) + + bs, err := util.NewBeaconStateAltair(func(state *ethpb.BeaconStateAltair) error { + state.BlockRoots[0] = r[:] + return nil + }) + require.NoError(t, err) + + require.NoError(t, bs.SetSlot(slot)) + require.NoError(t, bs.SetLatestBlockHeader(header.Header)) + + mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot: bs, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + muxVars := make(map[string]string) + muxVars["block_root"] = hexutil.Encode(r[:]) + request := httptest.NewRequest("GET", "http://foo.com/", nil) + request = mux.SetURLVars(request, muxVars) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientBootstrap(writer, request) + require.Equal(t, http.StatusOK, writer.Code) + resp := &structs.LightClientBootstrapResponse{} + require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) + require.NotNil(t, resp.Data) +} + +func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { helpers.ClearCache() slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) @@ -70,13 +121,64 @@ func TestLightClientHandler_GetLightClientBootstrap(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientBootstrapResponse{} + resp := &structs.LightClientBootstrapResponseCapella{} require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) require.Equal(t, "capella", resp.Version) require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) require.NotNil(t, resp.Data) } +func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { + helpers.ClearCache() + slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + + b := util.NewBeaconBlockDeneb() + b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) + b.Block.Slot = slot + + signedBlock, err := blocks.NewSignedBeaconBlock(b) + + require.NoError(t, err) + header, err := signedBlock.Header() + require.NoError(t, err) + + r, err := b.Block.HashTreeRoot() + require.NoError(t, err) + + bs, err := util.NewBeaconStateDeneb(func(state *ethpb.BeaconStateDeneb) error { + state.BlockRoots[0] = r[:] + return nil + }) + require.NoError(t, err) + + require.NoError(t, bs.SetSlot(slot)) + require.NoError(t, bs.SetLatestBlockHeader(header.Header)) + + mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot: bs, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + muxVars := make(map[string]string) + muxVars["block_root"] = hexutil.Encode(r[:]) + request := httptest.NewRequest("GET", "http://foo.com/", nil) + request = mux.SetURLVars(request, muxVars) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientBootstrap(writer, request) + require.Equal(t, http.StatusOK, writer.Code) + resp := &structs.LightClientBootstrapResponseDeneb{} + require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) + require.Equal(t, "deneb", resp.Version) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) + require.NotNil(t, resp.Data) +} + func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { helpers.ClearCache() ctx := context.Background() diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index e5c8a94966dc..b6f98d62d744 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -92,6 +92,116 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* return result, nil } +func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrapCapella, error) { + // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH + if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { + return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) + } + + // assert state.slot == state.latest_block_header.slot + latestBlockHeader := state.LatestBlockHeader() + if state.Slot() != latestBlockHeader.Slot { + return nil, fmt.Errorf("state slot %d not equal to latest block header slot %d", state.Slot(), latestBlockHeader.Slot) + } + + // Prepare data + currentSyncCommittee, err := state.CurrentSyncCommittee() + if err != nil { + return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) + } + + committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) + + currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) + if err != nil { + return nil, fmt.Errorf("could not get current sync committee proof: %s", err.Error()) + } + + branch := make([]string, fieldparams.NextSyncCommitteeBranchDepth) + for i, proof := range currentSyncCommitteeProof { + branch[i] = hexutil.Encode(proof) + } + + beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) + if beacon == nil { + return nil, fmt.Errorf("could not get beacon block header") + } + header := &structs.LightClientHeaderCapella{ + Beacon: beacon, + } + + // Above shared util function won't calculate state root, so we need to do it manually + stateRoot, err := state.HashTreeRoot(ctx) + if err != nil { + return nil, fmt.Errorf("could not get state root: %s", err.Error()) + } + header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) + + // Return result + result := &structs.LightClientBootstrapCapella{ + Header: header, + CurrentSyncCommittee: committee, + CurrentSyncCommitteeBranch: branch, + } + + return result, nil +} + +func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrapDeneb, error) { + // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH + if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { + return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) + } + + // assert state.slot == state.latest_block_header.slot + latestBlockHeader := state.LatestBlockHeader() + if state.Slot() != latestBlockHeader.Slot { + return nil, fmt.Errorf("state slot %d not equal to latest block header slot %d", state.Slot(), latestBlockHeader.Slot) + } + + // Prepare data + currentSyncCommittee, err := state.CurrentSyncCommittee() + if err != nil { + return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) + } + + committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) + + currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) + if err != nil { + return nil, fmt.Errorf("could not get current sync committee proof: %s", err.Error()) + } + + branch := make([]string, fieldparams.NextSyncCommitteeBranchDepth) + for i, proof := range currentSyncCommitteeProof { + branch[i] = hexutil.Encode(proof) + } + + beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) + if beacon == nil { + return nil, fmt.Errorf("could not get beacon block header") + } + header := &structs.LightClientHeaderDeneb{ + Beacon: beacon, + } + + // Above shared util function won't calculate state root, so we need to do it manually + stateRoot, err := state.HashTreeRoot(ctx) + if err != nil { + return nil, fmt.Errorf("could not get state root: %s", err.Error()) + } + header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) + + // Return result + result := &structs.LightClientBootstrapDeneb{ + Header: header, + CurrentSyncCommittee: committee, + CurrentSyncCommitteeBranch: branch, + } + + return result, nil +} + // createLightClientUpdate - implements https://github. // com/ethereum/consensus-specs/blob/d70dcd9926a4bbe987f1b4e65c3e05bd029fcfb8/specs/altair/light-client/full-node.md#create_light_client_update // def create_light_client_update(state: BeaconState, From 1849d358e49241a570ebab3a28873bd9fe3bd115 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Sat, 24 Aug 2024 01:06:51 +0530 Subject: [PATCH 02/34] add switch-case and replace `[][]byte` with `[][]string` --- api/server/structs/endpoints_lightclient.go | 4 +-- beacon-chain/rpc/eth/light-client/handlers.go | 31 +++++++++++-------- beacon-chain/rpc/eth/light-client/helpers.go | 26 ++++++++++++++-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index b2ccd7edddd7..902b5c24d8c5 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -7,13 +7,13 @@ type LightClientHeader struct { type LightClientHeaderCapella struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderCapella `json:"execution"` - ExecutionBranch [][]byte `json:"execution_branch"` + ExecutionBranch [][]string `json:"execution_branch"` } type LightClientHeaderDeneb struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderDeneb `json:"execution"` - ExecutionBranch [][]byte `json:"execution_branch"` + ExecutionBranch [][]string `json:"execution_branch"` } type LightClientBootstrapResponse struct { diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 1c261d51102d..f9f735562d5b 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -46,24 +46,27 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - ver := blk.Version() - if ver >= version.Deneb { - bootstrap, err := createLightClientBootstrapDeneb(ctx, state) + switch blk.Version() { + case version.Phase0: + httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusNotImplemented) + return + case version.Altair: + bootstrap, err := createLightClientBootstrap(ctx, state) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return } - response := &structs.LightClientBootstrapResponseDeneb{ + response := &structs.LightClientBootstrapResponse{ Version: version.String(blk.Version()), Data: bootstrap, } - httputil.WriteJson(w, response) return - } - - if ver >= version.Capella { + case version.Bellatrix: + httputil.HandleError(w, "light client bootstrap is not supported for bellatrix", http.StatusNotImplemented) + return + case version.Capella: bootstrap, err := createLightClientBootstrapCapella(ctx, state) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) @@ -76,21 +79,23 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques } httputil.WriteJson(w, response) return - } - - if ver >= version.Altair { - bootstrap, err := createLightClientBootstrap(ctx, state) + case version.Deneb: + bootstrap, err := createLightClientBootstrapDeneb(ctx, state) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return } - response := &structs.LightClientBootstrapResponse{ + response := &structs.LightClientBootstrapResponseDeneb{ Version: version.String(blk.Version()), Data: bootstrap, } + httputil.WriteJson(w, response) return + case version.Electra: + httputil.HandleError(w, "light client bootstrap is not supported for electra", http.StatusNotImplemented) + return } } diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index b6f98d62d744..c01b0c79d6b5 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -92,9 +92,9 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* return result, nil } -func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrapCapella, error) { +func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState, block *structs.BlindedBeaconBlockCapella) (*structs.LightClientBootstrapCapella, error) { // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH - if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { + if slots.ToEpoch(state.Slot()) < params.BeaconConfig().CapellaForkEpoch { return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) } @@ -128,6 +128,23 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt } header := &structs.LightClientHeaderCapella{ Beacon: beacon, + Execution: &structs.ExecutionPayloadHeaderCapella{ + ParentHash: block.Body.ExecutionPayloadHeader.ParentHash, + FeeRecipient: block.Body.ExecutionPayloadHeader.FeeRecipient, + StateRoot: block.Body.ExecutionPayloadHeader.StateRoot, + ReceiptsRoot: block.Body.ExecutionPayloadHeader.ReceiptsRoot, + LogsBloom: block.Body.ExecutionPayloadHeader.LogsBloom, + PrevRandao: block.Body.ExecutionPayloadHeader.PrevRandao, + BlockNumber: block.Body.ExecutionPayloadHeader.BlockNumber, + GasLimit: block.Body.ExecutionPayloadHeader.GasLimit, + GasUsed: block.Body.ExecutionPayloadHeader.GasUsed, + Timestamp: block.Body.ExecutionPayloadHeader.Timestamp, + ExtraData: block.Body.ExecutionPayloadHeader.ExtraData, + BaseFeePerGas: block.Body.ExecutionPayloadHeader.BaseFeePerGas, + BlockHash: block.Body.ExecutionPayloadHeader.BlockHash, + TransactionsRoot: block.Body.ExecutionPayloadHeader.TransactionsRoot, + WithdrawalsRoot: block.Body.ExecutionPayloadHeader.WithdrawalsRoot, + }, } // Above shared util function won't calculate state root, so we need to do it manually @@ -149,7 +166,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrapDeneb, error) { // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH - if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { + if slots.ToEpoch(state.Slot()) < params.BeaconConfig().DenebForkEpoch { return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) } @@ -183,6 +200,9 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat } header := &structs.LightClientHeaderDeneb{ Beacon: beacon, + Execution: &structs.ExecutionPayloadHeaderDeneb{ + ParentHash: hexutil.Encode(), + }, } // Above shared util function won't calculate state root, so we need to do it manually From 6b93f1ac26c4373fdc17f26e3a899af6af767743 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Sun, 25 Aug 2024 21:18:32 +0530 Subject: [PATCH 03/34] return version name in http header --- beacon-chain/rpc/eth/light-client/handlers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index f9f735562d5b..1f9b3c32ff1f 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/prysmaticlabs/prysm/v5/api" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" @@ -61,6 +62,8 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques Version: version.String(blk.Version()), Data: bootstrap, } + w.Header().Set(api.VersionHeader, version.String(version.Altair)) + httputil.WriteJson(w, response) return case version.Bellatrix: @@ -77,6 +80,8 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques Version: version.String(blk.Version()), Data: bootstrap, } + w.Header().Set(api.VersionHeader, version.String(version.Capella)) + httputil.WriteJson(w, response) return case version.Deneb: @@ -90,6 +95,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques Version: version.String(blk.Version()), Data: bootstrap, } + w.Header().Set(api.VersionHeader, version.String(version.Deneb)) httputil.WriteJson(w, response) return From 21652032e25542200dd98a2e36677f4841983d62 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Tue, 27 Aug 2024 01:27:33 +0530 Subject: [PATCH 04/34] populate header and use `interfaces.ReadOnlyBeaconBlock` --- api/server/structs/endpoints_lightclient.go | 14 +++-- beacon-chain/rpc/eth/light-client/BUILD.bazel | 2 + beacon-chain/rpc/eth/light-client/handlers.go | 34 +++++++++-- beacon-chain/rpc/eth/light-client/helpers.go | 61 ++++++++++--------- consensus-types/blocks/proofs.go | 17 +++--- 5 files changed, 82 insertions(+), 46 deletions(-) diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index 902b5c24d8c5..e7166ea99be2 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -1,19 +1,21 @@ package structs +import "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" + type LightClientHeader struct { Beacon *BeaconBlockHeader `json:"beacon"` } type LightClientHeaderCapella struct { - Beacon *BeaconBlockHeader `json:"beacon"` - Execution *ExecutionPayloadHeaderCapella `json:"execution"` - ExecutionBranch [][]string `json:"execution_branch"` + Beacon *BeaconBlockHeader `json:"beacon"` + Execution interfaces.ExecutionData `json:"execution"` + ExecutionBranch []string `json:"execution_branch"` } type LightClientHeaderDeneb struct { - Beacon *BeaconBlockHeader `json:"beacon"` - Execution *ExecutionPayloadHeaderDeneb `json:"execution"` - ExecutionBranch [][]string `json:"execution_branch"` + Beacon *BeaconBlockHeader `json:"beacon"` + Execution interfaces.ExecutionData `json:"execution"` + ExecutionBranch []string `json:"execution_branch"` } type LightClientBootstrapResponse struct { diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index a95416814183..5c68c28bd0ef 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -10,6 +10,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/light-client", visibility = ["//beacon-chain:__subpackages__"], deps = [ + "//api:go_default_library", "//api/server/structs:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/core/light-client:go_default_library", @@ -19,6 +20,7 @@ go_library( "//beacon-chain/state:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", "//network/httputil:go_default_library", diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 1f9b3c32ff1f..31e1271fe4b2 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -49,7 +49,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques switch blk.Version() { case version.Phase0: - httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusNotImplemented) + httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusBadRequest) return case version.Altair: bootstrap, err := createLightClientBootstrap(ctx, state) @@ -67,10 +67,22 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques httputil.WriteJson(w, response) return case version.Bellatrix: - httputil.HandleError(w, "light client bootstrap is not supported for bellatrix", http.StatusNotImplemented) + bootstrap, err := createLightClientBootstrap(ctx, state) + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } + + response := &structs.LightClientBootstrapResponse{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + w.Header().Set(api.VersionHeader, version.String(version.Bellatrix)) + + httputil.WriteJson(w, response) return case version.Capella: - bootstrap, err := createLightClientBootstrapCapella(ctx, state) + bootstrap, err := createLightClientBootstrapCapella(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return @@ -85,7 +97,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques httputil.WriteJson(w, response) return case version.Deneb: - bootstrap, err := createLightClientBootstrapDeneb(ctx, state) + bootstrap, err := createLightClientBootstrapDeneb(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return @@ -100,7 +112,19 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques httputil.WriteJson(w, response) return case version.Electra: - httputil.HandleError(w, "light client bootstrap is not supported for electra", http.StatusNotImplemented) + bootstrap, err := createLightClientBootstrapDeneb(ctx, state, blk.Block()) + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } + + response := &structs.LightClientBootstrapResponseDeneb{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + w.Header().Set(api.VersionHeader, version.String(version.Deneb)) + + httputil.WriteJson(w, response) return } } diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index c01b0c79d6b5..b9908ab33ec3 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -13,6 +13,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" + "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" v1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" v2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2" @@ -92,10 +93,10 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* return result, nil } -func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState, block *structs.BlindedBeaconBlockCapella) (*structs.LightClientBootstrapCapella, error) { - // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH +func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrapCapella, error) { + // assert compute_epoch_at_slot(state.slot) >= CAPELLA_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().CapellaForkEpoch { - return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) + return nil, fmt.Errorf("creating Capella light client bootstrap is not supported before Capella, invalid slot %d", state.Slot()) } // assert state.slot == state.latest_block_header.slot @@ -126,25 +127,20 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt if beacon == nil { return nil, fmt.Errorf("could not get beacon block header") } + + executionPayloadHeader, err := block.Body().Execution() + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + } + executionPayloadProof, err := blocks.PayloadProof(ctx, block) + var executionPayloadProofStr []string + for i, proof := range executionPayloadProof { + executionPayloadProofStr[i] = hexutil.Encode(proof) + } header := &structs.LightClientHeaderCapella{ - Beacon: beacon, - Execution: &structs.ExecutionPayloadHeaderCapella{ - ParentHash: block.Body.ExecutionPayloadHeader.ParentHash, - FeeRecipient: block.Body.ExecutionPayloadHeader.FeeRecipient, - StateRoot: block.Body.ExecutionPayloadHeader.StateRoot, - ReceiptsRoot: block.Body.ExecutionPayloadHeader.ReceiptsRoot, - LogsBloom: block.Body.ExecutionPayloadHeader.LogsBloom, - PrevRandao: block.Body.ExecutionPayloadHeader.PrevRandao, - BlockNumber: block.Body.ExecutionPayloadHeader.BlockNumber, - GasLimit: block.Body.ExecutionPayloadHeader.GasLimit, - GasUsed: block.Body.ExecutionPayloadHeader.GasUsed, - Timestamp: block.Body.ExecutionPayloadHeader.Timestamp, - ExtraData: block.Body.ExecutionPayloadHeader.ExtraData, - BaseFeePerGas: block.Body.ExecutionPayloadHeader.BaseFeePerGas, - BlockHash: block.Body.ExecutionPayloadHeader.BlockHash, - TransactionsRoot: block.Body.ExecutionPayloadHeader.TransactionsRoot, - WithdrawalsRoot: block.Body.ExecutionPayloadHeader.WithdrawalsRoot, - }, + Beacon: beacon, + Execution: executionPayloadHeader, + ExecutionBranch: executionPayloadProofStr, } // Above shared util function won't calculate state root, so we need to do it manually @@ -164,10 +160,10 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return result, nil } -func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrapDeneb, error) { - // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH +func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrapDeneb, error) { + // assert compute_epoch_at_slot(state.slot) >= DENEB_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().DenebForkEpoch { - return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) + return nil, fmt.Errorf("creating Deneb light client bootstrap is not supported before Deneb, invalid slot %d", state.Slot()) } // assert state.slot == state.latest_block_header.slot @@ -198,11 +194,20 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat if beacon == nil { return nil, fmt.Errorf("could not get beacon block header") } + + executionPayloadHeader, err := block.Body().Execution() + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + } + executionPayloadProof, err := blocks.PayloadProof(ctx, block) + var executionPayloadProofStr []string + for i, proof := range executionPayloadProof { + executionPayloadProofStr[i] = hexutil.Encode(proof) + } header := &structs.LightClientHeaderDeneb{ - Beacon: beacon, - Execution: &structs.ExecutionPayloadHeaderDeneb{ - ParentHash: hexutil.Encode(), - }, + Beacon: beacon, + Execution: executionPayloadHeader, + ExecutionBranch: executionPayloadProofStr, } // Above shared util function won't calculate state root, so we need to do it manually diff --git a/consensus-types/blocks/proofs.go b/consensus-types/blocks/proofs.go index 34e0f394a055..5b9c756a2b74 100644 --- a/consensus-types/blocks/proofs.go +++ b/consensus-types/blocks/proofs.go @@ -8,6 +8,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/stateutil" "github.com/prysmaticlabs/prysm/v5/config/params" + "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" "github.com/prysmaticlabs/prysm/v5/container/trie" "github.com/prysmaticlabs/prysm/v5/crypto/hash/htr" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" @@ -181,7 +182,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) return fieldRoots, nil } -func ComputeBlockFieldRoots(ctx context.Context, block *BeaconBlock) ([][]byte, error) { +func ComputeBlockFieldRoots(ctx context.Context, block interfaces.ReadOnlyBeaconBlock) ([][]byte, error) { _, span := trace.StartSpan(ctx, "blocks.ComputeBlockFieldRoots") defer span.End() @@ -195,21 +196,23 @@ func ComputeBlockFieldRoots(ctx context.Context, block *BeaconBlock) ([][]byte, } // Slot - slotRoot := ssz.Uint64Root(uint64(block.slot)) + slotRoot := ssz.Uint64Root(uint64(block.Slot())) copy(fieldRoots[0], slotRoot[:]) // Proposer Index - proposerRoot := ssz.Uint64Root(uint64(block.proposerIndex)) + proposerRoot := ssz.Uint64Root(uint64(block.ProposerIndex())) copy(fieldRoots[1], proposerRoot[:]) // Parent Root - copy(fieldRoots[2], block.parentRoot[:]) + parentRoot := block.ParentRoot() + copy(fieldRoots[2], parentRoot[:]) // State Root - copy(fieldRoots[3], block.stateRoot[:]) + stateRoot := block.StateRoot() + copy(fieldRoots[3], stateRoot[:]) // block body Root - blockBodyRoot, err := block.body.HashTreeRoot() + blockBodyRoot, err := block.Body().HashTreeRoot() if err != nil { return nil, err } @@ -218,7 +221,7 @@ func ComputeBlockFieldRoots(ctx context.Context, block *BeaconBlock) ([][]byte, return fieldRoots, nil } -func PayloadProof(ctx context.Context, block *BeaconBlock) ([][]byte, error) { +func PayloadProof(ctx context.Context, block interfaces.ReadOnlyBeaconBlock) ([][]byte, error) { i := block.Body() blockBody, ok := i.(*BeaconBlockBody) if !ok { From 738790073b9a64408b7fe44ea5af1db830306752 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Tue, 27 Aug 2024 01:35:04 +0530 Subject: [PATCH 05/34] fix lint --- beacon-chain/rpc/eth/light-client/helpers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index b9908ab33ec3..d2794ae0fd1c 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -133,6 +133,9 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } executionPayloadProof, err := blocks.PayloadProof(ctx, block) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } var executionPayloadProofStr []string for i, proof := range executionPayloadProof { executionPayloadProofStr[i] = hexutil.Encode(proof) @@ -200,6 +203,9 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } executionPayloadProof, err := blocks.PayloadProof(ctx, block) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } var executionPayloadProofStr []string for i, proof := range executionPayloadProof { executionPayloadProofStr[i] = hexutil.Encode(proof) From b83d8a831b660853aeaadba18ecc0ee6a464e025 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Wed, 28 Aug 2024 01:34:10 +0530 Subject: [PATCH 06/34] merge cases in switch case and replace `interfaces.ExecutionData` with `*ExecutionPayloadHeader` --- api/server/structs/endpoints_lightclient.go | 14 ++--- beacon-chain/rpc/eth/light-client/handlers.go | 34 +--------- beacon-chain/rpc/eth/light-client/helpers.go | 62 ++++++++++++++++++- 3 files changed, 67 insertions(+), 43 deletions(-) diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index e7166ea99be2..e255f62526a7 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -1,21 +1,19 @@ package structs -import "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" - type LightClientHeader struct { Beacon *BeaconBlockHeader `json:"beacon"` } type LightClientHeaderCapella struct { - Beacon *BeaconBlockHeader `json:"beacon"` - Execution interfaces.ExecutionData `json:"execution"` - ExecutionBranch []string `json:"execution_branch"` + Beacon *BeaconBlockHeader `json:"beacon"` + Execution *ExecutionPayloadHeaderCapella `json:"execution"` + ExecutionBranch []string `json:"execution_branch"` } type LightClientHeaderDeneb struct { - Beacon *BeaconBlockHeader `json:"beacon"` - Execution interfaces.ExecutionData `json:"execution"` - ExecutionBranch []string `json:"execution_branch"` + Beacon *BeaconBlockHeader `json:"beacon"` + Execution *ExecutionPayloadHeaderDeneb `json:"execution"` + ExecutionBranch []string `json:"execution_branch"` } type LightClientBootstrapResponse struct { diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 31e1271fe4b2..62a8caf83c1b 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -51,7 +51,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques case version.Phase0: httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusBadRequest) return - case version.Altair: + case version.Altair, version.Bellatrix: bootstrap, err := createLightClientBootstrap(ctx, state) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) @@ -64,21 +64,6 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques } w.Header().Set(api.VersionHeader, version.String(version.Altair)) - httputil.WriteJson(w, response) - return - case version.Bellatrix: - bootstrap, err := createLightClientBootstrap(ctx, state) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) - return - } - - response := &structs.LightClientBootstrapResponse{ - Version: version.String(blk.Version()), - Data: bootstrap, - } - w.Header().Set(api.VersionHeader, version.String(version.Bellatrix)) - httputil.WriteJson(w, response) return case version.Capella: @@ -96,22 +81,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques httputil.WriteJson(w, response) return - case version.Deneb: - bootstrap, err := createLightClientBootstrapDeneb(ctx, state, blk.Block()) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) - return - } - - response := &structs.LightClientBootstrapResponseDeneb{ - Version: version.String(blk.Version()), - Data: bootstrap, - } - w.Header().Set(api.VersionHeader, version.String(version.Deneb)) - - httputil.WriteJson(w, response) - return - case version.Electra: + case version.Deneb, version.Electra: bootstrap, err := createLightClientBootstrapDeneb(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index d2794ae0fd1c..65a48affd13f 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -128,15 +128,43 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return nil, fmt.Errorf("could not get beacon block header") } - executionPayloadHeader, err := block.Body().Execution() + executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } + var executionPayloadHeader *structs.ExecutionPayloadHeaderCapella + if executionPayloadHeaderInterface != nil { + executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) + executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) + executionPayloadHeader.StateRoot = hexutil.Encode(executionPayloadHeaderInterface.StateRoot()) + executionPayloadHeader.ReceiptsRoot = hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()) + executionPayloadHeader.LogsBloom = hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()) + executionPayloadHeader.PrevRandao = hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()) + executionPayloadHeader.BlockNumber = hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()) + executionPayloadHeader.GasLimit = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()) + executionPayloadHeader.GasUsed = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()) + executionPayloadHeader.Timestamp = hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()) + executionPayloadHeader.ExtraData = hexutil.Encode(executionPayloadHeaderInterface.ExtraData()) + executionPayloadHeader.BaseFeePerGas = hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()) + executionPayloadHeader.BlockHash = hexutil.Encode(executionPayloadHeaderInterface.BlockHash()) + + transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + executionPayloadHeader.TransactionsRoot = hexutil.Encode(transactionsRoot) + + withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + executionPayloadHeader.WithdrawalsRoot = hexutil.Encode(withdrawalsRoot) + } executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) } - var executionPayloadProofStr []string + executionPayloadProofStr := make([]string, len(executionPayloadProof)) for i, proof := range executionPayloadProof { executionPayloadProofStr[i] = hexutil.Encode(proof) } @@ -198,10 +226,38 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat return nil, fmt.Errorf("could not get beacon block header") } - executionPayloadHeader, err := block.Body().Execution() + executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } + var executionPayloadHeader *structs.ExecutionPayloadHeaderDeneb + if executionPayloadHeaderInterface != nil { + executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) + executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) + executionPayloadHeader.StateRoot = hexutil.Encode(executionPayloadHeaderInterface.StateRoot()) + executionPayloadHeader.ReceiptsRoot = hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()) + executionPayloadHeader.LogsBloom = hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()) + executionPayloadHeader.PrevRandao = hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()) + executionPayloadHeader.BlockNumber = hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()) + executionPayloadHeader.GasLimit = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()) + executionPayloadHeader.GasUsed = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()) + executionPayloadHeader.Timestamp = hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()) + executionPayloadHeader.ExtraData = hexutil.Encode(executionPayloadHeaderInterface.ExtraData()) + executionPayloadHeader.BaseFeePerGas = hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()) + executionPayloadHeader.BlockHash = hexutil.Encode(executionPayloadHeaderInterface.BlockHash()) + + transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + executionPayloadHeader.TransactionsRoot = hexutil.Encode(transactionsRoot) + + withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + executionPayloadHeader.WithdrawalsRoot = hexutil.Encode(withdrawalsRoot) + } executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) From 7641787bb590024f6e5a678a54a406dc5cad6669 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Thu, 29 Aug 2024 22:36:34 +0530 Subject: [PATCH 07/34] minor fixes --- beacon-chain/rpc/eth/light-client/helpers.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 080748651d7a..6a7b162ddd5b 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -124,15 +124,12 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt } beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) - if beacon == nil { - return nil, fmt.Errorf("could not get beacon block header") - } executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, err } - var executionPayloadHeader *structs.ExecutionPayloadHeaderCapella + executionPayloadHeader := &structs.ExecutionPayloadHeaderCapella{} if executionPayloadHeaderInterface != nil { executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) @@ -222,15 +219,12 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat } beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) - if beacon == nil { - return nil, fmt.Errorf("could not get beacon block header") - } executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, err } - var executionPayloadHeader *structs.ExecutionPayloadHeaderDeneb + executionPayloadHeader := &structs.ExecutionPayloadHeaderDeneb{} if executionPayloadHeaderInterface != nil { executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) From 78fb4058ff8721631478254f60acf1ef213930c3 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Fri, 30 Aug 2024 21:29:13 +0530 Subject: [PATCH 08/34] refactor `createLightClientBootstrapCapella` and `createLightClientBootstrapDeneb` --- beacon-chain/rpc/eth/light-client/helpers.go | 110 +++++++++---------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 6a7b162ddd5b..7a502d4d3912 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -127,36 +127,34 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { - return nil, err + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } - executionPayloadHeader := &structs.ExecutionPayloadHeaderCapella{} - if executionPayloadHeaderInterface != nil { - executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) - executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) - executionPayloadHeader.StateRoot = hexutil.Encode(executionPayloadHeaderInterface.StateRoot()) - executionPayloadHeader.ReceiptsRoot = hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()) - executionPayloadHeader.LogsBloom = hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()) - executionPayloadHeader.PrevRandao = hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()) - executionPayloadHeader.BlockNumber = hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()) - executionPayloadHeader.GasLimit = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()) - executionPayloadHeader.GasUsed = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()) - executionPayloadHeader.Timestamp = hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()) - executionPayloadHeader.ExtraData = hexutil.Encode(executionPayloadHeaderInterface.ExtraData()) - executionPayloadHeader.BaseFeePerGas = hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()) - executionPayloadHeader.BlockHash = hexutil.Encode(executionPayloadHeaderInterface.BlockHash()) - - transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() - if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - executionPayloadHeader.TransactionsRoot = hexutil.Encode(transactionsRoot) - - withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) - } - executionPayloadHeader.WithdrawalsRoot = hexutil.Encode(withdrawalsRoot) + transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + executionPayloadHeader := &structs.ExecutionPayloadHeaderCapella{ + ParentHash: hexutil.Encode(executionPayloadHeaderInterface.ParentHash()), + FeeRecipient: hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()), + StateRoot: hexutil.Encode(executionPayloadHeaderInterface.StateRoot()), + ReceiptsRoot: hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()), + LogsBloom: hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()), + PrevRandao: hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()), + BlockNumber: hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()), + GasLimit: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()), + GasUsed: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()), + Timestamp: hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()), + ExtraData: hexutil.Encode(executionPayloadHeaderInterface.ExtraData()), + BaseFeePerGas: hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()), + BlockHash: hexutil.Encode(executionPayloadHeaderInterface.BlockHash()), + TransactionsRoot: hexutil.Encode(transactionsRoot), + WithdrawalsRoot: hexutil.Encode(withdrawalsRoot), } + executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) @@ -222,41 +220,39 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat executionPayloadHeaderInterface, err := block.Body().Execution() if err != nil { - return nil, err + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } - executionPayloadHeader := &structs.ExecutionPayloadHeaderDeneb{} - if executionPayloadHeaderInterface != nil { - executionPayloadHeader.ParentHash = hexutil.Encode(executionPayloadHeaderInterface.ParentHash()) - executionPayloadHeader.FeeRecipient = hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()) - executionPayloadHeader.StateRoot = hexutil.Encode(executionPayloadHeaderInterface.StateRoot()) - executionPayloadHeader.ReceiptsRoot = hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()) - executionPayloadHeader.LogsBloom = hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()) - executionPayloadHeader.PrevRandao = hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()) - executionPayloadHeader.BlockNumber = hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()) - executionPayloadHeader.GasLimit = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()) - executionPayloadHeader.GasUsed = hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()) - executionPayloadHeader.Timestamp = hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()) - executionPayloadHeader.ExtraData = hexutil.Encode(executionPayloadHeaderInterface.ExtraData()) - executionPayloadHeader.BaseFeePerGas = hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()) - executionPayloadHeader.BlockHash = hexutil.Encode(executionPayloadHeaderInterface.BlockHash()) - - transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() - if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - executionPayloadHeader.TransactionsRoot = hexutil.Encode(transactionsRoot) - - withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) - } - executionPayloadHeader.WithdrawalsRoot = hexutil.Encode(withdrawalsRoot) + transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + executionPayloadHeader := &structs.ExecutionPayloadHeaderDeneb{ + ParentHash: hexutil.Encode(executionPayloadHeaderInterface.ParentHash()), + FeeRecipient: hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()), + StateRoot: hexutil.Encode(executionPayloadHeaderInterface.StateRoot()), + ReceiptsRoot: hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()), + LogsBloom: hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()), + PrevRandao: hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()), + BlockNumber: hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()), + GasLimit: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()), + GasUsed: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()), + Timestamp: hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()), + ExtraData: hexutil.Encode(executionPayloadHeaderInterface.ExtraData()), + BaseFeePerGas: hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()), + BlockHash: hexutil.Encode(executionPayloadHeaderInterface.BlockHash()), + TransactionsRoot: hexutil.Encode(transactionsRoot), + WithdrawalsRoot: hexutil.Encode(withdrawalsRoot), } + executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) } - var executionPayloadProofStr []string + executionPayloadProofStr := make([]string, len(executionPayloadProof)) for i, proof := range executionPayloadProof { executionPayloadProofStr[i] = hexutil.Encode(proof) } From 490d15e412f3cfa1d3c376f2e00a4bf1557d0f5d Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 18:38:35 +0200 Subject: [PATCH 09/34] use lightclientheader instead of different versions --- api/server/structs/endpoints_lightclient.go | 215 ++++++++++++-- beacon-chain/rpc/eth/light-client/handlers.go | 4 +- .../rpc/eth/light-client/handlers_test.go | 264 +++++++++--------- beacon-chain/rpc/eth/light-client/helpers.go | 54 ++-- 4 files changed, 348 insertions(+), 189 deletions(-) diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index 74b05e95b585..3704772aa525 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -1,62 +1,107 @@ package structs +import ( + "encoding/json" + "fmt" +) + +// the interface is used in other structs to reference a light client header object regardless of its version +type lightClientHeader interface { + isLightClientHeader() +} + type LightClientHeader struct { Beacon *BeaconBlockHeader `json:"beacon"` } +func (a *LightClientHeader) isLightClientHeader() {} + type LightClientHeaderCapella struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderCapella `json:"execution"` ExecutionBranch []string `json:"execution_branch"` } +func (a *LightClientHeaderCapella) isLightClientHeader() {} + type LightClientHeaderDeneb struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderDeneb `json:"execution"` ExecutionBranch []string `json:"execution_branch"` } +func (a *LightClientHeaderDeneb) isLightClientHeader() {} + +type LightClientBootstrap struct { + Header lightClientHeader `json:"header"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` +} + type LightClientBootstrapResponse struct { Version string `json:"version"` Data *LightClientBootstrap `json:"data"` } -type LightClientBootstrapResponseCapella struct { - Version string `json:"version"` - Data *LightClientBootstrapCapella `json:"data"` -} +func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { + var aux struct { + Version string + Data struct { + Header json.RawMessage + CurrentSyncCommittee *SyncCommittee + CurrentSyncCommitteeBranch []string + } + } + err := json.Unmarshal(data, &aux) + if err != nil { + return nil, err + } -type LightClientBootstrapResponseDeneb struct { - Version string `json:"version"` - Data *LightClientBootstrapDeneb `json:"data"` -} + result := LightClientBootstrapResponse{ + Version: aux.Version, + Data: &LightClientBootstrap{ + CurrentSyncCommittee: aux.Data.CurrentSyncCommittee, + CurrentSyncCommitteeBranch: aux.Data.CurrentSyncCommitteeBranch, + Header: nil, + }, + } + switch aux.Version { + case "altair", "bellatrix": + var x LightClientHeader + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x + case "capella": + var x LightClientHeaderCapella + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x + case "deneb", "electra": + var x LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x -type LightClientBootstrap struct { - Header *LightClientHeader `json:"header"` - CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` -} + } -type LightClientBootstrapCapella struct { - Header *LightClientHeaderCapella `json:"header"` - CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` -} + return &result, nil -type LightClientBootstrapDeneb struct { - Header *LightClientHeaderDeneb `json:"header"` - CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` } type LightClientUpdate struct { - AttestedHeader *LightClientHeader `json:"attested_header"` - NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` - FinalizedHeader *LightClientHeader `json:"finalized_header,omitempty"` - SyncAggregate *SyncAggregate `json:"sync_aggregate"` - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` - FinalityBranch []string `json:"finality_branch,omitempty"` - SignatureSlot string `json:"signature_slot"` + AttestedHeader lightClientHeader `json:"attested_header"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` + FinalizedHeader lightClientHeader `json:"finalized_header,omitempty"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` + FinalityBranch []string `json:"finality_branch,omitempty"` + SignatureSlot string `json:"signature_slot"` } type LightClientUpdateWithVersion struct { @@ -64,6 +109,118 @@ type LightClientUpdateWithVersion struct { Data *LightClientUpdate `json:"data"` } +func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { + fmt.Println("versioned data") + fmt.Println(string(data)) + + var aux struct { + Version string `json:"version"` + Data struct { + AttestedHeader json.RawMessage `json:"attested_header"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` + FinalizedHeader json.RawMessage `json:"finalized_header,omitempty"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` + FinalityBranch []string `json:"finality_branch,omitempty"` + SignatureSlot string `json:"signature_slot"` + } `json:"data"` + } + err := json.Unmarshal(data, &aux) + if err != nil { + return nil, err + } + + result := LightClientUpdateWithVersion{ + Version: aux.Version, + Data: &LightClientUpdate{ + NextSyncCommittee: aux.Data.NextSyncCommittee, + SyncAggregate: aux.Data.SyncAggregate, + NextSyncCommitteeBranch: aux.Data.NextSyncCommitteeBranch, + FinalityBranch: aux.Data.FinalityBranch, + SignatureSlot: aux.Data.SignatureSlot, + AttestedHeader: nil, + FinalizedHeader: nil, + }, + } + + switch aux.Version { + case "altair", "bellatrix": + var x LightClientHeader + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + result.Data.AttestedHeader = &x + var y LightClientHeader + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + case "capella": + var x LightClientHeaderCapella + fmt.Println("attested header data") + fmt.Println(string(aux.Data.AttestedHeader)) + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + result.Data.AttestedHeader = &x + fmt.Println("attested header is set") + var y LightClientHeaderCapella + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + fmt.Println("finalized header is set") + case "deneb", "electra": + var x LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + //TODO handle the case where the finalized header is nil + result.Data.AttestedHeader = &x + var y LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + } + + return &result, nil +} + type LightClientUpdatesByRangeResponse struct { Updates []*LightClientUpdateWithVersion `json:"updates"` } + +func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { + fmt.Println("data ") + fmt.Println(string(data)) + var Updates []json.RawMessage + + err := json.Unmarshal(data, &Updates) + if err != nil { + return nil, err + } + fmt.Println("updates ") + fmt.Println(string(Updates[0])) + fmt.Println(len(Updates)) + + result := LightClientUpdatesByRangeResponse{ + Updates: make([]*LightClientUpdateWithVersion, len(Updates)), + } + + for i, u := range Updates { + update, err := LightClientUpdateWithVersionFromJson(u) + if err != nil { + return nil, err + } + result.Updates[i] = update + } + + return &result, nil +} diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 62a8caf83c1b..2f419b1f3503 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -73,7 +73,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - response := &structs.LightClientBootstrapResponseCapella{ + response := &structs.LightClientBootstrapResponse{ Version: version.String(blk.Version()), Data: bootstrap, } @@ -88,7 +88,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - response := &structs.LightClientBootstrapResponseDeneb{ + response := &structs.LightClientBootstrapResponse{ Version: version.String(blk.Version()), Data: bootstrap, } diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index d7316f5831b6..07b8776da599 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -3,7 +3,6 @@ package lightclient import ( "bytes" "context" - "encoding/json" "fmt" "net/http" "net/http/httptest" @@ -70,114 +69,115 @@ func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientBootstrapResponse{} - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) - require.Equal(t, "altair", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) - require.NotNil(t, resp.Data) -} - -func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { - helpers.ClearCache() - slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) - - b := util.NewBeaconBlockCapella() - b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) - b.Block.Slot = slot - - signedBlock, err := blocks.NewSignedBeaconBlock(b) - + resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) - header, err := signedBlock.Header() - require.NoError(t, err) - - r, err := b.Block.HashTreeRoot() - require.NoError(t, err) - - bs, err := util.NewBeaconStateCapella(func(state *ethpb.BeaconStateCapella) error { - state.BlockRoots[0] = r[:] - return nil - }) - require.NoError(t, err) - - require.NoError(t, bs.SetSlot(slot)) - require.NoError(t, bs.SetLatestBlockHeader(header.Header)) - - mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} - mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} - s := &Server{ - Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ - slot: bs, - }}, - Blocker: mockBlocker, - HeadFetcher: mockChainService, - } - muxVars := make(map[string]string) - muxVars["block_root"] = hexutil.Encode(r[:]) - request := httptest.NewRequest("GET", "http://foo.com/", nil) - request = mux.SetURLVars(request, muxVars) - writer := httptest.NewRecorder() - writer.Body = &bytes.Buffer{} - - s.GetLightClientBootstrap(writer, request) - require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientBootstrapResponseCapella{} - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) - require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeader).Beacon.BodyRoot) require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { - helpers.ClearCache() - slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) - - b := util.NewBeaconBlockDeneb() - b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) - b.Block.Slot = slot - - signedBlock, err := blocks.NewSignedBeaconBlock(b) - - require.NoError(t, err) - header, err := signedBlock.Header() - require.NoError(t, err) - - r, err := b.Block.HashTreeRoot() - require.NoError(t, err) - - bs, err := util.NewBeaconStateDeneb(func(state *ethpb.BeaconStateDeneb) error { - state.BlockRoots[0] = r[:] - return nil - }) - require.NoError(t, err) - - require.NoError(t, bs.SetSlot(slot)) - require.NoError(t, bs.SetLatestBlockHeader(header.Header)) - - mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} - mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} - s := &Server{ - Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ - slot: bs, - }}, - Blocker: mockBlocker, - HeadFetcher: mockChainService, - } - muxVars := make(map[string]string) - muxVars["block_root"] = hexutil.Encode(r[:]) - request := httptest.NewRequest("GET", "http://foo.com/", nil) - request = mux.SetURLVars(request, muxVars) - writer := httptest.NewRecorder() - writer.Body = &bytes.Buffer{} - - s.GetLightClientBootstrap(writer, request) - require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientBootstrapResponseDeneb{} - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) - require.Equal(t, "deneb", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.Beacon.BodyRoot) - require.NotNil(t, resp.Data) -} +// +//func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { +// helpers.ClearCache() +// slot := primitives.Slot(params.BeaconConfig().CapellaForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) +// +// b := util.NewBeaconBlockCapella() +// b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) +// b.Block.Slot = slot +// +// signedBlock, err := blocks.NewSignedBeaconBlock(b) +// +// require.NoError(t, err) +// header, err := signedBlock.Header() +// require.NoError(t, err) +// +// r, err := b.Block.HashTreeRoot() +// require.NoError(t, err) +// +// bs, err := util.NewBeaconStateCapella(func(state *ethpb.BeaconStateCapella) error { +// state.BlockRoots[0] = r[:] +// return nil +// }) +// require.NoError(t, err) +// +// require.NoError(t, bs.SetSlot(slot)) +// require.NoError(t, bs.SetLatestBlockHeader(header.Header)) +// +// mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} +// mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} +// s := &Server{ +// Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ +// slot: bs, +// }}, +// Blocker: mockBlocker, +// HeadFetcher: mockChainService, +// } +// muxVars := make(map[string]string) +// muxVars["block_root"] = hexutil.Encode(r[:]) +// request := httptest.NewRequest("GET", "http://foo.com/", nil) +// request = mux.SetURLVars(request, muxVars) +// writer := httptest.NewRecorder() +// writer.Body = &bytes.Buffer{} +// +// s.GetLightClientBootstrap(writer, request) +// require.Equal(t, http.StatusOK, writer.Code) +// resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) +// require.NoError(t, err) +// require.Equal(t, "capella", resp.Version) +// require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) +// require.NotNil(t, resp.Data) +//} + +//func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { +// helpers.ClearCache() +// slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) +// +// b := util.NewBeaconBlockDeneb() +// b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) +// b.Block.Slot = slot +// +// signedBlock, err := blocks.NewSignedBeaconBlock(b) +// +// require.NoError(t, err) +// header, err := signedBlock.Header() +// require.NoError(t, err) +// +// r, err := b.Block.HashTreeRoot() +// require.NoError(t, err) +// +// bs, err := util.NewBeaconStateDeneb(func(state *ethpb.BeaconStateDeneb) error { +// state.BlockRoots[0] = r[:] +// return nil +// }) +// require.NoError(t, err) +// +// require.NoError(t, bs.SetSlot(slot)) +// require.NoError(t, bs.SetLatestBlockHeader(header.Header)) +// +// mockBlocker := &testutil.MockBlocker{BlockToReturn: signedBlock} +// mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot} +// s := &Server{ +// Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ +// slot: bs, +// }}, +// Blocker: mockBlocker, +// HeadFetcher: mockChainService, +// } +// muxVars := make(map[string]string) +// muxVars["block_root"] = hexutil.Encode(r[:]) +// request := httptest.NewRequest("GET", "http://foo.com/", nil) +// request = mux.SetURLVars(request, muxVars) +// writer := httptest.NewRecorder() +// writer.Body = &bytes.Buffer{} +// +// s.GetLightClientBootstrap(writer, request) +// require.Equal(t, http.StatusOK, writer.Code) +// resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) +// require.NoError(t, err) +// require.Equal(t, "deneb", resp.Version) +// require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) +// require.NotNil(t, resp.Data) +//} func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { helpers.ClearCache() @@ -272,12 +272,14 @@ func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { s.GetLightClientUpdatesByRange(writer, request) + //fmt.Println(string(writer.Body.Bytes())) + require.Equal(t, http.StatusOK, writer.Code) - var resp []structs.LightClientUpdateWithVersion - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) - require.Equal(t, 1, len(resp)) - require.Equal(t, "capella", resp[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp[0].Data.AttestedHeader.Beacon.BodyRoot) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp) } @@ -376,11 +378,11 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCount(t *tes s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []structs.LightClientUpdateWithVersion - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) - require.Equal(t, 1, len(resp)) // Even with big count input, the response is still the max available period, which is 1 in test case. - require.Equal(t, "capella", resp[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp[0].Data.AttestedHeader.Beacon.BodyRoot) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp) } @@ -479,11 +481,11 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriod(t *testi s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []structs.LightClientUpdateWithVersion - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) - require.Equal(t, 1, len(resp)) - require.Equal(t, "capella", resp[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp[0].Data.AttestedHeader.Beacon.BodyRoot) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp) } @@ -582,11 +584,11 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - var resp []structs.LightClientUpdateWithVersion - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp)) - require.Equal(t, 1, len(resp)) - require.Equal(t, "capella", resp[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp[0].Data.AttestedHeader.Beacon.BodyRoot) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp) } @@ -786,10 +788,10 @@ func TestLightClientHandler_GetLightClientFinalityUpdate(t *testing.T) { s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientUpdateWithVersion{} - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + require.NoError(t, err) require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -892,10 +894,10 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp := &structs.LightClientUpdateWithVersion{} - require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp)) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + require.NoError(t, err) require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) require.NotNil(t, resp.Data) } diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 6a7b162ddd5b..3644e285191e 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -93,7 +93,7 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (* return result, nil } -func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrapCapella, error) { +func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrap, error) { // assert compute_epoch_at_slot(state.slot) >= CAPELLA_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().CapellaForkEpoch { return nil, fmt.Errorf("creating Capella light client bootstrap is not supported before Capella, invalid slot %d", state.Slot()) @@ -179,7 +179,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) // Return result - result := &structs.LightClientBootstrapCapella{ + result := &structs.LightClientBootstrap{ Header: header, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, @@ -188,7 +188,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return result, nil } -func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrapDeneb, error) { +func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconState, block interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrap, error) { // assert compute_epoch_at_slot(state.slot) >= DENEB_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().DenebForkEpoch { return nil, fmt.Errorf("creating Deneb light client bootstrap is not supported before Deneb, invalid slot %d", state.Slot()) @@ -256,7 +256,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat if err != nil { return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) } - var executionPayloadProofStr []string + executionPayloadProofStr := make([]string, len(executionPayloadProof)) for i, proof := range executionPayloadProof { executionPayloadProofStr[i] = hexutil.Encode(proof) } @@ -274,7 +274,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) // Return result - result := &structs.LightClientBootstrapDeneb{ + result := &structs.LightClientBootstrap{ Header: header, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, @@ -426,28 +426,28 @@ func newLightClientOptimisticUpdateFromBeaconState( return newLightClientUpdateToJSON(result), nil } -func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { - bootstrap := &v2.LightClientBootstrap{} - - var err error - - v1Alpha1Header, err := bootstrapJSON.Header.Beacon.ToConsensus() - if err != nil { - return nil, err - } - bootstrap.Header = &v2.LightClientHeader{Beacon: migration.V1Alpha1HeaderToV1(v1Alpha1Header)} - - currentSyncCommittee, err := bootstrapJSON.CurrentSyncCommittee.ToConsensus() - if err != nil { - return nil, err - } - bootstrap.CurrentSyncCommittee = migration.V1Alpha1SyncCommitteeToV2(currentSyncCommittee) - - if bootstrap.CurrentSyncCommitteeBranch, err = branchFromJSON(bootstrapJSON.CurrentSyncCommitteeBranch); err != nil { - return nil, err - } - return bootstrap, nil -} +//func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { +// bootstrap := &v2.LightClientBootstrap{} +// +// var err error +// +// v1Alpha1Header, err := bootstrapJSON.Header.Beacon.ToConsensus() +// if err != nil { +// return nil, err +// } +// bootstrap.Header = &v2.LightClientHeader{Beacon: migration.V1Alpha1HeaderToV1(v1Alpha1Header)} +// +// currentSyncCommittee, err := bootstrapJSON.CurrentSyncCommittee.ToConsensus() +// if err != nil { +// return nil, err +// } +// bootstrap.CurrentSyncCommittee = migration.V1Alpha1SyncCommitteeToV2(currentSyncCommittee) +// +// if bootstrap.CurrentSyncCommitteeBranch, err = branchFromJSON(bootstrapJSON.CurrentSyncCommitteeBranch); err != nil { +// return nil, err +// } +// return bootstrap, nil +//} func branchFromJSON(branch []string) ([][]byte, error) { var branchBytes [][]byte From fbf36ce799a472641d8b04e4f6a686ee900e7abb Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Fri, 30 Aug 2024 22:23:58 +0530 Subject: [PATCH 10/34] fix failing `TestLightClientHandler_GetLightClientBootstrap` tests --- .../rpc/eth/light-client/handlers_test.go | 4 +- beacon-chain/rpc/eth/light-client/helpers.go | 114 ++++++++++++------ 2 files changed, 78 insertions(+), 40 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index d7316f5831b6..5c925d5a3cb8 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -79,7 +79,7 @@ func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) { func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { helpers.ClearCache() - slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + slot := primitives.Slot(params.BeaconConfig().CapellaForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) b := util.NewBeaconBlockCapella() b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) @@ -130,7 +130,7 @@ func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { helpers.ClearCache() - slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + slot := primitives.Slot(params.BeaconConfig().DenebForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) b := util.NewBeaconBlockDeneb() b.Block.StateRoot = bytesutil.PadTo([]byte("foo"), 32) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 7a502d4d3912..923b1668571f 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -7,6 +7,8 @@ import ( "strconv" lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client" + consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" + "github.com/prysmaticlabs/prysm/v5/encoding/ssz" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/prysm/v5/api/server/structs" @@ -125,32 +127,50 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) - executionPayloadHeaderInterface, err := block.Body().Execution() + payloadInterface, err := block.Body().Execution() if err != nil { return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } - transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() - if err != nil { + transactionsRoot, err := payloadInterface.TransactionsRoot() + if err == consensus_types.ErrUnsupportedField { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) } - withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if err == consensus_types.ErrUnsupportedField { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + withdrawalsRoot = withdrawalsRootArray[:] } executionPayloadHeader := &structs.ExecutionPayloadHeaderCapella{ - ParentHash: hexutil.Encode(executionPayloadHeaderInterface.ParentHash()), - FeeRecipient: hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()), - StateRoot: hexutil.Encode(executionPayloadHeaderInterface.StateRoot()), - ReceiptsRoot: hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()), - LogsBloom: hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()), - PrevRandao: hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()), - BlockNumber: hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()), - GasLimit: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()), - GasUsed: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()), - Timestamp: hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()), - ExtraData: hexutil.Encode(executionPayloadHeaderInterface.ExtraData()), - BaseFeePerGas: hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()), - BlockHash: hexutil.Encode(executionPayloadHeaderInterface.BlockHash()), + ParentHash: hexutil.Encode(payloadInterface.ParentHash()), + FeeRecipient: hexutil.Encode(payloadInterface.FeeRecipient()), + StateRoot: hexutil.Encode(payloadInterface.StateRoot()), + ReceiptsRoot: hexutil.Encode(payloadInterface.ReceiptsRoot()), + LogsBloom: hexutil.Encode(payloadInterface.LogsBloom()), + PrevRandao: hexutil.Encode(payloadInterface.PrevRandao()), + BlockNumber: hexutil.EncodeUint64(payloadInterface.BlockNumber()), + GasLimit: hexutil.EncodeUint64(payloadInterface.GasLimit()), + GasUsed: hexutil.EncodeUint64(payloadInterface.GasUsed()), + Timestamp: hexutil.EncodeUint64(payloadInterface.Timestamp()), + ExtraData: hexutil.Encode(payloadInterface.ExtraData()), + BaseFeePerGas: hexutil.Encode(payloadInterface.BaseFeePerGas()), + BlockHash: hexutil.Encode(payloadInterface.BlockHash()), TransactionsRoot: hexutil.Encode(transactionsRoot), WithdrawalsRoot: hexutil.Encode(withdrawalsRoot), } @@ -218,32 +238,50 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat beacon := structs.BeaconBlockHeaderFromConsensus(latestBlockHeader) - executionPayloadHeaderInterface, err := block.Body().Execution() + payloadInterface, err := block.Body().Execution() if err != nil { return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } - transactionsRoot, err := executionPayloadHeaderInterface.TransactionsRoot() - if err != nil { + transactionsRoot, err := payloadInterface.TransactionsRoot() + if err == consensus_types.ErrUnsupportedField { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) } - withdrawalsRoot, err := executionPayloadHeaderInterface.WithdrawalsRoot() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if err == consensus_types.ErrUnsupportedField { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + withdrawalsRoot = withdrawalsRootArray[:] } executionPayloadHeader := &structs.ExecutionPayloadHeaderDeneb{ - ParentHash: hexutil.Encode(executionPayloadHeaderInterface.ParentHash()), - FeeRecipient: hexutil.Encode(executionPayloadHeaderInterface.FeeRecipient()), - StateRoot: hexutil.Encode(executionPayloadHeaderInterface.StateRoot()), - ReceiptsRoot: hexutil.Encode(executionPayloadHeaderInterface.ReceiptsRoot()), - LogsBloom: hexutil.Encode(executionPayloadHeaderInterface.LogsBloom()), - PrevRandao: hexutil.Encode(executionPayloadHeaderInterface.PrevRandao()), - BlockNumber: hexutil.EncodeUint64(executionPayloadHeaderInterface.BlockNumber()), - GasLimit: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasLimit()), - GasUsed: hexutil.EncodeUint64(executionPayloadHeaderInterface.GasUsed()), - Timestamp: hexutil.EncodeUint64(executionPayloadHeaderInterface.Timestamp()), - ExtraData: hexutil.Encode(executionPayloadHeaderInterface.ExtraData()), - BaseFeePerGas: hexutil.Encode(executionPayloadHeaderInterface.BaseFeePerGas()), - BlockHash: hexutil.Encode(executionPayloadHeaderInterface.BlockHash()), + ParentHash: hexutil.Encode(payloadInterface.ParentHash()), + FeeRecipient: hexutil.Encode(payloadInterface.FeeRecipient()), + StateRoot: hexutil.Encode(payloadInterface.StateRoot()), + ReceiptsRoot: hexutil.Encode(payloadInterface.ReceiptsRoot()), + LogsBloom: hexutil.Encode(payloadInterface.LogsBloom()), + PrevRandao: hexutil.Encode(payloadInterface.PrevRandao()), + BlockNumber: hexutil.EncodeUint64(payloadInterface.BlockNumber()), + GasLimit: hexutil.EncodeUint64(payloadInterface.GasLimit()), + GasUsed: hexutil.EncodeUint64(payloadInterface.GasUsed()), + Timestamp: hexutil.EncodeUint64(payloadInterface.Timestamp()), + ExtraData: hexutil.Encode(payloadInterface.ExtraData()), + BaseFeePerGas: hexutil.Encode(payloadInterface.BaseFeePerGas()), + BlockHash: hexutil.Encode(payloadInterface.BlockHash()), TransactionsRoot: hexutil.Encode(transactionsRoot), WithdrawalsRoot: hexutil.Encode(withdrawalsRoot), } From 8e336c018b1e0174efdbe46e8c4f6d66f454f6a2 Mon Sep 17 00:00:00 2001 From: rupam-04 Date: Fri, 30 Aug 2024 22:30:53 +0530 Subject: [PATCH 11/34] fix lint --- beacon-chain/rpc/eth/light-client/helpers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 923b1668571f..5cfca38a58ac 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -2,6 +2,7 @@ package lightclient import ( "context" + "errors" "fmt" "reflect" "strconv" @@ -132,7 +133,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } transactionsRoot, err := payloadInterface.TransactionsRoot() - if err == consensus_types.ErrUnsupportedField { + if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { return nil, fmt.Errorf("could not get transactions: %s", err.Error()) @@ -146,7 +147,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() - if err == consensus_types.ErrUnsupportedField { + if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) @@ -243,7 +244,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } transactionsRoot, err := payloadInterface.TransactionsRoot() - if err == consensus_types.ErrUnsupportedField { + if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { return nil, fmt.Errorf("could not get transactions: %s", err.Error()) @@ -257,7 +258,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() - if err == consensus_types.ErrUnsupportedField { + if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) From a99ea65580c80fa8351a758bec6320231f7a94ca Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 19:06:10 +0200 Subject: [PATCH 12/34] refactor handlers --- beacon-chain/rpc/eth/light-client/handlers.go | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 2f419b1f3503..13d21e774454 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -47,56 +47,40 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } + var bootstrap *structs.LightClientBootstrap switch blk.Version() { case version.Phase0: httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusBadRequest) return case version.Altair, version.Bellatrix: - bootstrap, err := createLightClientBootstrap(ctx, state) + bootstrap, err = createLightClientBootstrap(ctx, state) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return } - response := &structs.LightClientBootstrapResponse{ - Version: version.String(blk.Version()), - Data: bootstrap, - } - w.Header().Set(api.VersionHeader, version.String(version.Altair)) - - httputil.WriteJson(w, response) - return case version.Capella: - bootstrap, err := createLightClientBootstrapCapella(ctx, state, blk.Block()) + bootstrap, err = createLightClientBootstrapCapella(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return } - response := &structs.LightClientBootstrapResponse{ - Version: version.String(blk.Version()), - Data: bootstrap, - } - w.Header().Set(api.VersionHeader, version.String(version.Capella)) - - httputil.WriteJson(w, response) - return case version.Deneb, version.Electra: - bootstrap, err := createLightClientBootstrapDeneb(ctx, state, blk.Block()) + bootstrap, err = createLightClientBootstrapDeneb(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return } - response := &structs.LightClientBootstrapResponse{ - Version: version.String(blk.Version()), - Data: bootstrap, - } - w.Header().Set(api.VersionHeader, version.String(version.Deneb)) - - httputil.WriteJson(w, response) - return } + response := &structs.LightClientBootstrapResponse{ + Version: version.String(blk.Version()), + Data: bootstrap, + } + w.Header().Set(api.VersionHeader, version.String(version.Deneb)) + + httputil.WriteJson(w, response) } // GetLightClientUpdatesByRange - implements https://github.com/ethereum/beacon-APIs/blob/263f4ed6c263c967f13279c7a9f5629b51c5fc55/apis/beacon/light_client/updates.yaml From 9940aed91f8f857ffd6ffa9061705a47eb415e9f Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 19:11:17 +0200 Subject: [PATCH 13/34] refactor handlers more --- beacon-chain/rpc/eth/light-client/handlers.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 13d21e774454..672bf28dfda9 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -54,26 +54,18 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return case version.Altair, version.Bellatrix: bootstrap, err = createLightClientBootstrap(ctx, state) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) - return - } case version.Capella: bootstrap, err = createLightClientBootstrapCapella(ctx, state, blk.Block()) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) - return - } case version.Deneb, version.Electra: bootstrap, err = createLightClientBootstrapDeneb(ctx, state, blk.Block()) - if err != nil { - httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) - return - } } + if err != nil { + httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) + return + } response := &structs.LightClientBootstrapResponse{ Version: version.String(blk.Version()), Data: bootstrap, From e074683dbe0c677949dff1829d4ec2ce4f4a37ca Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 19:29:49 +0200 Subject: [PATCH 14/34] refactor handlers even more --- beacon-chain/rpc/eth/light-client/handlers.go | 16 +--------------- beacon-chain/rpc/eth/light-client/helpers.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 672bf28dfda9..efeb4cbf7e0d 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -47,21 +47,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - var bootstrap *structs.LightClientBootstrap - switch blk.Version() { - case version.Phase0: - httputil.HandleError(w, "light client bootstrap is not supported for phase0", http.StatusBadRequest) - return - case version.Altair, version.Bellatrix: - bootstrap, err = createLightClientBootstrap(ctx, state) - - case version.Capella: - bootstrap, err = createLightClientBootstrapCapella(ctx, state, blk.Block()) - - case version.Deneb, version.Electra: - bootstrap, err = createLightClientBootstrapDeneb(ctx, state, blk.Block()) - - } + bootstrap, err := createLightClientBootstrapVersionAgnostic(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index e7d40508fbc8..88a4bc1d534b 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -10,6 +10,7 @@ import ( lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client" consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" + "github.com/prysmaticlabs/prysm/v5/runtime/version" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/prysm/v5/api/server/structs" @@ -24,6 +25,20 @@ import ( "github.com/prysmaticlabs/prysm/v5/time/slots" ) +func createLightClientBootstrapVersionAgnostic(ctx context.Context, state state.BeaconState, blk interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrap, error) { + switch blk.Version() { + case version.Phase0: + return nil, fmt.Errorf("light client bootstrap is not supported for phase0") + case version.Altair, version.Bellatrix: + return createLightClientBootstrap(ctx, state) + case version.Capella: + return createLightClientBootstrapCapella(ctx, state, blk) + case version.Deneb, version.Electra: + return createLightClientBootstrapDeneb(ctx, state, blk) + } + return nil, fmt.Errorf("unsupported block version") +} + // createLightClientBootstrap - implements https://github.com/ethereum/consensus-specs/blob/3d235740e5f1e641d3b160c8688f26e7dc5a1894/specs/altair/light-client/full-node.md#create_light_client_bootstrap // def create_light_client_bootstrap(state: BeaconState) -> LightClientBootstrap: // From 259d6d57c7e6c64f9b110a1b56bdfedc5c5bccc1 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 19:38:46 +0200 Subject: [PATCH 15/34] create conversions_lightclient --- api/server/structs/BUILD.bazel | 1 + api/server/structs/conversions_lightclient.go | 169 ++++++++++++++++++ api/server/structs/endpoints_lightclient.go | 168 ----------------- 3 files changed, 170 insertions(+), 168 deletions(-) create mode 100644 api/server/structs/conversions_lightclient.go diff --git a/api/server/structs/BUILD.bazel b/api/server/structs/BUILD.bazel index df11af3b0221..cbe01272a175 100644 --- a/api/server/structs/BUILD.bazel +++ b/api/server/structs/BUILD.bazel @@ -6,6 +6,7 @@ go_library( "block.go", "conversions.go", "conversions_block.go", + "conversions_lightclient.go", "conversions_state.go", "endpoints_beacon.go", "endpoints_blob.go", diff --git a/api/server/structs/conversions_lightclient.go b/api/server/structs/conversions_lightclient.go new file mode 100644 index 000000000000..ed95b1f0a25c --- /dev/null +++ b/api/server/structs/conversions_lightclient.go @@ -0,0 +1,169 @@ +package structs + +import ( + "encoding/json" + "fmt" +) + +func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { + var aux struct { + Version string + Data struct { + Header json.RawMessage + CurrentSyncCommittee *SyncCommittee + CurrentSyncCommitteeBranch []string + } + } + err := json.Unmarshal(data, &aux) + if err != nil { + return nil, err + } + + result := LightClientBootstrapResponse{ + Version: aux.Version, + Data: &LightClientBootstrap{ + CurrentSyncCommittee: aux.Data.CurrentSyncCommittee, + CurrentSyncCommitteeBranch: aux.Data.CurrentSyncCommitteeBranch, + Header: nil, + }, + } + switch aux.Version { + case "altair", "bellatrix": + var x LightClientHeader + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x + case "capella": + var x LightClientHeaderCapella + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x + case "deneb", "electra": + var x LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.Header, &x) + if err != nil { + return nil, err + } + result.Data.Header = &x + + } + + return &result, nil + +} + +func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { + fmt.Println("versioned data") + fmt.Println(string(data)) + + var aux struct { + Version string `json:"version"` + Data struct { + AttestedHeader json.RawMessage `json:"attested_header"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` + FinalizedHeader json.RawMessage `json:"finalized_header,omitempty"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` + FinalityBranch []string `json:"finality_branch,omitempty"` + SignatureSlot string `json:"signature_slot"` + } `json:"data"` + } + err := json.Unmarshal(data, &aux) + if err != nil { + return nil, err + } + + result := LightClientUpdateWithVersion{ + Version: aux.Version, + Data: &LightClientUpdate{ + NextSyncCommittee: aux.Data.NextSyncCommittee, + SyncAggregate: aux.Data.SyncAggregate, + NextSyncCommitteeBranch: aux.Data.NextSyncCommitteeBranch, + FinalityBranch: aux.Data.FinalityBranch, + SignatureSlot: aux.Data.SignatureSlot, + AttestedHeader: nil, + FinalizedHeader: nil, + }, + } + + switch aux.Version { + case "altair", "bellatrix": + var x LightClientHeader + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + result.Data.AttestedHeader = &x + var y LightClientHeader + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + case "capella": + var x LightClientHeaderCapella + fmt.Println("attested header data") + fmt.Println(string(aux.Data.AttestedHeader)) + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + result.Data.AttestedHeader = &x + fmt.Println("attested header is set") + var y LightClientHeaderCapella + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + fmt.Println("finalized header is set") + case "deneb", "electra": + var x LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.AttestedHeader, &x) + if err != nil { + return nil, err + } + //TODO handle the case where the finalized header is nil + result.Data.AttestedHeader = &x + var y LightClientHeaderDeneb + err = json.Unmarshal(aux.Data.FinalizedHeader, &y) + if err != nil { + return nil, err + } + result.Data.FinalizedHeader = &y + } + + return &result, nil +} + +func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { + fmt.Println("data ") + fmt.Println(string(data)) + var Updates []json.RawMessage + + err := json.Unmarshal(data, &Updates) + if err != nil { + return nil, err + } + fmt.Println("updates ") + fmt.Println(string(Updates[0])) + fmt.Println(len(Updates)) + + result := LightClientUpdatesByRangeResponse{ + Updates: make([]*LightClientUpdateWithVersion, len(Updates)), + } + + for i, u := range Updates { + update, err := LightClientUpdateWithVersionFromJson(u) + if err != nil { + return nil, err + } + result.Updates[i] = update + } + + return &result, nil +} diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index 3704772aa525..02234f5ac1f1 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -1,10 +1,5 @@ package structs -import ( - "encoding/json" - "fmt" -) - // the interface is used in other structs to reference a light client header object regardless of its version type lightClientHeader interface { isLightClientHeader() @@ -43,57 +38,6 @@ type LightClientBootstrapResponse struct { Data *LightClientBootstrap `json:"data"` } -func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { - var aux struct { - Version string - Data struct { - Header json.RawMessage - CurrentSyncCommittee *SyncCommittee - CurrentSyncCommitteeBranch []string - } - } - err := json.Unmarshal(data, &aux) - if err != nil { - return nil, err - } - - result := LightClientBootstrapResponse{ - Version: aux.Version, - Data: &LightClientBootstrap{ - CurrentSyncCommittee: aux.Data.CurrentSyncCommittee, - CurrentSyncCommitteeBranch: aux.Data.CurrentSyncCommitteeBranch, - Header: nil, - }, - } - switch aux.Version { - case "altair", "bellatrix": - var x LightClientHeader - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - case "capella": - var x LightClientHeaderCapella - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - case "deneb", "electra": - var x LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - - } - - return &result, nil - -} - type LightClientUpdate struct { AttestedHeader lightClientHeader `json:"attested_header"` NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` @@ -109,118 +53,6 @@ type LightClientUpdateWithVersion struct { Data *LightClientUpdate `json:"data"` } -func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { - fmt.Println("versioned data") - fmt.Println(string(data)) - - var aux struct { - Version string `json:"version"` - Data struct { - AttestedHeader json.RawMessage `json:"attested_header"` - NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` - FinalizedHeader json.RawMessage `json:"finalized_header,omitempty"` - SyncAggregate *SyncAggregate `json:"sync_aggregate"` - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` - FinalityBranch []string `json:"finality_branch,omitempty"` - SignatureSlot string `json:"signature_slot"` - } `json:"data"` - } - err := json.Unmarshal(data, &aux) - if err != nil { - return nil, err - } - - result := LightClientUpdateWithVersion{ - Version: aux.Version, - Data: &LightClientUpdate{ - NextSyncCommittee: aux.Data.NextSyncCommittee, - SyncAggregate: aux.Data.SyncAggregate, - NextSyncCommitteeBranch: aux.Data.NextSyncCommitteeBranch, - FinalityBranch: aux.Data.FinalityBranch, - SignatureSlot: aux.Data.SignatureSlot, - AttestedHeader: nil, - FinalizedHeader: nil, - }, - } - - switch aux.Version { - case "altair", "bellatrix": - var x LightClientHeader - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - result.Data.AttestedHeader = &x - var y LightClientHeader - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - case "capella": - var x LightClientHeaderCapella - fmt.Println("attested header data") - fmt.Println(string(aux.Data.AttestedHeader)) - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - result.Data.AttestedHeader = &x - fmt.Println("attested header is set") - var y LightClientHeaderCapella - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - fmt.Println("finalized header is set") - case "deneb", "electra": - var x LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - //TODO handle the case where the finalized header is nil - result.Data.AttestedHeader = &x - var y LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - } - - return &result, nil -} - type LightClientUpdatesByRangeResponse struct { Updates []*LightClientUpdateWithVersion `json:"updates"` } - -func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { - fmt.Println("data ") - fmt.Println(string(data)) - var Updates []json.RawMessage - - err := json.Unmarshal(data, &Updates) - if err != nil { - return nil, err - } - fmt.Println("updates ") - fmt.Println(string(Updates[0])) - fmt.Println(len(Updates)) - - result := LightClientUpdatesByRangeResponse{ - Updates: make([]*LightClientUpdateWithVersion, len(Updates)), - } - - for i, u := range Updates { - update, err := LightClientUpdateWithVersionFromJson(u) - if err != nil { - return nil, err - } - result.Updates[i] = update - } - - return &result, nil -} From 75a2b5ea58e8426c61a9afac45ae95b1240063c6 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 30 Aug 2024 19:44:03 +0200 Subject: [PATCH 16/34] fix lint errors --- beacon-chain/rpc/eth/light-client/helpers.go | 52 +++++++++++--------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 88a4bc1d534b..b89e47f56cf0 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -10,6 +10,7 @@ import ( lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client" consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" + eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/version" "github.com/ethereum/go-ethereum/common/hexutil" @@ -476,28 +477,35 @@ func newLightClientOptimisticUpdateFromBeaconState( return newLightClientUpdateToJSON(result), nil } -//func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { -// bootstrap := &v2.LightClientBootstrap{} -// -// var err error -// -// v1Alpha1Header, err := bootstrapJSON.Header.Beacon.ToConsensus() -// if err != nil { -// return nil, err -// } -// bootstrap.Header = &v2.LightClientHeader{Beacon: migration.V1Alpha1HeaderToV1(v1Alpha1Header)} -// -// currentSyncCommittee, err := bootstrapJSON.CurrentSyncCommittee.ToConsensus() -// if err != nil { -// return nil, err -// } -// bootstrap.CurrentSyncCommittee = migration.V1Alpha1SyncCommitteeToV2(currentSyncCommittee) -// -// if bootstrap.CurrentSyncCommitteeBranch, err = branchFromJSON(bootstrapJSON.CurrentSyncCommitteeBranch); err != nil { -// return nil, err -// } -// return bootstrap, nil -//} +func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { + bootstrap := &v2.LightClientBootstrap{} + + var err error + var v1Alpha1Header *eth.BeaconBlockHeader + switch bootstrapJSON.Header.(type) { + case *structs.LightClientHeader: + v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeader).Beacon.ToConsensus() + case *structs.LightClientHeaderCapella: + v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeaderCapella).Beacon.ToConsensus() + case *structs.LightClientHeaderDeneb: + v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeaderDeneb).Beacon.ToConsensus() + } + if err != nil { + return nil, err + } + bootstrap.Header = &v2.LightClientHeader{Beacon: migration.V1Alpha1HeaderToV1(v1Alpha1Header)} + + currentSyncCommittee, err := bootstrapJSON.CurrentSyncCommittee.ToConsensus() + if err != nil { + return nil, err + } + bootstrap.CurrentSyncCommittee = migration.V1Alpha1SyncCommitteeToV2(currentSyncCommittee) + + if bootstrap.CurrentSyncCommitteeBranch, err = branchFromJSON(bootstrapJSON.CurrentSyncCommitteeBranch); err != nil { + return nil, err + } + return bootstrap, nil +} func branchFromJSON(branch []string) ([][]byte, error) { var branchBytes [][]byte From 579b26c4296f19fd8aaf54e23e25b12358657e72 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Sat, 31 Aug 2024 13:32:45 +0200 Subject: [PATCH 17/34] add deneb and capella proto headers --- beacon-chain/rpc/eth/light-client/BUILD.bazel | 1 + proto/eth/v2/beacon_lightclient.pb.go | 574 ++++++++++++------ proto/eth/v2/beacon_lightclient.proto | 14 + 3 files changed, 396 insertions(+), 193 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index f0b45bad1759..4de9f4bd1869 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -29,6 +29,7 @@ go_library( "//proto/eth/v1:go_default_library", "//proto/eth/v2:go_default_library", "//proto/migration:go_default_library", + "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", diff --git a/proto/eth/v2/beacon_lightclient.pb.go b/proto/eth/v2/beacon_lightclient.pb.go index c5020da60529..e9bba0b490fe 100755 --- a/proto/eth/v2/beacon_lightclient.pb.go +++ b/proto/eth/v2/beacon_lightclient.pb.go @@ -11,6 +11,7 @@ import ( sync "sync" github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" + v11 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" _ "github.com/prysmaticlabs/prysm/v5/proto/eth/ext" v1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -71,6 +72,132 @@ func (x *LightClientHeader) GetBeacon() *v1.BeaconBlockHeader { return nil } +type LightClientHeaderCapella struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Beacon *v1.BeaconBlockHeader `protobuf:"bytes,1,opt,name=beacon,proto3" json:"beacon,omitempty"` + Execution *v11.ExecutionPayloadHeaderCapella `protobuf:"bytes,2,opt,name=execution,proto3" json:"execution,omitempty"` + ExecutionBranch [][]byte `protobuf:"bytes,3,rep,name=execution_branch,json=executionBranch,proto3" json:"execution_branch,omitempty"` +} + +func (x *LightClientHeaderCapella) Reset() { + *x = LightClientHeaderCapella{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LightClientHeaderCapella) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LightClientHeaderCapella) ProtoMessage() {} + +func (x *LightClientHeaderCapella) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LightClientHeaderCapella.ProtoReflect.Descriptor instead. +func (*LightClientHeaderCapella) Descriptor() ([]byte, []int) { + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{1} +} + +func (x *LightClientHeaderCapella) GetBeacon() *v1.BeaconBlockHeader { + if x != nil { + return x.Beacon + } + return nil +} + +func (x *LightClientHeaderCapella) GetExecution() *v11.ExecutionPayloadHeaderCapella { + if x != nil { + return x.Execution + } + return nil +} + +func (x *LightClientHeaderCapella) GetExecutionBranch() [][]byte { + if x != nil { + return x.ExecutionBranch + } + return nil +} + +type LightClientHeaderDeneb struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Beacon *v1.BeaconBlockHeader `protobuf:"bytes,1,opt,name=beacon,proto3" json:"beacon,omitempty"` + Execution *v11.ExecutionPayloadHeaderDeneb `protobuf:"bytes,2,opt,name=execution,proto3" json:"execution,omitempty"` + ExecutionBranch [][]byte `protobuf:"bytes,3,rep,name=execution_branch,json=executionBranch,proto3" json:"execution_branch,omitempty"` +} + +func (x *LightClientHeaderDeneb) Reset() { + *x = LightClientHeaderDeneb{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LightClientHeaderDeneb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LightClientHeaderDeneb) ProtoMessage() {} + +func (x *LightClientHeaderDeneb) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LightClientHeaderDeneb.ProtoReflect.Descriptor instead. +func (*LightClientHeaderDeneb) Descriptor() ([]byte, []int) { + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{2} +} + +func (x *LightClientHeaderDeneb) GetBeacon() *v1.BeaconBlockHeader { + if x != nil { + return x.Beacon + } + return nil +} + +func (x *LightClientHeaderDeneb) GetExecution() *v11.ExecutionPayloadHeaderDeneb { + if x != nil { + return x.Execution + } + return nil +} + +func (x *LightClientHeaderDeneb) GetExecutionBranch() [][]byte { + if x != nil { + return x.ExecutionBranch + } + return nil +} + type LightClientBootstrap struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -84,7 +211,7 @@ type LightClientBootstrap struct { func (x *LightClientBootstrap) Reset() { *x = LightClientBootstrap{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[1] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -97,7 +224,7 @@ func (x *LightClientBootstrap) String() string { func (*LightClientBootstrap) ProtoMessage() {} func (x *LightClientBootstrap) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[1] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -110,7 +237,7 @@ func (x *LightClientBootstrap) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientBootstrap.ProtoReflect.Descriptor instead. func (*LightClientBootstrap) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{1} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{3} } func (x *LightClientBootstrap) GetHeader() *LightClientHeader { @@ -151,7 +278,7 @@ type LightClientUpdate struct { func (x *LightClientUpdate) Reset() { *x = LightClientUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[2] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -164,7 +291,7 @@ func (x *LightClientUpdate) String() string { func (*LightClientUpdate) ProtoMessage() {} func (x *LightClientUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[2] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -177,7 +304,7 @@ func (x *LightClientUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientUpdate.ProtoReflect.Descriptor instead. func (*LightClientUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{2} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{4} } func (x *LightClientUpdate) GetAttestedHeader() *LightClientHeader { @@ -241,7 +368,7 @@ type LightClientFinalityUpdateWithVersion struct { func (x *LightClientFinalityUpdateWithVersion) Reset() { *x = LightClientFinalityUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -254,7 +381,7 @@ func (x *LightClientFinalityUpdateWithVersion) String() string { func (*LightClientFinalityUpdateWithVersion) ProtoMessage() {} func (x *LightClientFinalityUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -267,7 +394,7 @@ func (x *LightClientFinalityUpdateWithVersion) ProtoReflect() protoreflect.Messa // Deprecated: Use LightClientFinalityUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientFinalityUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{3} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{5} } func (x *LightClientFinalityUpdateWithVersion) GetVersion() Version { @@ -299,7 +426,7 @@ type LightClientFinalityUpdate struct { func (x *LightClientFinalityUpdate) Reset() { *x = LightClientFinalityUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -312,7 +439,7 @@ func (x *LightClientFinalityUpdate) String() string { func (*LightClientFinalityUpdate) ProtoMessage() {} func (x *LightClientFinalityUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -325,7 +452,7 @@ func (x *LightClientFinalityUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientFinalityUpdate.ProtoReflect.Descriptor instead. func (*LightClientFinalityUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{4} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{6} } func (x *LightClientFinalityUpdate) GetAttestedHeader() *LightClientHeader { @@ -375,7 +502,7 @@ type LightClientOptimisticUpdateWithVersion struct { func (x *LightClientOptimisticUpdateWithVersion) Reset() { *x = LightClientOptimisticUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -388,7 +515,7 @@ func (x *LightClientOptimisticUpdateWithVersion) String() string { func (*LightClientOptimisticUpdateWithVersion) ProtoMessage() {} func (x *LightClientOptimisticUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -401,7 +528,7 @@ func (x *LightClientOptimisticUpdateWithVersion) ProtoReflect() protoreflect.Mes // Deprecated: Use LightClientOptimisticUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientOptimisticUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{5} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{7} } func (x *LightClientOptimisticUpdateWithVersion) GetVersion() Version { @@ -431,7 +558,7 @@ type LightClientOptimisticUpdate struct { func (x *LightClientOptimisticUpdate) Reset() { *x = LightClientOptimisticUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +571,7 @@ func (x *LightClientOptimisticUpdate) String() string { func (*LightClientOptimisticUpdate) ProtoMessage() {} func (x *LightClientOptimisticUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,7 +584,7 @@ func (x *LightClientOptimisticUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientOptimisticUpdate.ProtoReflect.Descriptor instead. func (*LightClientOptimisticUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{6} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{8} } func (x *LightClientOptimisticUpdate) GetAttestedHeader() *LightClientHeader { @@ -493,7 +620,7 @@ type LightClientUpdateWithVersion struct { func (x *LightClientUpdateWithVersion) Reset() { *x = LightClientUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -506,7 +633,7 @@ func (x *LightClientUpdateWithVersion) String() string { func (*LightClientUpdateWithVersion) ProtoMessage() {} func (x *LightClientUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -519,7 +646,7 @@ func (x *LightClientUpdateWithVersion) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{7} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{9} } func (x *LightClientUpdateWithVersion) GetVersion() Version { @@ -550,142 +677,171 @@ var file_proto_eth_v2_beacon_lightclient_proto_rawDesc = []byte{ 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4f, 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x06, 0x62, 0x65, - 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65, 0x61, - 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, - 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x22, 0xeb, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x67, 0x68, 0x74, - 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, - 0x3a, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, - 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x16, 0x63, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, - 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, - 0x65, 0x12, 0x41, 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, - 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x22, 0x9a, 0x04, 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4f, 0x0a, + 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x22, 0xd2, + 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x12, 0x3a, 0x0a, 0x06, 0x62, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65, + 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, + 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x09, 0x65, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x52, 0x09, 0x65, + 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x22, 0xce, 0x01, 0x0a, 0x16, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x3a, + 0x0a, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x52, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x12, 0x4d, 0x0a, 0x09, 0x65, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x52, 0x09, + 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x22, 0xeb, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x3a, 0x0a, + 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, + 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x16, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, + 0x41, 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, + 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x22, 0x9a, 0x04, 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, + 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, + 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, + 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, + 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, 0x74, 0x53, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, + 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, + 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, + 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, + 0x6c, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, + 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, + 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, + 0x9a, 0x01, 0x0a, 0x24, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, + 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, + 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, + 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x95, 0x03, 0x0a, + 0x19, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, - 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, - 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, - 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, - 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, - 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, - 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, + 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, + 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, + 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, + 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, + 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, + 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, + 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, + 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, - 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, - 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, - 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, - 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, - 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, - 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, - 0x74, 0x22, 0x9a, 0x01, 0x0a, 0x24, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, - 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x95, - 0x03, 0x0a, 0x19, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, - 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, - 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, - 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, - 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, - 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, - 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, - 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, - 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, - 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, - 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, - 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, 0x74, - 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, - 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, - 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, - 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, - 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, - 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, - 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, - 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, - 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, - 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, - 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, - 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, - 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, - 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, - 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, - 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, - 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, + 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x67, 0x68, + 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, + 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, + 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x42, 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, + 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, + 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, + 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -700,45 +856,53 @@ func file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP() []byte { return file_proto_eth_v2_beacon_lightclient_proto_rawDescData } -var file_proto_eth_v2_beacon_lightclient_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_proto_eth_v2_beacon_lightclient_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_proto_eth_v2_beacon_lightclient_proto_goTypes = []interface{}{ (*LightClientHeader)(nil), // 0: ethereum.eth.v2.LightClientHeader - (*LightClientBootstrap)(nil), // 1: ethereum.eth.v2.LightClientBootstrap - (*LightClientUpdate)(nil), // 2: ethereum.eth.v2.LightClientUpdate - (*LightClientFinalityUpdateWithVersion)(nil), // 3: ethereum.eth.v2.LightClientFinalityUpdateWithVersion - (*LightClientFinalityUpdate)(nil), // 4: ethereum.eth.v2.LightClientFinalityUpdate - (*LightClientOptimisticUpdateWithVersion)(nil), // 5: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion - (*LightClientOptimisticUpdate)(nil), // 6: ethereum.eth.v2.LightClientOptimisticUpdate - (*LightClientUpdateWithVersion)(nil), // 7: ethereum.eth.v2.LightClientUpdateWithVersion - (*v1.BeaconBlockHeader)(nil), // 8: ethereum.eth.v1.BeaconBlockHeader - (*SyncCommittee)(nil), // 9: ethereum.eth.v2.SyncCommittee - (*v1.SyncAggregate)(nil), // 10: ethereum.eth.v1.SyncAggregate - (Version)(0), // 11: ethereum.eth.v2.Version + (*LightClientHeaderCapella)(nil), // 1: ethereum.eth.v2.LightClientHeaderCapella + (*LightClientHeaderDeneb)(nil), // 2: ethereum.eth.v2.LightClientHeaderDeneb + (*LightClientBootstrap)(nil), // 3: ethereum.eth.v2.LightClientBootstrap + (*LightClientUpdate)(nil), // 4: ethereum.eth.v2.LightClientUpdate + (*LightClientFinalityUpdateWithVersion)(nil), // 5: ethereum.eth.v2.LightClientFinalityUpdateWithVersion + (*LightClientFinalityUpdate)(nil), // 6: ethereum.eth.v2.LightClientFinalityUpdate + (*LightClientOptimisticUpdateWithVersion)(nil), // 7: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion + (*LightClientOptimisticUpdate)(nil), // 8: ethereum.eth.v2.LightClientOptimisticUpdate + (*LightClientUpdateWithVersion)(nil), // 9: ethereum.eth.v2.LightClientUpdateWithVersion + (*v1.BeaconBlockHeader)(nil), // 10: ethereum.eth.v1.BeaconBlockHeader + (*v11.ExecutionPayloadHeaderCapella)(nil), // 11: ethereum.engine.v1.ExecutionPayloadHeaderCapella + (*v11.ExecutionPayloadHeaderDeneb)(nil), // 12: ethereum.engine.v1.ExecutionPayloadHeaderDeneb + (*SyncCommittee)(nil), // 13: ethereum.eth.v2.SyncCommittee + (*v1.SyncAggregate)(nil), // 14: ethereum.eth.v1.SyncAggregate + (Version)(0), // 15: ethereum.eth.v2.Version } var file_proto_eth_v2_beacon_lightclient_proto_depIdxs = []int32{ - 8, // 0: ethereum.eth.v2.LightClientHeader.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader - 0, // 1: ethereum.eth.v2.LightClientBootstrap.header:type_name -> ethereum.eth.v2.LightClientHeader - 9, // 2: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 3: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 9, // 4: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 5: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 10, // 6: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 11, // 7: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 4, // 8: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate - 0, // 9: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 0, // 10: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 10, // 11: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 11, // 12: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 6, // 13: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate - 0, // 14: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 10, // 15: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 11, // 16: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 2, // 17: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate - 18, // [18:18] is the sub-list for method output_type - 18, // [18:18] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name + 10, // 0: ethereum.eth.v2.LightClientHeader.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 10, // 1: ethereum.eth.v2.LightClientHeaderCapella.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 11, // 2: ethereum.eth.v2.LightClientHeaderCapella.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella + 10, // 3: ethereum.eth.v2.LightClientHeaderDeneb.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 12, // 4: ethereum.eth.v2.LightClientHeaderDeneb.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb + 0, // 5: ethereum.eth.v2.LightClientBootstrap.header:type_name -> ethereum.eth.v2.LightClientHeader + 13, // 6: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 0, // 7: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 13, // 8: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 0, // 9: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 10: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 11: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 6, // 12: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate + 0, // 13: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 0, // 14: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 15: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 16: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 8, // 17: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate + 0, // 18: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 19: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 20: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 4, // 21: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_proto_eth_v2_beacon_lightclient_proto_init() } @@ -762,7 +926,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientBootstrap); i { + switch v := v.(*LightClientHeaderCapella); i { case 0: return &v.state case 1: @@ -774,7 +938,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientUpdate); i { + switch v := v.(*LightClientHeaderDeneb); i { case 0: return &v.state case 1: @@ -786,7 +950,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientFinalityUpdateWithVersion); i { + switch v := v.(*LightClientBootstrap); i { case 0: return &v.state case 1: @@ -798,7 +962,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientFinalityUpdate); i { + switch v := v.(*LightClientUpdate); i { case 0: return &v.state case 1: @@ -810,7 +974,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientOptimisticUpdateWithVersion); i { + switch v := v.(*LightClientFinalityUpdateWithVersion); i { case 0: return &v.state case 1: @@ -822,7 +986,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientOptimisticUpdate); i { + switch v := v.(*LightClientFinalityUpdate); i { case 0: return &v.state case 1: @@ -834,6 +998,30 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LightClientOptimisticUpdateWithVersion); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LightClientOptimisticUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LightClientUpdateWithVersion); i { case 0: return &v.state @@ -852,7 +1040,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_eth_v2_beacon_lightclient_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 10, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/eth/v2/beacon_lightclient.proto b/proto/eth/v2/beacon_lightclient.proto index 6a3933daf99a..be7be5c60b27 100644 --- a/proto/eth/v2/beacon_lightclient.proto +++ b/proto/eth/v2/beacon_lightclient.proto @@ -19,6 +19,7 @@ import "proto/eth/ext/options.proto"; import "proto/eth/v1/beacon_block.proto"; import "proto/eth/v2/version.proto"; import "proto/eth/v2/sync_committee.proto"; +import "proto/engine/v1/execution_engine.proto"; option csharp_namespace = "Ethereum.Eth.V2"; option go_package = "github.com/prysmaticlabs/prysm/v5/proto/eth/v2;eth"; @@ -33,6 +34,19 @@ message LightClientHeader { v1.BeaconBlockHeader beacon = 1; } +message LightClientHeaderCapella { + v1.BeaconBlockHeader beacon = 1; + ethereum.engine.v1.ExecutionPayloadHeaderCapella execution = 2; + repeated bytes execution_branch = 3; +} + +message LightClientHeaderDeneb { + v1.BeaconBlockHeader beacon = 1; + ethereum.engine.v1.ExecutionPayloadHeaderDeneb execution = 2; + repeated bytes execution_branch = 3; +} + + message LightClientBootstrap { LightClientHeader header = 1; SyncCommittee current_sync_committee = 2; From fe5bc4cb4fbd9330f6c3849c7a34a4ea9cf325df Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Sat, 31 Aug 2024 13:38:21 +0200 Subject: [PATCH 18/34] update lightclientbootstrap proto struct to capella&deneb --- beacon-chain/rpc/eth/light-client/helpers.go | 43 --- proto/eth/v2/beacon_lightclient.pb.go | 354 +++++++++++-------- proto/eth/v2/beacon_lightclient.proto | 10 +- 3 files changed, 217 insertions(+), 190 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index b89e47f56cf0..9ef5c6e8687e 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -10,7 +10,6 @@ import ( lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client" consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" - eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/runtime/version" "github.com/ethereum/go-ethereum/common/hexutil" @@ -477,48 +476,6 @@ func newLightClientOptimisticUpdateFromBeaconState( return newLightClientUpdateToJSON(result), nil } -func NewLightClientBootstrapFromJSON(bootstrapJSON *structs.LightClientBootstrap) (*v2.LightClientBootstrap, error) { - bootstrap := &v2.LightClientBootstrap{} - - var err error - var v1Alpha1Header *eth.BeaconBlockHeader - switch bootstrapJSON.Header.(type) { - case *structs.LightClientHeader: - v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeader).Beacon.ToConsensus() - case *structs.LightClientHeaderCapella: - v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeaderCapella).Beacon.ToConsensus() - case *structs.LightClientHeaderDeneb: - v1Alpha1Header, err = bootstrapJSON.Header.(*structs.LightClientHeaderDeneb).Beacon.ToConsensus() - } - if err != nil { - return nil, err - } - bootstrap.Header = &v2.LightClientHeader{Beacon: migration.V1Alpha1HeaderToV1(v1Alpha1Header)} - - currentSyncCommittee, err := bootstrapJSON.CurrentSyncCommittee.ToConsensus() - if err != nil { - return nil, err - } - bootstrap.CurrentSyncCommittee = migration.V1Alpha1SyncCommitteeToV2(currentSyncCommittee) - - if bootstrap.CurrentSyncCommitteeBranch, err = branchFromJSON(bootstrapJSON.CurrentSyncCommitteeBranch); err != nil { - return nil, err - } - return bootstrap, nil -} - -func branchFromJSON(branch []string) ([][]byte, error) { - var branchBytes [][]byte - for _, root := range branch { - branch, err := hexutil.Decode(root) - if err != nil { - return nil, err - } - branchBytes = append(branchBytes, branch) - } - return branchBytes, nil -} - func branchToJSON(branchBytes [][]byte) []string { if branchBytes == nil { return nil diff --git a/proto/eth/v2/beacon_lightclient.pb.go b/proto/eth/v2/beacon_lightclient.pb.go index e9bba0b490fe..8bd344b1d55d 100755 --- a/proto/eth/v2/beacon_lightclient.pb.go +++ b/proto/eth/v2/beacon_lightclient.pb.go @@ -203,9 +203,14 @@ type LightClientBootstrap struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Header *LightClientHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` - CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,2,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` - CurrentSyncCommitteeBranch [][]byte `protobuf:"bytes,3,rep,name=current_sync_committee_branch,json=currentSyncCommitteeBranch,proto3" json:"current_sync_committee_branch,omitempty"` + // Types that are assignable to Header: + // + // *LightClientBootstrap_HeaderAltair + // *LightClientBootstrap_HeaderCapella + // *LightClientBootstrap_HeaderDeneb + Header isLightClientBootstrap_Header `protobuf_oneof:"header"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,4,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + CurrentSyncCommitteeBranch [][]byte `protobuf:"bytes,5,rep,name=current_sync_committee_branch,json=currentSyncCommitteeBranch,proto3" json:"current_sync_committee_branch,omitempty"` } func (x *LightClientBootstrap) Reset() { @@ -240,9 +245,30 @@ func (*LightClientBootstrap) Descriptor() ([]byte, []int) { return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{3} } -func (x *LightClientBootstrap) GetHeader() *LightClientHeader { - if x != nil { - return x.Header +func (m *LightClientBootstrap) GetHeader() isLightClientBootstrap_Header { + if m != nil { + return m.Header + } + return nil +} + +func (x *LightClientBootstrap) GetHeaderAltair() *LightClientHeader { + if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderAltair); ok { + return x.HeaderAltair + } + return nil +} + +func (x *LightClientBootstrap) GetHeaderCapella() *LightClientHeaderCapella { + if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderCapella); ok { + return x.HeaderCapella + } + return nil +} + +func (x *LightClientBootstrap) GetHeaderDeneb() *LightClientHeaderDeneb { + if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderDeneb); ok { + return x.HeaderDeneb } return nil } @@ -261,6 +287,28 @@ func (x *LightClientBootstrap) GetCurrentSyncCommitteeBranch() [][]byte { return nil } +type isLightClientBootstrap_Header interface { + isLightClientBootstrap_Header() +} + +type LightClientBootstrap_HeaderAltair struct { + HeaderAltair *LightClientHeader `protobuf:"bytes,1,opt,name=header_altair,json=headerAltair,proto3,oneof"` +} + +type LightClientBootstrap_HeaderCapella struct { + HeaderCapella *LightClientHeaderCapella `protobuf:"bytes,2,opt,name=header_capella,json=headerCapella,proto3,oneof"` +} + +type LightClientBootstrap_HeaderDeneb struct { + HeaderDeneb *LightClientHeaderDeneb `protobuf:"bytes,3,opt,name=header_deneb,json=headerDeneb,proto3,oneof"` +} + +func (*LightClientBootstrap_HeaderAltair) isLightClientBootstrap_Header() {} + +func (*LightClientBootstrap_HeaderCapella) isLightClientBootstrap_Header() {} + +func (*LightClientBootstrap_HeaderDeneb) isLightClientBootstrap_Header() {} + type LightClientUpdate struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -711,137 +759,148 @@ var file_proto_eth_v2_beacon_lightclient_proto_rawDesc = []byte{ 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x22, 0xeb, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x3a, 0x0a, - 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, + 0x61, 0x6e, 0x63, 0x68, 0x22, 0xa6, 0x03, 0x0a, 0x14, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x49, 0x0a, + 0x0d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x61, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0c, 0x68, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x52, 0x0a, 0x0e, 0x68, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x5f, 0x63, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x48, 0x00, 0x52, 0x0d, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x12, 0x4c, 0x0a, 0x0c, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x6e, 0x65, 0x62, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x48, 0x00, 0x52, 0x0b, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x54, 0x0a, 0x16, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, + 0x12, 0x41, 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, + 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, + 0x6e, 0x63, 0x68, 0x42, 0x08, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0x9a, 0x04, + 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, + 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x4e, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, - 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x16, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, - 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, - 0x41, 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, - 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, - 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x22, 0x9a, 0x04, 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, - 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, - 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, - 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, - 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, - 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, - 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, - 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, 0x74, 0x53, - 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, + 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, + 0x12, 0x3b, 0x0a, 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x4d, 0x0a, + 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, + 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, + 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, + 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, + 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, + 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9a, 0x01, 0x0a, 0x24, 0x4c, + 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x95, 0x03, 0x0a, 0x19, 0x4c, 0x69, 0x67, 0x68, + 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, + 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, + 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, + 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, - 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, - 0x6c, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, + 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, - 0x9a, 0x01, 0x0a, 0x24, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, - 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, - 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, - 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, - 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x95, 0x03, 0x0a, - 0x19, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, - 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, - 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, - 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, - 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, - 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, - 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, - 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, - 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, - 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, - 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, - 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, - 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, - 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, - 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, - 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, - 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, - 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, - 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, - 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, - 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, - 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, - 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, - 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, - 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, - 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, - 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, - 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x42, 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, - 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, - 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, - 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, - 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, - 0x76, 0x32, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, - 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, - 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, + 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, + 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, + 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, + 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x22, 0x9f, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, + 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x45, 0x0a, + 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, + 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, + 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, + 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, + 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, + 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, + 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, + 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, + 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, + 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, + 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, + 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -881,28 +940,30 @@ var file_proto_eth_v2_beacon_lightclient_proto_depIdxs = []int32{ 11, // 2: ethereum.eth.v2.LightClientHeaderCapella.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella 10, // 3: ethereum.eth.v2.LightClientHeaderDeneb.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader 12, // 4: ethereum.eth.v2.LightClientHeaderDeneb.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb - 0, // 5: ethereum.eth.v2.LightClientBootstrap.header:type_name -> ethereum.eth.v2.LightClientHeader - 13, // 6: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 7: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 13, // 8: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 9: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 10: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 11: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 6, // 12: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate - 0, // 13: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 0, // 14: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 15: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 16: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 8, // 17: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate - 0, // 18: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 19: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 20: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 4, // 21: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate - 22, // [22:22] is the sub-list for method output_type - 22, // [22:22] is the sub-list for method input_type - 22, // [22:22] is the sub-list for extension type_name - 22, // [22:22] is the sub-list for extension extendee - 0, // [0:22] is the sub-list for field type_name + 0, // 5: ethereum.eth.v2.LightClientBootstrap.header_altair:type_name -> ethereum.eth.v2.LightClientHeader + 1, // 6: ethereum.eth.v2.LightClientBootstrap.header_capella:type_name -> ethereum.eth.v2.LightClientHeaderCapella + 2, // 7: ethereum.eth.v2.LightClientBootstrap.header_deneb:type_name -> ethereum.eth.v2.LightClientHeaderDeneb + 13, // 8: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 0, // 9: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 13, // 10: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 0, // 11: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 12: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 13: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 6, // 14: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate + 0, // 15: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 0, // 16: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 17: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 18: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 8, // 19: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate + 0, // 20: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader + 14, // 21: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 15, // 22: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 4, // 23: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate + 24, // [24:24] is the sub-list for method output_type + 24, // [24:24] is the sub-list for method input_type + 24, // [24:24] is the sub-list for extension type_name + 24, // [24:24] is the sub-list for extension extendee + 0, // [0:24] is the sub-list for field type_name } func init() { file_proto_eth_v2_beacon_lightclient_proto_init() } @@ -1034,6 +1095,11 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } } + file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3].OneofWrappers = []interface{}{ + (*LightClientBootstrap_HeaderAltair)(nil), + (*LightClientBootstrap_HeaderCapella)(nil), + (*LightClientBootstrap_HeaderDeneb)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proto/eth/v2/beacon_lightclient.proto b/proto/eth/v2/beacon_lightclient.proto index be7be5c60b27..4bcf8f43c1c2 100644 --- a/proto/eth/v2/beacon_lightclient.proto +++ b/proto/eth/v2/beacon_lightclient.proto @@ -48,9 +48,13 @@ message LightClientHeaderDeneb { message LightClientBootstrap { - LightClientHeader header = 1; - SyncCommittee current_sync_committee = 2; - repeated bytes current_sync_committee_branch = 3; + oneof header { + LightClientHeader header_altair = 1; + LightClientHeaderCapella header_capella = 2; + LightClientHeaderDeneb header_deneb = 3; + } + SyncCommittee current_sync_committee = 4; + repeated bytes current_sync_committee_branch = 5; } message LightClientUpdate { From da64486624008b3aa69c15f661c9d85f682d37f0 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Sun, 1 Sep 2024 18:38:57 +0200 Subject: [PATCH 19/34] update usecases --- beacon-chain/core/light-client/BUILD.bazel | 6 + beacon-chain/core/light-client/lightclient.go | 179 +++++- beacon-chain/rpc/eth/events/events.go | 32 +- beacon-chain/rpc/eth/light-client/BUILD.bazel | 1 - beacon-chain/rpc/eth/light-client/helpers.go | 22 +- proto/eth/v2/BUILD.bazel | 1 + proto/eth/v2/beacon_lightclient.pb.go | 596 ++++++++++-------- proto/eth/v2/beacon_lightclient.proto | 22 +- proto/eth/v2/custom.go | 15 + 9 files changed, 558 insertions(+), 316 deletions(-) diff --git a/beacon-chain/core/light-client/BUILD.bazel b/beacon-chain/core/light-client/BUILD.bazel index 1643fdff3184..097aba812818 100644 --- a/beacon-chain/core/light-client/BUILD.bazel +++ b/beacon-chain/core/light-client/BUILD.bazel @@ -7,12 +7,18 @@ go_library( visibility = ["//visibility:public"], deps = [ "//beacon-chain/state:go_default_library", + "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//consensus-types:go_default_library", + "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", "//encoding/bytesutil:go_default_library", + "//encoding/ssz:go_default_library", + "//proto/engine/v1:go_default_library", "//proto/eth/v1:go_default_library", "//proto/eth/v2:go_default_library", "//proto/migration:go_default_library", + "//runtime/version:go_default_library", "//time/slots:go_default_library", ], ) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index d0038af7b3a1..19fe85a3fcb7 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -2,14 +2,21 @@ package light_client import ( "bytes" + "errors" "fmt" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" + fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" + consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" + "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" + "github.com/prysmaticlabs/prysm/v5/encoding/ssz" + enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" ethpbv2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2" "github.com/prysmaticlabs/prysm/v5/proto/migration" + "github.com/prysmaticlabs/prysm/v5/runtime/version" "github.com/prysmaticlabs/prysm/v5/time/slots" "context" @@ -32,13 +39,16 @@ const ( // signature_slot=update.signature_slot, // ) func CreateLightClientFinalityUpdate(update *ethpbv2.LightClientUpdate) *ethpbv2.LightClientFinalityUpdate { - return ðpbv2.LightClientFinalityUpdate{ + + finalityUpdate := ðpbv2.LightClientFinalityUpdate{ AttestedHeader: update.AttestedHeader, FinalizedHeader: update.FinalizedHeader, FinalityBranch: update.FinalityBranch, SyncAggregate: update.SyncAggregate, SignatureSlot: update.SignatureSlot, } + + return finalityUpdate } // CreateLightClientOptimisticUpdate - implements https://github.com/ethereum/consensus-specs/blob/3d235740e5f1e641d3b160c8688f26e7dc5a1894/specs/altair/light-client/full-node.md#create_light_client_optimistic_update @@ -50,11 +60,13 @@ func CreateLightClientFinalityUpdate(update *ethpbv2.LightClientUpdate) *ethpbv2 // signature_slot=update.signature_slot, // ) func CreateLightClientOptimisticUpdate(update *ethpbv2.LightClientUpdate) *ethpbv2.LightClientOptimisticUpdate { - return ðpbv2.LightClientOptimisticUpdate{ + optimisticUpdate := ðpbv2.LightClientOptimisticUpdate{ AttestedHeader: update.AttestedHeader, SyncAggregate: update.SyncAggregate, SignatureSlot: update.SignatureSlot, } + + return optimisticUpdate } func NewLightClientOptimisticUpdateFromBeaconState( @@ -130,30 +142,152 @@ func NewLightClientOptimisticUpdateFromBeaconState( return nil, fmt.Errorf("attested header root %#x not equal to block parent root %#x", attestedHeaderRoot, block.Block().ParentRoot()) } - // Return result - attestedHeaderResult := - ðpbv2.LightClientHeader{ - Beacon: ðpbv1.BeaconBlockHeader{ - Slot: attestedHeader.Slot, - ProposerIndex: attestedHeader.ProposerIndex, - ParentRoot: attestedHeader.ParentRoot, - StateRoot: attestedHeader.StateRoot, - BodyRoot: attestedHeader.BodyRoot, - }, - } - syncAggregateResult := ðpbv1.SyncAggregate{ SyncCommitteeBits: syncAggregate.SyncCommitteeBits, SyncCommitteeSignature: syncAggregate.SyncCommitteeSignature, } result := ðpbv2.LightClientUpdate{ - AttestedHeader: attestedHeaderResult, - SyncAggregate: syncAggregateResult, - SignatureSlot: block.Block().Slot(), + SyncAggregate: syncAggregateResult, + SignatureSlot: block.Block().Slot(), } - return result, nil + // Altair block + if block.Block().Version() == version.Altair || block.Block().Version() == version.Bellatrix { + result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{ + Beacon: ðpbv1.BeaconBlockHeader{ + Slot: attestedHeader.Slot, + ProposerIndex: attestedHeader.ProposerIndex, + ParentRoot: attestedHeader.ParentRoot, + StateRoot: attestedHeader.StateRoot, + BodyRoot: attestedHeader.BodyRoot, + }, + }, + }, + } + return result, nil + } + // post altair block + payloadInterface, err := block.Block().Body().Execution() + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + } + transactionsRoot, err := payloadInterface.TransactionsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + withdrawalsRoot = withdrawalsRootArray[:] + } + // Capella block + if block.Block().Version() == version.Capella { + executionPayloadHeader := &enginev1.ExecutionPayloadHeaderCapella{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + + executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } + + result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderCapella{ + HeaderCapella: ðpbv2.LightClientHeaderCapella{ + Beacon: ðpbv1.BeaconBlockHeader{ + Slot: attestedHeader.Slot, + ProposerIndex: attestedHeader.ProposerIndex, + ParentRoot: attestedHeader.ParentRoot, + StateRoot: attestedHeader.StateRoot, + BodyRoot: attestedHeader.BodyRoot, + }, + Execution: executionPayloadHeader, + ExecutionBranch: executionPayloadProof, + }, + }, + } + + return result, nil + } + // Deneb block + if block.Block().Version() == version.Deneb || block.Block().Version() == version.Electra { + executionPayloadHeader := &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + + executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } + + result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderDeneb{ + HeaderDeneb: ðpbv2.LightClientHeaderDeneb{ + Beacon: ðpbv1.BeaconBlockHeader{ + Slot: attestedHeader.Slot, + ProposerIndex: attestedHeader.ProposerIndex, + ParentRoot: attestedHeader.ParentRoot, + StateRoot: attestedHeader.StateRoot, + BodyRoot: attestedHeader.BodyRoot, + }, + Execution: executionPayloadHeader, + ExecutionBranch: executionPayloadProof, + }, + }, + } + + return result, nil + } + + return nil, fmt.Errorf("unsupported block version %d", block.Block().Version()) } func NewLightClientFinalityUpdateFromBeaconState( @@ -172,6 +306,9 @@ func NewLightClientFinalityUpdateFromBeaconState( return nil, err } + if block.Block().Version() != version.Altair || block.Block().Version() != version.Bellatrix { + return nil, fmt.Errorf("unsupported block version %d", block.Block().Version()) + } // Indicate finality whenever possible var finalizedHeader *ethpbv2.LightClientHeader var finalityBranch [][]byte @@ -226,7 +363,11 @@ func NewLightClientFinalityUpdateFromBeaconState( } } - result.FinalizedHeader = finalizedHeader + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: finalizedHeader, + }, + } result.FinalityBranch = finalityBranch return result, nil } diff --git a/beacon-chain/rpc/eth/events/events.go b/beacon-chain/rpc/eth/events/events.go index b39d99165d40..8f416bdf0977 100644 --- a/beacon-chain/rpc/eth/events/events.go +++ b/beacon-chain/rpc/eth/events/events.go @@ -306,21 +306,24 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f for _, b := range updateData.Data.FinalityBranch { finalityBranch = append(finalityBranch, hexutil.Encode(b)) } + + attestedBeacon := updateData.Data.AttestedHeader.GetBeacon() + finalizedBeacon := updateData.Data.FinalizedHeader.GetBeacon() update := &structs.LightClientFinalityUpdateEvent{ Version: version.String(int(updateData.Version)), Data: &structs.LightClientFinalityUpdate{ AttestedHeader: &structs.BeaconBlockHeader{ - Slot: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Beacon.Slot), - ProposerIndex: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Beacon.ProposerIndex), - ParentRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.ParentRoot), - StateRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.StateRoot), - BodyRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.BodyRoot), + Slot: fmt.Sprintf("%d", attestedBeacon.Slot), + ProposerIndex: fmt.Sprintf("%d", attestedBeacon.ProposerIndex), + ParentRoot: hexutil.Encode(attestedBeacon.ParentRoot), + StateRoot: hexutil.Encode(attestedBeacon.StateRoot), + BodyRoot: hexutil.Encode(attestedBeacon.BodyRoot), }, FinalizedHeader: &structs.BeaconBlockHeader{ - Slot: fmt.Sprintf("%d", updateData.Data.FinalizedHeader.Beacon.Slot), - ProposerIndex: fmt.Sprintf("%d", updateData.Data.FinalizedHeader.Beacon.ProposerIndex), - ParentRoot: hexutil.Encode(updateData.Data.FinalizedHeader.Beacon.ParentRoot), - StateRoot: hexutil.Encode(updateData.Data.FinalizedHeader.Beacon.StateRoot), + Slot: fmt.Sprintf("%d", finalizedBeacon.Slot), + ProposerIndex: fmt.Sprintf("%d", finalizedBeacon.ProposerIndex), + ParentRoot: hexutil.Encode(finalizedBeacon.ParentRoot), + StateRoot: hexutil.Encode(finalizedBeacon.StateRoot), }, FinalityBranch: finalityBranch, SyncAggregate: &structs.SyncAggregate{ @@ -339,15 +342,16 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f if !ok { return write(w, flusher, topicDataMismatch, event.Data, LightClientOptimisticUpdateTopic) } + attestedBeacon := updateData.Data.AttestedHeader.GetBeacon() update := &structs.LightClientOptimisticUpdateEvent{ Version: version.String(int(updateData.Version)), Data: &structs.LightClientOptimisticUpdate{ AttestedHeader: &structs.BeaconBlockHeader{ - Slot: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Beacon.Slot), - ProposerIndex: fmt.Sprintf("%d", updateData.Data.AttestedHeader.Beacon.ProposerIndex), - ParentRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.ParentRoot), - StateRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.StateRoot), - BodyRoot: hexutil.Encode(updateData.Data.AttestedHeader.Beacon.BodyRoot), + Slot: fmt.Sprintf("%d", attestedBeacon.Slot), + ProposerIndex: fmt.Sprintf("%d", attestedBeacon.ProposerIndex), + ParentRoot: hexutil.Encode(attestedBeacon.ParentRoot), + StateRoot: hexutil.Encode(attestedBeacon.StateRoot), + BodyRoot: hexutil.Encode(attestedBeacon.BodyRoot), }, SyncAggregate: &structs.SyncAggregate{ SyncCommitteeBits: hexutil.Encode(updateData.Data.SyncAggregate.SyncCommitteeBits), diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index 4de9f4bd1869..f0b45bad1759 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -29,7 +29,6 @@ go_library( "//proto/eth/v1:go_default_library", "//proto/eth/v2:go_default_library", "//proto/migration:go_default_library", - "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 9ef5c6e8687e..764b32cd67b0 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -410,7 +410,7 @@ func createLightClientUpdate( updateSignaturePeriod := slots.ToEpoch(block.Block().Slot()) // update_attested_period = compute_sync_committee_period(compute_epoch_at_slot(attested_header.slot)) - updateAttestedPeriod := slots.ToEpoch(result.AttestedHeader.Beacon.Slot) + updateAttestedPeriod := slots.ToEpoch(result.AttestedHeader.GetBeacon().Slot) if updateAttestedPeriod == updateSignaturePeriod { tempNextSyncCommittee, err := attestedState.NextSyncCommittee() @@ -509,11 +509,11 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien var finalizedHeader *structs.BeaconBlockHeader if input.FinalizedHeader != nil { - finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.FinalizedHeader.Beacon)) + finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.FinalizedHeader.GetBeacon())) } - return &structs.LightClientUpdate{ - AttestedHeader: &structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.AttestedHeader.Beacon))}, + result := &structs.LightClientUpdate{ + AttestedHeader: &structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.AttestedHeader.GetBeacon()))}, NextSyncCommittee: nextSyncCommittee, NextSyncCommitteeBranch: branchToJSON(input.NextSyncCommitteeBranch), FinalizedHeader: &structs.LightClientHeader{Beacon: finalizedHeader}, @@ -521,6 +521,8 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien SyncAggregate: syncAggregateToJSON(input.SyncAggregate), SignatureSlot: strconv.FormatUint(uint64(input.SignatureSlot), 10), } + + return result } func IsSyncCommitteeUpdate(update *v2.LightClientUpdate) bool { @@ -548,8 +550,8 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) bool { } // Compare presence of relevant sync committee - newHasRelevantSyncCommittee := IsSyncCommitteeUpdate(newUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.Beacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.SignatureSlot))) - oldHasRelevantSyncCommittee := IsSyncCommitteeUpdate(oldUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.Beacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.SignatureSlot))) + newHasRelevantSyncCommittee := IsSyncCommitteeUpdate(newUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.SignatureSlot))) + oldHasRelevantSyncCommittee := IsSyncCommitteeUpdate(oldUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.SignatureSlot))) if newHasRelevantSyncCommittee != oldHasRelevantSyncCommittee { return newHasRelevantSyncCommittee @@ -564,8 +566,8 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) bool { // Compare sync committee finality if newHasFinality { - newHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.FinalizedHeader.Beacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.Beacon.Slot)) - oldHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.FinalizedHeader.Beacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.Beacon.Slot)) + newHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.FinalizedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.GetBeacon().Slot)) + oldHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.FinalizedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.GetBeacon().Slot)) if newHasSyncCommitteeFinality != oldHasSyncCommitteeFinality { return newHasSyncCommitteeFinality @@ -578,8 +580,8 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) bool { } // Tiebreaker 2: Prefer older data (fewer changes to best) - if newUpdate.AttestedHeader.Beacon.Slot != oldUpdate.AttestedHeader.Beacon.Slot { - return newUpdate.AttestedHeader.Beacon.Slot < oldUpdate.AttestedHeader.Beacon.Slot + if newUpdate.AttestedHeader.GetBeacon().Slot != oldUpdate.AttestedHeader.GetBeacon().Slot { + return newUpdate.AttestedHeader.GetBeacon().Slot < oldUpdate.AttestedHeader.GetBeacon().Slot } return newUpdate.SignatureSlot < oldUpdate.SignatureSlot } diff --git a/proto/eth/v2/BUILD.bazel b/proto/eth/v2/BUILD.bazel index f5a6728a6e9f..8f3ce986442f 100644 --- a/proto/eth/v2/BUILD.bazel +++ b/proto/eth/v2/BUILD.bazel @@ -88,6 +88,7 @@ go_library( name = "go_default_library", srcs = [ ":ssz_generated_files", + "custom.go", ], embed = [":go_grpc_gateway_library"], importpath = "github.com/prysmaticlabs/prysm/v5/proto/eth/v2", diff --git a/proto/eth/v2/beacon_lightclient.pb.go b/proto/eth/v2/beacon_lightclient.pb.go index 8bd344b1d55d..e9f2f3704e5c 100755 --- a/proto/eth/v2/beacon_lightclient.pb.go +++ b/proto/eth/v2/beacon_lightclient.pb.go @@ -198,23 +198,21 @@ func (x *LightClientHeaderDeneb) GetExecutionBranch() [][]byte { return nil } -type LightClientBootstrap struct { +type LightClientHeaderContainer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to Header: // - // *LightClientBootstrap_HeaderAltair - // *LightClientBootstrap_HeaderCapella - // *LightClientBootstrap_HeaderDeneb - Header isLightClientBootstrap_Header `protobuf_oneof:"header"` - CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,4,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` - CurrentSyncCommitteeBranch [][]byte `protobuf:"bytes,5,rep,name=current_sync_committee_branch,json=currentSyncCommitteeBranch,proto3" json:"current_sync_committee_branch,omitempty"` + // *LightClientHeaderContainer_HeaderAltair + // *LightClientHeaderContainer_HeaderCapella + // *LightClientHeaderContainer_HeaderDeneb + Header isLightClientHeaderContainer_Header `protobuf_oneof:"header"` } -func (x *LightClientBootstrap) Reset() { - *x = LightClientBootstrap{} +func (x *LightClientHeaderContainer) Reset() { + *x = LightClientHeaderContainer{} if protoimpl.UnsafeEnabled { mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -222,13 +220,13 @@ func (x *LightClientBootstrap) Reset() { } } -func (x *LightClientBootstrap) String() string { +func (x *LightClientHeaderContainer) String() string { return protoimpl.X.MessageStringOf(x) } -func (*LightClientBootstrap) ProtoMessage() {} +func (*LightClientHeaderContainer) ProtoMessage() {} -func (x *LightClientBootstrap) ProtoReflect() protoreflect.Message { +func (x *LightClientHeaderContainer) ProtoReflect() protoreflect.Message { mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -240,84 +238,133 @@ func (x *LightClientBootstrap) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use LightClientBootstrap.ProtoReflect.Descriptor instead. -func (*LightClientBootstrap) Descriptor() ([]byte, []int) { +// Deprecated: Use LightClientHeaderContainer.ProtoReflect.Descriptor instead. +func (*LightClientHeaderContainer) Descriptor() ([]byte, []int) { return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{3} } -func (m *LightClientBootstrap) GetHeader() isLightClientBootstrap_Header { +func (m *LightClientHeaderContainer) GetHeader() isLightClientHeaderContainer_Header { if m != nil { return m.Header } return nil } -func (x *LightClientBootstrap) GetHeaderAltair() *LightClientHeader { - if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderAltair); ok { +func (x *LightClientHeaderContainer) GetHeaderAltair() *LightClientHeader { + if x, ok := x.GetHeader().(*LightClientHeaderContainer_HeaderAltair); ok { return x.HeaderAltair } return nil } -func (x *LightClientBootstrap) GetHeaderCapella() *LightClientHeaderCapella { - if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderCapella); ok { +func (x *LightClientHeaderContainer) GetHeaderCapella() *LightClientHeaderCapella { + if x, ok := x.GetHeader().(*LightClientHeaderContainer_HeaderCapella); ok { return x.HeaderCapella } return nil } -func (x *LightClientBootstrap) GetHeaderDeneb() *LightClientHeaderDeneb { - if x, ok := x.GetHeader().(*LightClientBootstrap_HeaderDeneb); ok { +func (x *LightClientHeaderContainer) GetHeaderDeneb() *LightClientHeaderDeneb { + if x, ok := x.GetHeader().(*LightClientHeaderContainer_HeaderDeneb); ok { return x.HeaderDeneb } return nil } -func (x *LightClientBootstrap) GetCurrentSyncCommittee() *SyncCommittee { - if x != nil { - return x.CurrentSyncCommittee - } - return nil +type isLightClientHeaderContainer_Header interface { + isLightClientHeaderContainer_Header() } -func (x *LightClientBootstrap) GetCurrentSyncCommitteeBranch() [][]byte { - if x != nil { - return x.CurrentSyncCommitteeBranch - } - return nil +type LightClientHeaderContainer_HeaderAltair struct { + HeaderAltair *LightClientHeader `protobuf:"bytes,1,opt,name=header_altair,json=headerAltair,proto3,oneof"` } -type isLightClientBootstrap_Header interface { - isLightClientBootstrap_Header() +type LightClientHeaderContainer_HeaderCapella struct { + HeaderCapella *LightClientHeaderCapella `protobuf:"bytes,2,opt,name=header_capella,json=headerCapella,proto3,oneof"` } -type LightClientBootstrap_HeaderAltair struct { - HeaderAltair *LightClientHeader `protobuf:"bytes,1,opt,name=header_altair,json=headerAltair,proto3,oneof"` +type LightClientHeaderContainer_HeaderDeneb struct { + HeaderDeneb *LightClientHeaderDeneb `protobuf:"bytes,3,opt,name=header_deneb,json=headerDeneb,proto3,oneof"` } -type LightClientBootstrap_HeaderCapella struct { - HeaderCapella *LightClientHeaderCapella `protobuf:"bytes,2,opt,name=header_capella,json=headerCapella,proto3,oneof"` +func (*LightClientHeaderContainer_HeaderAltair) isLightClientHeaderContainer_Header() {} + +func (*LightClientHeaderContainer_HeaderCapella) isLightClientHeaderContainer_Header() {} + +func (*LightClientHeaderContainer_HeaderDeneb) isLightClientHeaderContainer_Header() {} + +type LightClientBootstrap struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Header *LightClientHeaderContainer `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,2,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + CurrentSyncCommitteeBranch [][]byte `protobuf:"bytes,3,rep,name=current_sync_committee_branch,json=currentSyncCommitteeBranch,proto3" json:"current_sync_committee_branch,omitempty"` } -type LightClientBootstrap_HeaderDeneb struct { - HeaderDeneb *LightClientHeaderDeneb `protobuf:"bytes,3,opt,name=header_deneb,json=headerDeneb,proto3,oneof"` +func (x *LightClientBootstrap) Reset() { + *x = LightClientBootstrap{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (*LightClientBootstrap_HeaderAltair) isLightClientBootstrap_Header() {} +func (x *LightClientBootstrap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LightClientBootstrap) ProtoMessage() {} + +func (x *LightClientBootstrap) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} -func (*LightClientBootstrap_HeaderCapella) isLightClientBootstrap_Header() {} +// Deprecated: Use LightClientBootstrap.ProtoReflect.Descriptor instead. +func (*LightClientBootstrap) Descriptor() ([]byte, []int) { + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{4} +} -func (*LightClientBootstrap_HeaderDeneb) isLightClientBootstrap_Header() {} +func (x *LightClientBootstrap) GetHeader() *LightClientHeaderContainer { + if x != nil { + return x.Header + } + return nil +} + +func (x *LightClientBootstrap) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *LightClientBootstrap) GetCurrentSyncCommitteeBranch() [][]byte { + if x != nil { + return x.CurrentSyncCommitteeBranch + } + return nil +} type LightClientUpdate struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AttestedHeader *LightClientHeader `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` + AttestedHeader *LightClientHeaderContainer `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` NextSyncCommittee *SyncCommittee `protobuf:"bytes,2,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` NextSyncCommitteeBranch [][]byte `protobuf:"bytes,3,rep,name=next_sync_committee_branch,json=nextSyncCommitteeBranch,proto3" json:"next_sync_committee_branch,omitempty"` - FinalizedHeader *LightClientHeader `protobuf:"bytes,4,opt,name=finalized_header,json=finalizedHeader,proto3" json:"finalized_header,omitempty"` + FinalizedHeader *LightClientHeaderContainer `protobuf:"bytes,4,opt,name=finalized_header,json=finalizedHeader,proto3" json:"finalized_header,omitempty"` FinalityBranch [][]byte `protobuf:"bytes,5,rep,name=finality_branch,json=finalityBranch,proto3" json:"finality_branch,omitempty"` SyncAggregate *v1.SyncAggregate `protobuf:"bytes,6,opt,name=sync_aggregate,json=syncAggregate,proto3" json:"sync_aggregate,omitempty"` SignatureSlot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,7,opt,name=signature_slot,json=signatureSlot,proto3" json:"signature_slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"` @@ -326,7 +373,7 @@ type LightClientUpdate struct { func (x *LightClientUpdate) Reset() { *x = LightClientUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -339,7 +386,7 @@ func (x *LightClientUpdate) String() string { func (*LightClientUpdate) ProtoMessage() {} func (x *LightClientUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -352,10 +399,10 @@ func (x *LightClientUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientUpdate.ProtoReflect.Descriptor instead. func (*LightClientUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{4} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{5} } -func (x *LightClientUpdate) GetAttestedHeader() *LightClientHeader { +func (x *LightClientUpdate) GetAttestedHeader() *LightClientHeaderContainer { if x != nil { return x.AttestedHeader } @@ -376,7 +423,7 @@ func (x *LightClientUpdate) GetNextSyncCommitteeBranch() [][]byte { return nil } -func (x *LightClientUpdate) GetFinalizedHeader() *LightClientHeader { +func (x *LightClientUpdate) GetFinalizedHeader() *LightClientHeaderContainer { if x != nil { return x.FinalizedHeader } @@ -416,7 +463,7 @@ type LightClientFinalityUpdateWithVersion struct { func (x *LightClientFinalityUpdateWithVersion) Reset() { *x = LightClientFinalityUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -429,7 +476,7 @@ func (x *LightClientFinalityUpdateWithVersion) String() string { func (*LightClientFinalityUpdateWithVersion) ProtoMessage() {} func (x *LightClientFinalityUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -442,7 +489,7 @@ func (x *LightClientFinalityUpdateWithVersion) ProtoReflect() protoreflect.Messa // Deprecated: Use LightClientFinalityUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientFinalityUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{5} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{6} } func (x *LightClientFinalityUpdateWithVersion) GetVersion() Version { @@ -464,8 +511,8 @@ type LightClientFinalityUpdate struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AttestedHeader *LightClientHeader `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` - FinalizedHeader *LightClientHeader `protobuf:"bytes,2,opt,name=finalized_header,json=finalizedHeader,proto3" json:"finalized_header,omitempty"` + AttestedHeader *LightClientHeaderContainer `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` + FinalizedHeader *LightClientHeaderContainer `protobuf:"bytes,2,opt,name=finalized_header,json=finalizedHeader,proto3" json:"finalized_header,omitempty"` FinalityBranch [][]byte `protobuf:"bytes,3,rep,name=finality_branch,json=finalityBranch,proto3" json:"finality_branch,omitempty"` SyncAggregate *v1.SyncAggregate `protobuf:"bytes,4,opt,name=sync_aggregate,json=syncAggregate,proto3" json:"sync_aggregate,omitempty"` SignatureSlot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,5,opt,name=signature_slot,json=signatureSlot,proto3" json:"signature_slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"` @@ -474,7 +521,7 @@ type LightClientFinalityUpdate struct { func (x *LightClientFinalityUpdate) Reset() { *x = LightClientFinalityUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -487,7 +534,7 @@ func (x *LightClientFinalityUpdate) String() string { func (*LightClientFinalityUpdate) ProtoMessage() {} func (x *LightClientFinalityUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -500,17 +547,17 @@ func (x *LightClientFinalityUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientFinalityUpdate.ProtoReflect.Descriptor instead. func (*LightClientFinalityUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{6} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{7} } -func (x *LightClientFinalityUpdate) GetAttestedHeader() *LightClientHeader { +func (x *LightClientFinalityUpdate) GetAttestedHeader() *LightClientHeaderContainer { if x != nil { return x.AttestedHeader } return nil } -func (x *LightClientFinalityUpdate) GetFinalizedHeader() *LightClientHeader { +func (x *LightClientFinalityUpdate) GetFinalizedHeader() *LightClientHeaderContainer { if x != nil { return x.FinalizedHeader } @@ -550,7 +597,7 @@ type LightClientOptimisticUpdateWithVersion struct { func (x *LightClientOptimisticUpdateWithVersion) Reset() { *x = LightClientOptimisticUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -563,7 +610,7 @@ func (x *LightClientOptimisticUpdateWithVersion) String() string { func (*LightClientOptimisticUpdateWithVersion) ProtoMessage() {} func (x *LightClientOptimisticUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -576,7 +623,7 @@ func (x *LightClientOptimisticUpdateWithVersion) ProtoReflect() protoreflect.Mes // Deprecated: Use LightClientOptimisticUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientOptimisticUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{7} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{8} } func (x *LightClientOptimisticUpdateWithVersion) GetVersion() Version { @@ -598,7 +645,7 @@ type LightClientOptimisticUpdate struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AttestedHeader *LightClientHeader `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` + AttestedHeader *LightClientHeaderContainer `protobuf:"bytes,1,opt,name=attested_header,json=attestedHeader,proto3" json:"attested_header,omitempty"` SyncAggregate *v1.SyncAggregate `protobuf:"bytes,2,opt,name=sync_aggregate,json=syncAggregate,proto3" json:"sync_aggregate,omitempty"` SignatureSlot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=signature_slot,json=signatureSlot,proto3" json:"signature_slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"` } @@ -606,7 +653,7 @@ type LightClientOptimisticUpdate struct { func (x *LightClientOptimisticUpdate) Reset() { *x = LightClientOptimisticUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -619,7 +666,7 @@ func (x *LightClientOptimisticUpdate) String() string { func (*LightClientOptimisticUpdate) ProtoMessage() {} func (x *LightClientOptimisticUpdate) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -632,10 +679,10 @@ func (x *LightClientOptimisticUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientOptimisticUpdate.ProtoReflect.Descriptor instead. func (*LightClientOptimisticUpdate) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{8} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{9} } -func (x *LightClientOptimisticUpdate) GetAttestedHeader() *LightClientHeader { +func (x *LightClientOptimisticUpdate) GetAttestedHeader() *LightClientHeaderContainer { if x != nil { return x.AttestedHeader } @@ -668,7 +715,7 @@ type LightClientUpdateWithVersion struct { func (x *LightClientUpdateWithVersion) Reset() { *x = LightClientUpdateWithVersion{} if protoimpl.UnsafeEnabled { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -681,7 +728,7 @@ func (x *LightClientUpdateWithVersion) String() string { func (*LightClientUpdateWithVersion) ProtoMessage() {} func (x *LightClientUpdateWithVersion) ProtoReflect() protoreflect.Message { - mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9] + mi := &file_proto_eth_v2_beacon_lightclient_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -694,7 +741,7 @@ func (x *LightClientUpdateWithVersion) ProtoReflect() protoreflect.Message { // Deprecated: Use LightClientUpdateWithVersion.ProtoReflect.Descriptor instead. func (*LightClientUpdateWithVersion) Descriptor() ([]byte, []int) { - return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{9} + return file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP(), []int{10} } func (x *LightClientUpdateWithVersion) GetVersion() Version { @@ -759,148 +806,157 @@ var file_proto_eth_v2_beacon_lightclient_proto_rawDesc = []byte{ 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x22, 0xa6, 0x03, 0x0a, 0x14, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x49, 0x0a, - 0x0d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x61, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0c, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x52, 0x0a, 0x0e, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x5f, 0x63, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x61, 0x6e, 0x63, 0x68, 0x22, 0x93, 0x02, 0x0a, 0x1a, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, + 0x6e, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x0d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x61, 0x6c, + 0x74, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, + 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, + 0x52, 0x0c, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x41, 0x6c, 0x74, 0x61, 0x69, 0x72, 0x12, 0x52, + 0x0a, 0x0e, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, + 0x61, 0x48, 0x00, 0x52, 0x0d, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, + 0x6c, 0x61, 0x12, 0x4c, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x6e, + 0x65, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, + 0x62, 0x48, 0x00, 0x52, 0x0b, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, + 0x42, 0x08, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0xf4, 0x01, 0x0a, 0x14, 0x4c, + 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, + 0x72, 0x61, 0x70, 0x12, 0x43, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x54, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, + 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x41, + 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, + 0x68, 0x22, 0xac, 0x04, 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x54, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x48, 0x00, 0x52, 0x0d, 0x68, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x12, 0x4c, 0x0a, 0x0c, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x6e, 0x65, 0x62, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, - 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x48, 0x00, 0x52, 0x0b, 0x68, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x54, 0x0a, 0x16, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, - 0x74, 0x74, 0x65, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, + 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0e, 0x61, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x4e, 0x0a, + 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x79, 0x6e, - 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, - 0x12, 0x41, 0x0a, 0x1d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, - 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, - 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, - 0x6e, 0x63, 0x68, 0x42, 0x08, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0x9a, 0x04, - 0x0a, 0x11, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x4e, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, - 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, - 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, - 0x12, 0x3b, 0x0a, 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x4d, 0x0a, - 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, - 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, - 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, - 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, - 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, - 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, - 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, - 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, - 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, - 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9a, 0x01, 0x0a, 0x24, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, - 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x95, 0x03, 0x0a, 0x19, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, - 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, - 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x4d, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, - 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, - 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, - 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, - 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, - 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, - 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, - 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, - 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, - 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, - 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, - 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x65, - 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, - 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, - 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x22, 0x9f, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x12, 0x4b, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, - 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0e, 0x61, - 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x45, 0x0a, - 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, - 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, - 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, - 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, - 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, - 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, - 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, - 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, - 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, - 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, - 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, - 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, 0x74, - 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, - 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, - 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x3b, 0x0a, + 0x1a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x17, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x56, 0x0a, 0x10, 0x66, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, + 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, + 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, + 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, + 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, + 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, + 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, + 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, + 0x22, 0x9a, 0x01, 0x0a, 0x24, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, + 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, + 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, + 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa7, 0x03, + 0x0a, 0x19, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x54, 0x0a, 0x0f, 0x61, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x52, 0x0e, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x56, 0x0a, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, + 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x0e, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x42, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x12, 0x45, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, + 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x53, 0x6c, 0x6f, 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x26, 0x4c, 0x69, 0x67, 0x68, + 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, + 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa8, 0x02, 0x0a, 0x1b, 0x4c, 0x69, 0x67, + 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, + 0x69, 0x63, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x54, 0x0a, 0x0f, 0x61, 0x74, 0x74, 0x65, + 0x73, 0x74, 0x65, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0e, + 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x65, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x45, + 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, 0x72, + 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x0e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x5f, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, + 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, + 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, + 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, + 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, + 0x6c, 0x6f, 0x74, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x42, 0x83, 0x01, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x32, 0x42, 0x12, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, + 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, + 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x32, 0x3b, 0x65, + 0x74, 0x68, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, + 0x68, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, + 0x45, 0x74, 0x68, 0x5c, 0x76, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -915,55 +971,57 @@ func file_proto_eth_v2_beacon_lightclient_proto_rawDescGZIP() []byte { return file_proto_eth_v2_beacon_lightclient_proto_rawDescData } -var file_proto_eth_v2_beacon_lightclient_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_proto_eth_v2_beacon_lightclient_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_proto_eth_v2_beacon_lightclient_proto_goTypes = []interface{}{ (*LightClientHeader)(nil), // 0: ethereum.eth.v2.LightClientHeader (*LightClientHeaderCapella)(nil), // 1: ethereum.eth.v2.LightClientHeaderCapella (*LightClientHeaderDeneb)(nil), // 2: ethereum.eth.v2.LightClientHeaderDeneb - (*LightClientBootstrap)(nil), // 3: ethereum.eth.v2.LightClientBootstrap - (*LightClientUpdate)(nil), // 4: ethereum.eth.v2.LightClientUpdate - (*LightClientFinalityUpdateWithVersion)(nil), // 5: ethereum.eth.v2.LightClientFinalityUpdateWithVersion - (*LightClientFinalityUpdate)(nil), // 6: ethereum.eth.v2.LightClientFinalityUpdate - (*LightClientOptimisticUpdateWithVersion)(nil), // 7: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion - (*LightClientOptimisticUpdate)(nil), // 8: ethereum.eth.v2.LightClientOptimisticUpdate - (*LightClientUpdateWithVersion)(nil), // 9: ethereum.eth.v2.LightClientUpdateWithVersion - (*v1.BeaconBlockHeader)(nil), // 10: ethereum.eth.v1.BeaconBlockHeader - (*v11.ExecutionPayloadHeaderCapella)(nil), // 11: ethereum.engine.v1.ExecutionPayloadHeaderCapella - (*v11.ExecutionPayloadHeaderDeneb)(nil), // 12: ethereum.engine.v1.ExecutionPayloadHeaderDeneb - (*SyncCommittee)(nil), // 13: ethereum.eth.v2.SyncCommittee - (*v1.SyncAggregate)(nil), // 14: ethereum.eth.v1.SyncAggregate - (Version)(0), // 15: ethereum.eth.v2.Version + (*LightClientHeaderContainer)(nil), // 3: ethereum.eth.v2.LightClientHeaderContainer + (*LightClientBootstrap)(nil), // 4: ethereum.eth.v2.LightClientBootstrap + (*LightClientUpdate)(nil), // 5: ethereum.eth.v2.LightClientUpdate + (*LightClientFinalityUpdateWithVersion)(nil), // 6: ethereum.eth.v2.LightClientFinalityUpdateWithVersion + (*LightClientFinalityUpdate)(nil), // 7: ethereum.eth.v2.LightClientFinalityUpdate + (*LightClientOptimisticUpdateWithVersion)(nil), // 8: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion + (*LightClientOptimisticUpdate)(nil), // 9: ethereum.eth.v2.LightClientOptimisticUpdate + (*LightClientUpdateWithVersion)(nil), // 10: ethereum.eth.v2.LightClientUpdateWithVersion + (*v1.BeaconBlockHeader)(nil), // 11: ethereum.eth.v1.BeaconBlockHeader + (*v11.ExecutionPayloadHeaderCapella)(nil), // 12: ethereum.engine.v1.ExecutionPayloadHeaderCapella + (*v11.ExecutionPayloadHeaderDeneb)(nil), // 13: ethereum.engine.v1.ExecutionPayloadHeaderDeneb + (*SyncCommittee)(nil), // 14: ethereum.eth.v2.SyncCommittee + (*v1.SyncAggregate)(nil), // 15: ethereum.eth.v1.SyncAggregate + (Version)(0), // 16: ethereum.eth.v2.Version } var file_proto_eth_v2_beacon_lightclient_proto_depIdxs = []int32{ - 10, // 0: ethereum.eth.v2.LightClientHeader.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader - 10, // 1: ethereum.eth.v2.LightClientHeaderCapella.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader - 11, // 2: ethereum.eth.v2.LightClientHeaderCapella.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella - 10, // 3: ethereum.eth.v2.LightClientHeaderDeneb.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader - 12, // 4: ethereum.eth.v2.LightClientHeaderDeneb.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb - 0, // 5: ethereum.eth.v2.LightClientBootstrap.header_altair:type_name -> ethereum.eth.v2.LightClientHeader - 1, // 6: ethereum.eth.v2.LightClientBootstrap.header_capella:type_name -> ethereum.eth.v2.LightClientHeaderCapella - 2, // 7: ethereum.eth.v2.LightClientBootstrap.header_deneb:type_name -> ethereum.eth.v2.LightClientHeaderDeneb - 13, // 8: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 9: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 13, // 10: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee - 0, // 11: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 12: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 13: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 6, // 14: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate - 0, // 15: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 0, // 16: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 17: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 18: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 8, // 19: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate - 0, // 20: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeader - 14, // 21: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate - 15, // 22: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version - 4, // 23: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate - 24, // [24:24] is the sub-list for method output_type - 24, // [24:24] is the sub-list for method input_type - 24, // [24:24] is the sub-list for extension type_name - 24, // [24:24] is the sub-list for extension extendee - 0, // [0:24] is the sub-list for field type_name + 11, // 0: ethereum.eth.v2.LightClientHeader.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 11, // 1: ethereum.eth.v2.LightClientHeaderCapella.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 12, // 2: ethereum.eth.v2.LightClientHeaderCapella.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella + 11, // 3: ethereum.eth.v2.LightClientHeaderDeneb.beacon:type_name -> ethereum.eth.v1.BeaconBlockHeader + 13, // 4: ethereum.eth.v2.LightClientHeaderDeneb.execution:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb + 0, // 5: ethereum.eth.v2.LightClientHeaderContainer.header_altair:type_name -> ethereum.eth.v2.LightClientHeader + 1, // 6: ethereum.eth.v2.LightClientHeaderContainer.header_capella:type_name -> ethereum.eth.v2.LightClientHeaderCapella + 2, // 7: ethereum.eth.v2.LightClientHeaderContainer.header_deneb:type_name -> ethereum.eth.v2.LightClientHeaderDeneb + 3, // 8: ethereum.eth.v2.LightClientBootstrap.header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 14, // 9: ethereum.eth.v2.LightClientBootstrap.current_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 3, // 10: ethereum.eth.v2.LightClientUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 14, // 11: ethereum.eth.v2.LightClientUpdate.next_sync_committee:type_name -> ethereum.eth.v2.SyncCommittee + 3, // 12: ethereum.eth.v2.LightClientUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 15, // 13: ethereum.eth.v2.LightClientUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 16, // 14: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 7, // 15: ethereum.eth.v2.LightClientFinalityUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientFinalityUpdate + 3, // 16: ethereum.eth.v2.LightClientFinalityUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 3, // 17: ethereum.eth.v2.LightClientFinalityUpdate.finalized_header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 15, // 18: ethereum.eth.v2.LightClientFinalityUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 16, // 19: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 9, // 20: ethereum.eth.v2.LightClientOptimisticUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientOptimisticUpdate + 3, // 21: ethereum.eth.v2.LightClientOptimisticUpdate.attested_header:type_name -> ethereum.eth.v2.LightClientHeaderContainer + 15, // 22: ethereum.eth.v2.LightClientOptimisticUpdate.sync_aggregate:type_name -> ethereum.eth.v1.SyncAggregate + 16, // 23: ethereum.eth.v2.LightClientUpdateWithVersion.version:type_name -> ethereum.eth.v2.Version + 5, // 24: ethereum.eth.v2.LightClientUpdateWithVersion.data:type_name -> ethereum.eth.v2.LightClientUpdate + 25, // [25:25] is the sub-list for method output_type + 25, // [25:25] is the sub-list for method input_type + 25, // [25:25] is the sub-list for extension type_name + 25, // [25:25] is the sub-list for extension extendee + 0, // [0:25] is the sub-list for field type_name } func init() { file_proto_eth_v2_beacon_lightclient_proto_init() } @@ -1011,7 +1069,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientBootstrap); i { + switch v := v.(*LightClientHeaderContainer); i { case 0: return &v.state case 1: @@ -1023,7 +1081,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientUpdate); i { + switch v := v.(*LightClientBootstrap); i { case 0: return &v.state case 1: @@ -1035,7 +1093,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientFinalityUpdateWithVersion); i { + switch v := v.(*LightClientUpdate); i { case 0: return &v.state case 1: @@ -1047,7 +1105,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientFinalityUpdate); i { + switch v := v.(*LightClientFinalityUpdateWithVersion); i { case 0: return &v.state case 1: @@ -1059,7 +1117,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientOptimisticUpdateWithVersion); i { + switch v := v.(*LightClientFinalityUpdate); i { case 0: return &v.state case 1: @@ -1071,7 +1129,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LightClientOptimisticUpdate); i { + switch v := v.(*LightClientOptimisticUpdateWithVersion); i { case 0: return &v.state case 1: @@ -1083,6 +1141,18 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LightClientOptimisticUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_eth_v2_beacon_lightclient_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LightClientUpdateWithVersion); i { case 0: return &v.state @@ -1096,9 +1166,9 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { } } file_proto_eth_v2_beacon_lightclient_proto_msgTypes[3].OneofWrappers = []interface{}{ - (*LightClientBootstrap_HeaderAltair)(nil), - (*LightClientBootstrap_HeaderCapella)(nil), - (*LightClientBootstrap_HeaderDeneb)(nil), + (*LightClientHeaderContainer_HeaderAltair)(nil), + (*LightClientHeaderContainer_HeaderCapella)(nil), + (*LightClientHeaderContainer_HeaderDeneb)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -1106,7 +1176,7 @@ func file_proto_eth_v2_beacon_lightclient_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_eth_v2_beacon_lightclient_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/eth/v2/beacon_lightclient.proto b/proto/eth/v2/beacon_lightclient.proto index 4bcf8f43c1c2..e52fe819dcca 100644 --- a/proto/eth/v2/beacon_lightclient.proto +++ b/proto/eth/v2/beacon_lightclient.proto @@ -46,22 +46,26 @@ message LightClientHeaderDeneb { repeated bytes execution_branch = 3; } - -message LightClientBootstrap { +message LightClientHeaderContainer { oneof header { LightClientHeader header_altair = 1; LightClientHeaderCapella header_capella = 2; LightClientHeaderDeneb header_deneb = 3; } - SyncCommittee current_sync_committee = 4; - repeated bytes current_sync_committee_branch = 5; +} + + +message LightClientBootstrap { + LightClientHeaderContainer header = 1; + SyncCommittee current_sync_committee = 2; + repeated bytes current_sync_committee_branch = 3; } message LightClientUpdate { - LightClientHeader attested_header = 1; + LightClientHeaderContainer attested_header = 1; SyncCommittee next_sync_committee = 2; repeated bytes next_sync_committee_branch = 3; - LightClientHeader finalized_header = 4; + LightClientHeaderContainer finalized_header = 4; repeated bytes finality_branch = 5; v1.SyncAggregate sync_aggregate = 6; uint64 signature_slot = 7 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"]; @@ -73,8 +77,8 @@ message LightClientFinalityUpdateWithVersion { } message LightClientFinalityUpdate { - LightClientHeader attested_header = 1; - LightClientHeader finalized_header = 2; + LightClientHeaderContainer attested_header = 1; + LightClientHeaderContainer finalized_header = 2; repeated bytes finality_branch = 3; v1.SyncAggregate sync_aggregate = 4; uint64 signature_slot = 5 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"]; @@ -86,7 +90,7 @@ message LightClientOptimisticUpdateWithVersion { } message LightClientOptimisticUpdate { - LightClientHeader attested_header = 1; + LightClientHeaderContainer attested_header = 1; v1.SyncAggregate sync_aggregate = 2; uint64 signature_slot = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"]; } diff --git a/proto/eth/v2/custom.go b/proto/eth/v2/custom.go index 9e7d97493fbc..61d40e21a318 100644 --- a/proto/eth/v2/custom.go +++ b/proto/eth/v2/custom.go @@ -3,6 +3,8 @@ package eth import ( "bytes" "math/bits" + + v1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" ) const ( @@ -49,3 +51,16 @@ func (x *LightClientUpdate) IsSyncCommiteeUpdate() bool { func (x *LightClientUpdate) IsFinalityUpdate() bool { return !isEmptyWithLength(x.GetFinalityBranch(), FinalizedRootIndex) } + +func (x *LightClientHeaderContainer) GetBeacon() *v1.BeaconBlockHeader { + switch input := x.Header.(type) { + case *LightClientHeaderContainer_HeaderAltair: + return input.HeaderAltair.Beacon + case *LightClientHeaderContainer_HeaderCapella: + return input.HeaderCapella.Beacon + case *LightClientHeaderContainer_HeaderDeneb: + return input.HeaderDeneb.Beacon + default: + panic("invalid type") + } +} From ac4fc9eca059d6f3ee207ec6967d31dbb94c09d0 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Mon, 2 Sep 2024 15:19:46 +0200 Subject: [PATCH 20/34] update usecases --- api/server/structs/conversions_lightclient.go | 14 - beacon-chain/core/light-client/lightclient.go | 211 +++- .../core/light-client/lightclient_test.go | 104 +- .../rpc/eth/light-client/handlers_test.go | 984 ++++++++++++++++-- .../rpc/eth/light-client/helpers_test.go | 400 ++++--- testing/util/lightclient.go | 157 ++- 6 files changed, 1628 insertions(+), 242 deletions(-) diff --git a/api/server/structs/conversions_lightclient.go b/api/server/structs/conversions_lightclient.go index ed95b1f0a25c..367f3b116106 100644 --- a/api/server/structs/conversions_lightclient.go +++ b/api/server/structs/conversions_lightclient.go @@ -2,7 +2,6 @@ package structs import ( "encoding/json" - "fmt" ) func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { @@ -57,9 +56,6 @@ func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapRes } func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { - fmt.Println("versioned data") - fmt.Println(string(data)) - var aux struct { Version string `json:"version"` Data struct { @@ -106,28 +102,23 @@ func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVe result.Data.FinalizedHeader = &y case "capella": var x LightClientHeaderCapella - fmt.Println("attested header data") - fmt.Println(string(aux.Data.AttestedHeader)) err = json.Unmarshal(aux.Data.AttestedHeader, &x) if err != nil { return nil, err } result.Data.AttestedHeader = &x - fmt.Println("attested header is set") var y LightClientHeaderCapella err = json.Unmarshal(aux.Data.FinalizedHeader, &y) if err != nil { return nil, err } result.Data.FinalizedHeader = &y - fmt.Println("finalized header is set") case "deneb", "electra": var x LightClientHeaderDeneb err = json.Unmarshal(aux.Data.AttestedHeader, &x) if err != nil { return nil, err } - //TODO handle the case where the finalized header is nil result.Data.AttestedHeader = &x var y LightClientHeaderDeneb err = json.Unmarshal(aux.Data.FinalizedHeader, &y) @@ -141,17 +132,12 @@ func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVe } func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { - fmt.Println("data ") - fmt.Println(string(data)) var Updates []json.RawMessage err := json.Unmarshal(data, &Updates) if err != nil { return nil, err } - fmt.Println("updates ") - fmt.Println(string(Updates[0])) - fmt.Println(len(Updates)) result := LightClientUpdatesByRangeResponse{ Updates: make([]*LightClientUpdateWithVersion, len(Updates)), diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 19fe85a3fcb7..2d99803d30bd 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -167,6 +167,7 @@ func NewLightClientOptimisticUpdateFromBeaconState( }, }, } + return result, nil } // post altair block @@ -306,11 +307,8 @@ func NewLightClientFinalityUpdateFromBeaconState( return nil, err } - if block.Block().Version() != version.Altair || block.Block().Version() != version.Bellatrix { - return nil, fmt.Errorf("unsupported block version %d", block.Block().Version()) - } // Indicate finality whenever possible - var finalizedHeader *ethpbv2.LightClientHeader + var finalizedHeaderBeacon *ethpbv1.BeaconBlockHeader var finalityBranch [][]byte if finalizedBlock != nil && !finalizedBlock.IsNil() { @@ -319,9 +317,9 @@ func NewLightClientFinalityUpdateFromBeaconState( if err != nil { return nil, fmt.Errorf("could not get finalized header %w", err) } - finalizedHeader = ðpbv2.LightClientHeader{Beacon: migration.V1Alpha1SignedHeaderToV1(tempFinalizedHeader).GetMessage()} + finalizedHeaderBeacon := migration.V1Alpha1SignedHeaderToV1(tempFinalizedHeader).GetMessage() - finalizedHeaderRoot, err := finalizedHeader.Beacon.HashTreeRoot() + finalizedHeaderRoot, err := finalizedHeaderBeacon.HashTreeRoot() if err != nil { return nil, fmt.Errorf("could not get finalized header root %w", err) } @@ -329,18 +327,20 @@ func NewLightClientFinalityUpdateFromBeaconState( if finalizedHeaderRoot != bytesutil.ToBytes32(attestedState.FinalizedCheckpoint().Root) { return nil, fmt.Errorf("finalized header root %#x not equal to attested finalized checkpoint root %#x", finalizedHeaderRoot, bytesutil.ToBytes32(attestedState.FinalizedCheckpoint().Root)) } + } else { if !bytes.Equal(attestedState.FinalizedCheckpoint().Root, make([]byte, 32)) { return nil, fmt.Errorf("invalid finalized header root %v", attestedState.FinalizedCheckpoint().Root) } - finalizedHeader = ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + finalizedHeaderBeacon = ðpbv1.BeaconBlockHeader{ Slot: 0, ProposerIndex: 0, ParentRoot: make([]byte, 32), StateRoot: make([]byte, 32), BodyRoot: make([]byte, 32), - }} + } + } var bErr error @@ -349,13 +349,13 @@ func NewLightClientFinalityUpdateFromBeaconState( return nil, fmt.Errorf("could not get finalized root proof %w", bErr) } } else { - finalizedHeader = ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + finalizedHeaderBeacon = ðpbv1.BeaconBlockHeader{ Slot: 0, ProposerIndex: 0, ParentRoot: make([]byte, 32), StateRoot: make([]byte, 32), BodyRoot: make([]byte, 32), - }} + } finalityBranch = make([][]byte, FinalityBranchNumOfLeaves) for i := 0; i < FinalityBranchNumOfLeaves; i++ { @@ -363,13 +363,192 @@ func NewLightClientFinalityUpdateFromBeaconState( } } - result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ - Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ - HeaderAltair: finalizedHeader, - }, + if block.Block().Version() == version.Altair || block.Block().Version() == version.Bellatrix { + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: finalizedHeaderBeacon}, + }, + } + result.FinalityBranch = finalityBranch + return result, nil } - result.FinalityBranch = finalityBranch - return result, nil + // post altair block + if finalizedBlock != nil && !finalizedBlock.IsNil() { + payloadInterface, err := finalizedBlock.Block().Body().Execution() + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + } + transactionsRoot, err := payloadInterface.TransactionsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { + return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + withdrawalsRoot = withdrawalsRootArray[:] + } + + switch finalizedBlock.Block().Version() { + case version.Capella: + execution := &enginev1.ExecutionPayloadHeaderCapella{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } + + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderCapella{ + HeaderCapella: ðpbv2.LightClientHeaderCapella{ + Beacon: finalizedHeaderBeacon, + Execution: execution, + ExecutionBranch: executionBranch, + }, + }, + } + result.FinalityBranch = finalityBranch + return result, nil + case version.Deneb, version.Electra: + execution := &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + } + + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderDeneb{ + HeaderDeneb: ðpbv2.LightClientHeaderDeneb{ + Beacon: finalizedHeaderBeacon, + Execution: execution, + ExecutionBranch: executionBranch, + }, + }, + } + result.FinalityBranch = finalityBranch + return result, nil + default: + panic("unsupported block version") + } + + } else { + switch block.Block().Version() { + case version.Capella: + execution := &enginev1.ExecutionPayloadHeaderCapella{ + ParentHash: make([]byte, 32), + FeeRecipient: make([]byte, 20), + StateRoot: make([]byte, 32), + ReceiptsRoot: make([]byte, 32), + LogsBloom: make([]byte, 256), + PrevRandao: make([]byte, 32), + BlockNumber: 0, + GasLimit: 0, + GasUsed: 0, + Timestamp: 0, + ExtraData: make([]byte, 32), + BaseFeePerGas: make([]byte, 32), + BlockHash: make([]byte, 32), + TransactionsRoot: make([]byte, 32), + WithdrawalsRoot: make([]byte, 32), + } + executionBranch := make([][]byte, 0) + + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderCapella{ + HeaderCapella: ðpbv2.LightClientHeaderCapella{ + Beacon: finalizedHeaderBeacon, + Execution: execution, + ExecutionBranch: executionBranch, + }, + }, + } + + result.FinalityBranch = finalityBranch + return result, nil + case version.Deneb, version.Electra: + execution := &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: make([]byte, 32), + FeeRecipient: make([]byte, 20), + StateRoot: make([]byte, 32), + ReceiptsRoot: make([]byte, 32), + LogsBloom: make([]byte, 256), + PrevRandao: make([]byte, 32), + BlockNumber: 0, + GasLimit: 0, + GasUsed: 0, + Timestamp: 0, + ExtraData: make([]byte, 32), + BaseFeePerGas: make([]byte, 32), + BlockHash: make([]byte, 32), + TransactionsRoot: make([]byte, 32), + WithdrawalsRoot: make([]byte, 32), + } + executionBranch := make([][]byte, 0) + + result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderDeneb{ + HeaderDeneb: ðpbv2.LightClientHeaderDeneb{ + Beacon: finalizedHeaderBeacon, + Execution: execution, + ExecutionBranch: executionBranch, + }, + }, + } + + result.FinalityBranch = finalityBranch + return result, nil + default: + panic("unsupported block version") + } + } + } func NewLightClientUpdateFromFinalityUpdate(update *ethpbv2.LightClientFinalityUpdate) *ethpbv2.LightClientUpdate { diff --git a/beacon-chain/core/light-client/lightclient_test.go b/beacon-chain/core/light-client/lightclient_test.go index 568075c2db76..4ff6017c68a7 100644 --- a/beacon-chain/core/light-client/lightclient_test.go +++ b/beacon-chain/core/light-client/lightclient_test.go @@ -11,8 +11,8 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/util" ) -func TestLightClient_NewLightClientOptimisticUpdateFromBeaconState(t *testing.T) { - l := util.NewTestLightClient(t).SetupTest() +func TestLightClient_NewLightClientOptimisticUpdateFromBeaconStateCapella(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestCapella() update, err := lightClient.NewLightClientOptimisticUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState) require.NoError(t, err) @@ -23,12 +23,68 @@ func TestLightClient_NewLightClientOptimisticUpdateFromBeaconState(t *testing.T) l.CheckSyncAggregate(update) l.CheckAttestedHeader(update) - require.Equal(t, (*v2.LightClientHeader)(nil), update.FinalizedHeader, "Finalized header is not nil") + require.Equal(t, (*v2.LightClientHeaderContainer)(nil), update.FinalizedHeader, "Finalized header is not nil") require.DeepSSZEqual(t, ([][]byte)(nil), update.FinalityBranch, "Finality branch is not nil") } -func TestLightClient_NewLightClientFinalityUpdateFromBeaconState(t *testing.T) { - l := util.NewTestLightClient(t).SetupTest() +func TestLightClient_NewLightClientOptimisticUpdateFromBeaconStateAltair(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestAltair() + + update, err := lightClient.NewLightClientOptimisticUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState) + require.NoError(t, err) + require.NotNil(t, update, "update is nil") + + require.Equal(t, l.Block.Block().Slot(), update.SignatureSlot, "Signature slot is not equal") + + l.CheckSyncAggregate(update) + l.CheckAttestedHeader(update) + + require.Equal(t, (*v2.LightClientHeaderContainer)(nil), update.FinalizedHeader, "Finalized header is not nil") + require.DeepSSZEqual(t, ([][]byte)(nil), update.FinalityBranch, "Finality branch is not nil") +} + +func TestLightClient_NewLightClientOptimisticUpdateFromBeaconStateDeneb(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestDeneb() + + update, err := lightClient.NewLightClientOptimisticUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState) + require.NoError(t, err) + require.NotNil(t, update, "update is nil") + + require.Equal(t, l.Block.Block().Slot(), update.SignatureSlot, "Signature slot is not equal") + + l.CheckSyncAggregate(update) + l.CheckAttestedHeader(update) + + require.Equal(t, (*v2.LightClientHeaderContainer)(nil), update.FinalizedHeader, "Finalized header is not nil") + require.DeepSSZEqual(t, ([][]byte)(nil), update.FinalityBranch, "Finality branch is not nil") +} +func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateCapella(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestCapella() + + update, err := lightClient.NewLightClientFinalityUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState, nil) + require.NoError(t, err) + require.NotNil(t, update, "update is nil") + + require.Equal(t, l.Block.Block().Slot(), update.SignatureSlot, "Signature slot is not equal") + + l.CheckSyncAggregate(update) + l.CheckAttestedHeader(update) + + zeroHash := params.BeaconConfig().ZeroHash[:] + require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") + require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") + require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") + for _, leaf := range update.FinalityBranch { + require.DeepSSZEqual(t, zeroHash, leaf, "Leaf is not zero") + } +} + +func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateAltair(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestAltair() update, err := lightClient.NewLightClientFinalityUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState, nil) require.NoError(t, err) @@ -41,13 +97,41 @@ func TestLightClient_NewLightClientFinalityUpdateFromBeaconState(t *testing.T) { zeroHash := params.BeaconConfig().ZeroHash[:] require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") - require.Equal(t, primitives.Slot(0), update.FinalizedHeader.Beacon.Slot, "Finalized header slot is not zero") - require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.Beacon.ProposerIndex, "Finalized header proposer index is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.Beacon.ParentRoot, "Finalized header parent root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.Beacon.StateRoot, "Finalized header state root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.Beacon.BodyRoot, "Finalized header body root is not zero") + require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") for _, leaf := range update.FinalityBranch { require.DeepSSZEqual(t, zeroHash, leaf, "Leaf is not zero") } } + +func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateDeneb(t *testing.T) { + l := util.NewTestLightClient(t).SetupTestDeneb() + + update, err := lightClient.NewLightClientFinalityUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState, nil) + require.NoError(t, err) + require.NotNil(t, update, "update is nil") + + require.Equal(t, l.Block.Block().Slot(), update.SignatureSlot, "Signature slot is not equal") + + l.CheckSyncAggregate(update) + l.CheckAttestedHeader(update) + + zeroHash := params.BeaconConfig().ZeroHash[:] + require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") + require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") + require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetHeaderDeneb().Execution.BlockHash, "Execution BlockHash is not zero") + require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") + for _, leaf := range update.FinalityBranch { + require.DeepSSZEqual(t, zeroHash, leaf, "Leaf is not zero") + } +} + +// TODO - add finality update tests with non-nil finalized block for different versions diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index 202e04b7d3b2..4366e114f97d 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -178,18 +178,738 @@ func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateCapella() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockCapella() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateCapella() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockCapella() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + url := fmt.Sprintf("http://foo.com/?count=1&start_period=%d", startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockAltair() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockAltair() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + url := fmt.Sprintf("http://foo.com/?count=1&start_period=%d", startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +func TestLightClientHandler_GetLightClientUpdatesByRangeDeneb(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.DenebForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockDeneb() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockDeneb() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + url := fmt.Sprintf("http://foo.com/?count=1&start_period=%d", startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "deneb", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateCapella() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockCapella() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateCapella() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockCapella() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + count := 129 // config.MaxRequestLightClientUpdates is 128 + url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockAltair() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockAltair() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + count := 129 // config.MaxRequestLightClientUpdates is 128 + url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountDeneb(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.DenebForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockDeneb() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockDeneb() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) + count := 129 // config.MaxRequestLightClientUpdates is 128 + url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. + require.Equal(t, "deneb", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +// TODO - check for not having any blocks from the min period, and startPeriod being too early +func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriodAltair(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + parent := util.NewBeaconBlockAltair() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateAltair() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockAltair() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + startPeriod := 1 // very early period before Altair fork + count := 1 + url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) + request := httptest.NewRequest("GET", url, nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientUpdatesByRange(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, 1, len(resp.Updates)) + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.NotNil(t, resp) +} + +// TODO - same as above +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCountAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -209,7 +929,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -217,7 +937,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -263,30 +983,29 @@ func TestLightClientHandler_GetLightClientUpdatesByRange(t *testing.T) { Blocker: mockBlocker, HeadFetcher: mockChainService, } - startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) - url := fmt.Sprintf("http://foo.com/?count=1&start_period=%d", startPeriod) + startPeriod := 1 // very early period before Altair fork + count := 10 // This is big count as we only have one period in test case. + url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) request := httptest.NewRequest("GET", url, nil) writer := httptest.NewRecorder() writer.Body = &bytes.Buffer{} s.GetLightClientUpdatesByRange(writer, request) - //fmt.Println(string(writer.Body.Bytes())) - require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) require.NotNil(t, resp) } -func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCount(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Sub(1) attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) @@ -368,7 +1087,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCount(t *tes HeadFetcher: mockChainService, } startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) - count := 129 // config.MaxRequestLightClientUpdates is 128 + count := 1 url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) request := httptest.NewRequest("GET", url, nil) writer := httptest.NewRecorder() @@ -376,26 +1095,25 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCount(t *tes s.GetLightClientUpdatesByRange(writer, request) - require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) - require.NoError(t, err) - require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) - require.NotNil(t, resp) + require.Equal(t, http.StatusNotFound, writer.Code) } -func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriod(t *testing.T) { +func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) + require.NoError(t, attestedState.SetFinalizedCheckpoint(ðpb.Checkpoint{ + Epoch: config.AltairForkEpoch - 10, + Root: make([]byte, 32), + })) + parent := util.NewBeaconBlockCapella() parent.Block.Slot = slot.Sub(1) @@ -461,7 +1179,9 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriod(t *testi slot: signedBlock, }, } - mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st, FinalizedRoots: map[[32]byte]bool{ + root: true, + }} s := &Server{ Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ slot.Sub(1): attestedState, @@ -470,36 +1190,37 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriod(t *testi Blocker: mockBlocker, HeadFetcher: mockChainService, } - startPeriod := 1 // very early period before Altair fork - count := 1 - url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) - request := httptest.NewRequest("GET", url, nil) + request := httptest.NewRequest("GET", "http://foo.com", nil) writer := httptest.NewRecorder() writer.Body = &bytes.Buffer{} - s.GetLightClientUpdatesByRange(writer, request) + s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, 1, len(resp.Updates)) - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) - require.NotNil(t, resp) + require.Equal(t, "capella", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing.T) { +func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockCapella() + require.NoError(t, attestedState.SetFinalizedCheckpoint(ðpb.Checkpoint{ + Epoch: config.AltairForkEpoch - 10, + Root: make([]byte, 32), + })) + + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -519,7 +1240,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -527,7 +1248,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -564,7 +1285,9 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. slot: signedBlock, }, } - mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st, FinalizedRoots: map[[32]byte]bool{ + root: true, + }} s := &Server{ Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ slot.Sub(1): attestedState, @@ -573,36 +1296,37 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCount(t *testing. Blocker: mockBlocker, HeadFetcher: mockChainService, } - startPeriod := 1 // very early period before Altair fork - count := 10 // This is big count as we only have one period in test case. - url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) - request := httptest.NewRequest("GET", url, nil) + request := httptest.NewRequest("GET", "http://foo.com", nil) writer := httptest.NewRecorder() writer.Body = &bytes.Buffer{} - s.GetLightClientUpdatesByRange(writer, request) + s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, 1, len(resp.Updates)) - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) - require.NotNil(t, resp) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing.T) { +func TestLightClientHandler_GetLightClientFinalityUpdateDeneb(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Sub(1) + slot := primitives.Slot(config.DenebForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateDeneb() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockCapella() + require.NoError(t, attestedState.SetFinalizedCheckpoint(ðpb.Checkpoint{ + Epoch: config.AltairForkEpoch - 10, + Root: make([]byte, 32), + })) + + parent := util.NewBeaconBlockDeneb() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -622,7 +1346,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateDeneb() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -630,7 +1354,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockDeneb() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -667,7 +1391,9 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing slot: signedBlock, }, } - mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st} + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st, FinalizedRoots: map[[32]byte]bool{ + root: true, + }} s := &Server{ Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ slot.Sub(1): attestedState, @@ -676,23 +1402,25 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing Blocker: mockBlocker, HeadFetcher: mockChainService, } - startPeriod := slot.Div(uint64(config.EpochsPerSyncCommitteePeriod)).Div(uint64(config.SlotsPerEpoch)) - count := 1 - url := fmt.Sprintf("http://foo.com/?count=%d&start_period=%d", count, startPeriod) - request := httptest.NewRequest("GET", url, nil) + request := httptest.NewRequest("GET", "http://foo.com", nil) writer := httptest.NewRecorder() writer.Body = &bytes.Buffer{} - s.GetLightClientUpdatesByRange(writer, request) + s.GetLightClientFinalityUpdate(writer, request) - require.Equal(t, http.StatusNotFound, writer.Code) + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, "deneb", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientFinalityUpdate(t *testing.T) { +func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) @@ -784,7 +1512,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdate(t *testing.T) { writer := httptest.NewRecorder() writer.Body = &bytes.Buffer{} - s.GetLightClientFinalityUpdate(writer, request) + s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) @@ -794,13 +1522,13 @@ func TestLightClientHandler_GetLightClientFinalityUpdate(t *testing.T) { require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { +func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) @@ -810,7 +1538,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { Root: make([]byte, 32), })) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -830,7 +1558,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -838,7 +1566,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -895,8 +1623,114 @@ func TestLightClientHandler_GetLightClientOptimisticUpdate(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.NotNil(t, resp.Data) +} + +func TestLightClientHandler_GetLightClientOptimisticUpdateDeneb(t *testing.T) { + helpers.ClearCache() + ctx := context.Background() + config := params.BeaconConfig() + slot := primitives.Slot(config.DenebForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + + attestedState, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = attestedState.SetSlot(slot.Sub(1)) + require.NoError(t, err) + + require.NoError(t, attestedState.SetFinalizedCheckpoint(ðpb.Checkpoint{ + Epoch: config.AltairForkEpoch - 10, + Root: make([]byte, 32), + })) + + parent := util.NewBeaconBlockDeneb() + parent.Block.Slot = slot.Sub(1) + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + parentHeader, err := signedParent.Header() + require.NoError(t, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(t, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(t, err) + + st, err := util.NewBeaconStateDeneb() + require.NoError(t, err) + err = st.SetSlot(slot) + require.NoError(t, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(t, err) + + block := util.NewBeaconBlockDeneb() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < config.SyncCommitteeSize; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + h, err := signedBlock.Header() + require.NoError(t, err) + + err = st.SetLatestBlockHeader(h.Header) + require.NoError(t, err) + stateRoot, err := st.HashTreeRoot(ctx) + require.NoError(t, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(t, err) + + root, err := block.Block.HashTreeRoot() + require.NoError(t, err) + + mockBlocker := &testutil.MockBlocker{ + RootBlockMap: map[[32]byte]interfaces.ReadOnlySignedBeaconBlock{ + parentRoot: signedParent, + root: signedBlock, + }, + SlotBlockMap: map[primitives.Slot]interfaces.ReadOnlySignedBeaconBlock{ + slot.Sub(1): signedParent, + slot: signedBlock, + }, + } + mockChainService := &mock.ChainService{Optimistic: true, Slot: &slot, State: st, FinalizedRoots: map[[32]byte]bool{ + root: true, + }} + s := &Server{ + Stater: &testutil.MockStater{StatesBySlot: map[primitives.Slot]state.BeaconState{ + slot.Sub(1): attestedState, + slot: st, + }}, + Blocker: mockBlocker, + HeadFetcher: mockChainService, + } + request := httptest.NewRequest("GET", "http://foo.com", nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s.GetLightClientOptimisticUpdate(writer, request) + + require.Equal(t, http.StatusOK, writer.Code) + resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + require.NoError(t, err) + require.Equal(t, "deneb", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -904,7 +1738,7 @@ func TestLightClientHandler_GetLightClientEventBlock(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) @@ -1008,7 +1842,7 @@ func TestLightClientHandler_GetLightClientEventBlock_NeedFetchParent(t *testing. helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) diff --git a/beacon-chain/rpc/eth/light-client/helpers_test.go b/beacon-chain/rpc/eth/light-client/helpers_test.go index f693f9b88be3..31bcea36bbd8 100644 --- a/beacon-chain/rpc/eth/light-client/helpers_test.go +++ b/beacon-chain/rpc/eth/light-client/helpers_test.go @@ -94,9 +94,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: make([][]byte, fieldparams.NextSyncCommitteeBranchDepth), SignatureSlot: 9999, }, @@ -104,9 +108,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000001, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000001, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 1000000, }, @@ -118,9 +126,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000001, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000001, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 1000000, }, @@ -128,9 +140,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: make([][]byte, fieldparams.NextSyncCommitteeBranchDepth), SignatureSlot: 9999, }, @@ -142,9 +158,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: make([][]byte, lightclient.FinalityBranchNumOfLeaves), @@ -153,9 +173,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), @@ -168,9 +192,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), @@ -179,9 +207,13 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: make([][]byte, lightclient.FinalityBranchNumOfLeaves), @@ -194,29 +226,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 999999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 999999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 999999, + }}, + }, + }, }, expectedResult: true, }, @@ -226,29 +274,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 999999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 999999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 999999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: false, }, @@ -258,29 +322,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b01111100, 0b1}, // [0,1,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: true, }, @@ -290,29 +370,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b01111100, 0b1}, // [0,1,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: false, }, @@ -322,29 +418,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 999999, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 999999, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: true, }, @@ -354,29 +466,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 999999, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 999999, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: false, }, @@ -386,29 +514,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9998, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: true, }, @@ -418,29 +562,45 @@ func TestIsBetterUpdate(t *testing.T) { SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9998, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, newUpdate: ðpbv2.LightClientUpdate{ SyncAggregate: ðpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b00111100, 0b1}, // [0,0,1,1,1,1,0,0] }, - AttestedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 1000000, - }}, + AttestedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 1000000, + }}, + }, + }, NextSyncCommitteeBranch: createNonEmptySyncCommitteeBranch(), SignatureSlot: 9999, FinalityBranch: createNonEmptyFinalityBranch(), - FinalizedHeader: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ - Slot: 9999, - }}, + FinalizedHeader: ðpbv2.LightClientHeaderContainer{ + Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ + HeaderAltair: ðpbv2.LightClientHeader{Beacon: ðpbv1.BeaconBlockHeader{ + Slot: 9999, + }}, + }, + }, }, expectedResult: false, }, diff --git a/testing/util/lightclient.go b/testing/util/lightclient.go index 37cd8f26ffd1..1d3b8e777edd 100644 --- a/testing/util/lightclient.go +++ b/testing/util/lightclient.go @@ -21,16 +21,17 @@ type TestLightClient struct { Block interfaces.ReadOnlySignedBeaconBlock AttestedState state.BeaconState AttestedHeader *ethpb.BeaconBlockHeader + FinalizedBlock interfaces.ReadOnlySignedBeaconBlock } func NewTestLightClient(t *testing.T) *TestLightClient { return &TestLightClient{T: t} } -func (l *TestLightClient) SetupTest() *TestLightClient { +func (l *TestLightClient) SetupTestCapella() *TestLightClient { ctx := context.Background() - slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + slot := primitives.Slot(params.BeaconConfig().CapellaForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) attestedState, err := NewBeaconStateCapella() require.NoError(l.T, err) @@ -98,15 +99,157 @@ func (l *TestLightClient) SetupTest() *TestLightClient { return l } +func (l *TestLightClient) SetupTestAltair() *TestLightClient { + ctx := context.Background() + + slot := primitives.Slot(params.BeaconConfig().AltairForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + + attestedState, err := NewBeaconStateAltair() + require.NoError(l.T, err) + err = attestedState.SetSlot(slot) + require.NoError(l.T, err) + + parent := NewBeaconBlockAltair() + parent.Block.Slot = slot + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(l.T, err) + + parentHeader, err := signedParent.Header() + require.NoError(l.T, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(l.T, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(l.T, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(l.T, err) + + state, err := NewBeaconStateAltair() + require.NoError(l.T, err) + err = state.SetSlot(slot) + require.NoError(l.T, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(l.T, err) + + block := NewBeaconBlockAltair() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < params.BeaconConfig().MinSyncCommitteeParticipants; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(l.T, err) + + h, err := signedBlock.Header() + require.NoError(l.T, err) + + err = state.SetLatestBlockHeader(h.Header) + require.NoError(l.T, err) + stateRoot, err := state.HashTreeRoot(ctx) + require.NoError(l.T, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(l.T, err) + + l.State = state + l.AttestedState = attestedState + l.AttestedHeader = attestedHeader + l.Block = signedBlock + l.Ctx = ctx + + return l +} + +func (l *TestLightClient) SetupTestDeneb() *TestLightClient { + ctx := context.Background() + + slot := primitives.Slot(params.BeaconConfig().DenebForkEpoch * primitives.Epoch(params.BeaconConfig().SlotsPerEpoch)).Add(1) + + attestedState, err := NewBeaconStateDeneb() + require.NoError(l.T, err) + err = attestedState.SetSlot(slot) + require.NoError(l.T, err) + + parent := NewBeaconBlockDeneb() + parent.Block.Slot = slot + + signedParent, err := blocks.NewSignedBeaconBlock(parent) + require.NoError(l.T, err) + + parentHeader, err := signedParent.Header() + require.NoError(l.T, err) + attestedHeader := parentHeader.Header + + err = attestedState.SetLatestBlockHeader(attestedHeader) + require.NoError(l.T, err) + attestedStateRoot, err := attestedState.HashTreeRoot(ctx) + require.NoError(l.T, err) + + // get a new signed block so the root is updated with the new state root + parent.Block.StateRoot = attestedStateRoot[:] + signedParent, err = blocks.NewSignedBeaconBlock(parent) + require.NoError(l.T, err) + + state, err := NewBeaconStateDeneb() + require.NoError(l.T, err) + err = state.SetSlot(slot) + require.NoError(l.T, err) + + parentRoot, err := signedParent.Block().HashTreeRoot() + require.NoError(l.T, err) + + block := NewBeaconBlockDeneb() + block.Block.Slot = slot + block.Block.ParentRoot = parentRoot[:] + + for i := uint64(0); i < params.BeaconConfig().MinSyncCommitteeParticipants; i++ { + block.Block.Body.SyncAggregate.SyncCommitteeBits.SetBitAt(i, true) + } + + signedBlock, err := blocks.NewSignedBeaconBlock(block) + require.NoError(l.T, err) + + h, err := signedBlock.Header() + require.NoError(l.T, err) + + err = state.SetLatestBlockHeader(h.Header) + require.NoError(l.T, err) + stateRoot, err := state.HashTreeRoot(ctx) + require.NoError(l.T, err) + + // get a new signed block so the root is updated with the new state root + block.Block.StateRoot = stateRoot[:] + signedBlock, err = blocks.NewSignedBeaconBlock(block) + require.NoError(l.T, err) + + l.State = state + l.AttestedState = attestedState + l.AttestedHeader = attestedHeader + l.Block = signedBlock + l.Ctx = ctx + + return l +} + func (l *TestLightClient) CheckAttestedHeader(update *ethpbv2.LightClientUpdate) { - require.Equal(l.T, l.AttestedHeader.Slot, update.AttestedHeader.Beacon.Slot, "Attested header slot is not equal") - require.Equal(l.T, l.AttestedHeader.ProposerIndex, update.AttestedHeader.Beacon.ProposerIndex, "Attested header proposer index is not equal") - require.DeepSSZEqual(l.T, l.AttestedHeader.ParentRoot, update.AttestedHeader.Beacon.ParentRoot, "Attested header parent root is not equal") - require.DeepSSZEqual(l.T, l.AttestedHeader.BodyRoot, update.AttestedHeader.Beacon.BodyRoot, "Attested header body root is not equal") + require.Equal(l.T, l.AttestedHeader.Slot, update.AttestedHeader.GetBeacon().Slot, "Attested header slot is not equal") + require.Equal(l.T, l.AttestedHeader.ProposerIndex, update.AttestedHeader.GetBeacon().ProposerIndex, "Attested header proposer index is not equal") + require.DeepSSZEqual(l.T, l.AttestedHeader.ParentRoot, update.AttestedHeader.GetBeacon().ParentRoot, "Attested header parent root is not equal") + require.DeepSSZEqual(l.T, l.AttestedHeader.BodyRoot, update.AttestedHeader.GetBeacon().BodyRoot, "Attested header body root is not equal") attestedStateRoot, err := l.AttestedState.HashTreeRoot(l.Ctx) require.NoError(l.T, err) - require.DeepSSZEqual(l.T, attestedStateRoot[:], update.AttestedHeader.Beacon.StateRoot, "Attested header state root is not equal") + require.DeepSSZEqual(l.T, attestedStateRoot[:], update.AttestedHeader.GetBeacon().StateRoot, "Attested header state root is not equal") } func (l *TestLightClient) CheckSyncAggregate(update *ethpbv2.LightClientUpdate) { From 2d60884724c04d2b238b37451db15607b6e8f6ee Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 01:29:30 +0200 Subject: [PATCH 21/34] resolve panic in header.GetBeacon --- .../core/light-client/lightclient_test.go | 36 ++++++----- beacon-chain/rpc/eth/events/events.go | 15 ++++- beacon-chain/rpc/eth/light-client/helpers.go | 63 ++++++++++++++----- .../rpc/eth/light-client/helpers_test.go | 4 +- proto/eth/v2/custom.go | 13 ++-- testing/util/lightclient.go | 12 ++-- 6 files changed, 96 insertions(+), 47 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient_test.go b/beacon-chain/core/light-client/lightclient_test.go index 4ff6017c68a7..fa36633a8d47 100644 --- a/beacon-chain/core/light-client/lightclient_test.go +++ b/beacon-chain/core/light-client/lightclient_test.go @@ -72,11 +72,13 @@ func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateCapella(t *testi zeroHash := params.BeaconConfig().ZeroHash[:] require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") - require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") - require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") + updateFinalizedHeaderBeacon, err := update.FinalizedHeader.GetBeacon() + require.NoError(t, err) + require.Equal(t, primitives.Slot(0), updateFinalizedHeaderBeacon.Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), updateFinalizedHeaderBeacon.ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.BodyRoot, "Finalized header body root is not zero") require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") for _, leaf := range update.FinalityBranch { require.DeepSSZEqual(t, zeroHash, leaf, "Leaf is not zero") @@ -97,11 +99,13 @@ func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateAltair(t *testin zeroHash := params.BeaconConfig().ZeroHash[:] require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") - require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") - require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") + updateFinalizedHeaderBeacon, err := update.FinalizedHeader.GetBeacon() + require.NoError(t, err) + require.Equal(t, primitives.Slot(0), updateFinalizedHeaderBeacon.Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), updateFinalizedHeaderBeacon.ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.BodyRoot, "Finalized header body root is not zero") require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") for _, leaf := range update.FinalityBranch { require.DeepSSZEqual(t, zeroHash, leaf, "Leaf is not zero") @@ -122,11 +126,13 @@ func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateDeneb(t *testing zeroHash := params.BeaconConfig().ZeroHash[:] require.NotNil(t, update.FinalizedHeader, "Finalized header is nil") - require.Equal(t, primitives.Slot(0), update.FinalizedHeader.GetBeacon().Slot, "Finalized header slot is not zero") - require.Equal(t, primitives.ValidatorIndex(0), update.FinalizedHeader.GetBeacon().ProposerIndex, "Finalized header proposer index is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().ParentRoot, "Finalized header parent root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().StateRoot, "Finalized header state root is not zero") - require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetBeacon().BodyRoot, "Finalized header body root is not zero") + updateFinalizedHeaderBeacon, err := update.FinalizedHeader.GetBeacon() + require.NoError(t, err) + require.Equal(t, primitives.Slot(0), updateFinalizedHeaderBeacon.Slot, "Finalized header slot is not zero") + require.Equal(t, primitives.ValidatorIndex(0), updateFinalizedHeaderBeacon.ProposerIndex, "Finalized header proposer index is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.ParentRoot, "Finalized header parent root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.StateRoot, "Finalized header state root is not zero") + require.DeepSSZEqual(t, zeroHash, updateFinalizedHeaderBeacon.BodyRoot, "Finalized header body root is not zero") require.DeepSSZEqual(t, zeroHash, update.FinalizedHeader.GetHeaderDeneb().Execution.BlockHash, "Execution BlockHash is not zero") require.Equal(t, lightClient.FinalityBranchNumOfLeaves, len(update.FinalityBranch), "Invalid finality branch leaves") for _, leaf := range update.FinalityBranch { diff --git a/beacon-chain/rpc/eth/events/events.go b/beacon-chain/rpc/eth/events/events.go index 8f416bdf0977..980171cd9f2b 100644 --- a/beacon-chain/rpc/eth/events/events.go +++ b/beacon-chain/rpc/eth/events/events.go @@ -307,8 +307,14 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f finalityBranch = append(finalityBranch, hexutil.Encode(b)) } - attestedBeacon := updateData.Data.AttestedHeader.GetBeacon() - finalizedBeacon := updateData.Data.FinalizedHeader.GetBeacon() + attestedBeacon, err := updateData.Data.AttestedHeader.GetBeacon() + if err != nil { + return errors.Wrap(err, "could not get attested header") + } + finalizedBeacon, err := updateData.Data.FinalizedHeader.GetBeacon() + if err != nil { + return errors.Wrap(err, "could not get finalized header") + } update := &structs.LightClientFinalityUpdateEvent{ Version: version.String(int(updateData.Version)), Data: &structs.LightClientFinalityUpdate{ @@ -342,7 +348,10 @@ func (s *Server) handleStateEvents(ctx context.Context, w http.ResponseWriter, f if !ok { return write(w, flusher, topicDataMismatch, event.Data, LightClientOptimisticUpdateTopic) } - attestedBeacon := updateData.Data.AttestedHeader.GetBeacon() + attestedBeacon, err := updateData.Data.AttestedHeader.GetBeacon() + if err != nil { + return errors.Wrap(err, "could not get attested header") + } update := &structs.LightClientOptimisticUpdateEvent{ Version: version.String(int(updateData.Version)), Data: &structs.LightClientOptimisticUpdate{ diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 757cc4460ad2..31b6a25b1424 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -410,7 +410,11 @@ func createLightClientUpdate( updateSignaturePeriod := slots.SyncCommitteePeriod(slots.ToEpoch(block.Block().Slot())) // update_attested_period = compute_sync_committee_period(compute_epoch_at_slot(attested_header.slot)) - updateAttestedPeriod := slots.SyncCommitteePeriod(slots.ToEpoch(result.AttestedHeader.GetBeacon().Slot)) + resultAttestedHeaderBeacon, err := result.AttestedHeader.GetBeacon() + if err != nil { + return nil, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + } + updateAttestedPeriod := slots.SyncCommitteePeriod(slots.ToEpoch(resultAttestedHeaderBeacon.Slot)) if updateAttestedPeriod == updateSignaturePeriod { tempNextSyncCommittee, err := attestedState.NextSyncCommittee() @@ -509,11 +513,19 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien var finalizedHeader *structs.BeaconBlockHeader if input.FinalizedHeader != nil { - finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.FinalizedHeader.GetBeacon())) + inputFinalizedHeaderBeacon, err := input.FinalizedHeader.GetBeacon() + if err != nil { + return nil + } + finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputFinalizedHeaderBeacon)) } + inputAttestedHeaderBeacon, err := input.AttestedHeader.GetBeacon() + if err != nil { + return nil + } result := &structs.LightClientUpdate{ - AttestedHeader: &structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(input.AttestedHeader.GetBeacon()))}, + AttestedHeader: &structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}, NextSyncCommittee: nextSyncCommittee, NextSyncCommitteeBranch: branchToJSON(input.NextSyncCommitteeBranch), FinalizedHeader: &structs.LightClientHeader{Beacon: finalizedHeader}, @@ -535,7 +547,7 @@ func IsFinalityUpdate(update *v2.LightClientUpdate) bool { return !reflect.DeepEqual(update.FinalityBranch, finalityBranch) } -func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) bool { +func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) (bool, error) { maxActiveParticipants := newUpdate.SyncAggregate.SyncCommitteeBits.Len() newNumActiveParticipants := newUpdate.SyncAggregate.SyncCommitteeBits.Count() oldNumActiveParticipants := oldUpdate.SyncAggregate.SyncCommitteeBits.Count() @@ -543,45 +555,62 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) bool { oldHasSupermajority := oldNumActiveParticipants*3 >= maxActiveParticipants*2 if newHasSupermajority != oldHasSupermajority { - return newHasSupermajority + return newHasSupermajority, nil } if !newHasSupermajority && newNumActiveParticipants != oldNumActiveParticipants { - return newNumActiveParticipants > oldNumActiveParticipants + return newNumActiveParticipants > oldNumActiveParticipants, nil + } + + newUpdateAttestedHeaderBeacon, err := newUpdate.AttestedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + } + oldUpdateAttestedHeaderBeacon, err := oldUpdate.AttestedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + } + newUpdateFinalizedHeaderBeacon, err := newUpdate.FinalizedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) + } + oldUpdateFinalizedHeaderBeacon, err := oldUpdate.FinalizedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) } // Compare presence of relevant sync committee - newHasRelevantSyncCommittee := IsSyncCommitteeUpdate(newUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.SignatureSlot))) - oldHasRelevantSyncCommittee := IsSyncCommitteeUpdate(oldUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.SignatureSlot))) + newHasRelevantSyncCommittee := IsSyncCommitteeUpdate(newUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateAttestedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.SignatureSlot))) + oldHasRelevantSyncCommittee := IsSyncCommitteeUpdate(oldUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdateAttestedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.SignatureSlot))) if newHasRelevantSyncCommittee != oldHasRelevantSyncCommittee { - return newHasRelevantSyncCommittee + return newHasRelevantSyncCommittee, nil } // Compare indication of any finality newHasFinality := IsFinalityUpdate(newUpdate) oldHasFinality := IsFinalityUpdate(oldUpdate) if newHasFinality != oldHasFinality { - return newHasFinality + return newHasFinality, nil } // Compare sync committee finality if newHasFinality { - newHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.FinalizedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.AttestedHeader.GetBeacon().Slot)) - oldHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.FinalizedHeader.GetBeacon().Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdate.AttestedHeader.GetBeacon().Slot)) + newHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateFinalizedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateAttestedHeaderBeacon.Slot)) + oldHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdateFinalizedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(oldUpdateAttestedHeaderBeacon.Slot)) if newHasSyncCommitteeFinality != oldHasSyncCommitteeFinality { - return newHasSyncCommitteeFinality + return newHasSyncCommitteeFinality, nil } } // Tiebreaker 1: Sync committee participation beyond supermajority if newNumActiveParticipants != oldNumActiveParticipants { - return newNumActiveParticipants > oldNumActiveParticipants + return newNumActiveParticipants > oldNumActiveParticipants, nil } // Tiebreaker 2: Prefer older data (fewer changes to best) - if newUpdate.AttestedHeader.GetBeacon().Slot != oldUpdate.AttestedHeader.GetBeacon().Slot { - return newUpdate.AttestedHeader.GetBeacon().Slot < oldUpdate.AttestedHeader.GetBeacon().Slot + if newUpdateAttestedHeaderBeacon.Slot != oldUpdateAttestedHeaderBeacon.Slot { + return newUpdateAttestedHeaderBeacon.Slot < oldUpdateAttestedHeaderBeacon.Slot, nil } - return newUpdate.SignatureSlot < oldUpdate.SignatureSlot + return newUpdate.SignatureSlot < oldUpdate.SignatureSlot, nil } diff --git a/beacon-chain/rpc/eth/light-client/helpers_test.go b/beacon-chain/rpc/eth/light-client/helpers_test.go index 31bcea36bbd8..726527ef8be4 100644 --- a/beacon-chain/rpc/eth/light-client/helpers_test.go +++ b/beacon-chain/rpc/eth/light-client/helpers_test.go @@ -608,7 +608,9 @@ func TestIsBetterUpdate(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { - assert.Equal(t, testCase.expectedResult, IsBetterUpdate(testCase.newUpdate, testCase.oldUpdate)) + result, err := IsBetterUpdate(testCase.newUpdate, testCase.oldUpdate) + assert.NoError(t, err) + assert.Equal(t, testCase.expectedResult, result) }) } } diff --git a/proto/eth/v2/custom.go b/proto/eth/v2/custom.go index 61d40e21a318..9a9633db2df3 100644 --- a/proto/eth/v2/custom.go +++ b/proto/eth/v2/custom.go @@ -2,6 +2,7 @@ package eth import ( "bytes" + "fmt" "math/bits" v1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" @@ -44,7 +45,7 @@ func isEmptyWithLength(bb [][]byte, length uint64) bool { return true } -func (x *LightClientUpdate) IsSyncCommiteeUpdate() bool { +func (x *LightClientUpdate) IsSyncCommitteeUpdate() bool { return !isEmptyWithLength(x.GetNextSyncCommitteeBranch(), NextSyncCommitteeIndex) } @@ -52,15 +53,15 @@ func (x *LightClientUpdate) IsFinalityUpdate() bool { return !isEmptyWithLength(x.GetFinalityBranch(), FinalizedRootIndex) } -func (x *LightClientHeaderContainer) GetBeacon() *v1.BeaconBlockHeader { +func (x *LightClientHeaderContainer) GetBeacon() (*v1.BeaconBlockHeader, error) { switch input := x.Header.(type) { case *LightClientHeaderContainer_HeaderAltair: - return input.HeaderAltair.Beacon + return input.HeaderAltair.Beacon, nil case *LightClientHeaderContainer_HeaderCapella: - return input.HeaderCapella.Beacon + return input.HeaderCapella.Beacon, nil case *LightClientHeaderContainer_HeaderDeneb: - return input.HeaderDeneb.Beacon + return input.HeaderDeneb.Beacon, nil default: - panic("invalid type") + return nil, fmt.Errorf("unknown header type: %T", input) } } diff --git a/testing/util/lightclient.go b/testing/util/lightclient.go index 1d3b8e777edd..dbdbaec9fb34 100644 --- a/testing/util/lightclient.go +++ b/testing/util/lightclient.go @@ -242,14 +242,16 @@ func (l *TestLightClient) SetupTestDeneb() *TestLightClient { } func (l *TestLightClient) CheckAttestedHeader(update *ethpbv2.LightClientUpdate) { - require.Equal(l.T, l.AttestedHeader.Slot, update.AttestedHeader.GetBeacon().Slot, "Attested header slot is not equal") - require.Equal(l.T, l.AttestedHeader.ProposerIndex, update.AttestedHeader.GetBeacon().ProposerIndex, "Attested header proposer index is not equal") - require.DeepSSZEqual(l.T, l.AttestedHeader.ParentRoot, update.AttestedHeader.GetBeacon().ParentRoot, "Attested header parent root is not equal") - require.DeepSSZEqual(l.T, l.AttestedHeader.BodyRoot, update.AttestedHeader.GetBeacon().BodyRoot, "Attested header body root is not equal") + updateAttestedHeaderBeacon, err := update.AttestedHeader.GetBeacon() + require.NoError(l.T, err) + require.Equal(l.T, l.AttestedHeader.Slot, updateAttestedHeaderBeacon.Slot, "Attested header slot is not equal") + require.Equal(l.T, l.AttestedHeader.ProposerIndex, updateAttestedHeaderBeacon.ProposerIndex, "Attested header proposer index is not equal") + require.DeepSSZEqual(l.T, l.AttestedHeader.ParentRoot, updateAttestedHeaderBeacon.ParentRoot, "Attested header parent root is not equal") + require.DeepSSZEqual(l.T, l.AttestedHeader.BodyRoot, updateAttestedHeaderBeacon.BodyRoot, "Attested header body root is not equal") attestedStateRoot, err := l.AttestedState.HashTreeRoot(l.Ctx) require.NoError(l.T, err) - require.DeepSSZEqual(l.T, attestedStateRoot[:], update.AttestedHeader.GetBeacon().StateRoot, "Attested header state root is not equal") + require.DeepSSZEqual(l.T, attestedStateRoot[:], updateAttestedHeaderBeacon.StateRoot, "Attested header state root is not equal") } func (l *TestLightClient) CheckSyncAggregate(update *ethpbv2.LightClientUpdate) { From 892d00ceea291a41bfbc2dead31075ebfdeaf8f5 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 01:32:46 +0200 Subject: [PATCH 22/34] fix spacings --- beacon-chain/core/light-client/lightclient.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 2d99803d30bd..ce7f00f66e41 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -170,6 +170,7 @@ func NewLightClientOptimisticUpdateFromBeaconState( return result, nil } + // post altair block payloadInterface, err := block.Block().Body().Execution() if err != nil { @@ -201,6 +202,7 @@ func NewLightClientOptimisticUpdateFromBeaconState( } withdrawalsRoot = withdrawalsRootArray[:] } + // Capella block if block.Block().Version() == version.Capella { executionPayloadHeader := &enginev1.ExecutionPayloadHeaderCapella{ @@ -327,7 +329,6 @@ func NewLightClientFinalityUpdateFromBeaconState( if finalizedHeaderRoot != bytesutil.ToBytes32(attestedState.FinalizedCheckpoint().Root) { return nil, fmt.Errorf("finalized header root %#x not equal to attested finalized checkpoint root %#x", finalizedHeaderRoot, bytesutil.ToBytes32(attestedState.FinalizedCheckpoint().Root)) } - } else { if !bytes.Equal(attestedState.FinalizedCheckpoint().Root, make([]byte, 32)) { return nil, fmt.Errorf("invalid finalized header root %v", attestedState.FinalizedCheckpoint().Root) From 70f46dcee62208df3c55b56daf2b8d6b21a02ecd Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 02:10:03 +0200 Subject: [PATCH 23/34] refactor core/lightclient.go --- beacon-chain/core/light-client/lightclient.go | 372 ++++++++---------- beacon-chain/rpc/eth/light-client/helpers.go | 4 +- 2 files changed, 169 insertions(+), 207 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index ce7f00f66e41..872b96679de7 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -152,8 +152,8 @@ func NewLightClientOptimisticUpdateFromBeaconState( SignatureSlot: block.Block().Slot(), } - // Altair block - if block.Block().Version() == version.Altair || block.Block().Version() == version.Bellatrix { + switch block.Block().Version() { + case version.Altair, version.Bellatrix: result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ HeaderAltair: ðpbv2.LightClientHeader{ @@ -167,60 +167,10 @@ func NewLightClientOptimisticUpdateFromBeaconState( }, }, } - - return result, nil - } - - // post altair block - payloadInterface, err := block.Block().Body().Execution() - if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) - } - transactionsRoot, err := payloadInterface.TransactionsRoot() - if errors.Is(err, consensus_types.ErrUnsupportedField) { - transactions, err := payloadInterface.Transactions() - if err != nil { - return nil, fmt.Errorf("could not get transactions: %s", err.Error()) - } - transactionsRootArray, err := ssz.TransactionsRoot(transactions) - if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - transactionsRoot = transactionsRootArray[:] - } else if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() - if errors.Is(err, consensus_types.ErrUnsupportedField) { - withdrawals, err := payloadInterface.Withdrawals() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) - } - withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + case version.Capella: + executionPayloadHeader, err := getExecutionPayloadHeaderCapella(block) if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) - } - withdrawalsRoot = withdrawalsRootArray[:] - } - - // Capella block - if block.Block().Version() == version.Capella { - executionPayloadHeader := &enginev1.ExecutionPayloadHeaderCapella{ - ParentHash: payloadInterface.ParentHash(), - FeeRecipient: payloadInterface.FeeRecipient(), - StateRoot: payloadInterface.StateRoot(), - ReceiptsRoot: payloadInterface.ReceiptsRoot(), - LogsBloom: payloadInterface.LogsBloom(), - PrevRandao: payloadInterface.PrevRandao(), - BlockNumber: payloadInterface.BlockNumber(), - GasLimit: payloadInterface.GasLimit(), - GasUsed: payloadInterface.GasUsed(), - Timestamp: payloadInterface.Timestamp(), - ExtraData: payloadInterface.ExtraData(), - BaseFeePerGas: payloadInterface.BaseFeePerGas(), - BlockHash: payloadInterface.BlockHash(), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalsRoot, + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) @@ -244,26 +194,10 @@ func NewLightClientOptimisticUpdateFromBeaconState( }, } - return result, nil - } - // Deneb block - if block.Block().Version() == version.Deneb || block.Block().Version() == version.Electra { - executionPayloadHeader := &enginev1.ExecutionPayloadHeaderDeneb{ - ParentHash: payloadInterface.ParentHash(), - FeeRecipient: payloadInterface.FeeRecipient(), - StateRoot: payloadInterface.StateRoot(), - ReceiptsRoot: payloadInterface.ReceiptsRoot(), - LogsBloom: payloadInterface.LogsBloom(), - PrevRandao: payloadInterface.PrevRandao(), - BlockNumber: payloadInterface.BlockNumber(), - GasLimit: payloadInterface.GasLimit(), - GasUsed: payloadInterface.GasUsed(), - Timestamp: payloadInterface.Timestamp(), - ExtraData: payloadInterface.ExtraData(), - BaseFeePerGas: payloadInterface.BaseFeePerGas(), - BlockHash: payloadInterface.BlockHash(), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalsRoot, + case version.Deneb, version.Electra: + executionPayloadHeader, err := getExecutionPayloadHeaderDeneb(block) + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) @@ -286,11 +220,11 @@ func NewLightClientOptimisticUpdateFromBeaconState( }, }, } - - return result, nil + default: + return nil, fmt.Errorf("unsupported block version %s", version.String(block.Block().Version())) } - return nil, fmt.Errorf("unsupported block version %d", block.Block().Version()) + return result, nil } func NewLightClientFinalityUpdateFromBeaconState( @@ -364,66 +298,19 @@ func NewLightClientFinalityUpdateFromBeaconState( } } - if block.Block().Version() == version.Altair || block.Block().Version() == version.Bellatrix { + switch block.Block().Version() { + case version.Altair, version.Bellatrix: result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ Header: ðpbv2.LightClientHeaderContainer_HeaderAltair{ HeaderAltair: ðpbv2.LightClientHeader{Beacon: finalizedHeaderBeacon}, }, } result.FinalityBranch = finalityBranch - return result, nil - } - // post altair block - if finalizedBlock != nil && !finalizedBlock.IsNil() { - payloadInterface, err := finalizedBlock.Block().Body().Execution() - if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) - } - transactionsRoot, err := payloadInterface.TransactionsRoot() - if errors.Is(err, consensus_types.ErrUnsupportedField) { - transactions, err := payloadInterface.Transactions() + case version.Capella: + if finalizedBlock != nil && !finalizedBlock.IsNil() { + execution, err := getExecutionPayloadHeaderCapella(finalizedBlock) if err != nil { - return nil, fmt.Errorf("could not get transactions: %s", err.Error()) - } - transactionsRootArray, err := ssz.TransactionsRoot(transactions) - if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - transactionsRoot = transactionsRootArray[:] - } else if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) - } - withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() - if errors.Is(err, consensus_types.ErrUnsupportedField) { - withdrawals, err := payloadInterface.Withdrawals() - if err != nil { - return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) - } - withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) - if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) - } - withdrawalsRoot = withdrawalsRootArray[:] - } - - switch finalizedBlock.Block().Version() { - case version.Capella: - execution := &enginev1.ExecutionPayloadHeaderCapella{ - ParentHash: payloadInterface.ParentHash(), - FeeRecipient: payloadInterface.FeeRecipient(), - StateRoot: payloadInterface.StateRoot(), - ReceiptsRoot: payloadInterface.ReceiptsRoot(), - LogsBloom: payloadInterface.LogsBloom(), - PrevRandao: payloadInterface.PrevRandao(), - BlockNumber: payloadInterface.BlockNumber(), - GasLimit: payloadInterface.GasLimit(), - GasUsed: payloadInterface.GasUsed(), - Timestamp: payloadInterface.Timestamp(), - ExtraData: payloadInterface.ExtraData(), - BaseFeePerGas: payloadInterface.BaseFeePerGas(), - BlockHash: payloadInterface.BlockHash(), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalsRoot, + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) } executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) if err != nil { @@ -440,97 +327,45 @@ func NewLightClientFinalityUpdateFromBeaconState( }, } result.FinalityBranch = finalityBranch - return result, nil - case version.Deneb, version.Electra: - execution := &enginev1.ExecutionPayloadHeaderDeneb{ - ParentHash: payloadInterface.ParentHash(), - FeeRecipient: payloadInterface.FeeRecipient(), - StateRoot: payloadInterface.StateRoot(), - ReceiptsRoot: payloadInterface.ReceiptsRoot(), - LogsBloom: payloadInterface.LogsBloom(), - PrevRandao: payloadInterface.PrevRandao(), - BlockNumber: payloadInterface.BlockNumber(), - GasLimit: payloadInterface.GasLimit(), - GasUsed: payloadInterface.GasUsed(), - Timestamp: payloadInterface.Timestamp(), - ExtraData: payloadInterface.ExtraData(), - BaseFeePerGas: payloadInterface.BaseFeePerGas(), - BlockHash: payloadInterface.BlockHash(), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalsRoot, - } - executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) - if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) - } + } else { + execution := createEmptyExecutionPayloadHeaderCapella() + executionBranch := make([][]byte, 0) result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ - Header: ðpbv2.LightClientHeaderContainer_HeaderDeneb{ - HeaderDeneb: ðpbv2.LightClientHeaderDeneb{ + Header: ðpbv2.LightClientHeaderContainer_HeaderCapella{ + HeaderCapella: ðpbv2.LightClientHeaderCapella{ Beacon: finalizedHeaderBeacon, Execution: execution, ExecutionBranch: executionBranch, }, }, } + result.FinalityBranch = finalityBranch - return result, nil - default: - panic("unsupported block version") } - - } else { - switch block.Block().Version() { - case version.Capella: - execution := &enginev1.ExecutionPayloadHeaderCapella{ - ParentHash: make([]byte, 32), - FeeRecipient: make([]byte, 20), - StateRoot: make([]byte, 32), - ReceiptsRoot: make([]byte, 32), - LogsBloom: make([]byte, 256), - PrevRandao: make([]byte, 32), - BlockNumber: 0, - GasLimit: 0, - GasUsed: 0, - Timestamp: 0, - ExtraData: make([]byte, 32), - BaseFeePerGas: make([]byte, 32), - BlockHash: make([]byte, 32), - TransactionsRoot: make([]byte, 32), - WithdrawalsRoot: make([]byte, 32), + case version.Deneb, version.Electra: + if finalizedBlock != nil && !finalizedBlock.IsNil() { + execution, err := getExecutionPayloadHeaderDeneb(finalizedBlock) + if err != nil { + return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + } + executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) + if err != nil { + return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) } - executionBranch := make([][]byte, 0) result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ - Header: ðpbv2.LightClientHeaderContainer_HeaderCapella{ - HeaderCapella: ðpbv2.LightClientHeaderCapella{ + Header: ðpbv2.LightClientHeaderContainer_HeaderDeneb{ + HeaderDeneb: ðpbv2.LightClientHeaderDeneb{ Beacon: finalizedHeaderBeacon, Execution: execution, ExecutionBranch: executionBranch, }, }, } - result.FinalityBranch = finalityBranch - return result, nil - case version.Deneb, version.Electra: - execution := &enginev1.ExecutionPayloadHeaderDeneb{ - ParentHash: make([]byte, 32), - FeeRecipient: make([]byte, 20), - StateRoot: make([]byte, 32), - ReceiptsRoot: make([]byte, 32), - LogsBloom: make([]byte, 256), - PrevRandao: make([]byte, 32), - BlockNumber: 0, - GasLimit: 0, - GasUsed: 0, - Timestamp: 0, - ExtraData: make([]byte, 32), - BaseFeePerGas: make([]byte, 32), - BlockHash: make([]byte, 32), - TransactionsRoot: make([]byte, 32), - WithdrawalsRoot: make([]byte, 32), - } + } else { + execution := createEmptyExecutionPayloadHeaderDeneb() executionBranch := make([][]byte, 0) result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ @@ -544,12 +379,139 @@ func NewLightClientFinalityUpdateFromBeaconState( } result.FinalityBranch = finalityBranch - return result, nil - default: - panic("unsupported block version") } + default: + return nil, fmt.Errorf("unsupported block version %s", version.String(block.Block().Version())) + } + + return result, nil +} + +func createEmptyExecutionPayloadHeaderCapella() *enginev1.ExecutionPayloadHeaderCapella { + return &enginev1.ExecutionPayloadHeaderCapella{ + ParentHash: make([]byte, 32), + FeeRecipient: make([]byte, 20), + StateRoot: make([]byte, 32), + ReceiptsRoot: make([]byte, 32), + LogsBloom: make([]byte, 256), + PrevRandao: make([]byte, 32), + BlockNumber: 0, + GasLimit: 0, + GasUsed: 0, + Timestamp: 0, + ExtraData: make([]byte, 32), + BaseFeePerGas: make([]byte, 32), + BlockHash: make([]byte, 32), + TransactionsRoot: make([]byte, 32), + WithdrawalsRoot: make([]byte, 32), + } +} + +func createEmptyExecutionPayloadHeaderDeneb() *enginev1.ExecutionPayloadHeaderDeneb { + return &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: make([]byte, 32), + FeeRecipient: make([]byte, 20), + StateRoot: make([]byte, 32), + ReceiptsRoot: make([]byte, 32), + LogsBloom: make([]byte, 256), + PrevRandao: make([]byte, 32), + BlockNumber: 0, + GasLimit: 0, + GasUsed: 0, + Timestamp: 0, + ExtraData: make([]byte, 32), + BaseFeePerGas: make([]byte, 32), + BlockHash: make([]byte, 32), + TransactionsRoot: make([]byte, 32), + WithdrawalsRoot: make([]byte, 32), + } +} + +func getExecutionPayloadHeaderCapella(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderCapella, error) { + payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) + if err != nil { + return nil, fmt.Errorf("could not get execution data: %s", err.Error()) + } + execution := &enginev1.ExecutionPayloadHeaderCapella{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + + return execution, nil +} + +func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderDeneb, error) { + payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) + if err != nil { + return nil, fmt.Errorf("could not get execution data: %s", err.Error()) + } + execution := &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } + + return execution, nil +} + +func getExecutionData(block interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, []byte, []byte, error) { + payloadInterface, err := block.Block().Body().Execution() + if err != nil { + return nil, nil, nil, fmt.Errorf("could not get execution payload: %s", err.Error()) + } + transactionsRoot, err := payloadInterface.TransactionsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, nil, nil, fmt.Errorf("could not get transactions: %s", err.Error()) + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, nil, nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { + return nil, nil, nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + } + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, nil, nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, nil, nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + } + withdrawalsRoot = withdrawalsRootArray[:] } + return payloadInterface, transactionsRoot, withdrawalsRoot, nil } func NewLightClientUpdateFromFinalityUpdate(update *ethpbv2.LightClientFinalityUpdate) *ethpbv2.LightClientUpdate { diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 31b6a25b1424..c7a6cadadf7e 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -145,7 +145,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt payloadInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, fmt.Errorf("could not get execution payload: %s", err.Error()) } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { @@ -256,7 +256,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat payloadInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, fmt.Errorf("could not get execution payload: %s", err.Error()) } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { From 7dfa520be8845aa64da1213d62c68b617ed40d44 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 02:28:20 +0200 Subject: [PATCH 24/34] fix isBetterUpdate --- beacon-chain/rpc/eth/light-client/handlers.go | 2 +- beacon-chain/rpc/eth/light-client/helpers.go | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index efeb4cbf7e0d..2166d38c4fd0 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -47,7 +47,7 @@ func (s *Server) GetLightClientBootstrap(w http.ResponseWriter, req *http.Reques return } - bootstrap, err := createLightClientBootstrapVersionAgnostic(ctx, state, blk.Block()) + bootstrap, err := createLightClientBootstrap(ctx, state, blk.Block()) if err != nil { httputil.HandleError(w, "could not get light client bootstrap: "+err.Error(), http.StatusInternalServerError) return diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index c7a6cadadf7e..4f98763e27e9 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -25,12 +25,12 @@ import ( "github.com/prysmaticlabs/prysm/v5/time/slots" ) -func createLightClientBootstrapVersionAgnostic(ctx context.Context, state state.BeaconState, blk interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrap, error) { +func createLightClientBootstrap(ctx context.Context, state state.BeaconState, blk interfaces.ReadOnlyBeaconBlock) (*structs.LightClientBootstrap, error) { switch blk.Version() { case version.Phase0: return nil, fmt.Errorf("light client bootstrap is not supported for phase0") case version.Altair, version.Bellatrix: - return createLightClientBootstrap(ctx, state) + return createLightClientBootstrapAltair(ctx, state) case version.Capella: return createLightClientBootstrapCapella(ctx, state, blk) case version.Deneb, version.Electra: @@ -39,7 +39,7 @@ func createLightClientBootstrapVersionAgnostic(ctx context.Context, state state. return nil, fmt.Errorf("unsupported block version") } -// createLightClientBootstrap - implements https://github.com/ethereum/consensus-specs/blob/3d235740e5f1e641d3b160c8688f26e7dc5a1894/specs/altair/light-client/full-node.md#create_light_client_bootstrap +// createLightClientBootstrapAltair - implements https://github.com/ethereum/consensus-specs/blob/3d235740e5f1e641d3b160c8688f26e7dc5a1894/specs/altair/light-client/full-node.md#create_light_client_bootstrap // def create_light_client_bootstrap(state: BeaconState) -> LightClientBootstrap: // // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH @@ -56,7 +56,7 @@ func createLightClientBootstrapVersionAgnostic(ctx context.Context, state state. // current_sync_committee=state.current_sync_committee, // current_sync_committee_branch=compute_merkle_proof_for_state(state, CURRENT_SYNC_COMMITTEE_INDEX) // ) -func createLightClientBootstrap(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrap, error) { +func createLightClientBootstrapAltair(ctx context.Context, state state.BeaconState) (*structs.LightClientBootstrap, error) { // assert compute_epoch_at_slot(state.slot) >= ALTAIR_FORK_EPOCH if slots.ToEpoch(state.Slot()) < params.BeaconConfig().AltairForkEpoch { return nil, fmt.Errorf("light client bootstrap is not supported before Altair, invalid slot %d", state.Slot()) @@ -569,14 +569,6 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) (bool, error) { if err != nil { return false, fmt.Errorf("could not get attested header beacon: %s", err.Error()) } - newUpdateFinalizedHeaderBeacon, err := newUpdate.FinalizedHeader.GetBeacon() - if err != nil { - return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) - } - oldUpdateFinalizedHeaderBeacon, err := oldUpdate.FinalizedHeader.GetBeacon() - if err != nil { - return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) - } // Compare presence of relevant sync committee newHasRelevantSyncCommittee := IsSyncCommitteeUpdate(newUpdate) && (slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateAttestedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdate.SignatureSlot))) @@ -593,6 +585,15 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) (bool, error) { return newHasFinality, nil } + newUpdateFinalizedHeaderBeacon, err := newUpdate.FinalizedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) + } + oldUpdateFinalizedHeaderBeacon, err := oldUpdate.FinalizedHeader.GetBeacon() + if err != nil { + return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) + } + // Compare sync committee finality if newHasFinality { newHasSyncCommitteeFinality := slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateFinalizedHeaderBeacon.Slot)) == slots.SyncCommitteePeriod(slots.ToEpoch(newUpdateAttestedHeaderBeacon.Slot)) From 25417ae5a47015a416b6b99c0d78778c54807be3 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 02:59:01 +0200 Subject: [PATCH 25/34] use errors.wrap instead of fmt.errorf --- beacon-chain/core/light-client/BUILD.bazel | 1 + beacon-chain/core/light-client/lightclient.go | 52 +++++++-------- beacon-chain/rpc/eth/light-client/BUILD.bazel | 1 + beacon-chain/rpc/eth/light-client/handlers.go | 15 +++-- beacon-chain/rpc/eth/light-client/helpers.go | 65 ++++++++++--------- 5 files changed, 69 insertions(+), 65 deletions(-) diff --git a/beacon-chain/core/light-client/BUILD.bazel b/beacon-chain/core/light-client/BUILD.bazel index 097aba812818..094c8782a2f6 100644 --- a/beacon-chain/core/light-client/BUILD.bazel +++ b/beacon-chain/core/light-client/BUILD.bazel @@ -20,6 +20,7 @@ go_library( "//proto/migration:go_default_library", "//runtime/version:go_default_library", "//time/slots:go_default_library", + "@com_github_pkg_errors//:go_default_library", ], ) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 872b96679de7..e6c5e13ee1fc 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -2,9 +2,9 @@ package light_client import ( "bytes" - "errors" "fmt" + "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" @@ -83,7 +83,7 @@ func NewLightClientOptimisticUpdateFromBeaconState( // assert sum(block.message.body.sync_aggregate.sync_committee_bits) >= MIN_SYNC_COMMITTEE_PARTICIPANTS syncAggregate, err := block.Block().Body().SyncAggregate() if err != nil { - return nil, fmt.Errorf("could not get sync aggregate %w", err) + return nil, errors.Wrap(err, "could not get sync aggregate") } if syncAggregate.SyncCommitteeBits.Count() < params.BeaconConfig().MinSyncCommitteeParticipants { @@ -99,18 +99,18 @@ func NewLightClientOptimisticUpdateFromBeaconState( header := state.LatestBlockHeader() stateRoot, err := state.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get state root %w", err) + return nil, errors.Wrap(err, "could not get state root") } header.StateRoot = stateRoot[:] headerRoot, err := header.HashTreeRoot() if err != nil { - return nil, fmt.Errorf("could not get header root %w", err) + return nil, errors.Wrap(err, "could not get header root") } blockRoot, err := block.Block().HashTreeRoot() if err != nil { - return nil, fmt.Errorf("could not get block root %w", err) + return nil, errors.Wrap(err, "could not get block root") } if headerRoot != blockRoot { @@ -128,14 +128,14 @@ func NewLightClientOptimisticUpdateFromBeaconState( // attested_header.state_root = hash_tree_root(attested_state) attestedStateRoot, err := attestedState.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get attested state root %w", err) + return nil, errors.Wrap(err, "could not get attested state root") } attestedHeader.StateRoot = attestedStateRoot[:] // assert hash_tree_root(attested_header) == block.message.parent_root attestedHeaderRoot, err := attestedHeader.HashTreeRoot() if err != nil { - return nil, fmt.Errorf("could not get attested header root %w", err) + return nil, errors.Wrap(err, "could not get attested header root") } if attestedHeaderRoot != block.Block().ParentRoot() { @@ -170,12 +170,12 @@ func NewLightClientOptimisticUpdateFromBeaconState( case version.Capella: executionPayloadHeader, err := getExecutionPayloadHeaderCapella(block) if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload header") } executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ @@ -197,12 +197,12 @@ func NewLightClientOptimisticUpdateFromBeaconState( case version.Deneb, version.Electra: executionPayloadHeader, err := getExecutionPayloadHeaderDeneb(block) if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload header") } executionPayloadProof, err := blocks.PayloadProof(ctx, block.Block()) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } result.AttestedHeader = ðpbv2.LightClientHeaderContainer{ @@ -251,13 +251,13 @@ func NewLightClientFinalityUpdateFromBeaconState( if finalizedBlock.Block().Slot() != 0 { tempFinalizedHeader, err := finalizedBlock.Header() if err != nil { - return nil, fmt.Errorf("could not get finalized header %w", err) + return nil, errors.Wrap(err, "could not get finalized header") } finalizedHeaderBeacon := migration.V1Alpha1SignedHeaderToV1(tempFinalizedHeader).GetMessage() finalizedHeaderRoot, err := finalizedHeaderBeacon.HashTreeRoot() if err != nil { - return nil, fmt.Errorf("could not get finalized header root %w", err) + return nil, errors.Wrap(err, "could not get finalized header root") } if finalizedHeaderRoot != bytesutil.ToBytes32(attestedState.FinalizedCheckpoint().Root) { @@ -281,7 +281,7 @@ func NewLightClientFinalityUpdateFromBeaconState( var bErr error finalityBranch, bErr = attestedState.FinalizedRootProof(ctx) if bErr != nil { - return nil, fmt.Errorf("could not get finalized root proof %w", bErr) + return nil, errors.Wrap(bErr, "could not get finalized root proof") } } else { finalizedHeaderBeacon = ðpbv1.BeaconBlockHeader{ @@ -310,11 +310,11 @@ func NewLightClientFinalityUpdateFromBeaconState( if finalizedBlock != nil && !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderCapella(finalizedBlock) if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload header") } executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ @@ -347,11 +347,11 @@ func NewLightClientFinalityUpdateFromBeaconState( if finalizedBlock != nil && !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderDeneb(finalizedBlock) if err != nil { - return nil, fmt.Errorf("could not get execution payload header: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload header") } executionBranch, err := blocks.PayloadProof(ctx, finalizedBlock.Block()) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } result.FinalizedHeader = ðpbv2.LightClientHeaderContainer{ @@ -430,7 +430,7 @@ func createEmptyExecutionPayloadHeaderDeneb() *enginev1.ExecutionPayloadHeaderDe func getExecutionPayloadHeaderCapella(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderCapella, error) { payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) if err != nil { - return nil, fmt.Errorf("could not get execution data: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution data") } execution := &enginev1.ExecutionPayloadHeaderCapella{ ParentHash: payloadInterface.ParentHash(), @@ -456,7 +456,7 @@ func getExecutionPayloadHeaderCapella(block interfaces.ReadOnlySignedBeaconBlock func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderDeneb, error) { payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) if err != nil { - return nil, fmt.Errorf("could not get execution data: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution data") } execution := &enginev1.ExecutionPayloadHeaderDeneb{ ParentHash: payloadInterface.ParentHash(), @@ -482,31 +482,31 @@ func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) func getExecutionData(block interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, []byte, []byte, error) { payloadInterface, err := block.Block().Body().Execution() if err != nil { - return nil, nil, nil, fmt.Errorf("could not get execution payload: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get execution data") } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { - return nil, nil, nil, fmt.Errorf("could not get transactions: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get transactions") } transactionsRootArray, err := ssz.TransactionsRoot(transactions) if err != nil { - return nil, nil, nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get transactions root") } transactionsRoot = transactionsRootArray[:] } else if err != nil { - return nil, nil, nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get transactions root") } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { - return nil, nil, nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get withdrawals") } withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) if err != nil { - return nil, nil, nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + return nil, nil, nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] } diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index f0b45bad1759..04848190b738 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -33,6 +33,7 @@ go_library( "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_gorilla_mux//:go_default_library", + "@com_github_pkg_errors//:go_default_library", "@com_github_wealdtech_go_bytesutil//:go_default_library", "@io_opencensus_go//trace:go_default_library", ], diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 2166d38c4fd0..33f07cf214e2 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" + "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared" @@ -352,27 +353,27 @@ func (s *Server) getLightClientEventBlock(ctx context.Context, minSignaturesRequ // Get the current state state, err := s.HeadFetcher.HeadState(ctx) if err != nil { - return nil, fmt.Errorf("could not get head state %w", err) + return nil, errors.Wrap(err, "could not get head state") } // Get the block latestBlockHeader := *state.LatestBlockHeader() stateRoot, err := state.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get state root %w", err) + return nil, errors.Wrap(err, "could not get state root") } latestBlockHeader.StateRoot = stateRoot[:] latestBlockHeaderRoot, err := latestBlockHeader.HashTreeRoot() if err != nil { - return nil, fmt.Errorf("could not get latest block header root %w", err) + return nil, errors.Wrap(err, "could not get latest block header root") } block, err := s.Blocker.Block(ctx, latestBlockHeaderRoot[:]) if err != nil { - return nil, fmt.Errorf("could not get latest block %w", err) + return nil, errors.Wrap(err, "could not get latest block") } if block == nil { - return nil, fmt.Errorf("latest block is nil") + return nil, errors.New("latest block is nil") } // Loop through the blocks until we find a block that satisfies minSignaturesRequired requirement @@ -386,10 +387,10 @@ func (s *Server) getLightClientEventBlock(ctx context.Context, minSignaturesRequ parentRoot := block.Block().ParentRoot() block, err = s.Blocker.Block(ctx, parentRoot[:]) if err != nil { - return nil, fmt.Errorf("could not get parent block %w", err) + return nil, errors.Wrap(err, "could not get parent block") } if block == nil { - return nil, fmt.Errorf("parent block is nil") + return nil, errors.New("parent block is nil") } // Get the number of sync committee signatures diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 4f98763e27e9..912082a69144 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -2,11 +2,12 @@ package lightclient import ( "context" - "errors" "fmt" "reflect" "strconv" + "github.com/pkg/errors" + lightclient "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/light-client" consensus_types "github.com/prysmaticlabs/prysm/v5/consensus-types" "github.com/prysmaticlabs/prysm/v5/encoding/ssz" @@ -36,7 +37,7 @@ func createLightClientBootstrap(ctx context.Context, state state.BeaconState, bl case version.Deneb, version.Electra: return createLightClientBootstrapDeneb(ctx, state, blk) } - return nil, fmt.Errorf("unsupported block version") + return nil, fmt.Errorf("unsupported block version %s", version.String(blk.Version())) } // createLightClientBootstrapAltair - implements https://github.com/ethereum/consensus-specs/blob/3d235740e5f1e641d3b160c8688f26e7dc5a1894/specs/altair/light-client/full-node.md#create_light_client_bootstrap @@ -71,14 +72,14 @@ func createLightClientBootstrapAltair(ctx context.Context, state state.BeaconSta // Prepare data currentSyncCommittee, err := state.CurrentSyncCommittee() if err != nil { - return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee") } committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) if err != nil { - return nil, fmt.Errorf("could not get current sync committee proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee proof") } branch := make([]string, fieldparams.NextSyncCommitteeBranchDepth) @@ -97,7 +98,7 @@ func createLightClientBootstrapAltair(ctx context.Context, state state.BeaconSta // Above shared util function won't calculate state root, so we need to do it manually stateRoot, err := state.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get state root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get state root") } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) @@ -126,14 +127,14 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt // Prepare data currentSyncCommittee, err := state.CurrentSyncCommittee() if err != nil { - return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee") } committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) if err != nil { - return nil, fmt.Errorf("could not get current sync committee proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee proof") } branch := make([]string, fieldparams.NextSyncCommitteeBranchDepth) @@ -145,31 +146,31 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt payloadInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload") } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { - return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions") } transactionsRootArray, err := ssz.TransactionsRoot(transactions) if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions root") } transactionsRoot = transactionsRootArray[:] } else if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions root") } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { - return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + return nil, errors.Wrap(err, "could not get withdrawals") } withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] } @@ -193,7 +194,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } executionPayloadProofStr := make([]string, len(executionPayloadProof)) for i, proof := range executionPayloadProof { @@ -208,7 +209,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt // Above shared util function won't calculate state root, so we need to do it manually stateRoot, err := state.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get state root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get state root") } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) @@ -237,14 +238,14 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat // Prepare data currentSyncCommittee, err := state.CurrentSyncCommittee() if err != nil { - return nil, fmt.Errorf("could not get current sync committee: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee") } committee := structs.SyncCommitteeFromConsensus(currentSyncCommittee) currentSyncCommitteeProof, err := state.CurrentSyncCommitteeProof(ctx) if err != nil { - return nil, fmt.Errorf("could not get current sync committee proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get current sync committee proof") } branch := make([]string, fieldparams.NextSyncCommitteeBranchDepth) @@ -256,31 +257,31 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat payloadInterface, err := block.Body().Execution() if err != nil { - return nil, fmt.Errorf("could not get execution payload: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload") } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { - return nil, fmt.Errorf("could not get transactions: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions") } transactionsRootArray, err := ssz.TransactionsRoot(transactions) if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions root") } transactionsRoot = transactionsRootArray[:] } else if err != nil { - return nil, fmt.Errorf("could not get transactions root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get transactions root") } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { - return nil, fmt.Errorf("could not get withdrawals: %s", err.Error()) + return nil, errors.Wrap(err, "could not get withdrawals") } withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) if err != nil { - return nil, fmt.Errorf("could not get withdrawals root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] } @@ -304,7 +305,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat executionPayloadProof, err := blocks.PayloadProof(ctx, block) if err != nil { - return nil, fmt.Errorf("could not get execution payload proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get execution payload proof") } executionPayloadProofStr := make([]string, len(executionPayloadProof)) for i, proof := range executionPayloadProof { @@ -319,7 +320,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat // Above shared util function won't calculate state root, so we need to do it manually stateRoot, err := state.HashTreeRoot(ctx) if err != nil { - return nil, fmt.Errorf("could not get state root: %s", err.Error()) + return nil, errors.Wrap(err, "could not get state root") } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) @@ -412,14 +413,14 @@ func createLightClientUpdate( // update_attested_period = compute_sync_committee_period(compute_epoch_at_slot(attested_header.slot)) resultAttestedHeaderBeacon, err := result.AttestedHeader.GetBeacon() if err != nil { - return nil, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + return nil, errors.Wrap(err, "could not get attested header beacon") } updateAttestedPeriod := slots.SyncCommitteePeriod(slots.ToEpoch(resultAttestedHeaderBeacon.Slot)) if updateAttestedPeriod == updateSignaturePeriod { tempNextSyncCommittee, err := attestedState.NextSyncCommittee() if err != nil { - return nil, fmt.Errorf("could not get next sync committee: %s", err.Error()) + return nil, errors.Wrap(err, "could not get next sync committee") } nextSyncCommittee = &v2.SyncCommittee{ @@ -429,7 +430,7 @@ func createLightClientUpdate( nextSyncCommitteeBranch, err = attestedState.NextSyncCommitteeProof(ctx) if err != nil { - return nil, fmt.Errorf("could not get next sync committee proof: %s", err.Error()) + return nil, errors.Wrap(err, "could not get next sync committee proof") } } else { syncCommitteeSize := params.BeaconConfig().SyncCommitteeSize @@ -563,11 +564,11 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) (bool, error) { newUpdateAttestedHeaderBeacon, err := newUpdate.AttestedHeader.GetBeacon() if err != nil { - return false, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + return false, errors.Wrap(err, "could not get attested header beacon") } oldUpdateAttestedHeaderBeacon, err := oldUpdate.AttestedHeader.GetBeacon() if err != nil { - return false, fmt.Errorf("could not get attested header beacon: %s", err.Error()) + return false, errors.Wrap(err, "could not get attested header beacon") } // Compare presence of relevant sync committee @@ -587,11 +588,11 @@ func IsBetterUpdate(newUpdate, oldUpdate *v2.LightClientUpdate) (bool, error) { newUpdateFinalizedHeaderBeacon, err := newUpdate.FinalizedHeader.GetBeacon() if err != nil { - return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) + return false, errors.Wrap(err, "could not get finalized header beacon") } oldUpdateFinalizedHeaderBeacon, err := oldUpdate.FinalizedHeader.GetBeacon() if err != nil { - return false, fmt.Errorf("could not get finalized header beacon: %s", err.Error()) + return false, errors.Wrap(err, "could not get finalized header beacon") } // Compare sync committee finality From 35d3154d11d19a438cf320619a12d275fc44752e Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 03:06:23 +0200 Subject: [PATCH 26/34] changelog entry --- CHANGELOG.md | 630 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 412 insertions(+), 218 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a8d1abd1c9..426982c4614d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Changelog +# Changelog All notable changes to this project will be documented in this file. @@ -10,27 +10,30 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Aggregate and proof committee validation for Electra. - More tests for electra field generation. -- Light client support: implement `ComputeFieldRootsForBlockBody`. +- Light client support: Implement `ComputeFieldRootsForBlockBody`. - Light client support: Add light client database changes. +- Light client support: Implement capella and deneb changes. ### Changed - `getLocalPayload` has been refactored to enable work in ePBS branch. -- `TestNodeServer_GetPeer` and `TestNodeServer_ListPeers` test flakes resolved by iterating the whole peer list to find a match rather than taking the first peer in the map. +- `TestNodeServer_GetPeer` and `TestNodeServer_ListPeers` test flakes resolved by iterating the whole peer list to find + a match rather than taking the first peer in the map. - Passing spectests v1.5.0-alpha.4 and v1.5.0-alpha.5. - Beacon chain now asserts that the external builder block uses the expected gas limit. - Electra: Add electra objects to beacon API. - Electra: Updated block publishing beacon APIs to support Electra. - "Submitted builder validator registration settings for custom builders" log message moved to debug level. - config: Genesis validator root is now hardcoded in params.BeaconConfig() +- Light client support: abstracted out the light client headers with different versions. ### Deprecated -- `--enable-experimental-state` flag is deprecated. This feature is now on by default. Opt-out with `--disable-experimental-state`. +- `--enable-experimental-state` flag is deprecated. This feature is now on by default. Opt-out + with `--disable-experimental-state`. ### Removed - ### Fixed - Fixed early release of read lock in BeaconState.getValidatorIndex. @@ -41,14 +44,18 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve ### Security - ## [v5.1.0](https://github.com/prysmaticlabs/prysm/compare/v5.0.4...v5.1.0) - 2024-08-20 -This release contains 171 new changes and many of these are related to Electra! Along side the Electra changes, there are nearly 100 changes related to bug fixes, feature additions, and other improvements to Prysm. Updating to this release is recommended at your convenience. +This release contains 171 new changes and many of these are related to Electra! Along side the Electra changes, there +are nearly 100 changes related to bug fixes, feature additions, and other improvements to Prysm. Updating to this +release is recommended at your convenience. ⚠️ Deprecation Notice: Removal of gRPC Gateway and Gateway Flag Renaming ⚠️ -In an upcoming release, we will be deprecating the gRPC gateway and renaming several associated flags. This change will result in the removal of access to several internal APIs via REST, though the gRPC endpoints will remain unaffected. We strongly encourage systems to transition to using the beacon API endpoints moving forward. Please refer to PR for more details. +In an upcoming release, we will be deprecating the gRPC gateway and renaming several associated flags. This change will +result in the removal of access to several internal APIs via REST, though the gRPC endpoints will remain unaffected. We +strongly encourage systems to transition to using the beacon API endpoints moving forward. Please refer to PR for more +details. ### Added @@ -59,7 +66,8 @@ In an upcoming release, we will be deprecating the gRPC gateway and renaming sev - Add middleware for Content-Type and Accept headers - Add debug logs for proposer settings - Add tracing to beacon api package -- Add support for persistent validator keys when using remote signer. --validators-external-signer-public-keys and --validators-external-signer-key-file See the docs page for more info. +- Add support for persistent validator keys when using remote signer. --validators-external-signer-public-keys and + --validators-external-signer-key-file See the docs page for more info. - Add AggregateKeyFromIndices to beacon state to reduce memory usage when processing attestations - Add GetIndividualVotes endpoint - Implement is_better_update for light client @@ -113,8 +121,7 @@ In an upcoming release, we will be deprecating the gRPC gateway and renaming sev - Fix Event stream with carriage return support - Fix panic on empty block result in REST API - engine_getPayloadBodiesByRangeV1 - fix, adding hexutil encoding on request parameters -- Use sync committee period instead of epoch in `createLightClientUpdate` - +- Use sync committee period instead of epoch in `createLightClientUpdate` ### Security @@ -122,7 +129,9 @@ In an upcoming release, we will be deprecating the gRPC gateway and renaming sev ## [v5.0.4](https://github.com/prysmaticlabs/prysm/compare/v5.0.3...v5.0.4) - 2024-07-21 -This release has many wonderful bug fixes and improvements. Some highlights include p2p peer fix for windows users, beacon API fix for retrieving blobs older than the minimum blob retention period, and improvements to initial sync by avoiding redundant blob downloads. +This release has many wonderful bug fixes and improvements. Some highlights include p2p peer fix for windows users, +beacon API fix for retrieving blobs older than the minimum blob retention period, and improvements to initial sync by +avoiding redundant blob downloads. Updating to this release is recommended at your earliest convenience, especially for windows users. @@ -184,7 +193,9 @@ Updating to this release is recommended at your earliest convenience, especially ## [v5.0.3](https://github.com/prysmaticlabs/prysm/compare/v5.0.2...v5.0.3) - 2024-04-04 -Prysm v5.0.3 is a small patch release with some nice additions and bug fixes. Updating to this release is recommended for users on v5.0.0 or v5.0.1. There aren't many changes since last week's v5.0.2 so upgrading is not strictly required, but there are still improvements in this release so update if you can! +Prysm v5.0.3 is a small patch release with some nice additions and bug fixes. Updating to this release is recommended +for users on v5.0.0 or v5.0.1. There aren't many changes since last week's v5.0.2 so upgrading is not strictly required, +but there are still improvements in this release so update if you can! ### Added @@ -216,16 +227,19 @@ No security updates in this release. ## [v5.0.2](https://github.com/prysmaticlabs/prysm/compare/v5.0.1...v5.0.2) - 2024-03-27 -This release has many optimizations, UX improvements, and bug fixes. Due to the number of important bug fixes and optimizations, we encourage all operators to update to v5.0.2 at their earliest convenience. - -In this release, there is a notable change to the default value of --local-block-value-boost from 0 to 10. This means that the default behavior of using the builder API / mev-boost requires the builder bid to be 10% better than your local block profit. If you want to preserve the existing behavior, set --local-block-value-boost=0. +This release has many optimizations, UX improvements, and bug fixes. Due to the number of important bug fixes and +optimizations, we encourage all operators to update to v5.0.2 at their earliest convenience. +In this release, there is a notable change to the default value of --local-block-value-boost from 0 to 10. This means +that the default behavior of using the builder API / mev-boost requires the builder bid to be 10% better than your local +block profit. If you want to preserve the existing behavior, set --local-block-value-boost=0. ### Added - API: Add support for sync committee selections - blobs: call fsync between part file write and rename (feature flag --blob-save-fsync) -- Implement EIP-3076 minimal slashing protection, using a filesystem database (feature flag --enable-minimal-slashing-protection) +- Implement EIP-3076 minimal slashing protection, using a filesystem database (feature flag + --enable-minimal-slashing-protection) - Save invalid block to temp --save-invalid-block-temp - Compute unrealized checkpoints with pcli - Add gossip blob sidecar verification ms metric @@ -304,7 +318,8 @@ In this release, there is a notable change to the default value of --local-block - Fix Data Race in Epoch Boundary - exit blob fetching for cp block if outside retention - Do not check parent weight on early FCU -- Fix VC DB conversion when no proposer settings is defined and add Experimental flag in the --enable-minimal-slashing-protection help. +- Fix VC DB conversion when no proposer settings is defined and add Experimental flag in the + --enable-minimal-slashing-protection help. - keymanager api: lowercase statuses - Fix unrealized justification - fix race condition when pinging peers @@ -337,9 +352,11 @@ In this release, there is a notable change to the default value of --local-block ## [v5.0.1](https://github.com/prysmaticlabs/prysm/compare/v5.0.0...v5.0.1) - 2024-03-08 -This minor patch release has some nice improvements over the recent v5.0.0 for Deneb. We have minimized this patch release to include only low risk and valuable fixes or features ahead of the upcoming network upgrade on March 13th. +This minor patch release has some nice improvements over the recent v5.0.0 for Deneb. We have minimized this patch +release to include only low risk and valuable fixes or features ahead of the upcoming network upgrade on March 13th. -Deneb is scheduled for mainnet epoch 269568 on March 13, 2024 at 01:55:35pm UTC. All operators MUST update their Prysm software to v5.0.0 or later before the upgrade in order to continue following the blockchain. +Deneb is scheduled for mainnet epoch 269568 on March 13, 2024 at 01:55:35pm UTC. All operators MUST update their Prysm +software to v5.0.0 or later before the upgrade in order to continue following the blockchain. ### Added @@ -367,14 +384,19 @@ Prysm version v5.0.0 or later is required to maintain participation in the netwo Behold the Prysm v5 release with official support for Deneb on Ethereum mainnet! -Deneb is scheduled for mainnet epoch 269568 on March 13, 2024 at 01:55:35pm UTC. All operators MUST update their Prysm software to v5.0.0 or later before the upgrade in order to continue following the blockchain. +Deneb is scheduled for mainnet epoch 269568 on March 13, 2024 at 01:55:35pm UTC. All operators MUST update their Prysm +software to v5.0.0 or later before the upgrade in order to continue following the blockchain. -This release brings improvements to the backfill functionality of the beacon node to support backfilling blobs. If running a beacon node with checkpoint sync, we encourage you to test the backfilling functionality and share your feedback. Run with backfill enabled using the flag --enable-experimental-backfill. +This release brings improvements to the backfill functionality of the beacon node to support backfilling blobs. If +running a beacon node with checkpoint sync, we encourage you to test the backfilling functionality and share your +feedback. Run with backfill enabled using the flag --enable-experimental-backfill. Known Issues - --backfill-batch-size with a value of 1 or less breaks backfill. -- Validator client on v4.2.0 or older uses some API methods that are incompatible with beacon node v5. Ensure that you have updated the beacon node and validator client to v4.2.1 and then upgrade to v5 or update both processes at the same time to minimize downtime. +- Validator client on v4.2.0 or older uses some API methods that are incompatible with beacon node v5. Ensure that you + have updated the beacon node and validator client to v4.2.1 and then upgrade to v5 or update both processes at the + same time to minimize downtime. ### Added @@ -414,7 +436,6 @@ The following flags have been removed entirely: - --safe-slots-to-import-optimistically - --show-deposit-data - ### Removed - Prysm gRPC slasher endpoints are removed @@ -444,49 +465,50 @@ The following flags have been removed entirely: - Check non-zero blob data is written to disk - Avoid blob partial filepath collisions with mem addr entropy - ### Security v5.0.0 of Prysm is required to maintain participation in the network after the Deneb upgrade. ## [v4.2.1](https://github.com/prysmaticlabs/prysm/compare/v4.2.0...v4.2.1) - 2024-01-29 -Welcome to Prysm Release v4.2.1! This release is highly recommended for stakers and node operators, possibly being the final update before V5. +Welcome to Prysm Release v4.2.1! This release is highly recommended for stakers and node operators, possibly being the +final update before V5. -⚠️ This release will cause failures on Goerli, Sepolia and Holeski testnets, when running on certain older CPUs without AVX support (eg Celeron) after the Deneb fork. This is not an issue for mainnet. +⚠️ This release will cause failures on Goerli, Sepolia and Holeski testnets, when running on certain older CPUs without +AVX support (eg Celeron) after the Deneb fork. This is not an issue for mainnet. ### Added - Linter: Wastedassign linter enabled to improve code quality. - API Enhancements: - - Added payload return in Wei for /eth/v3/validator/blocks. - - Added Holesky Deneb Epoch for better epoch management. + - Added payload return in Wei for /eth/v3/validator/blocks. + - Added Holesky Deneb Epoch for better epoch management. - Testing Enhancements: - - Clear cache in tests of core helpers to ensure test reliability. - - Added Debug State Transition Method for improved debugging. - - Backfilling test: Enabled backfill in E2E tests for more comprehensive coverage. + - Clear cache in tests of core helpers to ensure test reliability. + - Added Debug State Transition Method for improved debugging. + - Backfilling test: Enabled backfill in E2E tests for more comprehensive coverage. - API Updates: Re-enabled jwt on keymanager API for enhanced security. - Logging Improvements: Enhanced block by root log for better traceability. - Validator Client Improvements: - - Added Spans to Core Validator Methods for enhanced monitoring. - - Improved readability in validator client code for better maintenance (various commits). + - Added Spans to Core Validator Methods for enhanced monitoring. + - Improved readability in validator client code for better maintenance (various commits). ### Changed - Optimizations and Refinements: - - Lowered resource usage in certain processes for efficiency. - - Moved blob rpc validation closer to peer read for optimized processing. - - Cleaned up validate beacon block code for clarity and efficiency. - - Updated Sepolia Deneb fork epoch for alignment with network changes. - - Changed blob latency metrics to milliseconds for more precise measurement. - - Altered getLegacyDatabaseLocation message for better clarity. - - Improved wait for activation method for enhanced performance. - - Capitalized Aggregated Unaggregated Attestations Log for consistency. - - Modified HistoricalRoots usage for accuracy. - - Adjusted checking of attribute emptiness for efficiency. + - Lowered resource usage in certain processes for efficiency. + - Moved blob rpc validation closer to peer read for optimized processing. + - Cleaned up validate beacon block code for clarity and efficiency. + - Updated Sepolia Deneb fork epoch for alignment with network changes. + - Changed blob latency metrics to milliseconds for more precise measurement. + - Altered getLegacyDatabaseLocation message for better clarity. + - Improved wait for activation method for enhanced performance. + - Capitalized Aggregated Unaggregated Attestations Log for consistency. + - Modified HistoricalRoots usage for accuracy. + - Adjusted checking of attribute emptiness for efficiency. - Database Management: - - Moved --db-backup-output-dir as a deprecated flag for database management simplification. - - Added the Ability to Defragment the Beacon State for improved database performance. + - Moved --db-backup-output-dir as a deprecated flag for database management simplification. + - Added the Ability to Defragment the Beacon State for improved database performance. - Dependency Update: Bumped quic-go version from 0.39.3 to 0.39.4 for up-to-date dependencies. ### Removed @@ -497,12 +519,12 @@ Welcome to Prysm Release v4.2.1! This release is highly recommended for stakers ### Fixed - Bug Fixes: - - Fixed off by one error for improved accuracy. - - Resolved small typo in error messages for clarity. - - Addressed minor issue in blsToExecChange validator for better validation. - - Corrected blobsidecar json tag for commitment inclusion proof. - - Fixed ssz post-requests content type check. - - Resolved issue with port logging in bootnode. + - Fixed off by one error for improved accuracy. + - Resolved small typo in error messages for clarity. + - Addressed minor issue in blsToExecChange validator for better validation. + - Corrected blobsidecar json tag for commitment inclusion proof. + - Fixed ssz post-requests content type check. + - Resolved issue with port logging in bootnode. - Test Fixes: Re-enabled Slasher E2E Test for more comprehensive testing. ### Security @@ -511,32 +533,42 @@ No security issues in this release. ## [v4.2.0](https://github.com/prysmaticlabs/prysm/compare/v4.1.1...v4.2.0) - 2024-01-11 -Happy new year! We have an incredibly exciting release to kick off the new year. This release is **strongly recommended** for all operators to update as it has many bug fixes, security patches, and features that will improve the Prysm experience on mainnet. This release has so many wonderful changes that we've deviated from our normal release notes format to aptly categorize the changes. +Happy new year! We have an incredibly exciting release to kick off the new year. This release is **strongly recommended +** for all operators to update as it has many bug fixes, security patches, and features that will improve the Prysm +experience on mainnet. This release has so many wonderful changes that we've deviated from our normal release notes +format to aptly categorize the changes. ### Highlights #### Upgrading / Downgrading Validators -There are some API changes bundled in this release that require you to upgrade or downgrade in particular order. If the validator is updated before the beacon node, it will see repeated 404 errors at start up until the beacon node is updated as it uses a new API endpoint introduced in v4.2.0. +There are some API changes bundled in this release that require you to upgrade or downgrade in particular order. If the +validator is updated before the beacon node, it will see repeated 404 errors at start up until the beacon node is +updated as it uses a new API endpoint introduced in v4.2.0. :arrow_up_small: **Upgrading**: Upgrade the beacon node, then the validator. :arrow_down_small: **Downgrading**: Downgrade the validator to v4.1.1 then downgrade the beacon node. #### Deneb Goerli Support + This release adds in full support for the upcoming deneb hard fork on goerli next week on January 17th. #### Networking Parameter Changes + This release increases the default peer count to 70 from 45. The reason this is done is so that node's running with default peer counts can perform their validator duties as expected. Users who want to use the old peer count can add in `--p2p-max-peers=45` as a flag. #### Profile Guided Optimization -This release has binaries built using PGO, for more information on how it works feel free to look here: https://tip.golang.org/doc/pgo . -This allows the go compiler to build more optimized Prysm binaries using production profiles and workloads. + +This release has binaries built using PGO, for more information on how it works feel free to look +here: https://tip.golang.org/doc/pgo . +This allows the go compiler to build more optimized Prysm binaries using production profiles and workloads. #### ARM Supported Docker Images -Our docker images now support amd64 and arm64 architecture! This long awaited feature is finally here for Apple Silicon and Raspberry Pi users. +Our docker images now support amd64 and arm64 architecture! This long awaited feature is finally here for Apple Silicon +and Raspberry Pi users. ### Deneb @@ -588,18 +620,18 @@ Our docker images now support amd64 and arm64 architecture! This long awaited fe - Prune dangling blob - Use Afero Walk for Pruning Blob - Initialize blob storage without pruning -- Fix batch pruning errors +- Fix batch pruning errors - Blob filesystem add pruning during blob write - Blob filesystem add pruning at startup - Ensure partial blob is deleted if there's an error - Split blob pruning into two funcs - Use functional options for `--blob-retention-epochs` -- Blob filesystem: delete blobs +- Blob filesystem: delete blobs - Fix Blob Storage Path - Add blob getters - Blob filesystem: Save Blobs - Blob filesystem: prune blobs -- blobstorage: Improve mkdirall error +- blobstorage: Improve mkdirall error #### Beacon-API @@ -617,7 +649,7 @@ Our docker images now support amd64 and arm64 architecture! This long awaited fe #### Validator Client - Validator client: remove blob signing -- Deneb - web3signer +- Deneb - web3signer #### Testing @@ -635,7 +667,7 @@ Our docker images now support amd64 and arm64 architecture! This long awaited fe - Check builder header kzg commitment - Add more color to sending blob by range req log - Move pruning log to after retention check -- Enhance Pruning Logs +- Enhance Pruning Logs - Rename Blob retention epoch flag - Check that blobs count is correct when unblinding - Log blob's kzg commmitment at sync @@ -675,7 +707,7 @@ Our docker images now support amd64 and arm64 architecture! This long awaited fe - Verify lmd without ancestor - Track target in forkchoice - Return early from ReceiveBlock if already sycned - + #### Builder - Adding builder boost factor to get block v3 @@ -724,7 +756,7 @@ _Most of the PRs here involve shifting our http endpoints to using vanilla http - http endpoint cleanup - Revert "REST VC: Subscribe to Beacon API events " - proposer and attester slashing sse -- REST VC: Subscribe to Beacon API events +- REST VC: Subscribe to Beacon API events - Simplify error handling for JsonRestHandler - Update block publishing to 2.4.2 spec - Use `SkipMevBoost` properly during block production @@ -864,12 +896,12 @@ _Most of the PRs here involve shifting our http endpoints to using vanilla http - Fix missing testnet versions. Issue - Update README.md - Only run metrics for canonical blocks -- Relax file permissions check on existing directories +- Relax file permissions check on existing directories - forkchoice.Getter wrapper with locking wrappers - Initialize cancellable root context in main.go - Fix forkchoice pkg's comments grammar - lock RecentBlockSlot -- Comment typo +- Comment typo - Optimize `ReplayBlocks` for Zero Diff - Remove default value of circuit breaker flags - Fix Withdrawals @@ -894,7 +926,8 @@ _Most of the PRs here involve shifting our http endpoints to using vanilla http ## [v4.1.1](https://github.com/prysmaticlabs/prysm/compare/v4.1.0...v4.1.1) - 2023-10-24 -This patch release includes two cherry-picked changes from the develop branch to resolve critical issues that affect a small set of users. +This patch release includes two cherry-picked changes from the develop branch to resolve critical issues that affect a +small set of users. ### Fixed @@ -907,11 +940,17 @@ No security issues in thsi release. ## [v4.1.0](https://github.com/prysmaticlabs/prysm/compare/v4.0.8...v4.1.0) - 2023-08-22 -- **Fundamental Deneb Support**: This release lays the foundation for Deneb support, although features like backwards syncing and filesystem-based blob storage are planned for Q4 2024. -- **Multi-Value Slices for Beacon State**: Implemented multi-value slices to reduce the memory footprint and optimize certain processing paths. This data structure allows for storing values shared between state instances more efficiently. This feature is controller by the `--enable-experimental-state` flag. -- **EIP-4881 Deposit Tree**: Integrated the EIP-4881 Deposit Tree into Prysm to optimize runtime block processing and production. This feature is controlled by a flag: `--enable-eip-4881` -- **BLST version 0.3.11**: Introduced a significant improvement to the portable build's performance. The portable build now features runtime detection, automatically enabling optimized code paths if your CPU supports it. -- **Multiarch Containers Preview Available**: multiarch (:wave: arm64 support :wave:) containers will be offered for preview at the following locations: +- **Fundamental Deneb Support**: This release lays the foundation for Deneb support, although features like backwards + syncing and filesystem-based blob storage are planned for Q4 2024. +- **Multi-Value Slices for Beacon State**: Implemented multi-value slices to reduce the memory footprint and optimize + certain processing paths. This data structure allows for storing values shared between state instances more + efficiently. This feature is controller by the `--enable-experimental-state` flag. +- **EIP-4881 Deposit Tree**: Integrated the EIP-4881 Deposit Tree into Prysm to optimize runtime block processing and + production. This feature is controlled by a flag: `--enable-eip-4881` +- **BLST version 0.3.11**: Introduced a significant improvement to the portable build's performance. The portable build + now features runtime detection, automatically enabling optimized code paths if your CPU supports it. +- **Multiarch Containers Preview Available**: multiarch (:wave: arm64 support :wave:) containers will be offered for + preview at the following locations: - Beacon Chain: [gcr.io/prylabs-dev/prysm/beacon-chain:v4.1.0](gcr.io/prylabs-dev/prysm/beacon-chain:v4.1.0) - Validator: [gcr.io/prylabs-dev/prysm/validator:v4.1.0](gcr.io/prylabs-dev/prysm/validator:v4.1.0) - Please note that in the next cycle, we will exclusively use these containers at the canonical URLs. @@ -919,13 +958,16 @@ No security issues in thsi release. ### Added #### EIP-4844: + ##### Core: + - **Deneb State & Block Types**: New state and block types added specifically for Deneb. - **Deneb Protobufs**: Protocol Buffers designed exclusively for Deneb. - **Deneb Engine API**: Specialized API endpoints for Deneb. - **Deneb Config/Params**: Deneb-specific configurations and parameters from the deneb-integration branch. ##### Blob Management: + - **Blob Retention Epoch Period**: Configurable retention periods for blobs. - **Blob Arrival Gossip Metric**: Metrics for blob arrivals via gossip protocol. - **Blob Merge Function**: Functionality to merge and validate saved/new blobs. @@ -933,37 +975,45 @@ No security issues in thsi release. - **Save Blobs to DB**: Feature to save blobs to the database for subscribers. ##### Logging and Validation: + - **Logging for Blob Sidecar**: Improved logging functionalities for Blob Sidecar. - **Blob Commitment Count Logging**: Introduced logging for blob commitment counts. - **Blob Validation**: A feature to validate blobs. ##### Additional Features and Tests: + - **Deneb Changes & Blobs to Builder**: Deneb-specific changes and blob functionality added to the builder. - **Deneb Blob Sidecar Events**: Blob sidecar events added as part of the Deneb release. - **KZG Commitments**: Functionality to copy KZG commitments when using the builder block. - **Deneb Validator Beacon APIs**: New REST APIs specifically for the Deneb release. - **Deneb Tests**: Test cases specific to the Deneb version. - **PublishBlockV2 for Deneb**: The `publishblockv2` endpoint implemented specifically for Deneb. -- **Builder Override & Builder Flow for Deneb**: An override for the builder and a new RPC to handle the builder flow in Deneb. +- **Builder Override & Builder Flow for Deneb**: An override for the builder and a new RPC to handle the builder flow in + Deneb. - **SSZ Detection for Deneb**: SSZ detection capabilities added for Deneb. - **Validator Signing for Deneb**: Validators can now sign Deneb blocks. - **Deneb Upgrade Function**: A function to handle the upgrade to Deneb. #### Rest of EIPs + - **EIP-4788**: Added support for Beacon block root in the EVM. -- **EIP-7044** and **EIP-7045**: Implemented support for Perpetually Valid Signed Voluntary Exits and increased the max attestation inclusion slot. +- **EIP-7044** and **EIP-7045**: Implemented support for Perpetually Valid Signed Voluntary Exits and increased the max + attestation inclusion slot. #### Beacon API: *Note: All Beacon API work is related with moving endpoints into pure HTTP handlers. This is NOT new functionality.* ##### Endpoints moved to HTTP: + - `/eth/v1/beacon/blocks` and `/eth/v1/beacon/blinded_blocks`. - `/eth/v1/beacon/states/{state_id}/committees`. - `/eth/v1/config/deposit_contract`. - `/eth/v1/beacon/pool/sync_committees`. -- `/eth/v1/beacon/states/{state_id}/validators`, `/eth/v1/beacon/states/{state_id}/validators/{validator_id}` and `/eth/v1/beacon/states/{state_id}/validator_balances`. -- `/eth/v1/validator/duties/attester/{epoch}`, `/eth/v1/validator/duties/proposer/{epoch}` and `/eth/v1/validator/duties/sync/{epoch}`. +- `/eth/v1/beacon/states/{state_id}/validators`, `/eth/v1/beacon/states/{state_id}/validators/{validator_id}` + and `/eth/v1/beacon/states/{state_id}/validator_balances`. +- `/eth/v1/validator/duties/attester/{epoch}`, `/eth/v1/validator/duties/proposer/{epoch}` + and `/eth/v1/validator/duties/sync/{epoch}`. - `/eth/v1/validator/register_validator`. - `/eth/v1/validator/prepare_beacon_proposer`. - `/eth/v1/beacon/headers`. @@ -976,13 +1026,16 @@ No security issues in thsi release. - `/eth/v1/beacon/headers/{block_id}` and `/eth/v1/validator/liveness/{epoch}`. ##### Miscellaneous: + - **Comma-Separated Query Params**: Support for comma-separated query parameters added to Beacon API. - **Middleware for Query Params**: Middleware introduced for handling comma-separated query parameters. - **Content-Type Header**: Compliance improved by adding Content-Type header to VC POST requests. - **Node Version**: REST-based node version endpoint implemented. #### Other additions + ##### Protocol: + - **Multi-Value Slice for Beacon State**: Enhanced the beacon state by utilizing a multi-value slice. - **EIP-4881 Deposit Tree**: EIP-4881 Deposit Tree integrated into Prysm, controlled by a feature flag. - **New Engine Methods**: New engine methods set as the default. @@ -990,36 +1043,45 @@ No security issues in thsi release. - **Block Commitment Checks**: Functionality to reject blocks with excessive commitments added. ##### State Management: + - **Alloc More Items**: Modified beacon-node/state to allocate an additional item during appends. -- **GetParentBlockHash Helper**: Refactoring of `getLocalPayloadAndBlobs` with a new helper function for fetching parent block hashes. +- **GetParentBlockHash Helper**: Refactoring of `getLocalPayloadAndBlobs` with a new helper function for fetching parent + block hashes. - **RW Lock for Duties**: Read-Write lock mechanism introduced for managing validator duties. ##### Build and CI/CD Improvements: + - **Manual Build Tag**: A "manual" build tag introduced to expedite CI build times. - **Multiarch Docker Containers**: Support for multiple architectures in Docker containers added. ##### Testing: + - **Init-Sync DA Tests**: Tests for initial sync Data Availability (DA) included. - **Fuzz List Timeout**: Github workflow for fuzz testing now includes a timeout setting. - **Go Fuzzing Workflow**: New Github workflow for Go fuzzing on a cron schedule. ##### Logging and Monitoring: + - **FFG-LMD Consistency Logging**: Enhanced logging for Finality Gadget LMD (FFG-LMD) consistency. - **Validator Count Endpoint**: New endpoint to count the number of validators. ##### User Interface and Web: + - **Web UI Release**: Prysm Web UI v2.0.4 released with unspecified updates and improvements. ##### Testnet support: + - **Holesky Support**: Support for Holesky decompositions integrated into the codebase. ##### Error Handling and Responses: + - **Validation Error in ForkchoiceUpdatedResponse**: Included validation errors in fork choice update responses. - **Wrapped Invalid Block Error**: Improved error handling for cases where an invalid block error is wrapped.. ### Changed #### General: + - **Skip MEV-Boost Flag**: Updated `GetBlock` RPC to utilize `skip mev-boost` flag. - **Portable Version of BLST**: Transitioned to portable BLST version as default. - **Teku Mainnet Bootnodes**: Refreshed Teku mainnet bootnodes ENRs. @@ -1027,6 +1089,7 @@ No security issues in thsi release. - **Parallel Block Building**: Deprecated sequential block building path #### Deneb-Specific Changes: + - **Deneb Spectests Release**: Upgraded to Deneb spectests v1.4.0-beta.2-hotfix. - **Deneb API and Builder Cleanup**: Conducted clean-up activities for Deneb-specific API and builder. - **Deneb Block Versioning**: Introduced changes related to Deneb produce block version 3. @@ -1035,23 +1098,28 @@ No security issues in thsi release. - **Blob Sidecar Syncing**: Altered behavior when value is 0. #### Code Cleanup and Refactor: + - **API Types Cleanup**: Reorganized API types for improved readability. - **Geth Client Headers**: Simplified code for setting geth client headers. - **Bug Report Template**: Revised requirements for more clarity. #### Flags and Configuration: + - **Safe Slots to Import Flag**: Deprecated this flag for standard alignment. - **Holesky Config**: Revised the Holesky configuration for new genesis. #### Logging: + - **Genesis State Warning**: Will log a warning if the genesis state size is under 1KB. - **Debug Log Removal**: Excised debug logs for cleaner output. #### Miscellaneous: + - **First Aggregation Timing**: Default setting for first aggregation is 7 seconds post-genesis. - **Pointer Usage**: Modified execution chain to use pointers, reducing copy operations. #### Dependency Updates: + - **Go Version Update**: Updated to Go version 1.20.7. - **Go Version Update**: Updated to Go version 1.20.9 for better security. - **Various Dependencies**: Updated multiple dependencies including Geth, Bazel, rules_go, Gazelle, BLST, and go-libp2p. @@ -1064,13 +1132,16 @@ No security issues in thsi release. - **Go-Playground/Validator**: Removed go-playground/validator from Beacon API. - **Reverted Cache Proposer ID**: Reversed the change that cached proposer ID on GetProposerDuties. - **Cache Proposer ID**: Reversed the functionality that cached proposer ID on GetProposerDuties. -- **Quadratic Loops in Exiting**: Eliminated quadratic loops that occurred during voluntary exits, improving performance. -- **Deprecated Go Embed Rules**: Removed deprecated `go_embed` rules from rules_go, to stay up-to-date with best practices. +- **Quadratic Loops in Exiting**: Eliminated quadratic loops that occurred during voluntary exits, improving + performance. +- **Deprecated Go Embed Rules**: Removed deprecated `go_embed` rules from rules_go, to stay up-to-date with best + practices. - **Alpine Images**: Removed Alpine images from the Prysm project. ### Fixed #### Deneb-Specific Bug Fixes: + - **Deneb Builder Bid HTR**: Fixed an issue related to HashTreeRoot (HTR) in Deneb builder bid. - **PBV2 Condition**: Corrected conditions related to PBV2. - **Route Handler and Cleanup**: Updated the route handler and performed minor cleanups. @@ -1083,11 +1154,13 @@ No security issues in thsi release. - **Sync/RPC Blob Usage**: Rectified blob usage when requesting a block by root in Sync/RPC. #### Cache Fixes: + - **Don't Prune Proposer ID Cache**: Fixed a loop erroneously pruning the proposer ID cache. - **LastRoot Adjustment**: Altered `LastRoot` to return the head root. - **Last Canonical Root**: Modified forkchoice to return the last canonical root of the epoch. #### Block Processing fixes: + - **Block Validation**: Fixed an issue where blocks were incorrectly marked as bad during validation. - **Churn Limit Helpers**: Improved churn limit calculations through refactoring. - **Churn with 0 Exits**: Rectified a bug that calculated churn even when there were 0 exits. @@ -1095,19 +1168,22 @@ No security issues in thsi release. - **Duplicate Block Processing**: Eliminated redundant block processing. #### Error Handling and Logging: + - **RpcError from Core Service**: Ensured that `RpcError` is returned from core services. - **Unhandled Error**: Enhanced error management by handling previously unhandled errors. - **Error Handling**: Wrapped `ctx.Err` for improved error handling. - **Attestation Error**: Optimized error management in attestation processing. #### Test and Build Fixes: + - **Racy Tests in Blockchain**: Resolved race conditions in blockchain tests. - **TestService_ReceiveBlock**: Modified `TestService_ReceiveBlock` to work as expected. - **Build Issue with @com_github_ethereum_c_kzg_4844**: Resolved build issues related to this specific library. -- **Fuzz Testing**: Addressed fuzz testing issues in the `origin/deneb-integration` +- **Fuzz Testing**: Addressed fuzz testing issues in the `origin/deneb-integration` - **Long-Running E2E Tests**: Fixed issues that were causing the end-to-end tests to run for an extended period. #### Additional Fixes: + - **Public Key Copies During Aggregation**: Optimized to avoid unnecessary public key copies during aggregation. - **Epoch Participations**: Fixed the setting of current and previous epoch participations. - **Verify Attestations**: Resolved an attestation verification issue in proposer logic. @@ -1117,7 +1193,6 @@ No security issues in thsi release. - **Hex Handling**: Upgraded the hex handling in various modules. - **Initial Sync PreProcessing**: Resolved an issue affecting the initial sync preprocessing. - ### Security No security updates in this release. @@ -1128,7 +1203,8 @@ Welcome to Prysm Release v4.0.8! This release is recommended. Highlights: - Parallel hashing of validator entries in the beacon state. This results in a faster hash tree root. ~3x reduction - Parallel validations of consensus and execution checks. This results in a faster block verification -- Aggregate parallel is now the default. This results in faster attestation aggregation time if a node is subscribed to multiple beacon attestation subnets. ~3x reduction +- Aggregate parallel is now the default. This results in faster attestation aggregation time if a node is subscribed to + multiple beacon attestation subnets. ~3x reduction - Better process block epoch boundary cache usages and bug fixes - Beacon-API endpoints optimizations and bug fixes @@ -1210,12 +1286,20 @@ Welcome to the v4.0.7 release of Prysm! This recommended release contains many e Highlights: - The validator proposal time for slot 0 has been reduced by 800ms. Writeup and PR -- The attestation aggregation time has been reduced by 400ms—roughly 75% with all subnets subscribed. Flag --aggregate-parallel. PR. This is only useful if running more than a dozen validator keys. The more subnets your node subscribe to, the more useful. -- The usage of fork choice lock has been reduced and optimized, significantly reducing block processing time. This results in a higher proposal and attest rate. PR -- The block proposal path has been optimized with more efficient copies and a better pruning algorithm for pending deposits. PR and PR -- Validator Registration cache is enabled by default, this affects users who have used webui along with mevboost. Please review PR for details. - -Note: We remind our users that there are two versions of the cryptographic library BLST, one is "portable" and less performant, and another is "non-portable" or "modern" and more performant. Most users would want to use the second one. You can set the environment variable USE_PRYSM_MODERN=true when using prysm.sh. The released docker images are using the non-portable version by default. +- The attestation aggregation time has been reduced by 400ms—roughly 75% with all subnets subscribed. Flag + --aggregate-parallel. PR. This is only useful if running more than a dozen validator keys. The more subnets your node + subscribe to, the more useful. +- The usage of fork choice lock has been reduced and optimized, significantly reducing block processing time. This + results in a higher proposal and attest rate. PR +- The block proposal path has been optimized with more efficient copies and a better pruning algorithm for pending + deposits. PR and PR +- Validator Registration cache is enabled by default, this affects users who have used webui along with mevboost. Please + review PR for details. + +Note: We remind our users that there are two versions of the cryptographic library BLST, one is "portable" and less +performant, and another is "non-portable" or "modern" and more performant. Most users would want to use the second one. +You can set the environment variable USE_PRYSM_MODERN=true when using prysm.sh. The released docker images are using the +non-portable version by default. ### Added @@ -1285,21 +1369,29 @@ No security updates in this release. ## [v4.0.6](https://github.com/prysmaticlabs/prysm/compare/v4.0.5...v4.0.6) - 2023-07-15 -Welcome to v4.0.6 release of Prysm! This recommended release contains many essential optimizations since v4.0.5. Notable highlights: +Welcome to v4.0.6 release of Prysm! This recommended release contains many essential optimizations since v4.0.5. Notable +highlights: Better handling of state field trie under late block scenario. This improves the next slot proposer's proposed time Better utilization of next slot cache under various conditions **Important read:** -1.) We use this opportunity to remind you that two different implementations of the underlying cryptographic library BLST exist. +1.) We use this opportunity to remind you that two different implementations of the underlying cryptographic library +BLST exist. - portable: supports every CPU made in the modern era - non-portable: more performant but requires your CPU to support special instructions -Most users will want to use the "non-portable" version since most CPUs support these instructions. Our docker builds are now non-portable by default. Most users will benefit from the performance improvements. You can run with the "portable" versions if your CPU is old or unsupported. For binary distributions and to maintain backward compatibility with older versions of prysm.sh or prysm.bat, users that want to benefit from the non-portable performance improvements need to add an environment variable, like so: USE_PRYSM_MODERN=true prysm.sh beacon-chain prefix, or download the "non-portable" version of the binaries from the github repo. +Most users will want to use the "non-portable" version since most CPUs support these instructions. Our docker builds are +now non-portable by default. Most users will benefit from the performance improvements. You can run with the "portable" +versions if your CPU is old or unsupported. For binary distributions and to maintain backward compatibility with older +versions of prysm.sh or prysm.bat, users that want to benefit from the non-portable performance improvements need to add +an environment variable, like so: USE_PRYSM_MODERN=true prysm.sh beacon-chain prefix, or download the "non-portable" +version of the binaries from the github repo. -2.) A peering bug that led to nodes losing peers gradually and eventually needing a restart has been patched. Nodes previously affected by it can remove the --disable-resource-manager flag from v4.0.6 onwards. +2.) A peering bug that led to nodes losing peers gradually and eventually needing a restart has been patched. Nodes +previously affected by it can remove the --disable-resource-manager flag from v4.0.6 onwards. ### Added @@ -1353,22 +1445,31 @@ No security updates in this release. ## [v4.0.5](https://github.com/prysmaticlabs/prysm/compare/v4.0.4...v4.0.5) - 2023-05-22 -Welcome to v4.0.5 release of Prysm! This release contains many important improvements and bug fixes since v4.0.4, including significant improvements to attestation aggregation. See @potuz's notes [here](https://hackmd.io/TtyFurRJRKuklG3n8lMO9Q). This release is **strongly** recommended for all users. +Welcome to v4.0.5 release of Prysm! This release contains many important improvements and bug fixes since v4.0.4, +including significant improvements to attestation aggregation. See @potuz's +notes [here](https://hackmd.io/TtyFurRJRKuklG3n8lMO9Q). This release is **strongly** recommended for all users. -Note: The released docker images are using the portable version of the blst cryptography library. The Prysm team will release docker images with the non-portable blst library as the default image. In the meantime, you can compile docker images with blst non-portable locally with the `--define=blst_modern=true` bazel flag, use the "-modern-" assets attached to releases, or set environment varaible USE_PRYSM_MODERN=true when using prysm.sh. +Note: The released docker images are using the portable version of the blst cryptography library. The Prysm team will +release docker images with the non-portable blst library as the default image. In the meantime, you can compile docker +images with blst non-portable locally with the `--define=blst_modern=true` bazel flag, use the "-modern-" assets +attached to releases, or set environment varaible USE_PRYSM_MODERN=true when using prysm.sh. ### Added - Added epoch and root to "not a checkpt in forkchoice" log message - Added cappella support for eth1voting tool - Persist validator proposer settings in the validator db. -- Add flag to disable p2p resource management. This flag is for debugging purposes and should not be used in production for extended periods of time. Use this flag if you are experiencing significant peering issues. --disable-resource-manager +- Add flag to disable p2p resource management. This flag is for debugging purposes and should not be used in production + for extended periods of time. Use this flag if you are experiencing significant peering issues. + --disable-resource-manager ### Changed - Improved slot ticker for attestation aggregation -- Parallel block production enabled by default. Opt out with --disable-build-block-parallel if issues are suspected with this feature. -- Improve attestation aggregation by not using max cover on unaggregated attestations and not checking subgroup of previously validated signatures. +- Parallel block production enabled by default. Opt out with --disable-build-block-parallel if issues are suspected with + this feature. +- Improve attestation aggregation by not using max cover on unaggregated attestations and not checking subgroup of + previously validated signatures. - Improve sync message processing by using forkchoice ### Fixed @@ -1383,14 +1484,17 @@ No security updates in this release. ## [v4.0.4](https://github.com/prysmaticlabs/prysm/compare/v4.0.3...v4.0.4) - 2023-05-15 -Welcome to v4.0.4 release of Prysm! This is the first full release following the recent mainnet issues and it is very important that all stakers update to this release as soon as possible. +Welcome to v4.0.4 release of Prysm! This is the first full release following the recent mainnet issues and it is very +important that all stakers update to this release as soon as possible. Aside from the critical fixes for mainnet, this release contains a number of new features and other fixes since v4.0.3. ### Added -- Feature to build consensus and execution blocks in parallel. This feature has shown a noticeable reduction (~200ms) in block proposal times. Enable with --build-block-parallel -- An in memory cache for validator registration can be enabled with --enable-registration-cache. See PR description before enabling. +- Feature to build consensus and execution blocks in parallel. This feature has shown a noticeable reduction (~200ms) in + block proposal times. Enable with --build-block-parallel +- An in memory cache for validator registration can be enabled with --enable-registration-cache. See PR description + before enabling. - Added new linters - Improved tracing data for builder pipeline - Improved withdrawal phrasing in validator withdrawal tooling @@ -1439,7 +1543,8 @@ Aside from the critical fixes for mainnet, this release contains a number of new ### Security -This release contains some important fixes that improve the resiliency of Ethereum Consensus Layer. See https://github.com/prysmaticlabs/prysm/pull/12387 and https://github.com/prysmaticlabs/prysm/pull/12398. +This release contains some important fixes that improve the resiliency of Ethereum Consensus Layer. +See https://github.com/prysmaticlabs/prysm/pull/12387 and https://github.com/prysmaticlabs/prysm/pull/12398. ## [v4.0.3](https://github.com/prysmaticlabs/prysm/compare/v4.0.2...v4.0.3) - 2023-04-20 @@ -1473,21 +1578,27 @@ No security updates in this release. ## [v4.0.2](https://github.com/prysmaticlabs/prysm/compare/v4.0.1...v4.0.2) - 2023-04-12 -This release fixes a critical bug on Prysm interacting with mev-boost / relayer. You MUST upgrade to this release if you run Prysm with mev boost and relayer, or you will be missing block proposals during the first days after the Shapella fork while the block has bls-to-exec changes. +This release fixes a critical bug on Prysm interacting with mev-boost / relayer. You MUST upgrade to this release if you +run Prysm with mev boost and relayer, or you will be missing block proposals during the first days after the Shapella +fork while the block has bls-to-exec changes. Post-mortem that describes this incident will be provided by the end of the week. -One of this release's main optimizations is revamping the next slot cache. It has been upgraded to be more performant across edge case re-org scenarios. This can help with the bad head attestation vote. +One of this release's main optimizations is revamping the next slot cache. It has been upgraded to be more performant +across edge case re-org scenarios. This can help with the bad head attestation vote. -Minor fixes in this release address a bug that affected certain large operators querying RPC endpoints. This bug caused unexpected behavior and may have impacted the performance of affected operators. To resolve this issue, we have included a patch that ensures proper functionality when querying RPC endpoints. +Minor fixes in this release address a bug that affected certain large operators querying RPC endpoints. This bug caused +unexpected behavior and may have impacted the performance of affected operators. To resolve this issue, we have included +a patch that ensures proper functionality when querying RPC endpoints. ### Added -- CLI: New beacon node flag local-block-value-boost that allows the local block value to be multiplied by the boost value +- CLI: New beacon node flag local-block-value-boost that allows the local block value to be multiplied by the boost + value - Smart caching for square root computation - Beacon-API: Implemented Block rewards endpoint - Beacon-API client: Implemented GetSyncStatus endpoint - Beacon-API client: Implemented GetGenesis endpoint -- Beacon-API client: Implemented ListValidators endpoint +- Beacon-API client: Implemented ListValidators endpoint ### Changed @@ -1565,7 +1676,6 @@ This is a reissue of v4.0.0. See https://github.com/prysmaticlabs/prysm/issues/1 - Test: disable e2e slasher test - CLI: derecate the following flags - ### Deprecated The following flags have been deprecated. @@ -1623,10 +1733,12 @@ This release is required to participate in the Capella upgrade. Gm! ☀️ We are excited to announce our release for upgrading Goerli testnet to Shanghai / Capella! 🚀 -This release is MANDATORY for Goerli testnet. You must upgrade your Prysm beacon node and validator client to this release before Shapella hard fork time epoch=162304 or UTC=14/03/2023, 10:25:36 pm. +This release is MANDATORY for Goerli testnet. You must upgrade your Prysm beacon node and validator client to this +release before Shapella hard fork time epoch=162304 or UTC=14/03/2023, 10:25:36 pm. This release is a low-priority for the mainnet. -This release is the same commit as v3.2.2-rc.3. If you are already running v3.2.2-rc.3, then you do not need to update your client. +This release is the same commit as v3.2.2-rc.3. If you are already running v3.2.2-rc.3, then you do not need to update +your client. ### Added @@ -1667,14 +1779,17 @@ This release is required for Goerli to upgrade to Capella. We are excited to announce the release of Prysm v3.2.1 🎉 -This is the first release to support Capella / Shanghai. The Sepolia testnet Capella upgrade time is currently set to 2/28/2023, 4:04:48 AM UTC. The Goerli testnet and Mainnet upgrade times are still yet to be determined. In Summary: +This is the first release to support Capella / Shanghai. The Sepolia testnet Capella upgrade time is currently set to +2/28/2023, 4:04:48 AM UTC. The Goerli testnet and Mainnet upgrade times are still yet to be determined. In Summary: - This is a mandatory upgrade for Sepolia nodes and validators - This is a recommended upgrade for Goerli and Mainnet nodes and validators There are some known issues with this release. -- mev-boost, relayer, and builder support for Capella upgrade are built in but still need to be tested. Given the lack of testing infrastructure, none of the clients could test this for withdrawals testnet. There may be hiccups when using mev-boost on the Capella upgraded testnets. +- mev-boost, relayer, and builder support for Capella upgrade are built in but still need to be tested. Given the lack + of testing infrastructure, none of the clients could test this for withdrawals testnet. There may be hiccups when + using mev-boost on the Capella upgraded testnets. ### Added @@ -1731,7 +1846,10 @@ There are no security updates in this release. ## [v3.2.0](https://github.com/prysmaticlabs/prysm/compare/v3.1.2...v3.2.0) - 2022-12-16 -This release contains a number of great features and improvements as well as progress towards the upcoming Capella upgrade. This release also includes some API changes which are reflected in the minor version bump. If you are using mev-boost, you will need to update your prysm client to v3.2.0 before updating your mev-boost instance in the future. See [flashbots/mev-boost#404](https://github.com/flashbots/mev-boost/issues/404) for more details. +This release contains a number of great features and improvements as well as progress towards the upcoming Capella +upgrade. This release also includes some API changes which are reflected in the minor version bump. If you are using +mev-boost, you will need to update your prysm client to v3.2.0 before updating your mev-boost instance in the future. +See [flashbots/mev-boost#404](https://github.com/flashbots/mev-boost/issues/404) for more details. ### Added @@ -1859,7 +1977,9 @@ This release contains a number of great features and improvements as well as pro ## [v3.1.1](https://github.com/prysmaticlabs/prysm/compare/v3.1.0...v3.1.1) - 2022-09-09 -This is another highly recommended release. It contains a forkchoice pruning fix and a gossipsub optimization. It is recommended to upgrade to this release before the Merge next week, which is currently tracking for Wed Sept 14 (https://bordel.wtf/). Happy staking! See you on the other side! +This is another highly recommended release. It contains a forkchoice pruning fix and a gossipsub optimization. It is +recommended to upgrade to this release before the Merge next week, which is currently tracking for Wed Sept +14 (https://bordel.wtf/). Happy staking! See you on the other side! ### Fixed @@ -1872,14 +1992,14 @@ No security updates in this release. ## [v3.1.0](https://github.com/prysmaticlabs/prysm/compare/v3.1.0...v3.0.0) - 2022-09-05 -Updating to this release is highly recommended as it contains several important fixes and features for the merge. You must be using Prysm v3 or later before Bellatrix activates on September 6th. +Updating to this release is highly recommended as it contains several important fixes and features for the merge. You +must be using Prysm v3 or later before Bellatrix activates on September 6th. **Important docs links** - [How to prepare for the merge](https://docs.prylabs.network/docs/prepare-for-merge) - [How to check merge readiness status](https://docs.prylabs.network/docs/monitoring/checking-status) - ### Added - Add time until next duty in epoch logs for validator @@ -1932,16 +2052,21 @@ There are no security updates in this release. - Keymanager: Add support for setting the gas limit via API. - Merge: Mainnet merge epoch and TTD defined! - Validator: Added expected wait time for pending validator activation in log message. -- Go: Prysm now uses proper versioning suffix v3 for this release. GoDocs and downstream users can now import prysm as expected for go projects. +- Go: Prysm now uses proper versioning suffix v3 for this release. GoDocs and downstream users can now import prysm as + expected for go projects. - Builder API: Register validator via HTTP REST Beacon API endpoint /eth/v1/validator/register_validator - Cross compilation support for Mac ARM64 chips (Mac M1, M2) ### Changed -- **Require an execution client** `--execution-endpoint=...`. The default value has changed to `localhost:8551` and you must use the jwt flag `--jwt-secret=...`. Review [the docs](https://docs.prylabs.network/docs/prepare-for-merge) for more information -- `--http-web3provider` has been renamed to `--execution-endpoint`. Please update your configuration as `--http-web3provider` will be removed in a future release. +- **Require an execution client** `--execution-endpoint=...`. The default value has changed to `localhost:8551` and you + must use the jwt flag `--jwt-secret=...`. Review [the docs](https://docs.prylabs.network/docs/prepare-for-merge) for + more information +- `--http-web3provider` has been renamed to `--execution-endpoint`. Please update your configuration + as `--http-web3provider` will be removed in a future release. - Insert attestations into forkchoice sooner -- Builder API: `gas_limit` changed from int to string to support JSON / YAML configs. `--suggested-gas-limit` changed from int to string. +- Builder API: `gas_limit` changed from int to string to support JSON / YAML configs. `--suggested-gas-limit` changed + from int to string. - Fork choice: Improved handling of double locks / deadlocks - Lower libp2p log level - Improved re-org logs with additional metadata @@ -1950,25 +2075,31 @@ There are no security updates in this release. - Protobuf message renaming (non-breaking changes) - Enabled feature to use gohashtree by default. Disable with `--disable-vectorized-htr` - Enabled fork choice doubly linked tree feature by default. Disable with `--disable-forkchoice-doubly-linked-tree` -- Remote signer: Renamed some field names to better represent block types (non-breaking changes for gRPC users, possibly breaking change for JSON API users) +- Remote signer: Renamed some field names to better represent block types (non-breaking changes for gRPC users, possibly + breaking change for JSON API users) - Builder API: require header and payload root match. - Improved responses for json-rpc requests batching when using blinded beacon blocks. - Builder API: Improved error messages -- Builder API: Issue warning when validator expects builder ready beacon node, but beacon node is not configured with a relay. +- Builder API: Issue warning when validator expects builder ready beacon node, but beacon node is not configured with a + relay. - Execution API: Improved payload ID to handle reorg scenarios ### Deprecated -- Several features have been promoted to stable or removed. The following flags are now deprecated and will be removed in a future release. `--enable-db-backup-webhook`, `--bolt-mmap-initial-size`, `--disable-discv5`, `--disable-attesting-history-db-cache`, `--enable-vectorized-htr`, `--enable-peer-scorer`, `--enable-forkchoice-doubly-linked-tree`, `--enable-duty-count-down`, `--head-sync`, `--enable-gossip-batch-aggregateion`, `--enable-larger-gossip-history`, `--fallback-web3provider`, `--use-check-point-cache`. +- Several features have been promoted to stable or removed. The following flags are now deprecated and will be removed + in a future + release. `--enable-db-backup-webhook`, `--bolt-mmap-initial-size`, `--disable-discv5`, `--disable-attesting-history-db-cache`, `--enable-vectorized-htr`, `--enable-peer-scorer`, `--enable-forkchoice-doubly-linked-tree`, `--enable-duty-count-down`, `--head-sync`, `--enable-gossip-batch-aggregateion`, `--enable-larger-gossip-history`, `--fallback-web3provider`, `--use-check-point-cache`. - Several beacon API endpoints marked as deprecated ### Removed - Logging: Removed phase0 fields from validator performance log messages - Deprecated slasher protos have been removed -- Deprecated beacon API endpoints removed: `GetBeaconState`, `ProduceBlock`, `ListForkChoiceHeads`, `ListBlocks`, `SubmitValidatorRegistration`, `GetBlock`, `ProposeBlock` +- Deprecated beacon API endpoints + removed: `GetBeaconState`, `ProduceBlock`, `ListForkChoiceHeads`, `ListBlocks`, `SubmitValidatorRegistration`, `GetBlock`, `ProposeBlock` - API: Forkchoice method `GetForkChoice` has been removed. -- All previously deprecated feature flags have been removed. `--enable-active-balance-cache`, `--correctly-prune-canonical-atts`, `--correctly-insert-orphaned-atts`, `--enable-next-slot-state-cache`, `--enable-batch-gossip-verification`, `--enable-get-block-optimizations`, `--enable-balance-trie-computation`, `--disable-next-slot-state-cache`, `--attestation-aggregation-strategy`, `--attestation-aggregation-force-opt-maxcover`, `--pyrmont`, `--disable-get-block-optimizations`, `--disable-proposer-atts-selection-using-max-cover`, `--disable-optimized-balance-update`, `--disable-active-balance-cache`, `--disable-balance-trie-computation`, `--disable-batch-gossip-verification`, `--disable-correctly-prune-canonical-atts`, `--disable-correctly-insert-orphaned-atts`, `--enable-native-state`, `--enable-peer-scorer`, `--enable-gossip-batch-aggregation`, `--experimental-disable-boundry-checks` +- All previously deprecated feature flags have been + removed. `--enable-active-balance-cache`, `--correctly-prune-canonical-atts`, `--correctly-insert-orphaned-atts`, `--enable-next-slot-state-cache`, `--enable-batch-gossip-verification`, `--enable-get-block-optimizations`, `--enable-balance-trie-computation`, `--disable-next-slot-state-cache`, `--attestation-aggregation-strategy`, `--attestation-aggregation-force-opt-maxcover`, `--pyrmont`, `--disable-get-block-optimizations`, `--disable-proposer-atts-selection-using-max-cover`, `--disable-optimized-balance-update`, `--disable-active-balance-cache`, `--disable-balance-trie-computation`, `--disable-batch-gossip-verification`, `--disable-correctly-prune-canonical-atts`, `--disable-correctly-insert-orphaned-atts`, `--enable-native-state`, `--enable-peer-scorer`, `--enable-gossip-batch-aggregation`, `--experimental-disable-boundry-checks` - Validator Web API: Removed unused ImportAccounts and DeleteAccounts rpc options ### Fixed @@ -1985,44 +2116,50 @@ There are no security updates in this release. ## [v2.1.4](https://github.com/prysmaticlabs/prysm/compare/v2.1.4...v2.1.3) - 2022-08-10 -As we prepare our `v3` mainnet release for [The Merge](https://ethereum.org/en/upgrades/merge/), `v2.1.4` marks the end of the `v2` era. Node operators and validators are **highly encouraged** to upgrade to release `v2.1.4` - many bug fixes and improvements have been included in preparation for The Merge. `v3` will contain breaking changes, and will be released within the next few weeks. Using `v2.1.4` in the meantime will give you access to a more streamlined user experience. See our [v2.1.4 doc](https://docs.prylabs.network/docs/vnext/214-rc) to learn how to use v2.1.4 to run a Merge-ready configuration on the Goerli-Prater network pair. +As we prepare our `v3` mainnet release for [The Merge](https://ethereum.org/en/upgrades/merge/), `v2.1.4` marks the end +of the `v2` era. Node operators and validators are **highly encouraged** to upgrade to release `v2.1.4` - many bug fixes +and improvements have been included in preparation for The Merge. `v3` will contain breaking changes, and will be +released within the next few weeks. Using `v2.1.4` in the meantime will give you access to a more streamlined user +experience. See our [v2.1.4 doc](https://docs.prylabs.network/docs/vnext/214-rc) to learn how to use v2.1.4 to run a +Merge-ready configuration on the Goerli-Prater network pair. ### Added - Sepolia testnet configs `--sepolia` -- Goerli as an alias to Prater and testnet configs `--prater` or `--goerli` +- Goerli as an alias to Prater and testnet configs `--prater` or `--goerli` - Fee recipient API for key manager - YML config flag support for web3 signer -- Validator registration API for web3 signer +- Validator registration API for web3 signer - JSON tcontent type with optional metadata -- Flashbots MEV boost support -- Store blind block (i.e block with payload header) instead of full block (i.e. block with payload) for storage efficiency (currently only available when the `enable-only-blinded-beacon-blocks` feature flag is enabled) -- Pcli utility support to print blinded block +- Flashbots MEV boost support +- Store blind block (i.e block with payload header) instead of full block (i.e. block with payload) for storage + efficiency (currently only available when the `enable-only-blinded-beacon-blocks` feature flag is enabled) +- Pcli utility support to print blinded block - New Web v2.0 release into Prysm ### Changed -- Native state improvement is enabled by default -- Use native blocks instead of protobuf blocks +- Native state improvement is enabled by default +- Use native blocks instead of protobuf blocks - Peer scorer is enabled by default -- Enable fastssz to use vectorized HTR hash algorithm improvement +- Enable fastssz to use vectorized HTR hash algorithm improvement - Forkchoice store refactor and cleanups -- Update libp2p library dependency -- RPC proposer duty is now allowed next epoch query +- Update libp2p library dependency +- RPC proposer duty is now allowed next epoch query - Do not print traces with `log.withError(err)` - Testnets are running with pre-defined feature flags ### Removed -- Deprecate Step Parameter from our Block By Range Requests +- Deprecate Step Parameter from our Block By Range Requests ### Fixed -- Ignore nil forkchoice node when saving orphaned atts -- Sync: better handling of missing state summary in DB -- Validator: creates invalid terminal block using the same timestamp as payload -- P2P: uses incorrect goodbye codes -- P2p: defaults Incorrectly to using Mplex, which results in losing Teku peers +- Ignore nil forkchoice node when saving orphaned atts +- Sync: better handling of missing state summary in DB +- Validator: creates invalid terminal block using the same timestamp as payload +- P2P: uses incorrect goodbye codes +- P2p: defaults Incorrectly to using Mplex, which results in losing Teku peers - Disable returning future state for API - Eth1 connection API panic @@ -2036,14 +2173,15 @@ There are no security updates in this release. - Many fuzz test additions - Support bellatrix blocks with web3signer -- Support for the Sepolia testnet with `--terminal-total-difficulty-override 17000000000000000`. The override flag is required in this release. +- Support for the Sepolia testnet with `--terminal-total-difficulty-override 17000000000000000`. The override flag is + required in this release. - Support for the Ropsten testnet. No override flag required - JSON API allows SSZ-serialized blocks in `publishBlock` - JSON API allows SSZ-serialized blocks in `publishBlindedBlock` - JSON API allows SSZ-serialized requests in `produceBlockV2` and `produceBlindedBlock` - Progress towards Builder API and MEV boost support (not ready for testing in this release) - Support for `DOMAIN_APPLICATION_MARK` configuration -- Ignore subset aggregates if a better aggregate has been seen already +- Ignore subset aggregates if a better aggregate has been seen already - Reinsertion of reorg'd attestations - Command `beacon-chain generate-auth-secret` to assist with generating a hex encoded secret for engine API - Return optimistic status to `ChainHead` related grpc service @@ -2053,7 +2191,7 @@ There are no security updates in this release. ### Changed - Improvements to forkchoice -- Invalid checksummed (or no checksum) addresses used for fee recipient will log a warning. fixes, +- Invalid checksummed (or no checksum) addresses used for fee recipient will log a warning. fixes, - Use cache backed `getBlock` method in several places of blockchain package - Reduced log frequency of "beacon node doesn't have a parent in db with root" error - Improved nil checks for state management @@ -2063,26 +2201,27 @@ There are no security updates in this release. - Handle connection closing for web3/eth1 nil connection - Testing improvements - E2E test improvements -- Increase file descriptor limit up to the maximum by default +- Increase file descriptor limit up to the maximum by default - Improved classification of "bad blocks" - Updated engine API error code handling - Improved "Synced new block" message to include minimal information based on the log verbosity. - Add nil checks for nil finalized checkpoints -- Change weak subjectivity sync to use the most recent finalized state rather than the oldest state within the current period. +- Change weak subjectivity sync to use the most recent finalized state rather than the oldest state within the current + period. - Ensure a finalized root can't be all zeros -- Improved db lookup of HighestSlotBlocksBelow to start from the end of the index rather than the beginning. +- Improved db lookup of HighestSlotBlocksBelow to start from the end of the index rather than the beginning. - Improved packing of state balances for hashtreeroot - Improved field trie recomputation ### Removed -- Removed handling of `INVALID_TERMINAL_BLOCK` response from engine API +- Removed handling of `INVALID_TERMINAL_BLOCK` response from engine API ### Fixed - `/eth/v1/beacon/blinded_blocks` JSON API endpoint - SSZ handling of JSON API payloads -- Config registry fixes +- Config registry fixes - Withdrawal epoch overflows - Race condition with blockchain service Head() - Race condition with validator's highest valid slot accessor @@ -2115,11 +2254,12 @@ There are no security updates in this release. ### Removed - Prymont testnet support -- Flag `disable-proposer-atts-selection-using-max-cover` which disables defaulting max cover strategy for proposer selecting attestations +- Flag `disable-proposer-atts-selection-using-max-cover` which disables defaulting max cover strategy for proposer + selecting attestations - Flag `disable-get-block-optimizations` which disables optimization with beacon block construction - Flag `disable-optimized-balance-update"` which disables optimized effective balance update - Flag `disable-active-balance-cache` which disables active balance cache -- Flag `disable-balance-trie-computation` which disables balance trie optimization for hash tree root +- Flag `disable-balance-trie-computation` which disables balance trie optimization for hash tree root - Flag `disable-batch-gossip-verification` which disables batch gossip verification - Flag `disable-correctly-insert-orphaned-atts` which disables the fix for orphaned attestations insertion @@ -2139,45 +2279,54 @@ This patch release includes 3 cherry picked fixes for regressions found in v2.1. View the full changelist from v2.1.0: https://github.com/prysmaticlabs/prysm/compare/v2.1.0...v2.1.1 -If upgrading from v2.0.6, please review the [full changelist](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.1) of both v2.1.0 and v2.1.1. +If upgrading from v2.0.6, please review +the [full changelist](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.1) of both v2.1.0 and v2.1.1. This release is required for users on v2.1.0 and recommended for anyone on v2.0.6. The following known issues exist in v2.1.0 and also exist in this release. - -- Erroneous warning message in validator client when bellatrix fee recipient is unset. This is a cosmetic message and does not affect run time behavior in Phase0/Altair. + +- Erroneous warning message in validator client when bellatrix fee recipient is unset. This is a cosmetic message and + does not affect run time behavior in Phase0/Altair. - In Bellatrix/Kiln: Fee recipient flags may not work as expected. See for a fix and more details. ### Fixed -- Doppelganger false positives may have caused a failure to start in the validator client. -- Connections to execution layer clients were not properly cleaned up and lead to resource leaks when using ipc. -- Initial sync (or resync when beacon node falls out of sync) could lead to a panic. +- Doppelganger false positives may have caused a failure to start in the validator client. +- Connections to execution layer clients were not properly cleaned up and lead to resource leaks when using ipc. +- Initial sync (or resync when beacon node falls out of sync) could lead to a panic. ### Security There are no security updates in this release. -## [v2.1.0](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.0) - 2022-04-26 +## [v2.1.0](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.0) - 2022-04-26 There are two known issues with this release: -- Erroneous warning message in validator client when bellatrix fee recipient is unset. This is a cosmetic message and does not affect run time behavior in Phase0/Altair. +- Erroneous warning message in validator client when bellatrix fee recipient is unset. This is a cosmetic message and + does not affect run time behavior in Phase0/Altair. - In Bellatrix/Kiln: Fee recipient flags may not work as expected. See for a fix and more details. ### Added -- Web3Signer support. See the [documentation](https://docs.prylabs.network/docs/next/wallet/web3signer) for more details. +- Web3Signer support. See the [documentation](https://docs.prylabs.network/docs/next/wallet/web3signer) for more + details. - Bellatrix support. See [kiln testnet instructions](https://hackmd.io/OqIoTiQvS9KOIataIFksBQ?view) -- Weak subjectivity sync / checkpoint sync. This is an experimental feature and may have unintended side effects for certain operators serving historical data. See the [documentation](https://docs.prylabs.network/docs/next/prysm-usage/checkpoint-sync) for more details. -- A faster build of blst for beacon chain on linux amd64. Use the environment variable `USE_PRYSM_MODERN=true` with prysm.sh, use the "modern" binary, or bazel build with `--define=blst_modern=true`. +- Weak subjectivity sync / checkpoint sync. This is an experimental feature and may have unintended side effects for + certain operators serving historical data. See + the [documentation](https://docs.prylabs.network/docs/next/prysm-usage/checkpoint-sync) for more details. +- A faster build of blst for beacon chain on linux amd64. Use the environment variable `USE_PRYSM_MODERN=true` with + prysm.sh, use the "modern" binary, or bazel build with `--define=blst_modern=true`. - Vectorized sha256. This may have performance improvements with use of the new flag `--enable-vectorized-htr`. -- A new forkchoice structure that uses a doubly linked tree implementation. Try this feature with the flag `--enable-forkchoice-doubly-linked-tree` +- A new forkchoice structure that uses a doubly linked tree implementation. Try this feature with the + flag `--enable-forkchoice-doubly-linked-tree` - Fork choice proposer boost is implemented and enabled by default. See PR description for more details. ### Changed -- **Flag Default Change** The default value for `--http-web3provider` is now `localhost:8545`. Previously was empty string. +- **Flag Default Change** The default value for `--http-web3provider` is now `localhost:8545`. Previously was empty + string. - Updated spectest compliance to v1.1.10. - Updated to bazel 5.0.0 - Gossip peer scorer is now part of the `--dev` flag. @@ -2188,7 +2337,8 @@ There are two known issues with this release: ### Fixed -Too many bug fixes and improvements to mention all of them. See the [full changelist](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.0) +Too many bug fixes and improvements to mention all of them. See +the [full changelist](https://github.com/prysmaticlabs/prysm/compare/v2.0.6...v2.1.0) ### Security @@ -2280,7 +2430,9 @@ There are no security updates in this release. ### Deprecated -Please be advised that Prysm's package path naming will change in the next release. If you are a downstream user of Prysm (i.e. import prysm libraries into your project) then you may be impacted. Please see issue https://github.com/prysmaticlabs/prysm/issues/10006. +Please be advised that Prysm's package path naming will change in the next release. If you are a downstream user of +Prysm (i.e. import prysm libraries into your project) then you may be impacted. Please see +issue https://github.com/prysmaticlabs/prysm/issues/10006. ### Fixed @@ -2309,7 +2461,8 @@ Please be advised that Prysm's package path naming will change in the next relea ### Fixed -- Revert PR [9830](https://github.com/prysmaticlabs/prysm/pull/9830) to remove performance regression. See: issue [9935](https://github.com/prysmaticlabs/prysm/issues/9935) +- Revert PR [9830](https://github.com/prysmaticlabs/prysm/pull/9830) to remove performance regression. See: + issue [9935](https://github.com/prysmaticlabs/prysm/issues/9935) ### Security @@ -2317,7 +2470,8 @@ No security updates in this release. ## [v2.0.3](https://github.com/prysmaticlabs/prysm/compare/v2.0.2...v2.0.3) - 2021-11-22 -This release also includes a major update to the web UI. Please review the v1 web UI notes [here](https://github.com/prysmaticlabs/prysm-web-ui/releases/tag/v1.0.0) +This release also includes a major update to the web UI. Please review the v1 web UI +notes [here](https://github.com/prysmaticlabs/prysm-web-ui/releases/tag/v1.0.0) ### Added @@ -2375,7 +2529,8 @@ This release also includes a major update to the web UI. Please review the v1 we ### Removed -- Prysmatic Labs' [go-ethereum fork](https://github.com/prysmaticlabs/bazel-go-ethereum) removed from build tooling. Upstream go-ethereum is now used with familiar go.mod tooling. +- Prysmatic Labs' [go-ethereum fork](https://github.com/prysmaticlabs/bazel-go-ethereum) removed from build tooling. + Upstream go-ethereum is now used with familiar go.mod tooling. - Removed duplicate aggergation validation p2p pipelines. - Metrics calculation removed extra condition - Removed superflous errors from peer scoring parameters registration @@ -2386,7 +2541,8 @@ This release also includes a major update to the web UI. Please review the v1 we - Ignore validators without committee assignment when fetching attester duties - Return "version" field for ssz blocks in beacon API - Fixed bazel build transitions for dbg builds. Allows IDEs to hook into debugger again. -- Fixed case where GetDuties RPC endpoint might return a false positive for sync committee selection for validators that have no deposited yet +- Fixed case where GetDuties RPC endpoint might return a false positive for sync committee selection for validators that + have no deposited yet - Fixed validator exits in v1 method, broadcast correct object - Fix Altair individual votes endpoint - Validator performance calculations fixed @@ -2395,7 +2551,7 @@ This release also includes a major update to the web UI. Please review the v1 we - Fix stategen with genesis state. - Fixed multiple typos - Fix genesis state registration in interop mode -- Fix network flags in slashing protection export +- Fix network flags in slashing protection export ### Security @@ -2405,7 +2561,9 @@ This release also includes a major update to the web UI. Please review the v1 we ### Added -- Optimizations to block proposals. Enabled with `--enable-get-block-optimizations`. See [issue 8943](https://github.com/prysmaticlabs/prysm/issues/8943) and [issue 9708](https://github.com/prysmaticlabs/prysm/issues/9708) before enabling. +- Optimizations to block proposals. Enabled with `--enable-get-block-optimizations`. + See [issue 8943](https://github.com/prysmaticlabs/prysm/issues/8943) + and [issue 9708](https://github.com/prysmaticlabs/prysm/issues/9708) before enabling. - Beacon Standard API: register v1alpha2 endpoints ### Changed @@ -2453,64 +2611,87 @@ We've updated the Prysm base docker images to a more recent build. ## [v2.0.0](https://github.com/prysmaticlabs/prysm/compare/v1.4.4...v2.0.0) -This release is the largest release of Prysm to date. v2.0.0 includes support for the upcoming Altair hard fork on the mainnet Ethereum Beacon Chain. -This release consists of [380 changes](https://github.com/prysmaticlabs/prysm/compare/v1.4.4...f7845afa575963302116e673d400d2ab421252ac) to support Altair, improve performance of phase0 beacon nodes, and various bug fixes from v1.4.4. +This release is the largest release of Prysm to date. v2.0.0 includes support for the upcoming Altair hard fork on the +mainnet Ethereum Beacon Chain. +This release consists +of [380 changes](https://github.com/prysmaticlabs/prysm/compare/v1.4.4...f7845afa575963302116e673d400d2ab421252ac) to +support Altair, improve performance of phase0 beacon nodes, and various bug fixes from v1.4.4. ### Upgrading From v1 -Please update your beacon node to v2.0.0 prior to updating your validator. The beacon node can serve requests to a v1.4.4 validator, however a v2.0.0 validator will not start against a v1.4.4 beacon node. If you're operating a highly available beacon chain service, ensure that all of your beacon nodes are updated to v2.0.0 before starting the upgrade on your validators. +Please update your beacon node to v2.0.0 prior to updating your validator. The beacon node can serve requests to a +v1.4.4 validator, however a v2.0.0 validator will not start against a v1.4.4 beacon node. If you're operating a highly +available beacon chain service, ensure that all of your beacon nodes are updated to v2.0.0 before starting the upgrade +on your validators. ### Added -- Full Altair support. [Learn more about Altair.](https://github.com/ethereum/annotated-spec/blob/8473024d745a3a2b8a84535d57773a8e86b66c9a/altair/beacon-chain.md) +- Full Altair + support. [Learn more about Altair.](https://github.com/ethereum/annotated-spec/blob/8473024d745a3a2b8a84535d57773a8e86b66c9a/altair/beacon-chain.md) - Added bootnodes from the Nimbus team. -- Revamped slasher implementation. The slasher functionality is no longer a standalone binary. Slasher functionality is available from the beacon node with the `--slasher` flag. Note: Running the slasher has considerably increased resource requirements. Be sure to review the latest documentation before enabling this feature. This feature is experimental. +- Revamped slasher implementation. The slasher functionality is no longer a standalone binary. Slasher functionality is + available from the beacon node with the `--slasher` flag. Note: Running the slasher has considerably increased + resource requirements. Be sure to review the latest documentation before enabling this feature. This feature is + experimental. - Support for standard JSON API in the beacon node. Prysm validators continue to use Prysm's API. -- Configurable subnet peer requirements. Increased minimum desired peers per subnet from 4 to 6. This can be modified with `--minimum-peers-per-subnet` in the beacon node.. +- Configurable subnet peer requirements. Increased minimum desired peers per subnet from 4 to 6. This can be modified + with `--minimum-peers-per-subnet` in the beacon node.. - Support for go build on darwin_arm64 devices (Mac M1 chips). Cross compiling for darwin_arm64 is not yet supported.. - Batch verification of pubsub objects. This should improve pubsub processing performance on multithreaded machines. -- Improved attestation pruning. This feature should improve block proposer performance and overall network attestation inclusion rates. Opt-out with `--disable-correctly-prune-canonical-atts` in the beacon node. +- Improved attestation pruning. This feature should improve block proposer performance and overall network attestation + inclusion rates. Opt-out with `--disable-correctly-prune-canonical-atts` in the beacon node. - Active balance cache to improve epoch processing. Opt-out with `--disable-active-balance-cache` -- Experimental database improvements to reduce history state entry space usage in the beaconchain.db. This functionality can be permanently enabled with the flag `--enable-historical-state-representation`. Enabling this feature can realize a 25% improvement in space utilization for the average user , while 70 -80% for power users(archival node operators). Note: once this feature is toggled on, it modifies the structure of the database with a migration and cannot be rolled back. This feature is experimental and should only be used in non-serving beacon nodes in case of database corruption or other critical issue. +- Experimental database improvements to reduce history state entry space usage in the beaconchain.db. This functionality + can be permanently enabled with the flag `--enable-historical-state-representation`. Enabling this feature can realize + a 25% improvement in space utilization for the average user , while 70 -80% for power users(archival node operators). + Note: once this feature is toggled on, it modifies the structure of the database with a migration and cannot be rolled + back. This feature is experimental and should only be used in non-serving beacon nodes in case of database corruption + or other critical issue. #### New Metrics **Beacon chain node** -| Metric | Description | References | -|--------------------------------------------------|-------------------------------------------------------------------------------------------------------|-------------| -| `p2p_message_ignored_validation_total` | Count of messages that were ignored in validation | | -| `beacon_current_active_validators` | Current total active validators | | -| `beacon_processed_deposits_total` | Total number of deposits processed | | -| `sync_head_state_miss` | The number of sync head state requests that are not present in the cache | | -| `sync_head_state_hit` | The number of sync head state requests that are present in the cache | | -| `total_effective_balance_cache_miss` | The number of get requests that are not present in the cache | | -| `total_effective_balance_cache_hit` | The number of get requests that are present in the cache | | -| `sync_committee_index_cache_miss_total` | The number of committee requests that aren't present in the sync committee index cache | | -| `sync_committee_index_cache_hit_total` | The number of committee requests that are present in the sync committee index cache | | -| `next_slot_cache_hit` | The number of cache hits on the next slot state cache | | -| `next_slot_cache_miss` | The number of cache misses on the next slot state cache | | -| `validator_entry_cache_hit_total` | The number of cache hits on the validator entry cache | | -| `validator_entry_cache_miss_total` | The number of cache misses on the validator entry cache | | -| `validator_entry_cache_delete_total` | The number of cache deletes on the validator entry cache | | -| `saved_sync_committee_message_total` | The number of saved sync committee message total | | -| `saved_sync_committee_contribution_total` | The number of saved sync committee contribution total | | -| `libp2p_peers` | Tracks the total number of libp2p peers | | -| `p2p_status_message_missing` | The number of attempts the connection handler rejects a peer for a missing status message | | -| `p2p_sync_committee_subnet_recovered_broadcasts` | The number of sync committee messages that were attempted to be broadcast with no peers on the subnet | | -| `p2p_sync_committee_subnet_attempted_broadcasts` | The number of sync committees that were attempted to be broadcast | | -| `p2p_subscribed_topic_peer_total` | The number of peers subscribed to topics that a host node is also subscribed to | | -| `saved_orphaned_att_total` | Count the number of times an orphaned attestation is saved | | +| Metric | Description | References | +|--------------------------------------------------|-------------------------------------------------------------------------------------------------------|------------| +| `p2p_message_ignored_validation_total` | Count of messages that were ignored in validation | | +| `beacon_current_active_validators` | Current total active validators | | +| `beacon_processed_deposits_total` | Total number of deposits processed | | +| `sync_head_state_miss` | The number of sync head state requests that are not present in the cache | | +| `sync_head_state_hit` | The number of sync head state requests that are present in the cache | | +| `total_effective_balance_cache_miss` | The number of get requests that are not present in the cache | | +| `total_effective_balance_cache_hit` | The number of get requests that are present in the cache | | +| `sync_committee_index_cache_miss_total` | The number of committee requests that aren't present in the sync committee index cache | | +| `sync_committee_index_cache_hit_total` | The number of committee requests that are present in the sync committee index cache | | +| `next_slot_cache_hit` | The number of cache hits on the next slot state cache | | +| `next_slot_cache_miss` | The number of cache misses on the next slot state cache | | +| `validator_entry_cache_hit_total` | The number of cache hits on the validator entry cache | | +| `validator_entry_cache_miss_total` | The number of cache misses on the validator entry cache | | +| `validator_entry_cache_delete_total` | The number of cache deletes on the validator entry cache | | +| `saved_sync_committee_message_total` | The number of saved sync committee message total | | +| `saved_sync_committee_contribution_total` | The number of saved sync committee contribution total | | +| `libp2p_peers` | Tracks the total number of libp2p peers | | +| `p2p_status_message_missing` | The number of attempts the connection handler rejects a peer for a missing status message | | +| `p2p_sync_committee_subnet_recovered_broadcasts` | The number of sync committee messages that were attempted to be broadcast with no peers on the subnet | | +| `p2p_sync_committee_subnet_attempted_broadcasts` | The number of sync committees that were attempted to be broadcast | | +| `p2p_subscribed_topic_peer_total` | The number of peers subscribed to topics that a host node is also subscribed to | | +| `saved_orphaned_att_total` | Count the number of times an orphaned attestation is saved | | ### Changed - Much refactoring of "util" packages into more canonical packages. Please review Prysm package structure and godocs. -- Altair object keys in beacon-chain/db/kv are prefixed with "altair". BeaconBlocks and BeaconStates are the only objects affected by database key changes for Altair. This affects any third party tooling directly querying Prysm's beaconchain.db. +- Altair object keys in beacon-chain/db/kv are prefixed with "altair". BeaconBlocks and BeaconStates are the only + objects affected by database key changes for Altair. This affects any third party tooling directly querying Prysm's + beaconchain.db. - Updated Teku bootnodes. - Updated Lighthouse bootnodes. - End to end testing now collects jaeger spans - Improvements to experimental peer quality scoring. This feature is only enabled with `--enable-peer-scorer`. -- Validator performance logging behavior has changed in Altair. Post-Altair hardfork has the following changes: Inclusion distance and inclusion slots will no longer be displayed. Correctly voted target will only be true if also included within 32 slots. Correctly voted head will only be true if the attestation was included in the next slot. Correctly voted source will only be true if attestation is included within 5 slots. Inactivity score will be displayed. +- Validator performance logging behavior has changed in Altair. Post-Altair hardfork has the following changes: + Inclusion distance and inclusion slots will no longer be displayed. Correctly voted target will only be true if also + included within 32 slots. Correctly voted head will only be true if the attestation was included in the next slot. + Correctly voted source will only be true if attestation is included within 5 slots. Inactivity score will be + displayed. - Increased pubsub message queue size from 256 to 600 to support larger networks and higher message volume. - The default attestation aggregation changed to the improved optimized max cover algorithm. - Prysm is passing spectests at v1.1.0 (latest available release). @@ -2523,13 +2704,15 @@ Please update your beacon node to v2.0.0 prior to updating your validator. The b #### Changed Metrics **Beacon chain node** -| Metric | Old Name | Description | References | +| Metric | Old Name | Description | References | |-----------------------|----------------------|------------------------------------------------------|------------| -| `beacon_reorgs_total` | `beacon_reorg_total` | Count the number of times a beacon chain has a reorg | | +| `beacon_reorgs_total` | `beacon_reorg_total` | Count the number of times a beacon chain has a reorg | | ### Deprecated -These flags are hidden from the help text and no longer modify the behavior of Prysm. These flags should be removed from user runtime configuration as the flags will eventually be removed entirely and Prysm will fail to start if a deleted or unknown flag is provided. +These flags are hidden from the help text and no longer modify the behavior of Prysm. These flags should be removed from +user runtime configuration as the flags will eventually be removed entirely and Prysm will fail to start if a deleted or +unknown flag is provided. - `--enable-active-balance-cache` - `--correctly-prune-canonical-atts` @@ -2541,17 +2724,24 @@ These flags are hidden from the help text and no longer modify the behavior of P Note: Removed flags will block starting up with an error "flag provided but not defined:". Please check that you are not using any of the removed flags in this section! -- Prysm's standalone slasher application (cmd/slasher) has been fully removed. Use the `--slasher` flag with a beacon chain node for full slasher functionality. -- `--disable-blst` (beacon node and validator). [blst](https://github.com/supranational/blst) is the only BLS library offered for Prysm. -- `--disable-sync-backtracking` and `--enable-sync-backtracking` (beacon node). This feature has been released for some time. See. +- Prysm's standalone slasher application (cmd/slasher) has been fully removed. Use the `--slasher` flag with a beacon + chain node for full slasher functionality. +- `--disable-blst` (beacon node and validator). [blst](https://github.com/supranational/blst) is the only BLS library + offered for Prysm. +- `--disable-sync-backtracking` and `--enable-sync-backtracking` (beacon node). This feature has been released for some + time. See. - `--diable-pruning-deposit-proofs` (beacon node). This feature has been released for some time. See. - `--disable-eth1-data-majority-vote` (beacon node). This feature is no longer in use in Prysm. See,. - `--proposer-atts-selection-using-max-cover` (beacon node). This feature has been released for some time. See. - `--update-head-timely` (beacon node). This feature was released in v1.4.4. See. - `--enable-optimized-balance-update` (beacon node). This feature was released in v1.4.4. See. -- Kafka support is no longer available in the beacon node. This functionality was never fully completed and did not fulfill many desirable use cases. This removed the flag `--kafka-url` (beacon node). See. -- Removed tools/faucet. Use the faucet in [prysmaticlabs/periphery](https://github.com/prysmaticlabs/periphery/tree/c2ac600882c37fc0f2a81b0508039124fb6bcf47/eth-faucet) if operating a testnet faucet server. -- Tooling for prior testnet contracts has been removed. Any of the old testnet contracts with `drain()` function have been removed as well. +- Kafka support is no longer available in the beacon node. This functionality was never fully completed and did not + fulfill many desirable use cases. This removed the flag `--kafka-url` (beacon node). See. +- Removed tools/faucet. Use the faucet + in [prysmaticlabs/periphery](https://github.com/prysmaticlabs/periphery/tree/c2ac600882c37fc0f2a81b0508039124fb6bcf47/eth-faucet) + if operating a testnet faucet server. +- Tooling for prior testnet contracts has been removed. Any of the old testnet contracts with `drain()` function have + been removed as well. - Toledo tesnet config is removed. - Removed --eth-api-port (beacon node). All APIs interactions have been moved to --grpc-gateway-port. See. @@ -2569,10 +2759,14 @@ Please check that you are not using any of the removed flags in this section! ### Security -- You MUST update to v2.0.0 or later release before epoch 74240 or your client will fork off from the rest of the network. -- Prysm's JWT library has been updated to a maintained version of the previous JWT library. JWTs are only used in the UI. +- You MUST update to v2.0.0 or later release before epoch 74240 or your client will fork off from the rest of the + network. +- Prysm's JWT library has been updated to a maintained version of the previous JWT library. JWTs are only used in the + UI. + +Please review our newly +updated [security reporting policy](https://github.com/prysmaticlabs/prysm/blob/develop/SECURITY.md). -Please review our newly updated [security reporting policy](https://github.com/prysmaticlabs/prysm/blob/develop/SECURITY.md). - Fix subcommands such as validator accounts list ### Security From 300670dad9ce9fa28c0eb05ab3a7287ff4725f0b Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Tue, 3 Sep 2024 03:12:07 +0200 Subject: [PATCH 27/34] fix lint errors --- api/server/structs/conversions_lightclient.go | 2 -- beacon-chain/core/light-client/lightclient.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/api/server/structs/conversions_lightclient.go b/api/server/structs/conversions_lightclient.go index 367f3b116106..a4f8bad55dbf 100644 --- a/api/server/structs/conversions_lightclient.go +++ b/api/server/structs/conversions_lightclient.go @@ -48,11 +48,9 @@ func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapRes return nil, err } result.Data.Header = &x - } return &result, nil - } func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index e6c5e13ee1fc..7d8ea944e176 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -39,7 +39,6 @@ const ( // signature_slot=update.signature_slot, // ) func CreateLightClientFinalityUpdate(update *ethpbv2.LightClientUpdate) *ethpbv2.LightClientFinalityUpdate { - finalityUpdate := ðpbv2.LightClientFinalityUpdate{ AttestedHeader: update.AttestedHeader, FinalizedHeader: update.FinalizedHeader, @@ -275,7 +274,6 @@ func NewLightClientFinalityUpdateFromBeaconState( StateRoot: make([]byte, 32), BodyRoot: make([]byte, 32), } - } var bErr error From baf384f307f5be84eb8932332fcf966c300843eb Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Wed, 4 Sep 2024 21:49:40 +0200 Subject: [PATCH 28/34] fix api structs to use json rawMessage --- api/server/structs/conversions_lightclient.go | 142 ++----------- api/server/structs/endpoints_lightclient.go | 31 +-- .../rpc/eth/light-client/handlers_test.go | 198 +++++++++++------- beacon-chain/rpc/eth/light-client/helpers.go | 32 ++- 4 files changed, 183 insertions(+), 220 deletions(-) diff --git a/api/server/structs/conversions_lightclient.go b/api/server/structs/conversions_lightclient.go index a4f8bad55dbf..5a0b11b7411b 100644 --- a/api/server/structs/conversions_lightclient.go +++ b/api/server/structs/conversions_lightclient.go @@ -4,150 +4,48 @@ import ( "encoding/json" ) +func (h *LightClientHeader) ToRawMessage() (json.RawMessage, error) { + return json.Marshal(h) +} + +func (h *LightClientHeaderCapella) ToRawMessage() (json.RawMessage, error) { + return json.Marshal(h) +} + +func (h *LightClientHeaderDeneb) ToRawMessage() (json.RawMessage, error) { + return json.Marshal(h) +} + func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { - var aux struct { - Version string - Data struct { - Header json.RawMessage - CurrentSyncCommittee *SyncCommittee - CurrentSyncCommitteeBranch []string - } - } - err := json.Unmarshal(data, &aux) + var result LightClientBootstrapResponse + err := json.Unmarshal(data, &result) if err != nil { return nil, err } - result := LightClientBootstrapResponse{ - Version: aux.Version, - Data: &LightClientBootstrap{ - CurrentSyncCommittee: aux.Data.CurrentSyncCommittee, - CurrentSyncCommitteeBranch: aux.Data.CurrentSyncCommitteeBranch, - Header: nil, - }, - } - switch aux.Version { - case "altair", "bellatrix": - var x LightClientHeader - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - case "capella": - var x LightClientHeaderCapella - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - case "deneb", "electra": - var x LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.Header, &x) - if err != nil { - return nil, err - } - result.Data.Header = &x - } - return &result, nil } func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { - var aux struct { - Version string `json:"version"` - Data struct { - AttestedHeader json.RawMessage `json:"attested_header"` - NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` - FinalizedHeader json.RawMessage `json:"finalized_header,omitempty"` - SyncAggregate *SyncAggregate `json:"sync_aggregate"` - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` - FinalityBranch []string `json:"finality_branch,omitempty"` - SignatureSlot string `json:"signature_slot"` - } `json:"data"` - } - err := json.Unmarshal(data, &aux) + var result LightClientUpdateWithVersion + err := json.Unmarshal(data, &result) if err != nil { return nil, err } - result := LightClientUpdateWithVersion{ - Version: aux.Version, - Data: &LightClientUpdate{ - NextSyncCommittee: aux.Data.NextSyncCommittee, - SyncAggregate: aux.Data.SyncAggregate, - NextSyncCommitteeBranch: aux.Data.NextSyncCommitteeBranch, - FinalityBranch: aux.Data.FinalityBranch, - SignatureSlot: aux.Data.SignatureSlot, - AttestedHeader: nil, - FinalizedHeader: nil, - }, - } - - switch aux.Version { - case "altair", "bellatrix": - var x LightClientHeader - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - result.Data.AttestedHeader = &x - var y LightClientHeader - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - case "capella": - var x LightClientHeaderCapella - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - result.Data.AttestedHeader = &x - var y LightClientHeaderCapella - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - case "deneb", "electra": - var x LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.AttestedHeader, &x) - if err != nil { - return nil, err - } - result.Data.AttestedHeader = &x - var y LightClientHeaderDeneb - err = json.Unmarshal(aux.Data.FinalizedHeader, &y) - if err != nil { - return nil, err - } - result.Data.FinalizedHeader = &y - } - return &result, nil } func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { - var Updates []json.RawMessage + var updates []*LightClientUpdateWithVersion + var result LightClientUpdatesByRangeResponse - err := json.Unmarshal(data, &Updates) + err := json.Unmarshal(data, &updates) if err != nil { return nil, err } - result := LightClientUpdatesByRangeResponse{ - Updates: make([]*LightClientUpdateWithVersion, len(Updates)), - } - - for i, u := range Updates { - update, err := LightClientUpdateWithVersionFromJson(u) - if err != nil { - return nil, err - } - result.Updates[i] = update - } + result.Updates = updates return &result, nil } diff --git a/api/server/structs/endpoints_lightclient.go b/api/server/structs/endpoints_lightclient.go index 02234f5ac1f1..0abf361c44f0 100644 --- a/api/server/structs/endpoints_lightclient.go +++ b/api/server/structs/endpoints_lightclient.go @@ -1,36 +1,27 @@ package structs -// the interface is used in other structs to reference a light client header object regardless of its version -type lightClientHeader interface { - isLightClientHeader() -} +import "encoding/json" type LightClientHeader struct { Beacon *BeaconBlockHeader `json:"beacon"` } -func (a *LightClientHeader) isLightClientHeader() {} - type LightClientHeaderCapella struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderCapella `json:"execution"` ExecutionBranch []string `json:"execution_branch"` } -func (a *LightClientHeaderCapella) isLightClientHeader() {} - type LightClientHeaderDeneb struct { Beacon *BeaconBlockHeader `json:"beacon"` Execution *ExecutionPayloadHeaderDeneb `json:"execution"` ExecutionBranch []string `json:"execution_branch"` } -func (a *LightClientHeaderDeneb) isLightClientHeader() {} - type LightClientBootstrap struct { - Header lightClientHeader `json:"header"` - CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` + Header json.RawMessage `json:"header"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []string `json:"current_sync_committee_branch"` } type LightClientBootstrapResponse struct { @@ -39,13 +30,13 @@ type LightClientBootstrapResponse struct { } type LightClientUpdate struct { - AttestedHeader lightClientHeader `json:"attested_header"` - NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` - FinalizedHeader lightClientHeader `json:"finalized_header,omitempty"` - SyncAggregate *SyncAggregate `json:"sync_aggregate"` - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` - FinalityBranch []string `json:"finality_branch,omitempty"` - SignatureSlot string `json:"signature_slot"` + AttestedHeader json.RawMessage `json:"attested_header"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee,omitempty"` + FinalizedHeader json.RawMessage `json:"finalized_header,omitempty"` + SyncAggregate *SyncAggregate `json:"sync_aggregate"` + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch,omitempty"` + FinalityBranch []string `json:"finality_branch,omitempty"` + SignatureSlot string `json:"signature_slot"` } type LightClientUpdateWithVersion struct { diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index 4366e114f97d..ef76aab2b489 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -3,6 +3,7 @@ package lightclient import ( "bytes" "context" + "encoding/json" "fmt" "net/http" "net/http/httptest" @@ -71,8 +72,11 @@ func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Data.Header, &respHeader) + require.NoError(t, err) require.Equal(t, "altair", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeader).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -122,8 +126,11 @@ func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderCapella + err = json.Unmarshal(resp.Data.Header, &respHeader) + require.NoError(t, err) require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -173,23 +180,26 @@ func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderDeneb + err = json.Unmarshal(resp.Data.Header, &respHeader) + require.NoError(t, err) require.Equal(t, "deneb", resp.Version) - require.Equal(t, hexutil.Encode(header.Header.BodyRoot), resp.Data.Header.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(header.Header.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -209,7 +219,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -217,7 +227,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -274,24 +284,27 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } -func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateAltair() + attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockAltair() + parent := util.NewBeaconBlockCapella() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -311,7 +324,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateAltair() + st, err := util.NewBeaconStateCapella() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -319,7 +332,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockAltair() + block := util.NewBeaconBlockCapella() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -376,9 +389,12 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderCapella + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) - require.Equal(t, "altair", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } @@ -478,24 +494,27 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeDeneb(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderDeneb + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) require.Equal(t, "deneb", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } -func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -515,7 +534,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -523,7 +542,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -581,24 +600,27 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. - require.Equal(t, "capella", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + require.Equal(t, "altair", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } -func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair(t *testing.T) { +func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateAltair() + attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) - parent := util.NewBeaconBlockAltair() + parent := util.NewBeaconBlockCapella() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -618,7 +640,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair( signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateAltair() + st, err := util.NewBeaconStateCapella() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -626,7 +648,7 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair( parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockAltair() + block := util.NewBeaconBlockCapella() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -684,9 +706,12 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair( require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderCapella + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. - require.Equal(t, "altair", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.Equal(t, "capella", resp.Updates[0].Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } @@ -787,9 +812,12 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountDeneb(t require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderDeneb + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) // Even with big count input, the response is still the max available period, which is 1 in test case. require.Equal(t, "deneb", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } @@ -891,9 +919,12 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriodAltair(t require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) require.Equal(t, "altair", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } @@ -995,9 +1026,12 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCountAltair(t *te require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, 1, len(resp.Updates)) require.Equal(t, "altair", resp.Updates[0].Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Updates[0].Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp) } @@ -1098,13 +1132,13 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_BeforeAltair(t *testing require.Equal(t, http.StatusNotFound, writer.Code) } -func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { +func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) @@ -1114,7 +1148,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { Root: make([]byte, 32), })) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -1134,7 +1168,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -1142,7 +1176,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -1199,18 +1233,21 @@ func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { +func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateAltair() + attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) @@ -1220,7 +1257,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { Root: make([]byte, 32), })) - parent := util.NewBeaconBlockAltair() + parent := util.NewBeaconBlockCapella() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -1240,7 +1277,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateAltair() + st, err := util.NewBeaconStateCapella() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -1248,7 +1285,7 @@ func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockAltair() + block := util.NewBeaconBlockCapella() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -1305,8 +1342,11 @@ func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, "altair", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) + require.Equal(t, "capella", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -1411,18 +1451,21 @@ func TestLightClientHandler_GetLightClientFinalityUpdateDeneb(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderDeneb + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, "deneb", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) { +func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateCapella() + attestedState, err := util.NewBeaconStateAltair() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) @@ -1432,7 +1475,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) Root: make([]byte, 32), })) - parent := util.NewBeaconBlockCapella() + parent := util.NewBeaconBlockAltair() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -1452,7 +1495,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateCapella() + st, err := util.NewBeaconStateAltair() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -1460,7 +1503,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockCapella() + block := util.NewBeaconBlockAltair() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -1517,18 +1560,21 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, "capella", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderCapella).Beacon.BodyRoot) + var respHeader structs.LightClientHeader + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) + require.Equal(t, "altair", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } -func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { +func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) { helpers.ClearCache() ctx := context.Background() config := params.BeaconConfig() - slot := primitives.Slot(config.AltairForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) + slot := primitives.Slot(config.CapellaForkEpoch * primitives.Epoch(config.SlotsPerEpoch)).Add(1) - attestedState, err := util.NewBeaconStateAltair() + attestedState, err := util.NewBeaconStateCapella() require.NoError(t, err) err = attestedState.SetSlot(slot.Sub(1)) require.NoError(t, err) @@ -1538,7 +1584,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { Root: make([]byte, 32), })) - parent := util.NewBeaconBlockAltair() + parent := util.NewBeaconBlockCapella() parent.Block.Slot = slot.Sub(1) signedParent, err := blocks.NewSignedBeaconBlock(parent) @@ -1558,7 +1604,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { signedParent, err = blocks.NewSignedBeaconBlock(parent) require.NoError(t, err) - st, err := util.NewBeaconStateAltair() + st, err := util.NewBeaconStateCapella() require.NoError(t, err) err = st.SetSlot(slot) require.NoError(t, err) @@ -1566,7 +1612,7 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { parentRoot, err := signedParent.Block().HashTreeRoot() require.NoError(t, err) - block := util.NewBeaconBlockAltair() + block := util.NewBeaconBlockCapella() block.Block.Slot = slot block.Block.ParentRoot = parentRoot[:] @@ -1623,8 +1669,11 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) - require.Equal(t, "altair", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeader).Beacon.BodyRoot) + var respHeader structs.LightClientHeaderCapella + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) + require.Equal(t, "capella", resp.Version) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } @@ -1729,8 +1778,11 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateDeneb(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) require.NoError(t, err) + var respHeader structs.LightClientHeaderDeneb + err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) + require.NoError(t, err) require.Equal(t, "deneb", resp.Version) - require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), resp.Data.AttestedHeader.(*structs.LightClientHeaderDeneb).Beacon.BodyRoot) + require.Equal(t, hexutil.Encode(attestedHeader.BodyRoot), respHeader.Beacon.BodyRoot) require.NotNil(t, resp.Data) } diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 912082a69144..4926c72e574d 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -102,9 +102,14 @@ func createLightClientBootstrapAltair(ctx context.Context, state state.BeaconSta } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) + headerJson, err := header.ToRawMessage() + if err != nil { + return nil, errors.Wrap(err, "could not convert header to raw message") + } + // Return result result := &structs.LightClientBootstrap{ - Header: header, + Header: headerJson, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, } @@ -213,9 +218,14 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) + headerJson, err := header.ToRawMessage() + if err != nil { + return nil, errors.Wrap(err, "could not convert header to raw message") + } + // Return result result := &structs.LightClientBootstrap{ - Header: header, + Header: headerJson, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, } @@ -324,9 +334,13 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) + headerJson, err := header.ToRawMessage() + if err != nil { + return nil, errors.Wrap(err, "could not convert header to raw message") + } // Return result result := &structs.LightClientBootstrap{ - Header: header, + Header: headerJson, CurrentSyncCommittee: committee, CurrentSyncCommitteeBranch: branch, } @@ -525,11 +539,19 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien if err != nil { return nil } + attestedHeaderJson, err := (&structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}).ToRawMessage() + if err != nil { + return nil + } + finalizedHeaderJson, err := (&structs.LightClientHeader{Beacon: finalizedHeader}).ToRawMessage() + if err != nil { + return nil + } result := &structs.LightClientUpdate{ - AttestedHeader: &structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}, + AttestedHeader: attestedHeaderJson, NextSyncCommittee: nextSyncCommittee, NextSyncCommitteeBranch: branchToJSON(input.NextSyncCommitteeBranch), - FinalizedHeader: &structs.LightClientHeader{Beacon: finalizedHeader}, + FinalizedHeader: finalizedHeaderJson, FinalityBranch: branchToJSON(input.FinalityBranch), SyncAggregate: syncAggregateToJSON(input.SyncAggregate), SignatureSlot: strconv.FormatUint(uint64(input.SignatureSlot), 10), From 5ed956f0bb567342f10614457340157158e1cf77 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 13:09:01 +0200 Subject: [PATCH 29/34] inline unmarshal --- api/server/structs/conversions_lightclient.go | 50 +----------------- .../rpc/eth/light-client/handlers_test.go | 51 ++++++++++++------- beacon-chain/rpc/eth/light-client/helpers.go | 11 ++-- 3 files changed, 41 insertions(+), 71 deletions(-) diff --git a/api/server/structs/conversions_lightclient.go b/api/server/structs/conversions_lightclient.go index 5a0b11b7411b..aa780a37ac30 100644 --- a/api/server/structs/conversions_lightclient.go +++ b/api/server/structs/conversions_lightclient.go @@ -1,51 +1,3 @@ package structs -import ( - "encoding/json" -) - -func (h *LightClientHeader) ToRawMessage() (json.RawMessage, error) { - return json.Marshal(h) -} - -func (h *LightClientHeaderCapella) ToRawMessage() (json.RawMessage, error) { - return json.Marshal(h) -} - -func (h *LightClientHeaderDeneb) ToRawMessage() (json.RawMessage, error) { - return json.Marshal(h) -} - -func LightClientBootstrapResponseFromJson(data []byte) (*LightClientBootstrapResponse, error) { - var result LightClientBootstrapResponse - err := json.Unmarshal(data, &result) - if err != nil { - return nil, err - } - - return &result, nil -} - -func LightClientUpdateWithVersionFromJson(data []byte) (*LightClientUpdateWithVersion, error) { - var result LightClientUpdateWithVersion - err := json.Unmarshal(data, &result) - if err != nil { - return nil, err - } - - return &result, nil -} - -func LightClientUpdatesByRangeResponseFromJson(data []byte) (*LightClientUpdatesByRangeResponse, error) { - var updates []*LightClientUpdateWithVersion - var result LightClientUpdatesByRangeResponse - - err := json.Unmarshal(data, &updates) - if err != nil { - return nil, err - } - - result.Updates = updates - - return &result, nil -} +// diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index ef76aab2b489..807afd578a8d 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -70,7 +70,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Altair(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientBootstrapResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Data.Header, &respHeader) @@ -124,7 +125,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Capella(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientBootstrapResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeaderCapella err = json.Unmarshal(resp.Data.Header, &respHeader) @@ -178,7 +180,8 @@ func TestLightClientHandler_GetLightClientBootstrap_Deneb(t *testing.T) { s.GetLightClientBootstrap(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientBootstrapResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientBootstrapResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeaderDeneb err = json.Unmarshal(resp.Data.Header, &respHeader) @@ -282,7 +285,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeAltair(t *testing.T) { s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -387,7 +391,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeCapella(t *testing.T) { s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeaderCapella err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -492,7 +497,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRangeDeneb(t *testing.T) { s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeaderDeneb err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -598,7 +604,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountAltair( s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -704,7 +711,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountCapella s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeaderCapella err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -810,7 +818,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigInputCountDeneb(t s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeaderDeneb err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -917,7 +926,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooEarlyPeriodAltair(t s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -1024,7 +1034,8 @@ func TestLightClientHandler_GetLightClientUpdatesByRange_TooBigCountAltair(t *te s.GetLightClientUpdatesByRange(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdatesByRangeResponseFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdatesByRangeResponse + err = json.Unmarshal(writer.Body.Bytes(), &resp.Updates) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Updates[0].Data.AttestedHeader, &respHeader) @@ -1231,7 +1242,8 @@ func TestLightClientHandler_GetLightClientFinalityUpdateAltair(t *testing.T) { s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) @@ -1340,7 +1352,8 @@ func TestLightClientHandler_GetLightClientFinalityUpdateCapella(t *testing.T) { s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) @@ -1449,7 +1462,8 @@ func TestLightClientHandler_GetLightClientFinalityUpdateDeneb(t *testing.T) { s.GetLightClientFinalityUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeaderDeneb err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) @@ -1558,7 +1572,8 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateAltair(t *testing.T) { s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeader err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) @@ -1667,7 +1682,8 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateCapella(t *testing.T) s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeaderCapella err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) @@ -1776,7 +1792,8 @@ func TestLightClientHandler_GetLightClientOptimisticUpdateDeneb(t *testing.T) { s.GetLightClientOptimisticUpdate(writer, request) require.Equal(t, http.StatusOK, writer.Code) - resp, err := structs.LightClientUpdateWithVersionFromJson(writer.Body.Bytes()) + var resp structs.LightClientUpdateWithVersion + err = json.Unmarshal(writer.Body.Bytes(), &resp) require.NoError(t, err) var respHeader structs.LightClientHeaderDeneb err = json.Unmarshal(resp.Data.AttestedHeader, &respHeader) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index 4926c72e574d..db7e2ad2f5e2 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -2,6 +2,7 @@ package lightclient import ( "context" + "encoding/json" "fmt" "reflect" "strconv" @@ -102,7 +103,7 @@ func createLightClientBootstrapAltair(ctx context.Context, state state.BeaconSta } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) - headerJson, err := header.ToRawMessage() + headerJson, err := json.Marshal(header) if err != nil { return nil, errors.Wrap(err, "could not convert header to raw message") } @@ -218,7 +219,7 @@ func createLightClientBootstrapCapella(ctx context.Context, state state.BeaconSt } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) - headerJson, err := header.ToRawMessage() + headerJson, err := json.Marshal(header) if err != nil { return nil, errors.Wrap(err, "could not convert header to raw message") } @@ -334,7 +335,7 @@ func createLightClientBootstrapDeneb(ctx context.Context, state state.BeaconStat } header.Beacon.StateRoot = hexutil.Encode(stateRoot[:]) - headerJson, err := header.ToRawMessage() + headerJson, err := json.Marshal(header) if err != nil { return nil, errors.Wrap(err, "could not convert header to raw message") } @@ -539,11 +540,11 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien if err != nil { return nil } - attestedHeaderJson, err := (&structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}).ToRawMessage() + attestedHeaderJson, err := json.Marshal(&structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}) if err != nil { return nil } - finalizedHeaderJson, err := (&structs.LightClientHeader{Beacon: finalizedHeader}).ToRawMessage() + finalizedHeaderJson, err := json.Marshal(&structs.LightClientHeader{Beacon: finalizedHeader}) if err != nil { return nil } From 3762b9370d63954bd95eacf7a8be90597922cce0 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 13:10:15 +0200 Subject: [PATCH 30/34] remove redundant nil check --- beacon-chain/core/light-client/lightclient.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 7d8ea944e176..62860ccea22a 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -246,7 +246,7 @@ func NewLightClientFinalityUpdateFromBeaconState( var finalizedHeaderBeacon *ethpbv1.BeaconBlockHeader var finalityBranch [][]byte - if finalizedBlock != nil && !finalizedBlock.IsNil() { + if !finalizedBlock.IsNil() { if finalizedBlock.Block().Slot() != 0 { tempFinalizedHeader, err := finalizedBlock.Header() if err != nil { @@ -305,7 +305,7 @@ func NewLightClientFinalityUpdateFromBeaconState( } result.FinalityBranch = finalityBranch case version.Capella: - if finalizedBlock != nil && !finalizedBlock.IsNil() { + if !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderCapella(finalizedBlock) if err != nil { return nil, errors.Wrap(err, "could not get execution payload header") @@ -342,7 +342,7 @@ func NewLightClientFinalityUpdateFromBeaconState( result.FinalityBranch = finalityBranch } case version.Deneb, version.Electra: - if finalizedBlock != nil && !finalizedBlock.IsNil() { + if !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderDeneb(finalizedBlock) if err != nil { return nil, errors.Wrap(err, "could not get execution payload header") From 2f14fe4b3ebb2e0923b3cf3fcad676fa579e45db Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 13:18:29 +0200 Subject: [PATCH 31/34] revert remove redundant nil check --- beacon-chain/core/light-client/lightclient.go | 6 +++--- beacon-chain/core/light-client/lightclient_test.go | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 62860ccea22a..7d8ea944e176 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -246,7 +246,7 @@ func NewLightClientFinalityUpdateFromBeaconState( var finalizedHeaderBeacon *ethpbv1.BeaconBlockHeader var finalityBranch [][]byte - if !finalizedBlock.IsNil() { + if finalizedBlock != nil && !finalizedBlock.IsNil() { if finalizedBlock.Block().Slot() != 0 { tempFinalizedHeader, err := finalizedBlock.Header() if err != nil { @@ -305,7 +305,7 @@ func NewLightClientFinalityUpdateFromBeaconState( } result.FinalityBranch = finalityBranch case version.Capella: - if !finalizedBlock.IsNil() { + if finalizedBlock != nil && !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderCapella(finalizedBlock) if err != nil { return nil, errors.Wrap(err, "could not get execution payload header") @@ -342,7 +342,7 @@ func NewLightClientFinalityUpdateFromBeaconState( result.FinalityBranch = finalityBranch } case version.Deneb, version.Electra: - if !finalizedBlock.IsNil() { + if finalizedBlock != nil && !finalizedBlock.IsNil() { execution, err := getExecutionPayloadHeaderDeneb(finalizedBlock) if err != nil { return nil, errors.Wrap(err, "could not get execution payload header") diff --git a/beacon-chain/core/light-client/lightclient_test.go b/beacon-chain/core/light-client/lightclient_test.go index fa36633a8d47..51e706706d23 100644 --- a/beacon-chain/core/light-client/lightclient_test.go +++ b/beacon-chain/core/light-client/lightclient_test.go @@ -60,7 +60,6 @@ func TestLightClient_NewLightClientOptimisticUpdateFromBeaconStateDeneb(t *testi } func TestLightClient_NewLightClientFinalityUpdateFromBeaconStateCapella(t *testing.T) { l := util.NewTestLightClient(t).SetupTestCapella() - update, err := lightClient.NewLightClientFinalityUpdateFromBeaconState(l.Ctx, l.State, l.Block, l.AttestedState, nil) require.NoError(t, err) require.NotNil(t, update, "update is nil") From 887f6011a7d9c67add9843185fdf5168ae1c87cf Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 13:35:20 +0200 Subject: [PATCH 32/34] return error in newLightClientUpdateToJSON --- beacon-chain/rpc/eth/light-client/helpers.go | 32 ++++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/beacon-chain/rpc/eth/light-client/helpers.go b/beacon-chain/rpc/eth/light-client/helpers.go index db7e2ad2f5e2..aa5f8a6b81dd 100644 --- a/beacon-chain/rpc/eth/light-client/helpers.go +++ b/beacon-chain/rpc/eth/light-client/helpers.go @@ -466,7 +466,11 @@ func createLightClientUpdate( result.NextSyncCommittee = nextSyncCommittee result.NextSyncCommitteeBranch = nextSyncCommitteeBranch - return newLightClientUpdateToJSON(result), nil + res, err := newLightClientUpdateToJSON(result) + if err != nil { + return nil, errors.Wrap(err, "could not convert light client update to JSON") + } + return res, nil } func newLightClientFinalityUpdateFromBeaconState( @@ -480,7 +484,11 @@ func newLightClientFinalityUpdateFromBeaconState( return nil, err } - return newLightClientUpdateToJSON(result), nil + res, err := newLightClientUpdateToJSON(result) + if err != nil { + return nil, errors.Wrap(err, "could not convert light client update to JSON") + } + return res, nil } func newLightClientOptimisticUpdateFromBeaconState( @@ -493,7 +501,11 @@ func newLightClientOptimisticUpdateFromBeaconState( return nil, err } - return newLightClientUpdateToJSON(result), nil + res, err := newLightClientUpdateToJSON(result) + if err != nil { + return nil, errors.Wrap(err, "could not convert light client update to JSON") + } + return res, nil } func branchToJSON(branchBytes [][]byte) []string { @@ -517,9 +529,9 @@ func syncAggregateToJSON(input *v1.SyncAggregate) *structs.SyncAggregate { } } -func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClientUpdate { +func newLightClientUpdateToJSON(input *v2.LightClientUpdate) (*structs.LightClientUpdate, error) { if input == nil { - return nil + return nil, errors.New("input is nil") } var nextSyncCommittee *structs.SyncCommittee @@ -531,22 +543,22 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien if input.FinalizedHeader != nil { inputFinalizedHeaderBeacon, err := input.FinalizedHeader.GetBeacon() if err != nil { - return nil + return nil, errors.Wrap(err, "could not get finalized header beacon") } finalizedHeader = structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputFinalizedHeaderBeacon)) } inputAttestedHeaderBeacon, err := input.AttestedHeader.GetBeacon() if err != nil { - return nil + return nil, errors.Wrap(err, "could not get attested header beacon") } attestedHeaderJson, err := json.Marshal(&structs.LightClientHeader{Beacon: structs.BeaconBlockHeaderFromConsensus(migration.V1HeaderToV1Alpha1(inputAttestedHeaderBeacon))}) if err != nil { - return nil + return nil, errors.Wrap(err, "could not convert attested header to raw message") } finalizedHeaderJson, err := json.Marshal(&structs.LightClientHeader{Beacon: finalizedHeader}) if err != nil { - return nil + return nil, errors.Wrap(err, "could not convert finalized header to raw message") } result := &structs.LightClientUpdate{ AttestedHeader: attestedHeaderJson, @@ -558,7 +570,7 @@ func newLightClientUpdateToJSON(input *v2.LightClientUpdate) *structs.LightClien SignatureSlot: strconv.FormatUint(uint64(input.SignatureSlot), 10), } - return result + return result, nil } func IsSyncCommitteeUpdate(update *v2.LightClientUpdate) bool { From c534a655d4062c9ce909578c35f7ad3c863a1794 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 13:42:03 +0200 Subject: [PATCH 33/34] inline getExecutionData --- beacon-chain/core/light-client/lightclient.go | 86 +++++++++++-------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 7d8ea944e176..9ae33dbbe696 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -426,37 +426,37 @@ func createEmptyExecutionPayloadHeaderDeneb() *enginev1.ExecutionPayloadHeaderDe } func getExecutionPayloadHeaderCapella(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderCapella, error) { - payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) + payloadInterface, err := block.Block().Body().Execution() if err != nil { return nil, errors.Wrap(err, "could not get execution data") } - execution := &enginev1.ExecutionPayloadHeaderCapella{ - ParentHash: payloadInterface.ParentHash(), - FeeRecipient: payloadInterface.FeeRecipient(), - StateRoot: payloadInterface.StateRoot(), - ReceiptsRoot: payloadInterface.ReceiptsRoot(), - LogsBloom: payloadInterface.LogsBloom(), - PrevRandao: payloadInterface.PrevRandao(), - BlockNumber: payloadInterface.BlockNumber(), - GasLimit: payloadInterface.GasLimit(), - GasUsed: payloadInterface.GasUsed(), - Timestamp: payloadInterface.Timestamp(), - ExtraData: payloadInterface.ExtraData(), - BaseFeePerGas: payloadInterface.BaseFeePerGas(), - BlockHash: payloadInterface.BlockHash(), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalsRoot, + transactionsRoot, err := payloadInterface.TransactionsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + transactions, err := payloadInterface.Transactions() + if err != nil { + return nil, errors.Wrap(err, "could not get transactions") + } + transactionsRootArray, err := ssz.TransactionsRoot(transactions) + if err != nil { + return nil, errors.Wrap(err, "could not get transactions root") + } + transactionsRoot = transactionsRootArray[:] + } else if err != nil { + return nil, errors.Wrap(err, "could not get transactions root") } - - return execution, nil -} - -func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderDeneb, error) { - payloadInterface, transactionsRoot, withdrawalsRoot, err := getExecutionData(block) - if err != nil { - return nil, errors.Wrap(err, "could not get execution data") + withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() + if errors.Is(err, consensus_types.ErrUnsupportedField) { + withdrawals, err := payloadInterface.Withdrawals() + if err != nil { + return nil, errors.Wrap(err, "could not get withdrawals") + } + withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) + if err != nil { + return nil, errors.Wrap(err, "could not get withdrawals root") + } + withdrawalsRoot = withdrawalsRootArray[:] } - execution := &enginev1.ExecutionPayloadHeaderDeneb{ + execution := &enginev1.ExecutionPayloadHeaderCapella{ ParentHash: payloadInterface.ParentHash(), FeeRecipient: payloadInterface.FeeRecipient(), StateRoot: payloadInterface.StateRoot(), @@ -477,41 +477,57 @@ func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) return execution, nil } -func getExecutionData(block interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, []byte, []byte, error) { +func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) (*enginev1.ExecutionPayloadHeaderDeneb, error) { payloadInterface, err := block.Block().Body().Execution() if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get execution data") + return nil, errors.Wrap(err, "could not get execution data") } transactionsRoot, err := payloadInterface.TransactionsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { transactions, err := payloadInterface.Transactions() if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get transactions") + return nil, errors.Wrap(err, "could not get transactions") } transactionsRootArray, err := ssz.TransactionsRoot(transactions) if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get transactions root") + return nil, errors.Wrap(err, "could not get transactions root") } transactionsRoot = transactionsRootArray[:] } else if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get transactions root") + return nil, errors.Wrap(err, "could not get transactions root") } withdrawalsRoot, err := payloadInterface.WithdrawalsRoot() if errors.Is(err, consensus_types.ErrUnsupportedField) { withdrawals, err := payloadInterface.Withdrawals() if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get withdrawals") + return nil, errors.Wrap(err, "could not get withdrawals") } withdrawalsRootArray, err := ssz.WithdrawalSliceRoot(withdrawals, fieldparams.MaxWithdrawalsPerPayload) if err != nil { - return nil, nil, nil, errors.Wrap(err, "could not get withdrawals root") + return nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] } + execution := &enginev1.ExecutionPayloadHeaderDeneb{ + ParentHash: payloadInterface.ParentHash(), + FeeRecipient: payloadInterface.FeeRecipient(), + StateRoot: payloadInterface.StateRoot(), + ReceiptsRoot: payloadInterface.ReceiptsRoot(), + LogsBloom: payloadInterface.LogsBloom(), + PrevRandao: payloadInterface.PrevRandao(), + BlockNumber: payloadInterface.BlockNumber(), + GasLimit: payloadInterface.GasLimit(), + GasUsed: payloadInterface.GasUsed(), + Timestamp: payloadInterface.Timestamp(), + ExtraData: payloadInterface.ExtraData(), + BaseFeePerGas: payloadInterface.BaseFeePerGas(), + BlockHash: payloadInterface.BlockHash(), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalsRoot, + } - return payloadInterface, transactionsRoot, withdrawalsRoot, nil + return execution, nil } - func NewLightClientUpdateFromFinalityUpdate(update *ethpbv2.LightClientFinalityUpdate) *ethpbv2.LightClientUpdate { return ðpbv2.LightClientUpdate{ AttestedHeader: update.AttestedHeader, From 65c5ff8f97ab8ce05c3951ce6aead7170dc16ef9 Mon Sep 17 00:00:00 2001 From: Inspector-Butters Date: Fri, 6 Sep 2024 14:14:20 +0200 Subject: [PATCH 34/34] better error handling --- beacon-chain/core/light-client/lightclient.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index 9ae33dbbe696..c572a6325c29 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -455,7 +455,10 @@ func getExecutionPayloadHeaderCapella(block interfaces.ReadOnlySignedBeaconBlock return nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] + } else if err != nil { + return nil, errors.Wrap(err, "could not get withdrawals root") } + execution := &enginev1.ExecutionPayloadHeaderCapella{ ParentHash: payloadInterface.ParentHash(), FeeRecipient: payloadInterface.FeeRecipient(), @@ -507,7 +510,10 @@ func getExecutionPayloadHeaderDeneb(block interfaces.ReadOnlySignedBeaconBlock) return nil, errors.Wrap(err, "could not get withdrawals root") } withdrawalsRoot = withdrawalsRootArray[:] + } else if err != nil { + return nil, errors.Wrap(err, "could not get withdrawals root") } + execution := &enginev1.ExecutionPayloadHeaderDeneb{ ParentHash: payloadInterface.ParentHash(), FeeRecipient: payloadInterface.FeeRecipient(),