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. --- cmd/evm/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/evm/main.go b/cmd/evm/main.go index ef679e373..0ba6820e0 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 ( @@ -174,17 +175,23 @@ type VMEnv struct { Gas *big.Int time *big.Int logs []vm.StructLog + + evm *vm.Vm } func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int) *VMEnv { - return &VMEnv{ + params.HomesteadBlock = new(big.Int) + env := &VMEnv{ state: state, transactor: &transactor, value: value, time: big.NewInt(time.Now().Unix()), } + env.evm = vm.EVM(env) + 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)) } -- cgit 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. --- cmd/ethtest/main.go | 2 -- cmd/evm/main.go | 15 +++++++++------ cmd/geth/main.go | 1 - cmd/geth/usage.go | 1 - cmd/utils/flags.go | 11 ----------- 5 files changed, 9 insertions(+), 21 deletions(-) (limited to 'cmd') diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go index 67b965396..e19dca86b 100644 --- a/cmd/ethtest/main.go +++ b/cmd/ethtest/main.go @@ -26,7 +26,6 @@ import ( "strings" "github.com/codegangsta/cli" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/tests" ) @@ -188,7 +187,6 @@ func setupApp(c *cli.Context) { continueOnError = c.GlobalBool(ContinueOnErrorFlag.Name) useStdIn := c.GlobalBool(ReadStdInFlag.Name) skipTests = strings.Split(c.GlobalString(SkipTestsFlag.Name), " ") - vm.Debug = c.GlobalBool(TraceFlag.Name) if !useStdIn { runSuite(flagTest, flagFile) diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 0ba6820e0..2cc70d81b 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -106,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) @@ -119,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( @@ -176,10 +177,10 @@ type VMEnv struct { time *big.Int logs []vm.StructLog - evm *vm.Vm + evm *vm.EVM } -func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int) *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, @@ -187,11 +188,13 @@ func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int) *VM value: value, time: big.NewInt(time.Now().Unix()), } - env.evm = vm.EVM(env) + cfg.Logger.Collector = env + + env.evm = vm.New(env, cfg) return env } -func (self *VMEnv) Vm() *vm.Vm { return self.evm } +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)) } diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 68e09912b..a21fe71b5 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -321,7 +321,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.WhisperEnabledFlag, utils.DevModeFlag, utils.TestNetFlag, - utils.VMDebugFlag, utils.VMForceJitFlag, utils.VMJitCacheFlag, utils.VMEnableJitFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index d2f76eaa6..55daa63d7 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -142,7 +142,6 @@ var AppHelpFlagGroups = []flagGroup{ { Name: "VIRTUAL MACHINE", Flags: []cli.Flag{ - utils.VMDebugFlag, utils.VMEnableJitFlag, utils.VMForceJitFlag, utils.VMJitCacheFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 69fb0b9db..3b05c2963 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -203,11 +203,6 @@ var ( Value: "", } - // vm flags - VMDebugFlag = cli.BoolFlag{ - Name: "vmdebug", - Usage: "Virtual Machine debug output", - } VMForceJitFlag = cli.BoolFlag{ Name: "forcejit", Usage: "Force the JIT VM to take precedence", @@ -728,9 +723,6 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node. if !ctx.GlobalIsSet(WhisperEnabledFlag.Name) { shhEnable = true } - if !ctx.GlobalIsSet(VMDebugFlag.Name) { - vm.Debug = true - } ethConf.PowTest = true } // Assemble and return the protocol stack @@ -771,9 +763,6 @@ func SetupVM(ctx *cli.Context) { vm.EnableJit = ctx.GlobalBool(VMEnableJitFlag.Name) vm.ForceJit = ctx.GlobalBool(VMForceJitFlag.Name) vm.SetJITCacheSize(ctx.GlobalInt(VMJitCacheFlag.Name)) - if ctx.GlobalIsSet(VMDebugFlag.Name) { - vm.Debug = ctx.GlobalBool(VMDebugFlag.Name) - } } // MakeChain creates a chain manager from set command line flags. -- cgit From 0cfa21fc7f34d9da93abc41541dd4a98d70eb9dd Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sat, 19 Mar 2016 18:07:09 +0100 Subject: core, eth, cmd: temporary work around for enabling the jit This commit serves as a temporary workaround for enabling the jit until the block customisation PR is merged in. --- cmd/utils/flags.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmd') diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3b05c2963..10aa48735 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -668,6 +668,8 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node. ExtraData: MakeMinerExtra(extra, ctx), NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name), DocRoot: ctx.GlobalString(DocRootFlag.Name), + EnableJit: ctx.GlobalBool(VMEnableJitFlag.Name), + ForceJit: ctx.GlobalBool(VMForceJitFlag.Name), GasPrice: common.String2Big(ctx.GlobalString(GasPriceFlag.Name)), GpoMinGasPrice: common.String2Big(ctx.GlobalString(GpoMinGasPriceFlag.Name)), GpoMaxGasPrice: common.String2Big(ctx.GlobalString(GpoMaxGasPriceFlag.Name)), -- cgit