Skip to content

feat(tests): eip-5920 pay opcode cases #1574

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/actions/build-fixtures/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ runs:
env:
tests_url: https://github.com/ethereum/tests/archive/refs/tags/v
tests_version: 14.1
output_path: blockchain_tests/osaka/eofwrap
output_path: blockchain_tests/speculative/eofwrap
- name: Generate fixtures using fill
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/configs/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ zkevm:
solc: 0.8.21
eip7692:
evm-type: eip7692
fill-params: --fork=Osaka ./tests/osaka
fill-params: --fork=EOFv1 ./tests/speculative
solc: 0.8.21
eofwrap: true
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
paths:
- "tests/**" # This triggers the workflow for any changes in the tests folder
- "!tests/prague/**" # exclude changes in 'tests/prague'
- "!tests/osaka/**" # exclude changes in 'tests/osaka'
- "!tests/speculative/**" # exclude changes in 'tests/speculative'

jobs:
evmone-coverage-diff:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
tests:
- tests/**/test_*.py
- '!tests/prague/**'
- '!tests/osaka/**'
- '!tests/speculative/**'
converted_tests:
- converted-ethereum-tests.txt

Expand Down
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Test fixtures for use by clients are available for each release on the [Github r

### 💥 Breaking Change

#### EOF removed from Osaka

Following ["Interop Testing Call 34"](https://github.com/ethereum/pm/issues/1499) and the procedural EIPs [PR](https://github.com/ethereum/EIPs/pull/9703) the unfortunate decision to remove EOF from Osaka was made.

To accommodate EOF testing for the interim within EEST, its tests have migrated to a new `tests/speculative` folder. This folder will now contain tests for features that are not yet CFI'd in any fork. When EOF is CFI'd for a fork in the future, all tests will be moved from speculative to the respective future fork folder.

A new fork `EOFv1` has additionally been created to fill and consume EOF related fixtures. Client tests fillers such as `evmone` (and client consumers) will now need to use this fork name.

### 🛠️ Framework

- ✨ Add an empty account function for usage within fill and execute ([#1482](https://github.com/ethereum/execution-spec-tests/pull/1482)).
Expand All @@ -20,6 +28,7 @@ Test fixtures for use by clients are available for each release on the [Github r

- ✨ Engine API updates for Osaka, add `get_blobs` rpc method ([#1510](https://github.com/ethereum/execution-spec-tests/pull/1510)).
- ✨ The EIP Version checker has been moved from `fill` and `execute` to it's own command-line tool `check_eip_versions` that gets ran daily as a Github Action ([#1537](https://github.com/ethereum/execution-spec-tests/pull/1537)).
🔀 Add new `tests/speculative` folder, move EOF from Osaka to speculative, add `EOFv1` fork name for EOF tests ([#1507](https://github.com/ethereum/execution-spec-tests/pull/1507)).

### 🧪 Test Cases

Expand Down
11 changes: 8 additions & 3 deletions eels_resolutions.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
"same_as": "EELSMaster"
},
"Prague": {
"git_url": "https://github.com/marioevz/execution-specs.git",
"branch": "forks/prague",
"commit": "bb0eb750d643ced0ebf5dec732cdd23558d0b7f2"
"git_url": "https://github.com/marioevz/execution-specs.git",
"branch": "forks/prague",
"commit": "bb0eb750d643ced0ebf5dec732cdd23558d0b7f2"
},
"Osaka": {
"git_url": "https://github.com/spencer-tb/execution-specs.git",
"branch": "spec/eip-5920",
"commit": "bba905989fbbced524626f3e46b109f74f0ca6f7"
}
}
4 changes: 2 additions & 2 deletions src/cli/eofwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ethereum_test_base_types.conversions import to_hex
from ethereum_test_fixtures.blockchain import FixtureBlock, InvalidFixtureBlock
from ethereum_test_fixtures.file import Fixtures
from ethereum_test_forks.forks.forks import Osaka
from ethereum_test_forks.forks.forks import EOFv1
from ethereum_test_specs.blockchain import Block, BlockchainFixture, BlockchainTest
from ethereum_test_specs.debugging import print_traces
from ethereum_test_specs.eof import EOFParse
Expand Down Expand Up @@ -309,7 +309,7 @@ def _wrap_fixture(self, fixture: BlockchainFixture, traces: bool):

result = test.generate(
t8n=t8n,
fork=Osaka,
fork=EOFv1,
fixture_format=BlockchainFixture,
)
result.info["fixture-format"] = "blockchain_test"
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_forks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Cancun,
Constantinople,
ConstantinopleFix,
EOFv1,
Frontier,
GrayGlacier,
Homestead,
Expand Down Expand Up @@ -59,6 +60,7 @@
"Byzantium",
"Constantinople",
"ConstantinopleFix",
"EOFv1",
"ForkRangeDescriptor",
"Frontier",
"GrayGlacier",
Expand Down
21 changes: 19 additions & 2 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,10 +1291,27 @@ def engine_get_payload_version(
"""From Osaka, get payload calls must use version 5."""
return 5

@classmethod
def is_deployed(cls) -> bool:
"""
Flag that the fork has not been deployed to mainnet; it is under active
development.
"""
return False

@classmethod
def solc_min_version(cls) -> Version:
"""Return minimum version of solc that supports this fork."""
return Version.parse("1.0.0") # set a high version; currently unknown


class EOFv1(Prague, solc_name="cancun"):
"""EOF fork."""

@classmethod
def evm_code_types(cls, block_number: int = 0, timestamp: int = 0) -> List[EVMCodeType]:
"""EOF V1 is supported starting from Osaka."""
return super(Osaka, cls).evm_code_types(
return super(EOFv1, cls).evm_code_types(
block_number,
timestamp,
) + [EVMCodeType.EOF_V1]
Expand All @@ -1308,7 +1325,7 @@ def call_opcodes(
(Opcodes.EXTCALL, EVMCodeType.EOF_V1),
(Opcodes.EXTSTATICCALL, EVMCodeType.EOF_V1),
(Opcodes.EXTDELEGATECALL, EVMCodeType.EOF_V1),
] + super(Osaka, cls).call_opcodes(block_number, timestamp)
] + super(EOFv1, cls).call_opcodes(block_number, timestamp)

@classmethod
def is_deployed(cls) -> bool:
Expand Down
38 changes: 38 additions & 0 deletions src/ethereum_test_vm/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5592,6 +5592,44 @@ class Opcodes(Opcode, Enum):
Source: [EIP-7069](https://eips.ethereum.org/EIPS/eip-7069)
"""

PAY = Opcode(0xFC, popped_stack_items=2, pushed_stack_items=0)
"""
PAY(addr, val)
----
Description
----
Transfers wei (val) from the contracts balance to the address addr without executing any code.
Exceptionally halts if addr has any high 12 bytes set to non-zero values or if the contracts
balance is less than val.

Inputs
----
- addr: destination address (20 bytes)
- val: amount to transfer in wei

Outputs
----
None (consumes values and returns nothing)

Fork
----
Osaka

Gas
----
- Is addr in accessed_addresses:
- If yes, WARM_STORAGE_READ_COST (100)
- Otherwise, COLD_ACCOUNT_ACCESS_COST (2600)
- Does addr exist or is val zero:
- If yes to either, zero
- Otherwise, GAS_NEW_ACCOUNT (25000)
- Is val zero:
- If yes, zero
- Otherwise, GAS_CALL_VALUE (9000)

Source: [EIP-5920](https://eips.ethereum.org/EIPS/eip-5920)
"""

RETURNDATALOAD = Opcode(0xF7, popped_stack_items=1, pushed_stack_items=1, kwargs=["offset"])
"""
RETURNDATALOAD(offset)
Expand Down
6 changes: 3 additions & 3 deletions src/pytest_plugins/filler/gen_test_doc/gen_test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def add_directory_page_props(self) -> None:
pytest_node_id=str(directory),
source_code_url=generate_github_url(directory, branch_or_commit_or_tag=self.ref),
# TODO: This won't work in all cases; should be from the development fork
# Currently breaks for `tests/osaka/eip7692_eof_v1/index.md` # noqa: SC100
# Currently breaks for `tests/speculative/eip7692_eof_v1/index.md` # noqa: SC100
target_or_valid_fork=fork.capitalize(),
package_name=get_import_path(directory), # init.py will be used for docstrings
)
Expand Down Expand Up @@ -552,8 +552,8 @@ def sort_by_fork_deployment_and_path(x: PageProps) -> Tuple[Any, ...]:

- ("Test Case Reference",) -> tests/index.md
- ("Test Case Reference", "Berlin") -> tests/berlin/index.md
- ("Test Case Reference", "Osaka", "EIP-7692 EOF V1", tracker.md")
tests/osaka/eip7692_eof_v1/tracker.md
- ("Test Case Reference", "EIP-7692 EOF V1", tracker.md")
tests/speculative/eip7692_eof_v1/tracker.md
- ("Test Case Reference", "Shanghai", "EIP-3855 PUSH0", "Spec") ->
tests/shanghai/eip3855_push0/spec.py

Expand Down
Loading
Loading