Example #1
0
func NewEnv(state *state.StateDB, transactor common.Address, value *big.Int, cfg vm.Config) *VMEnv {
	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
}
Example #2
0
func NewEnv(state *state.StateDB, chainConfig *ChainConfig, chain *BlockChain, msg Message, header *types.Header, cfg vm.Config) *VMEnv {
	env := &VMEnv{
		chainConfig: chainConfig,
		chain:       chain,
		state:       state,
		header:      header,
		msg:         msg,
		getHashFn:   GetHashFn(header.ParentHash, chain),
	}

	// if no log collector is present set self as the collector
	if cfg.Logger.Collector == nil {
		cfg.Logger.Collector = env
	}

	env.evm = vm.New(env, cfg)
	return env
}
Example #3
0
func NewEnvFromMap(ruleSet RuleSet, state *state.StateDB, envValues map[string]string, exeValues map[string]string) *Env {
	env := NewEnv(ruleSet, state)

	env.origin = common.HexToAddress(exeValues["caller"])
	env.parent = common.HexToHash(envValues["previousHash"])
	env.coinbase = common.HexToAddress(envValues["currentCoinbase"])
	env.number = common.Big(envValues["currentNumber"])
	env.time = common.Big(envValues["currentTimestamp"])
	env.difficulty = common.Big(envValues["currentDifficulty"])
	env.gasLimit = common.Big(envValues["currentGasLimit"])
	env.Gas = new(big.Int)

	env.evm = vm.New(env, vm.Config{
		EnableJit: EnableJit,
		ForceJit:  ForceJit,
	})

	return env
}
Example #4
0
// NewEnv returns a new vm.Environment
func NewEnv(cfg *Config, state *state.StateDB) vm.Environment {
	env := &Env{
		state:      state,
		origin:     cfg.Origin,
		coinbase:   cfg.Coinbase,
		number:     cfg.BlockNumber,
		time:       cfg.Time,
		difficulty: cfg.Difficulty,
		gasLimit:   cfg.GasLimit,
	}
	env.evm = vm.New(env, &vm.Config{
		Debug:     cfg.Debug,
		EnableJit: !cfg.DisableJit,
		ForceJit:  !cfg.DisableJit,

		Logger: vm.LogConfig{
			Collector: env,
		},
	})

	return env
}