Skip to content

Commit

Permalink
Fix panics in debug_TraceTransaction (ethereum#27)
Browse files Browse the repository at this point in the history
* Make sure L1CostFunc is set on returned context

* Fix panic if HistoricalRPCService is not set

* Can we just return nil?

* Simplify
  • Loading branch information
mdehoog authored Nov 22, 2022
1 parent 30db39c commit 603a89b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eth/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec
msg, _ := tx.AsMessage(signer, block.BaseFee())
txContext := core.NewEVMTxContext(msg)
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
context.L1CostFunc = types.NewL1CostFunc(eth.blockchain.Config(), statedb)
if idx == txIndex {
return msg, context, statedb, release, nil
}
context.L1CostFunc = types.NewL1CostFunc(eth.blockchain.Config(), statedb)
// Not yet the searched for transaction, execute on top of the current state
vmenv := vm.NewEVM(context, txContext, statedb, eth.blockchain.Config(), vm.Config{})
statedb.Prepare(tx.Hash(), idx)
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
if err != nil {
return nil, err
}
if tx == nil {
if tx == nil && api.backend.HistoricalRPCService() != nil {
var histResult []*txTraceResult
err = api.backend.HistoricalRPCService().CallContext(ctx, &histResult, "debug_traceTransaction", hash, config)
if err != nil && err.Error() == "not found" {
Expand Down

0 comments on commit 603a89b

Please sign in to comment.