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

Disable EOF CALL opcodes in legacy #7544

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public long gasAvailableForChildCall(final MessageFrame frame) {

@Override
public OperationResult execute(final MessageFrame frame, final EVM evm) {
Code callingCode = frame.getCode();
if (callingCode.getEofVersion() == 0) {
return InvalidOperation.INVALID_RESULT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add some tests showing that an INVALID_RESULT is returned for legacy with EXTCALL, EXTDELEGATECALL and EXTSTATICCALL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ethereum/execution-spec-tests/pull/768/files

Tests all legacy-invalid opcodes, not just EXT*CREATE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we can pull in the latest execution-spec tests when they get published 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f19e242 also should address @jframe's concern

}

final Bytes toBytes = frame.getStackItem(STACK_TO).trimLeadingZeros();
final Wei value = value(frame);
final boolean zeroValue = value.isZero();
Expand Down Expand Up @@ -141,7 +146,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
frame.clearReturnData();

// delegate calls to prior EOF versions are prohibited
if (isDelegate() && frame.getCode().getEofVersion() != code.getEofVersion()) {
if (isDelegate() && callingCode.getEofVersion() != code.getEofVersion()) {
return softFailure(frame, cost);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void gasTest(
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(parentGas)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(Bytes.EMPTY)
.pushStackItem(Bytes.EMPTY)
Expand Down Expand Up @@ -208,6 +209,7 @@ void callWithValueTest(
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(parentGas)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(valueSent)
.pushStackItem(Bytes.EMPTY)
Expand Down Expand Up @@ -243,6 +245,7 @@ void overflowTest() {
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(400000)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(Bytes.EMPTY)
.pushStackItem(Bytes.EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void overflowTest() {
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(400000)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(Bytes.EMPTY)
.pushStackItem(Bytes.EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void gasTest(
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(parentGas)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(Bytes.EMPTY)
.pushStackItem(Bytes.EMPTY)
Expand Down Expand Up @@ -154,6 +155,7 @@ void overflowTest() {
final var messageFrame =
new TestMessageFrameBuilder()
.initialGas(400000)
.code(SIMPLE_EOF)
.pushStackItem(CONTRACT_ADDRESS) // canary for non-returning
.pushStackItem(Bytes.EMPTY)
.pushStackItem(Bytes.EMPTY)
Expand Down
Loading