diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-03-24 06:20:51 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-03-24 06:20:51 +0800 |
commit | 75c86f8646ed6a21116d6c5f5e400dd966bb218d (patch) | |
tree | 6c979fd121e7721328b9502f1855387b602dcd87 /cmd/evm/main.go | |
parent | 9866f19d6af607f629be311cb1c879e8f6472773 (diff) | |
parent | 0cfa21fc7f34d9da93abc41541dd4a98d70eb9dd (diff) | |
download | dexon-75c86f8646ed6a21116d6c5f5e400dd966bb218d.tar.gz dexon-75c86f8646ed6a21116d6c5f5e400dd966bb218d.tar.zst dexon-75c86f8646ed6a21116d6c5f5e400dd966bb218d.zip |
Merge pull request #2141 from obscuren/evm-init
core, core/vm, tests: changed the initialisation behaviour of the EVM
Diffstat (limited to 'cmd/evm/main.go')
-rw-r--r-- | cmd/evm/main.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go index ef679e373..2cc70d81b 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -33,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/params" ) var ( @@ -105,7 +106,6 @@ func init() { } func run(ctx *cli.Context) { - vm.Debug = ctx.GlobalBool(DebugFlag.Name) vm.ForceJit = ctx.GlobalBool(ForceJitFlag.Name) vm.EnableJit = !ctx.GlobalBool(DisableJitFlag.Name) @@ -118,7 +118,9 @@ func run(ctx *cli.Context) { receiver := statedb.CreateAccount(common.StringToAddress("receiver")) receiver.SetCode(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name))) - vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(ctx.GlobalString(ValueFlag.Name))) + vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(ctx.GlobalString(ValueFlag.Name)), &vm.Config{ + Debug: ctx.GlobalBool(DebugFlag.Name), + }) tstart := time.Now() ret, e := vmenv.Call( @@ -174,17 +176,25 @@ type VMEnv struct { Gas *big.Int time *big.Int logs []vm.StructLog + + evm *vm.EVM } -func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int) *VMEnv { - return &VMEnv{ +func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int, cfg *vm.Config) *VMEnv { + params.HomesteadBlock = new(big.Int) + env := &VMEnv{ state: state, transactor: &transactor, value: value, time: big.NewInt(time.Now().Unix()), } + cfg.Logger.Collector = env + + env.evm = vm.New(env, cfg) + return env } +func (self *VMEnv) Vm() vm.Vm { return self.evm } func (self *VMEnv) Db() vm.Database { return self.state } func (self *VMEnv) MakeSnapshot() vm.Database { return self.state.Copy() } func (self *VMEnv) SetSnapshot(db vm.Database) { self.state.Set(db.(*state.StateDB)) } |