From d528dbbd5015d877501155a8b807d00a1e081788 Mon Sep 17 00:00:00 2001 From: Rupam Dey Date: Sun, 3 Nov 2024 22:22:05 +0530 Subject: [PATCH] fix issue in `CreateDefaultLightClientUpdate` function (#14585) * use state in `CreateDefaultLightClientUpdate` * lint * add `stateSlot` to `update.go` structs * Revert "add `stateSlot` to `update.go` structs" This reverts commit 84468ae5e19543f93f48537b328c9fe506715266. * set sync committee based on attestedHeader in updateElectra * dependencies * add check to `SetNextSyncCommitteeBranchElectra` * add detailed error messages to `update.go` * dependencies * fix `createDefaultLightClientUpdate` * deps * fix errors * deps * revert error messages * deps --- beacon-chain/core/light-client/lightclient.go | 2 +- beacon-chain/db/kv/lightclient_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon-chain/core/light-client/lightclient.go b/beacon-chain/core/light-client/lightclient.go index c009fc5a5a9..d07813fc7a5 100644 --- a/beacon-chain/core/light-client/lightclient.go +++ b/beacon-chain/core/light-client/lightclient.go @@ -253,7 +253,7 @@ func CreateDefaultLightClientUpdate(currentSlot primitives.Slot, attestedState s } var nextSyncCommitteeBranch [][]byte - if currentEpoch >= params.BeaconConfig().ElectraForkEpoch { + if attestedState.Version() >= version.Electra { nextSyncCommitteeBranch = make([][]byte, fieldparams.SyncCommitteeBranchDepthElectra) } else { nextSyncCommitteeBranch = make([][]byte, fieldparams.SyncCommitteeBranchDepth) diff --git a/beacon-chain/db/kv/lightclient_test.go b/beacon-chain/db/kv/lightclient_test.go index fc7b6cbeef2..84702567a37 100644 --- a/beacon-chain/db/kv/lightclient_test.go +++ b/beacon-chain/db/kv/lightclient_test.go @@ -457,7 +457,7 @@ func createDefaultLightClientUpdate(currentSlot primitives.Slot, attestedState s } var nextSyncCommitteeBranch [][]byte - if currentEpoch >= params.BeaconConfig().ElectraForkEpoch { + if attestedState.Version() >= version.Electra { nextSyncCommitteeBranch = make([][]byte, fieldparams.SyncCommitteeBranchDepthElectra) } else { nextSyncCommitteeBranch = make([][]byte, fieldparams.SyncCommitteeBranchDepth)