Skip to content

Commit a50cac5

Browse files
authored
core/vm: EXTCODE* return delegation designator for 7702 (ethereum#31089)
Implements ethereum/EIPs#9248
1 parent 0e1a19d commit a50cac5

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

core/vm/eips.go

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ 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"
2826
"github.com/ethereum/go-ethereum/params"
2927
"github.com/holiman/uint256"
3028
)
@@ -709,65 +707,8 @@ func enableEOF(jt *JumpTable) {
709707
}
710708
}
711709

712-
// opExtCodeCopyEIP7702 implements the EIP-7702 variation of opExtCodeCopy.
713-
func opExtCodeCopyEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
714-
var (
715-
stack = scope.Stack
716-
a = stack.pop()
717-
memOffset = stack.pop()
718-
codeOffset = stack.pop()
719-
length = stack.pop()
720-
)
721-
uint64CodeOffset, overflow := codeOffset.Uint64WithOverflow()
722-
if overflow {
723-
uint64CodeOffset = math.MaxUint64
724-
}
725-
code := interpreter.evm.StateDB.GetCode(common.Address(a.Bytes20()))
726-
if _, ok := types.ParseDelegation(code); ok {
727-
code = types.DelegationPrefix[:2]
728-
}
729-
codeCopy := getData(code, uint64CodeOffset, length.Uint64())
730-
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
731-
732-
return nil, nil
733-
}
734-
735-
// opExtCodeSizeEIP7702 implements the EIP-7702 variation of opExtCodeSize.
736-
func opExtCodeSizeEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
737-
slot := scope.Stack.peek()
738-
code := interpreter.evm.StateDB.GetCode(common.Address(slot.Bytes20()))
739-
if _, ok := types.ParseDelegation(code); ok {
740-
code = types.DelegationPrefix[:2]
741-
}
742-
slot.SetUint64(uint64(len(code)))
743-
return nil, nil
744-
}
745-
746-
// opExtCodeHashEIP7702 implements the EIP-7702 variation of opExtCodeHash.
747-
func opExtCodeHashEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
748-
slot := scope.Stack.peek()
749-
addr := common.Address(slot.Bytes20())
750-
if interpreter.evm.StateDB.Empty(addr) {
751-
slot.Clear()
752-
return nil, nil
753-
}
754-
code := interpreter.evm.StateDB.GetCode(addr)
755-
if _, ok := types.ParseDelegation(code); ok {
756-
// If the code is a delegation, return the prefix without version.
757-
slot.SetBytes(crypto.Keccak256(types.DelegationPrefix[:2]))
758-
} else {
759-
// Otherwise, return normal code hash.
760-
slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(addr).Bytes())
761-
}
762-
return nil, nil
763-
}
764-
765710
// enable7702 the EIP-7702 changes to support delegation designators.
766711
func enable7702(jt *JumpTable) {
767-
jt[EXTCODECOPY].execute = opExtCodeCopyEIP7702
768-
jt[EXTCODESIZE].execute = opExtCodeSizeEIP7702
769-
jt[EXTCODEHASH].execute = opExtCodeHashEIP7702
770-
771712
jt[CALL].dynamicGas = gasCallEIP7702
772713
jt[CALLCODE].dynamicGas = gasCallCodeEIP7702
773714
jt[STATICCALL].dynamicGas = gasStaticCallEIP7702

0 commit comments

Comments
 (0)