2016-04-14 16:18:24 +00:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-10-09 12:56:12 +00: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 11:29:32 +00:00
|
|
|
func NewEnv(cfg *Config) *vm.EVM {
|
2020-11-13 12:42:19 +00:00
|
|
|
txContext := vm.TxContext{
|
2023-06-05 13:43:25 +00:00
|
|
|
Origin: cfg.Origin,
|
|
|
|
GasPrice: cfg.GasPrice,
|
|
|
|
BlobHashes: cfg.BlobHashes,
|
2023-11-08 09:22:08 +00:00
|
|
|
BlobFeeCap: cfg.BlobFeeCap,
|
2020-11-13 12:42:19 +00:00
|
|
|
}
|
|
|
|
blockContext := vm.BlockContext{
|
2016-12-06 01:16:03 +00:00
|
|
|
CanTransfer: core.CanTransfer,
|
|
|
|
Transfer: core.Transfer,
|
2020-02-04 10:32:31 +00:00
|
|
|
GetHash: cfg.GetHashFn,
|
2016-12-06 01:16:03 +00:00
|
|
|
Coinbase: cfg.Coinbase,
|
|
|
|
BlockNumber: cfg.BlockNumber,
|
|
|
|
Time: cfg.Time,
|
|
|
|
Difficulty: cfg.Difficulty,
|
2017-11-13 11:47:27 +00:00
|
|
|
GasLimit: cfg.GasLimit,
|
2021-06-16 06:53:27 +00:00
|
|
|
BaseFee: cfg.BaseFee,
|
2023-10-02 09:49:29 +00:00
|
|
|
BlobBaseFee: cfg.BlobBaseFee,
|
2023-08-25 08:05:33 +00:00
|
|
|
Random: cfg.Random,
|
2015-10-09 12:56:12 +00:00
|
|
|
}
|
2015-11-27 14:40:29 +00:00
|
|
|
|
2020-11-13 12:42:19 +00:00
|
|
|
return vm.NewEVM(blockContext, txContext, cfg.State, cfg.ChainConfig, cfg.EVMConfig)
|
2015-10-09 12:56:12 +00:00
|
|
|
}
|