Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fixed hive test: Transaction Reorg - Check Blockhash with NP on rever…
Browse files Browse the repository at this point in the history
…t (erigon) (ledgerwatch#4640)
  • Loading branch information
Giulio2002 committed Jul 5, 2022
1 parent a6a5b1d commit d4a0aff
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions turbo/stages/headerdownload/header_algos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,13 @@ func (hd *HeaderDownload) ValidatePayload(tx kv.RwTx, header *types.Header, body
hd.cleanupOutdateSideForks(*currentHeight, maxDepth)
return
}
// If the block is stored within the side fork it means it was already validated.
if _, ok := hd.sideForksBlock[header.Hash()]; ok {
status = remote.EngineStatus_VALID
latestValidHash = header.Hash()
return
}

// if the block is not in range of MAX_DEPTH from head then we do not validate it.
if abs64(int64(*currentHeight)-header.Number.Int64()) > maxDepth {
status = remote.EngineStatus_ACCEPTED
Expand Down Expand Up @@ -1213,10 +1220,7 @@ func (hd *HeaderDownload) FlushNextForkState(tx kv.RwTx) error {
if err := hd.nextForkState.Flush(tx); err != nil {
return err
}
// If the side fork hash is now becoming canonical we can clean up.
if _, ok := hd.sideForksBlock[hd.nextForkHash]; ok {
delete(hd.sideForksBlock, hd.nextForkHash)
}

hd.nextForkState.Close()
hd.nextForkHash = common.Hash{}
hd.nextForkState = nil
Expand Down

0 comments on commit d4a0aff

Please sign in to comment.