Skip to content

Commit 603a89b

Browse files
authored
Fix panics in debug_TraceTransaction (ethereum#27)
* Make sure L1CostFunc is set on returned context * Fix panic if HistoricalRPCService is not set * Can we just return nil? * Simplify
1 parent 30db39c commit 603a89b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

eth/state_accessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec
208208
msg, _ := tx.AsMessage(signer, block.BaseFee())
209209
txContext := core.NewEVMTxContext(msg)
210210
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
211+
context.L1CostFunc = types.NewL1CostFunc(eth.blockchain.Config(), statedb)
211212
if idx == txIndex {
212213
return msg, context, statedb, release, nil
213214
}
214-
context.L1CostFunc = types.NewL1CostFunc(eth.blockchain.Config(), statedb)
215215
// Not yet the searched for transaction, execute on top of the current state
216216
vmenv := vm.NewEVM(context, txContext, statedb, eth.blockchain.Config(), vm.Config{})
217217
statedb.Prepare(tx.Hash(), idx)

eth/tracers/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
827827
if err != nil {
828828
return nil, err
829829
}
830-
if tx == nil {
830+
if tx == nil && api.backend.HistoricalRPCService() != nil {
831831
var histResult []*txTraceResult
832832
err = api.backend.HistoricalRPCService().CallContext(ctx, &histResult, "debug_traceTransaction", hash, config)
833833
if err != nil && err.Error() == "not found" {

0 commit comments

Comments
 (0)