Skip to content

Commit

Permalink
increment Time and Block by 1 for debug_traceCall and createAccessList
Browse files Browse the repository at this point in the history
  • Loading branch information
bgelb committed Feb 26, 2022
1 parent 4b74cfc commit 96356dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions eth/tracers/api.go
Expand Up @@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"runtime"
"sync"
Expand Down Expand Up @@ -848,6 +849,11 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
}
vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)

// Increment the BlockNumber and Time values to simulate the transaction of
// interest in the next (N+1) block instead of the current (already mined) one
vmctx.Time.Add(vmctx.Time, big.NewInt(1))
vmctx.BlockNumber.Add(vmctx.BlockNumber, big.NewInt(1))

var traceConfig *TraceConfig
if config != nil {
traceConfig = &TraceConfig{
Expand Down
6 changes: 6 additions & 0 deletions internal/ethapi/api.go
Expand Up @@ -1466,6 +1466,12 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
tracer := logger.NewAccessListTracer(accessList, args.from(), to, precompiles)
config := vm.Config{Tracer: tracer, Debug: true, NoBaseFee: true}
vmenv, _, err := b.GetEVM(ctx, msg, statedb, header, &config)

// Increment the BlockNumber and Time values to simulate the transaction of
// interest in the next (N+1) block instead of the current (already mined) one
vmenv.Context.Time.Add(vmenv.Context.Time, big.NewInt(1))
vmenv.Context.BlockNumber.Add(vmenv.Context.BlockNumber, big.NewInt(1))

if err != nil {
return nil, 0, nil, err
}
Expand Down

0 comments on commit 96356dd

Please sign in to comment.