From 82f556c50fb50fdcfb2d0fbb5b7f2dd62ffa0b9f Mon Sep 17 00:00:00 2001 From: Potuz Date: Tue, 14 Oct 2025 09:39:19 -0300 Subject: [PATCH] Remove redundant check (#15844) * Remove redundant check * changelog * fix gazelle --- beacon-chain/node/BUILD.bazel | 1 - beacon-chain/node/node.go | 18 +----------------- changelog/potuz_redundant_check.md | 3 +++ 3 files changed, 4 insertions(+), 18 deletions(-) create mode 100644 changelog/potuz_redundant_check.md diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index 3a5ad5a7ae..560969063b 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -58,7 +58,6 @@ go_library( "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", "//container/slice:go_default_library", - "//encoding/bytesutil:go_default_library", "//genesis:go_default_library", "//monitoring/prometheus:go_default_library", "//monitoring/tracing:go_default_library", diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 6a6146e4be..129695ae3a 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -60,7 +60,6 @@ import ( "github.com/OffchainLabs/prysm/v6/config/params" "github.com/OffchainLabs/prysm/v6/consensus-types/primitives" "github.com/OffchainLabs/prysm/v6/container/slice" - "github.com/OffchainLabs/prysm/v6/encoding/bytesutil" "github.com/OffchainLabs/prysm/v6/genesis" "github.com/OffchainLabs/prysm/v6/monitoring/prometheus" "github.com/OffchainLabs/prysm/v6/runtime" @@ -598,22 +597,7 @@ func (b *BeaconNode) startStateGen(ctx context.Context, bfs coverage.AvailableBl return err } - r := bytesutil.ToBytes32(cp.Root) - // Consider edge case where finalized root are zeros instead of genesis root hash. - if r == params.BeaconConfig().ZeroHash { - genesisBlock, err := b.db.GenesisBlock(ctx) - if err != nil { - return err - } - if genesisBlock != nil && !genesisBlock.IsNil() { - r, err = genesisBlock.Block().HashTreeRoot() - if err != nil { - return err - } - } - } - - b.finalizedStateAtStartUp, err = sg.StateByRoot(ctx, r) + b.finalizedStateAtStartUp, err = sg.StateByRoot(ctx, [32]byte(cp.Root)) if err != nil { return err } diff --git a/changelog/potuz_redundant_check.md b/changelog/potuz_redundant_check.md new file mode 100644 index 0000000000..6f4531bd01 --- /dev/null +++ b/changelog/potuz_redundant_check.md @@ -0,0 +1,3 @@ +### Ignored + +- Remove redundant check for genesis root at startup.