@@ -23,6 +23,8 @@ import (
2323
2424 "github.com/ethereum/go-ethereum/common"
2525 "github.com/ethereum/go-ethereum/core/tracing"
26+ "github.com/ethereum/go-ethereum/core/types"
27+ "github.com/ethereum/go-ethereum/crypto"
2628 "github.com/ethereum/go-ethereum/params"
2729 "github.com/holiman/uint256"
2830)
@@ -718,8 +720,10 @@ func opExtCodeCopyEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
718720 if overflow {
719721 uint64CodeOffset = math .MaxUint64
720722 }
721- addr := common .Address (a .Bytes20 ())
722- code := interpreter .evm .resolveCode (addr )
723+ code := interpreter .evm .StateDB .GetCode (common .Address (a .Bytes20 ()))
724+ if _ , ok := types .ParseDelegation (code ); ok {
725+ code = types .DelegationPrefix [:2 ]
726+ }
723727 codeCopy := getData (code , uint64CodeOffset , length .Uint64 ())
724728 scope .Memory .Set (memOffset .Uint64 (), length .Uint64 (), codeCopy )
725729
@@ -729,18 +733,29 @@ func opExtCodeCopyEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
729733// opExtCodeSizeEIP7702 implements the EIP-7702 variation of opExtCodeSize.
730734func opExtCodeSizeEIP7702 (pc * uint64 , interpreter * EVMInterpreter , scope * ScopeContext ) ([]byte , error ) {
731735 slot := scope .Stack .peek ()
732- slot .SetUint64 (uint64 (len (interpreter .evm .resolveCode (slot .Bytes20 ()))))
736+ code := interpreter .evm .StateDB .GetCode (common .Address (slot .Bytes20 ()))
737+ if _ , ok := types .ParseDelegation (code ); ok {
738+ code = types .DelegationPrefix [:2 ]
739+ }
740+ slot .SetUint64 (uint64 (len (code )))
733741 return nil , nil
734742}
735743
736744// opExtCodeHashEIP7702 implements the EIP-7702 variation of opExtCodeHash.
737745func opExtCodeHashEIP7702 (pc * uint64 , interpreter * EVMInterpreter , scope * ScopeContext ) ([]byte , error ) {
738746 slot := scope .Stack .peek ()
739- address := common .Address (slot .Bytes20 ())
740- if interpreter .evm .StateDB .Empty (address ) {
747+ addr := common .Address (slot .Bytes20 ())
748+ if interpreter .evm .StateDB .Empty (addr ) {
741749 slot .Clear ()
750+ return nil , nil
751+ }
752+ code := interpreter .evm .StateDB .GetCode (addr )
753+ if _ , ok := types .ParseDelegation (code ); ok {
754+ // If the code is a delegation, return the prefix without version.
755+ slot .SetBytes (crypto .Keccak256 (types .DelegationPrefix [:2 ]))
742756 } else {
743- slot .SetBytes (interpreter .evm .resolveCodeHash (address ).Bytes ())
757+ // Otherwise, return normal code hash.
758+ slot .SetBytes (interpreter .evm .StateDB .GetCodeHash (addr ).Bytes ())
744759 }
745760 return nil , nil
746761}
0 commit comments