Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devnet-6: 7702 changes for EXTCODE* #8169

Merged
merged 14 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.tuweni.bytes.Bytes;

/** The Ext code copy operation. */
public class ExtCodeCopyOperation extends AbstractExtCodeOperation {
public class ExtCodeCopyOperation extends AbstractOperation {

/** This is the "code" legacy contracts see when copying code from an EOF contract. */
public static final Bytes EOF_REPLACEMENT_CODE = Bytes.fromHexString("0xef00");
Expand Down Expand Up @@ -93,8 +93,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
}

final Account account = frame.getWorldUpdater().get(address);

final Bytes code = getCode(account);
final Bytes code = account != null ? account.getCode() : Bytes.EMPTY;

if (enableEIP3540
&& code.size() >= 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.tuweni.bytes.Bytes;

/** The Ext code hash operation. */
public class ExtCodeHashOperation extends AbstractExtCodeOperation {
public class ExtCodeHashOperation extends AbstractOperation {

// // 0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5
static final Hash EOF_REPLACEMENT_HASH = Hash.hash(ExtCodeCopyOperation.EOF_REPLACEMENT_CODE);
Expand Down Expand Up @@ -85,14 +85,14 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
if (account == null || account.isEmpty()) {
frame.pushStackItem(Bytes.EMPTY);
} else {
final Bytes code = getCode(account);
final Bytes code = account.getCode();
if (enableEIP3540
&& code.size() >= 2
&& code.get(0) == EOFLayout.EOF_PREFIX_BYTE
&& code.get(1) == 0) {
frame.pushStackItem(EOF_REPLACEMENT_HASH);
} else {
frame.pushStackItem(getCodeHash(account));
frame.pushStackItem(account.getCodeHash());
}
}
return new OperationResult(cost, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.tuweni.bytes.Bytes;

/** The Ext code size operation. */
public class ExtCodeSizeOperation extends AbstractExtCodeOperation {
public class ExtCodeSizeOperation extends AbstractOperation {

static final Bytes EOF_SIZE = Bytes.of(2);

Expand Down Expand Up @@ -83,7 +83,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
if (account == null) {
codeSize = Bytes.EMPTY;
} else {
final Bytes code = getCode(account);
final Bytes code = account.getCode();
if (enableEIP3540
&& code.size() >= 2
&& code.get(0) == EOFLayout.EOF_PREFIX_BYTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

/** Helper class for 7702 delegated code interactions */
public class CodeDelegationHelper {
/**
* The designator that is returned when a ExtCode* operation calls a contract with delegated code
*/
public static final Bytes DELEGATED_CODE_DESIGNATOR = Bytes.fromHexString("ef01");

/** The prefix that is used to identify delegated code */
public static final Bytes CODE_DELEGATION_PREFIX = Bytes.fromHexString("ef0100");

Expand All @@ -47,13 +42,4 @@ public static boolean hasCodeDelegation(final Bytes code) {
&& code.size() == DELEGATED_CODE_SIZE
&& code.slice(0, CODE_DELEGATION_PREFIX.size()).equals(CODE_DELEGATION_PREFIX);
}

/**
* Returns the delegated code designator
*
* @return the hardcoded designator for delegated code: ef01
*/
public static Bytes getCodeDelegationForRead() {
return DELEGATED_CODE_DESIGNATOR;
}
}