Skip to content

Commit

Permalink
get parent block by hash
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Nov 1, 2024
1 parent f104803 commit 090d645
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 090d645

Please sign in to comment.