Skip to content

Commit

Permalink
Fix logging in block processing (#2870)
Browse files Browse the repository at this point in the history
* log blockhash and parentHash in stateRoot mismatch

* logs for case when parent not found

* some more logs in epilogue

* add parentHash
  • Loading branch information
advaita-saha authored Nov 25, 2024
1 parent daaf0f2 commit 5e152f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nimbus/core/chain/forked_chain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ proc importBlock*(c: ForkedChainRef, blk: Block): Result[void, string] =
if header.parentHash notin c.blocks:
# If it's parent is an invalid block
# there is no hope the descendant is valid
debug "Parent block not found",
blockHash = header.blockHash.short,
parentHash = header.parentHash.short
return err("Block is not part of valid chain")

# TODO: If engine API keep importing blocks
Expand Down
10 changes: 10 additions & 0 deletions nimbus/core/executor/process_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ proc procBlkEpilogue(
# TODO replace logging with better error
debug "wrong state root in block",
blockNumber = header.number,
blockHash = header.blockHash,
parentHash = header.parentHash,
expected = header.stateRoot,
actual = stateRoot,
arrivedFrom = vmState.parent.stateRoot
Expand All @@ -178,13 +180,19 @@ proc procBlkEpilogue(
let bloom = createBloom(vmState.receipts)

if header.logsBloom != bloom:
debug "wrong logsBloom in block",
blockNumber = header.number,
actual = bloom,
expected = header.logsBloom
return err("bloom mismatch")

let receiptsRoot = calcReceiptsRoot(vmState.receipts)
if header.receiptsRoot != receiptsRoot:
# TODO replace logging with better error
debug "wrong receiptRoot in block",
blockNumber = header.number,
parentHash = header.parentHash.short,
blockHash = header.blockHash.short,
actual = receiptsRoot,
expected = header.receiptsRoot
return err("receiptRoot mismatch")
Expand All @@ -197,6 +205,8 @@ proc procBlkEpilogue(
if header.requestsHash.get != requestsHash:
debug "wrong requestsHash in block",
blockNumber = header.number,
parentHash = header.parentHash.short,
blockHash = header.blockHash.short,
actual = requestsHash,
expected = header.requestsHash.get
return err("requestsHash mismatch")
Expand Down

0 comments on commit 5e152f9

Please sign in to comment.