Skip to content

Commit 5cabc4d

Browse files
authored
stagedsync: dbg option to log receipts on receipts hash mismatch (#13905)
ports #9340 to E3's `BlockPostValidation`
1 parent e0b3585 commit 5cabc4d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/blockchain.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHead
376376
return nil
377377
}
378378

379-
func BlockPostValidation(gasUsed, blobGasUsed uint64, checkReceipts bool, receipts types.Receipts, h *types.Header, isMining bool) error {
379+
func BlockPostValidation(gasUsed, blobGasUsed uint64, checkReceipts bool, receipts types.Receipts, h *types.Header, isMining bool, txns types.Transactions, chainConfig *chain.Config, logger log.Logger) error {
380380
if gasUsed != h.GasUsed {
381381
return fmt.Errorf("gas used by execution: %d, in header: %d, headerNum=%d, %x",
382382
gasUsed, h.GasUsed, h.Number.Uint64(), h.Hash())
@@ -396,6 +396,9 @@ func BlockPostValidation(gasUsed, blobGasUsed uint64, checkReceipts bool, receip
396396
h.ReceiptHash = receiptHash
397397
return nil
398398
}
399+
if dbg.LogHashMismatchReason() {
400+
logReceipts(receipts, txns, chainConfig, h, logger)
401+
}
399402
return fmt.Errorf("receiptHash mismatch: %x != %x, headerNum=%d, %x",
400403
receiptHash, h.ReceiptHash, h.Number.Uint64(), h.Hash())
401404
}

eth/stagedsync/exec3_serial.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (se *serialExecutor) execute(ctx context.Context, tasks []*state.TxTask) (c
6969
}
7070
checkReceipts := !se.cfg.vmConfig.StatelessExec && se.cfg.chainConfig.IsByzantium(txTask.BlockNum) && !se.cfg.vmConfig.NoReceipts && !se.isMining
7171
if txTask.BlockNum > 0 && !se.skipPostEvaluation { //Disable check for genesis. Maybe need somehow improve it in future - to satisfy TestExecutionSpec
72-
if err := core.BlockPostValidation(se.usedGas, se.blobGasUsed, checkReceipts, txTask.BlockReceipts, txTask.Header, se.isMining); err != nil {
72+
if err := core.BlockPostValidation(se.usedGas, se.blobGasUsed, checkReceipts, txTask.BlockReceipts, txTask.Header, se.isMining, txTask.Txs, se.cfg.chainConfig, se.logger); err != nil {
7373
return fmt.Errorf("%w, txnIdx=%d, %v", consensus.ErrInvalidBlock, txTask.TxIndex, err) //same as in stage_exec.go
7474
}
7575
}

0 commit comments

Comments
 (0)