Fix logging in block processing (#2870)

* log blockhash and parentHash in stateRoot mismatch

* logs for case when parent not found

* some more logs in epilogue

* add parentHash
This commit is contained in:
Advaita Saha 2024-11-26 01:40:03 +05:30 committed by GitHub
parent daaf0f2a20
commit 5e152f9436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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
@ -178,6 +180,10 @@ 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)
@ -185,6 +191,8 @@ proc procBlkEpilogue(
# 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")
@ -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")