44
44
func run (evm * EVM , contract * Contract , input []byte , readOnly bool ) ([]byte , error ) {
45
45
if contract .CodeAddr != nil {
46
46
precompiles := PrecompiledContractsHomestead
47
- if evm .ChainConfig () .IsByzantium ( evm . BlockNumber ) {
47
+ if evm .chainRules .IsByzantium {
48
48
precompiles = PrecompiledContractsByzantium
49
49
}
50
50
if p := precompiles [* contract .CodeAddr ]; p != nil {
@@ -203,10 +203,10 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
203
203
)
204
204
if ! evm .StateDB .Exist (addr ) {
205
205
precompiles := PrecompiledContractsHomestead
206
- if evm .ChainConfig () .IsByzantium ( evm . BlockNumber ) {
206
+ if evm .chainRules .IsByzantium {
207
207
precompiles = PrecompiledContractsByzantium
208
208
}
209
- if precompiles [addr ] == nil && evm .ChainConfig () .IsEIP158 ( evm . BlockNumber ) && value .Sign () == 0 {
209
+ if precompiles [addr ] == nil && evm .chainRules .IsEIP158 && value .Sign () == 0 {
210
210
// Calling a non existing account, don't do anything, but ping the tracer
211
211
if evm .vmConfig .Debug && evm .depth == 0 {
212
212
evm .vmConfig .Tracer .CaptureStart (caller .Address (), addr , false , input , gas , value )
@@ -394,7 +394,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
394
394
// Create a new account on the state
395
395
snapshot := evm .StateDB .Snapshot ()
396
396
evm .StateDB .CreateAccount (address )
397
- if evm .ChainConfig () .IsEIP158 ( evm . BlockNumber ) {
397
+ if evm .chainRules .IsEIP158 {
398
398
evm .StateDB .SetNonce (address , 1 )
399
399
}
400
400
evm .Transfer (evm .StateDB , caller .Address (), address , value )
@@ -416,7 +416,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
416
416
ret , err := run (evm , contract , nil , false )
417
417
418
418
// check whether the max code size has been exceeded
419
- maxCodeSizeExceeded := evm .ChainConfig () .IsEIP158 ( evm . BlockNumber ) && len (ret ) > params .MaxCodeSize
419
+ maxCodeSizeExceeded := evm .chainRules .IsEIP158 && len (ret ) > params .MaxCodeSize
420
420
// if the contract creation ran successfully and no errors were returned
421
421
// calculate the gas required to store the code. If the code could not
422
422
// be stored due to not enough gas set an error and let it be handled
@@ -433,7 +433,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
433
433
// When an error was returned by the EVM or when setting the creation code
434
434
// above we revert to the snapshot and consume any gas remaining. Additionally
435
435
// when we're in homestead this also counts for code storage gas errors.
436
- if maxCodeSizeExceeded || (err != nil && (evm .ChainConfig () .IsHomestead ( evm . BlockNumber ) || err != ErrCodeStoreOutOfGas )) {
436
+ if maxCodeSizeExceeded || (err != nil && (evm .chainRules .IsHomestead || err != ErrCodeStoreOutOfGas )) {
437
437
evm .StateDB .RevertToSnapshot (snapshot )
438
438
if err != errExecutionReverted {
439
439
contract .UseGas (contract .Gas )
0 commit comments