evm.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. // Copyright 2014 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package vm
  17. import (
  18. "math/big"
  19. "sync/atomic"
  20. "time"
  21. "github.com/ethereum/go-ethereum/common"
  22. "github.com/ethereum/go-ethereum/crypto"
  23. "github.com/ethereum/go-ethereum/params"
  24. "github.com/holiman/uint256"
  25. )
  26. // emptyCodeHash is used by create to ensure deployment is disallowed to already
  27. // deployed contract addresses (relevant after the account abstraction).
  28. var emptyCodeHash = crypto.Keccak256Hash(nil)
  29. type (
  30. // CanTransferFunc is the signature of a transfer guard function
  31. CanTransferFunc func(StateDB, common.Address, *big.Int) bool
  32. // TransferFunc is the signature of a transfer function
  33. TransferFunc func(StateDB, common.Address, common.Address, *big.Int)
  34. // GetHashFunc returns the n'th block hash in the blockchain
  35. // and is used by the BLOCKHASH EVM op code.
  36. GetHashFunc func(uint64) common.Hash
  37. )
  38. func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
  39. var precompiles map[common.Address]PrecompiledContract
  40. switch {
  41. case evm.chainRules.IsBerlin:
  42. precompiles = PrecompiledContractsBerlin
  43. case evm.chainRules.IsIstanbul:
  44. precompiles = PrecompiledContractsIstanbul
  45. case evm.chainRules.IsByzantium:
  46. precompiles = PrecompiledContractsByzantium
  47. default:
  48. precompiles = PrecompiledContractsHomestead
  49. }
  50. p, ok := precompiles[addr]
  51. return p, ok
  52. }
  53. // BlockContext provides the EVM with auxiliary information. Once provided
  54. // it shouldn't be modified.
  55. type BlockContext struct {
  56. // CanTransfer returns whether the account contains
  57. // sufficient ether to transfer the value
  58. CanTransfer CanTransferFunc
  59. // Transfer transfers ether from one account to the other
  60. Transfer TransferFunc
  61. // GetHash returns the hash corresponding to n
  62. GetHash GetHashFunc
  63. // Block information
  64. Coinbase common.Address // Provides information for COINBASE
  65. GasLimit uint64 // Provides information for GASLIMIT
  66. BlockNumber *big.Int // Provides information for NUMBER
  67. Time *big.Int // Provides information for TIME
  68. Difficulty *big.Int // Provides information for DIFFICULTY
  69. BaseFee *big.Int // Provides information for BASEFEE
  70. Random *common.Hash // Provides information for RANDOM
  71. }
  72. // TxContext provides the EVM with information about a transaction.
  73. // All fields can change between transactions.
  74. type TxContext struct {
  75. // Message information
  76. Origin common.Address // Provides information for ORIGIN
  77. GasPrice *big.Int // Provides information for GASPRICE
  78. }
  79. // EVM is the Ethereum Virtual Machine base object and provides
  80. // the necessary tools to run a contract on the given state with
  81. // the provided context. It should be noted that any error
  82. // generated through any of the calls should be considered a
  83. // revert-state-and-consume-all-gas operation, no checks on
  84. // specific errors should ever be performed. The interpreter makes
  85. // sure that any errors generated are to be considered faulty code.
  86. //
  87. // The EVM should never be reused and is not thread safe.
  88. type EVM struct {
  89. // Context provides auxiliary blockchain related information
  90. Context BlockContext
  91. TxContext
  92. // StateDB gives access to the underlying state
  93. StateDB StateDB
  94. // Depth is the current call stack
  95. depth int
  96. // chainConfig contains information about the current chain
  97. chainConfig *params.ChainConfig
  98. // chain rules contains the chain rules for the current epoch
  99. chainRules params.Rules
  100. // virtual machine configuration options used to initialise the
  101. // evm.
  102. Config Config
  103. // global (to this context) ethereum virtual machine
  104. // used throughout the execution of the tx.
  105. interpreter *EVMInterpreter
  106. // abort is used to abort the EVM calling operations
  107. // NOTE: must be set atomically
  108. abort int32
  109. // callGasTemp holds the gas available for the current call. This is needed because the
  110. // available gas is calculated in gasCall* according to the 63/64 rule and later
  111. // applied in opCall*.
  112. callGasTemp uint64
  113. }
  114. // NewEVM returns a new EVM. The returned EVM is not thread safe and should
  115. // only ever be used *once*.
  116. func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig *params.ChainConfig, config Config) *EVM {
  117. evm := &EVM{
  118. Context: blockCtx,
  119. TxContext: txCtx,
  120. StateDB: statedb,
  121. Config: config,
  122. chainConfig: chainConfig,
  123. chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil),
  124. }
  125. evm.interpreter = NewEVMInterpreter(evm, config)
  126. return evm
  127. }
  128. // Reset resets the EVM with a new transaction context.Reset
  129. // This is not threadsafe and should only be done very cautiously.
  130. func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
  131. evm.TxContext = txCtx
  132. evm.StateDB = statedb
  133. }
  134. // Cancel cancels any running EVM operation. This may be called concurrently and
  135. // it's safe to be called multiple times.
  136. func (evm *EVM) Cancel() {
  137. atomic.StoreInt32(&evm.abort, 1)
  138. }
  139. // Cancelled returns true if Cancel has been called
  140. func (evm *EVM) Cancelled() bool {
  141. return atomic.LoadInt32(&evm.abort) == 1
  142. }
  143. // Interpreter returns the current interpreter
  144. func (evm *EVM) Interpreter() *EVMInterpreter {
  145. return evm.interpreter
  146. }
  147. // Call executes the contract associated with the addr with the given input as
  148. // parameters. It also handles any necessary value transfer required and takes
  149. // the necessary steps to create accounts and reverses the state in case of an
  150. // execution error or failed value transfer.
  151. func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) {
  152. // Fail if we're trying to execute above the call depth limit
  153. if evm.depth > int(params.CallCreateDepth) {
  154. return nil, gas, ErrDepth
  155. }
  156. // Fail if we're trying to transfer more than the available balance
  157. if value.Sign() != 0 && !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
  158. return nil, gas, ErrInsufficientBalance
  159. }
  160. snapshot := evm.StateDB.Snapshot()
  161. p, isPrecompile := evm.precompile(addr)
  162. if !evm.StateDB.Exist(addr) {
  163. if !isPrecompile && evm.chainRules.IsEIP158 && value.Sign() == 0 {
  164. // Calling a non existing account, don't do anything, but ping the tracer
  165. if evm.Config.Debug {
  166. if evm.depth == 0 {
  167. evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
  168. evm.Config.Tracer.CaptureEnd(ret, 0, 0, nil)
  169. } else {
  170. evm.Config.Tracer.CaptureEnter(CALL, caller.Address(), addr, input, gas, value)
  171. evm.Config.Tracer.CaptureExit(ret, 0, nil)
  172. }
  173. }
  174. return nil, gas, nil
  175. }
  176. evm.StateDB.CreateAccount(addr)
  177. }
  178. evm.Context.Transfer(evm.StateDB, caller.Address(), addr, value)
  179. // Capture the tracer start/end events in debug mode
  180. if evm.Config.Debug {
  181. if evm.depth == 0 {
  182. evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
  183. defer func(startGas uint64, startTime time.Time) { // Lazy evaluation of the parameters
  184. evm.Config.Tracer.CaptureEnd(ret, startGas-gas, time.Since(startTime), err)
  185. }(gas, time.Now())
  186. } else {
  187. // Handle tracer events for entering and exiting a call frame
  188. evm.Config.Tracer.CaptureEnter(CALL, caller.Address(), addr, input, gas, value)
  189. defer func(startGas uint64) {
  190. evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
  191. }(gas)
  192. }
  193. }
  194. if isPrecompile {
  195. ret, gas, err = RunPrecompiledContract(p, input, gas)
  196. } else {
  197. // Initialise a new contract and set the code that is to be used by the EVM.
  198. // The contract is a scoped environment for this execution context only.
  199. code := evm.StateDB.GetCode(addr)
  200. if len(code) == 0 {
  201. ret, err = nil, nil // gas is unchanged
  202. } else {
  203. addrCopy := addr
  204. // If the account has no code, we can abort here
  205. // The depth-check is already done, and precompiles handled above
  206. contract := NewContract(caller, AccountRef(addrCopy), value, gas)
  207. contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), code)
  208. ret, err = evm.interpreter.Run(contract, input, false)
  209. gas = contract.Gas
  210. }
  211. }
  212. // When an error was returned by the EVM or when setting the creation code
  213. // above we revert to the snapshot and consume any gas remaining. Additionally
  214. // when we're in homestead this also counts for code storage gas errors.
  215. if err != nil {
  216. evm.StateDB.RevertToSnapshot(snapshot)
  217. if err != ErrExecutionReverted {
  218. gas = 0
  219. }
  220. // TODO: consider clearing up unused snapshots:
  221. //} else {
  222. // evm.StateDB.DiscardSnapshot(snapshot)
  223. }
  224. return ret, gas, err
  225. }
  226. // CallCode executes the contract associated with the addr with the given input
  227. // as parameters. It also handles any necessary value transfer required and takes
  228. // the necessary steps to create accounts and reverses the state in case of an
  229. // execution error or failed value transfer.
  230. //
  231. // CallCode differs from Call in the sense that it executes the given address'
  232. // code with the caller as context.
  233. func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) {
  234. // Fail if we're trying to execute above the call depth limit
  235. if evm.depth > int(params.CallCreateDepth) {
  236. return nil, gas, ErrDepth
  237. }
  238. // Fail if we're trying to transfer more than the available balance
  239. // Note although it's noop to transfer X ether to caller itself. But
  240. // if caller doesn't have enough balance, it would be an error to allow
  241. // over-charging itself. So the check here is necessary.
  242. if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
  243. return nil, gas, ErrInsufficientBalance
  244. }
  245. var snapshot = evm.StateDB.Snapshot()
  246. // Invoke tracer hooks that signal entering/exiting a call frame
  247. if evm.Config.Debug {
  248. evm.Config.Tracer.CaptureEnter(CALLCODE, caller.Address(), addr, input, gas, value)
  249. defer func(startGas uint64) {
  250. evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
  251. }(gas)
  252. }
  253. // It is allowed to call precompiles, even via delegatecall
  254. if p, isPrecompile := evm.precompile(addr); isPrecompile {
  255. ret, gas, err = RunPrecompiledContract(p, input, gas)
  256. } else {
  257. addrCopy := addr
  258. // Initialise a new contract and set the code that is to be used by the EVM.
  259. // The contract is a scoped environment for this execution context only.
  260. contract := NewContract(caller, AccountRef(caller.Address()), value, gas)
  261. contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), evm.StateDB.GetCode(addrCopy))
  262. ret, err = evm.interpreter.Run(contract, input, false)
  263. gas = contract.Gas
  264. }
  265. if err != nil {
  266. evm.StateDB.RevertToSnapshot(snapshot)
  267. if err != ErrExecutionReverted {
  268. gas = 0
  269. }
  270. }
  271. return ret, gas, err
  272. }
  273. // DelegateCall executes the contract associated with the addr with the given input
  274. // as parameters. It reverses the state in case of an execution error.
  275. //
  276. // DelegateCall differs from CallCode in the sense that it executes the given address'
  277. // code with the caller as context and the caller is set to the caller of the caller.
  278. func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error) {
  279. // Fail if we're trying to execute above the call depth limit
  280. if evm.depth > int(params.CallCreateDepth) {
  281. return nil, gas, ErrDepth
  282. }
  283. var snapshot = evm.StateDB.Snapshot()
  284. // Invoke tracer hooks that signal entering/exiting a call frame
  285. if evm.Config.Debug {
  286. evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, nil)
  287. defer func(startGas uint64) {
  288. evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
  289. }(gas)
  290. }
  291. // It is allowed to call precompiles, even via delegatecall
  292. if p, isPrecompile := evm.precompile(addr); isPrecompile {
  293. ret, gas, err = RunPrecompiledContract(p, input, gas)
  294. } else {
  295. addrCopy := addr
  296. // Initialise a new contract and make initialise the delegate values
  297. contract := NewContract(caller, AccountRef(caller.Address()), nil, gas).AsDelegate()
  298. contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), evm.StateDB.GetCode(addrCopy))
  299. ret, err = evm.interpreter.Run(contract, input, false)
  300. gas = contract.Gas
  301. }
  302. if err != nil {
  303. evm.StateDB.RevertToSnapshot(snapshot)
  304. if err != ErrExecutionReverted {
  305. gas = 0
  306. }
  307. }
  308. return ret, gas, err
  309. }
  310. // StaticCall executes the contract associated with the addr with the given input
  311. // as parameters while disallowing any modifications to the state during the call.
  312. // Opcodes that attempt to perform such modifications will result in exceptions
  313. // instead of performing the modifications.
  314. func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error) {
  315. // Fail if we're trying to execute above the call depth limit
  316. if evm.depth > int(params.CallCreateDepth) {
  317. return nil, gas, ErrDepth
  318. }
  319. // We take a snapshot here. This is a bit counter-intuitive, and could probably be skipped.
  320. // However, even a staticcall is considered a 'touch'. On mainnet, static calls were introduced
  321. // after all empty accounts were deleted, so this is not required. However, if we omit this,
  322. // then certain tests start failing; stRevertTest/RevertPrecompiledTouchExactOOG.json.
  323. // We could change this, but for now it's left for legacy reasons
  324. var snapshot = evm.StateDB.Snapshot()
  325. // We do an AddBalance of zero here, just in order to trigger a touch.
  326. // This doesn't matter on Mainnet, where all empties are gone at the time of Byzantium,
  327. // but is the correct thing to do and matters on other networks, in tests, and potential
  328. // future scenarios
  329. evm.StateDB.AddBalance(addr, big0)
  330. // Invoke tracer hooks that signal entering/exiting a call frame
  331. if evm.Config.Debug {
  332. evm.Config.Tracer.CaptureEnter(STATICCALL, caller.Address(), addr, input, gas, nil)
  333. defer func(startGas uint64) {
  334. evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
  335. }(gas)
  336. }
  337. if p, isPrecompile := evm.precompile(addr); isPrecompile {
  338. ret, gas, err = RunPrecompiledContract(p, input, gas)
  339. } else {
  340. // At this point, we use a copy of address. If we don't, the go compiler will
  341. // leak the 'contract' to the outer scope, and make allocation for 'contract'
  342. // even if the actual execution ends on RunPrecompiled above.
  343. addrCopy := addr
  344. // Initialise a new contract and set the code that is to be used by the EVM.
  345. // The contract is a scoped environment for this execution context only.
  346. contract := NewContract(caller, AccountRef(addrCopy), new(big.Int), gas)
  347. contract.SetCallCode(&addrCopy, evm.StateDB.GetCodeHash(addrCopy), evm.StateDB.GetCode(addrCopy))
  348. // When an error was returned by the EVM or when setting the creation code
  349. // above we revert to the snapshot and consume any gas remaining. Additionally
  350. // when we're in Homestead this also counts for code storage gas errors.
  351. ret, err = evm.interpreter.Run(contract, input, true)
  352. gas = contract.Gas
  353. }
  354. if err != nil {
  355. evm.StateDB.RevertToSnapshot(snapshot)
  356. if err != ErrExecutionReverted {
  357. gas = 0
  358. }
  359. }
  360. return ret, gas, err
  361. }
  362. type codeAndHash struct {
  363. code []byte
  364. hash common.Hash
  365. }
  366. func (c *codeAndHash) Hash() common.Hash {
  367. if c.hash == (common.Hash{}) {
  368. c.hash = crypto.Keccak256Hash(c.code)
  369. }
  370. return c.hash
  371. }
  372. // create creates a new contract using code as deployment code.
  373. func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, value *big.Int, address common.Address, typ OpCode) ([]byte, common.Address, uint64, error) {
  374. // Depth check execution. Fail if we're trying to execute above the
  375. // limit.
  376. if evm.depth > int(params.CallCreateDepth) {
  377. return nil, common.Address{}, gas, ErrDepth
  378. }
  379. if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
  380. return nil, common.Address{}, gas, ErrInsufficientBalance
  381. }
  382. nonce := evm.StateDB.GetNonce(caller.Address())
  383. if nonce+1 < nonce {
  384. return nil, common.Address{}, gas, ErrNonceUintOverflow
  385. }
  386. evm.StateDB.SetNonce(caller.Address(), nonce+1)
  387. // We add this to the access list _before_ taking a snapshot. Even if the creation fails,
  388. // the access-list change should not be rolled back
  389. if evm.chainRules.IsBerlin {
  390. evm.StateDB.AddAddressToAccessList(address)
  391. }
  392. // Ensure there's no existing contract already at the designated address
  393. contractHash := evm.StateDB.GetCodeHash(address)
  394. if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != emptyCodeHash) {
  395. return nil, common.Address{}, 0, ErrContractAddressCollision
  396. }
  397. // Create a new account on the state
  398. snapshot := evm.StateDB.Snapshot()
  399. evm.StateDB.CreateAccount(address)
  400. if evm.chainRules.IsEIP158 {
  401. evm.StateDB.SetNonce(address, 1)
  402. }
  403. evm.Context.Transfer(evm.StateDB, caller.Address(), address, value)
  404. // Initialise a new contract and set the code that is to be used by the EVM.
  405. // The contract is a scoped environment for this execution context only.
  406. contract := NewContract(caller, AccountRef(address), value, gas)
  407. contract.SetCodeOptionalHash(&address, codeAndHash)
  408. if evm.Config.Debug {
  409. if evm.depth == 0 {
  410. evm.Config.Tracer.CaptureStart(evm, caller.Address(), address, true, codeAndHash.code, gas, value)
  411. } else {
  412. evm.Config.Tracer.CaptureEnter(typ, caller.Address(), address, codeAndHash.code, gas, value)
  413. }
  414. }
  415. start := time.Now()
  416. ret, err := evm.interpreter.Run(contract, nil, false)
  417. // Check whether the max code size has been exceeded, assign err if the case.
  418. if err == nil && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSize {
  419. err = ErrMaxCodeSizeExceeded
  420. }
  421. // Reject code starting with 0xEF if EIP-3541 is enabled.
  422. if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsLondon {
  423. err = ErrInvalidCode
  424. }
  425. // if the contract creation ran successfully and no errors were returned
  426. // calculate the gas required to store the code. If the code could not
  427. // be stored due to not enough gas set an error and let it be handled
  428. // by the error checking condition below.
  429. if err == nil {
  430. createDataGas := uint64(len(ret)) * params.CreateDataGas
  431. if contract.UseGas(createDataGas) {
  432. evm.StateDB.SetCode(address, ret)
  433. } else {
  434. err = ErrCodeStoreOutOfGas
  435. }
  436. }
  437. // When an error was returned by the EVM or when setting the creation code
  438. // above we revert to the snapshot and consume any gas remaining. Additionally
  439. // when we're in homestead this also counts for code storage gas errors.
  440. if err != nil && (evm.chainRules.IsHomestead || err != ErrCodeStoreOutOfGas) {
  441. evm.StateDB.RevertToSnapshot(snapshot)
  442. if err != ErrExecutionReverted {
  443. contract.UseGas(contract.Gas)
  444. }
  445. }
  446. if evm.Config.Debug {
  447. if evm.depth == 0 {
  448. evm.Config.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err)
  449. } else {
  450. evm.Config.Tracer.CaptureExit(ret, gas-contract.Gas, err)
  451. }
  452. }
  453. return ret, address, contract.Gas, err
  454. }
  455. // Create creates a new contract using code as deployment code.
  456. func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
  457. contractAddr = crypto.CreateAddress(caller.Address(), evm.StateDB.GetNonce(caller.Address()))
  458. return evm.create(caller, &codeAndHash{code: code}, gas, value, contractAddr, CREATE)
  459. }
  460. // Create2 creates a new contract using code as deployment code.
  461. //
  462. // The different between Create2 with Create is Create2 uses keccak256(0xff ++ msg.sender ++ salt ++ keccak256(init_code))[12:]
  463. // instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
  464. func (evm *EVM) Create2(caller ContractRef, code []byte, gas uint64, endowment *big.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
  465. codeAndHash := &codeAndHash{code: code}
  466. contractAddr = crypto.CreateAddress2(caller.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes())
  467. return evm.create(caller, codeAndHash, gas, endowment, contractAddr, CREATE2)
  468. }
  469. // ChainConfig returns the environment's chain configuration
  470. func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig }