From 4050f57f325c7e623fc3e825ab55716885edadb3 Mon Sep 17 00:00:00 2001 From: lightclient Date: Tue, 2 Jul 2024 13:55:10 -0600 Subject: [PATCH] eth/tracers: check if reciept is not nil before accessing --- core/state_processor.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index c21f644f98..bb2e181eb6 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -107,7 +107,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg // ApplyTransactionWithEVM attempts to apply a transaction to the given state database // and uses the input parameters for its environment similar to ApplyTransaction. However, // this method takes an already created EVM instance as input. -func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (receipt *types.Receipt, err error) { +func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { + // Declare some variables early in case tracing is enabled. + var ( + result *ExecutionResult + receipt *types.Receipt + err error + ) if evm.Config.Tracer != nil && evm.Config.Tracer.OnTxStart != nil { evm.Config.Tracer.OnTxStart(evm.GetVMContext(), tx, msg.From) if evm.Config.Tracer.OnTxEnd != nil { @@ -121,7 +127,7 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo evm.Reset(txContext, statedb) // Apply the transaction to the current state (included in the env). - result, err := ApplyMessage(evm, msg, gp) + result, err = ApplyMessage(evm, msg, gp) if err != nil { return nil, err }