diff options
author | Kevin <denk.kevin@web.de> | 2018-09-20 14:24:53 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2018-09-20 14:24:53 +0800 |
commit | 3fec73500b60c82a827b36bb03f8ae011b861e72 (patch) | |
tree | cf3f09c1792d90da929c04449acf49050043edba /cmd/evm | |
parent | 6975c7298102f73981a62871f6da8db2b5dbf32c (diff) | |
download | dexon-3fec73500b60c82a827b36bb03f8ae011b861e72.tar.gz dexon-3fec73500b60c82a827b36bb03f8ae011b861e72.tar.zst dexon-3fec73500b60c82a827b36bb03f8ae011b861e72.zip |
cmd/evm: EVM prestate initialization (#17685)
* Bugfix #17216: evm loads prestate file properly now
* code gofmted
Diffstat (limited to 'cmd/evm')
-rw-r--r-- | cmd/evm/runner.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 7138a9ddd..962fc021d 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -80,13 +80,13 @@ func runCmd(ctx *cli.Context) error { } var ( - tracer vm.Tracer - debugLogger *vm.StructLogger - statedb *state.StateDB - chainConfig *params.ChainConfig - sender = common.BytesToAddress([]byte("sender")) - receiver = common.BytesToAddress([]byte("receiver")) - blockNumber uint64 + tracer vm.Tracer + debugLogger *vm.StructLogger + statedb *state.StateDB + chainConfig *params.ChainConfig + sender = common.BytesToAddress([]byte("sender")) + receiver = common.BytesToAddress([]byte("receiver")) + genesisConfig *core.Genesis ) if ctx.GlobalBool(MachineFlag.Name) { tracer = NewJSONLogger(logconfig, os.Stdout) @@ -98,13 +98,14 @@ func runCmd(ctx *cli.Context) error { } if ctx.GlobalString(GenesisFlag.Name) != "" { gen := readGenesis(ctx.GlobalString(GenesisFlag.Name)) + genesisConfig = gen db := ethdb.NewMemDatabase() genesis := gen.ToBlock(db) statedb, _ = state.New(genesis.Root(), state.NewDatabase(db)) chainConfig = gen.Config - blockNumber = gen.Number } else { statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) + genesisConfig = new(core.Genesis) } if ctx.GlobalString(SenderFlag.Name) != "" { sender = common.HexToAddress(ctx.GlobalString(SenderFlag.Name)) @@ -156,13 +157,19 @@ func runCmd(ctx *cli.Context) error { } initialGas := ctx.GlobalUint64(GasFlag.Name) + if genesisConfig.GasLimit != 0 { + initialGas = genesisConfig.GasLimit + } runtimeConfig := runtime.Config{ Origin: sender, State: statedb, GasLimit: initialGas, GasPrice: utils.GlobalBig(ctx, PriceFlag.Name), Value: utils.GlobalBig(ctx, ValueFlag.Name), - BlockNumber: new(big.Int).SetUint64(blockNumber), + Difficulty: genesisConfig.Difficulty, + Time: new(big.Int).SetUint64(genesisConfig.Timestamp), + Coinbase: genesisConfig.Coinbase, + BlockNumber: new(big.Int).SetUint64(genesisConfig.Number), EVMConfig: vm.Config{ Tracer: tracer, Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name), |