Skip to content

Commit 5449139

Browse files
authored
Merge pull request #16569 from holiman/evm_blocknum
cmd/evm: use block number from genesis
2 parents 579ac62 + 8dfa4f4 commit 5449139

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cmd/evm/runner.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"io/ioutil"
24+
"math/big"
2425
"os"
26+
goruntime "runtime"
2527
"runtime/pprof"
2628
"time"
2729

28-
goruntime "runtime"
29-
3030
"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
3131
"github.com/ethereum/go-ethereum/cmd/utils"
3232
"github.com/ethereum/go-ethereum/common"
@@ -86,6 +86,7 @@ func runCmd(ctx *cli.Context) error {
8686
chainConfig *params.ChainConfig
8787
sender = common.BytesToAddress([]byte("sender"))
8888
receiver = common.BytesToAddress([]byte("receiver"))
89+
blockNumber uint64
8990
)
9091
if ctx.GlobalBool(MachineFlag.Name) {
9192
tracer = NewJSONLogger(logconfig, os.Stdout)
@@ -101,6 +102,7 @@ func runCmd(ctx *cli.Context) error {
101102
genesis := gen.ToBlock(db)
102103
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db))
103104
chainConfig = gen.Config
105+
blockNumber = gen.Number
104106
} else {
105107
db, _ := ethdb.NewMemDatabase()
106108
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
@@ -156,11 +158,12 @@ func runCmd(ctx *cli.Context) error {
156158

157159
initialGas := ctx.GlobalUint64(GasFlag.Name)
158160
runtimeConfig := runtime.Config{
159-
Origin: sender,
160-
State: statedb,
161-
GasLimit: initialGas,
162-
GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
163-
Value: utils.GlobalBig(ctx, ValueFlag.Name),
161+
Origin: sender,
162+
State: statedb,
163+
GasLimit: initialGas,
164+
GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
165+
Value: utils.GlobalBig(ctx, ValueFlag.Name),
166+
BlockNumber: new(big.Int).SetUint64(blockNumber),
164167
EVMConfig: vm.Config{
165168
Tracer: tracer,
166169
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),

0 commit comments

Comments
 (0)