Merge pull request #2141 from obscuren/evm-init
core, core/vm, tests: changed the initialisation behaviour of the EVM
This commit is contained in:
@ -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)
|
||||
|
@ -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)) }
|
||||
|
@ -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,
|
||||
|
@ -142,7 +142,6 @@ var AppHelpFlagGroups = []flagGroup{
|
||||
{
|
||||
Name: "VIRTUAL MACHINE",
|
||||
Flags: []cli.Flag{
|
||||
utils.VMDebugFlag,
|
||||
utils.VMEnableJitFlag,
|
||||
utils.VMForceJitFlag,
|
||||
utils.VMJitCacheFlag,
|
||||
|
@ -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",
|
||||
@ -673,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)),
|
||||
@ -728,9 +725,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 +765,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.
|
||||
|
Reference in New Issue
Block a user