From 090d645b77461471083c0bded103b41b635d8b56 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Fri, 1 Nov 2024 08:25:58 -0300 Subject: [PATCH] get parent block by hash Signed-off-by: Ignacio Hagopian --- core/block_validator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index 8014fbeef680..4f15087e62b6 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -133,18 +133,18 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD return fmt.Errorf("invalid merkle root (remote: %x local: %x) dberr: %w", header.Root, root, statedb.Error()) } if blockEw := block.ExecutionWitness(); blockEw != nil { - parent := v.bc.GetHeaderByNumber(header.Number.Uint64() - 1) + parent := v.bc.GetBlockByHash(header.ParentHash) if parent == nil { return fmt.Errorf("nil parent header for block %d", header.Number) } - stateDiff, proof, err := beacon.BuildVerkleProof(header, statedb, parent.Root) + stateDiff, proof, err := beacon.BuildVerkleProof(header, statedb, parent.Root()) if err != nil { return fmt.Errorf("error building verkle proof: %w", err) } ew := types.ExecutionWitness{ StateDiff: stateDiff, VerkleProof: proof, - ParentStateRoot: parent.Root, + ParentStateRoot: parent.Root(), } if err := ew.Equal(blockEw); err != nil { return fmt.Errorf("invalid execution witness: %v", err)