From 342ae7ce7dfd7a0eab2dd06bfa65199825279f05 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Thu, 21 Jan 2016 15:29:58 +0100 Subject: core, core/vm, tests: changed the initialisation behaviour of the EVM The EVM was previously initialised and created for every CALL, CALLCODE, DELEGATECALL and CREATE. This PR changes this behaviour so that the same EVM can be used through the session and beyond as long as the Environment sticks around. --- tests/util.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/util.go b/tests/util.go index 29f4c9b72..2c749edba 100644 --- a/tests/util.go +++ b/tests/util.go @@ -143,12 +143,15 @@ type Env struct { logs []vm.StructLog vmTest bool + + evm *vm.Vm } func NewEnv(state *state.StateDB) *Env { - return &Env{ + env := &Env{ state: state, } + return env } func (self *Env) StructLogs() []vm.StructLog { @@ -171,9 +174,12 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues env.gasLimit = common.Big(envValues["currentGasLimit"]) env.Gas = new(big.Int) + env.evm = vm.EVM(env) + return env } +func (self *Env) Vm() *vm.Vm { return self.evm } func (self *Env) Origin() common.Address { return self.origin } func (self *Env) BlockNumber() *big.Int { return self.number } func (self *Env) Coinbase() common.Address { return self.coinbase } -- cgit v1.2.3 From 14013372aeca2d7f1d8c3a87b7df7c27868314be Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 3 Feb 2016 23:46:27 +0100 Subject: core: Added EVM configuration options The EVM is now initialised with an additional configured object that allows you to turn on debugging options. --- tests/state_test_util.go | 1 - tests/util.go | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 7d1701ff2..50be3a1ac 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -235,7 +235,6 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Log } // Set pre compiled contracts vm.Precompiled = vm.PrecompiledContracts() - vm.Debug = false snapshot := statedb.Copy() gaspool := new(core.GasPool).AddGas(common.Big(env["currentGasLimit"])) diff --git a/tests/util.go b/tests/util.go index 2c749edba..a0eb8158e 100644 --- a/tests/util.go +++ b/tests/util.go @@ -28,8 +28,13 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/logger/glog" ) +func init() { + glog.SetV(0) +} + func checkLogs(tlog []Log, logs vm.Logs) error { if len(tlog) != len(logs) { @@ -144,7 +149,7 @@ type Env struct { vmTest bool - evm *vm.Vm + evm *vm.EVM } func NewEnv(state *state.StateDB) *Env { @@ -174,12 +179,12 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues env.gasLimit = common.Big(envValues["currentGasLimit"]) env.Gas = new(big.Int) - env.evm = vm.EVM(env) + env.evm = vm.New(env, nil) return env } -func (self *Env) Vm() *vm.Vm { return self.evm } +func (self *Env) Vm() vm.Vm { return self.evm } func (self *Env) Origin() common.Address { return self.origin } func (self *Env) BlockNumber() *big.Int { return self.number } func (self *Env) Coinbase() common.Address { return self.coinbase } -- cgit v1.2.3