2016-04-14 11:18:24 -05:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-10-09 07:56:12 -05:00
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/core"
|
|
|
|
"github.com/ethereum/go-ethereum/core/vm"
|
|
|
|
)
|
|
|
|
|
2017-08-11 06:29:32 -05:00
|
|
|
func NewEnv(cfg *Config) *vm.EVM {
|
2020-11-13 06:42:19 -06:00
|
|
|
txContext := vm.TxContext{
|
2023-06-05 08:43:25 -05:00
|
|
|
Origin: cfg.Origin,
|
|
|
|
GasPrice: cfg.GasPrice,
|
|
|
|
BlobHashes: cfg.BlobHashes,
|
2023-11-08 03:22:08 -06:00
|
|
|
BlobFeeCap: cfg.BlobFeeCap,
|
2020-11-13 06:42:19 -06:00
|
|
|
}
|
|
|
|
blockContext := vm.BlockContext{
|
2016-12-05 19:16:03 -06:00
|
|
|
CanTransfer: core.CanTransfer,
|
|
|
|
Transfer: core.Transfer,
|
2020-02-04 04:32:31 -06:00
|
|
|
GetHash: cfg.GetHashFn,
|
2016-12-05 19:16:03 -06:00
|
|
|
Coinbase: cfg.Coinbase,
|
|
|
|
BlockNumber: cfg.BlockNumber,
|
|
|
|
Time: cfg.Time,
|
|
|
|
Difficulty: cfg.Difficulty,
|
2017-11-13 05:47:27 -06:00
|
|
|
GasLimit: cfg.GasLimit,
|
2021-06-16 01:53:27 -05:00
|
|
|
BaseFee: cfg.BaseFee,
|
2023-10-02 04:49:29 -05:00
|
|
|
BlobBaseFee: cfg.BlobBaseFee,
|
2023-08-25 03:05:33 -05:00
|
|
|
Random: cfg.Random,
|
2015-10-09 07:56:12 -05:00
|
|
|
}
|
2015-11-27 08:40:29 -06:00
|
|
|
|
2020-11-13 06:42:19 -06:00
|
|
|
return vm.NewEVM(blockContext, txContext, cfg.State, cfg.ChainConfig, cfg.EVMConfig)
|
2015-10-09 07:56:12 -05:00
|
|
|
}
|