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