-
Notifications
You must be signed in to change notification settings - Fork 456
feat(spec, spec-specs): EIP-7997 #2802
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
Open
kclowes
wants to merge
4
commits into
ethereum:forks/amsterdam
Choose a base branch
from
kclowes:eips/amsterdam/eip-7997
base: forks/amsterdam
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bf18f3c
feat(spec, specs): EIP-7997 - Spec and basic tests
kclowes b60c86c
feat(spec-specs): EIP 7997 - More tests
kclowes 2daf7a9
bugfix(specs): Add logic to add 0x12 as a special contract outside the
kclowes 97a92d1
feat(tests): 7997 - add a check at the transition, adds tests for preβ¦
kclowes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
packages/testing/src/execution_testing/forks/forks/eips/amsterdam/eip_7997.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """ | ||
| EIP-7997: Deterministic Factory Predeploy. | ||
|
|
||
| Predeploy a minimal `CREATE2` factory at address `0x12` so deterministic | ||
| deployments are available across chains without bootstrapping transactions. | ||
|
|
||
| https://eips.ethereum.org/EIPS/eip-7997 | ||
| """ | ||
|
|
||
| from typing import Mapping | ||
|
|
||
| from execution_testing.base_types import Address | ||
|
|
||
| from ....base_fork import BaseFork | ||
|
|
||
| DETERMINISTIC_FACTORY_PREDEPLOY_ADDRESS = 0x12 | ||
| DETERMINISTIC_FACTORY_PREDEPLOY_BYTECODE = bytes.fromhex( | ||
| "60203610602f57" | ||
| "60003560203603806020600037600034f5" | ||
| "806026573d600060003e3d6000fd" | ||
| "5b60005260206000f3" | ||
| "5b60006000fd" | ||
| ) | ||
|
|
||
|
|
||
| class EIP7997(BaseFork): | ||
| """EIP-7997 class.""" | ||
|
|
||
| @classmethod | ||
| def deterministic_factory_predeploy_address(cls) -> Address | None: | ||
| """Return the EIP-7997 deterministic factory predeploy address.""" | ||
| return Address( | ||
| DETERMINISTIC_FACTORY_PREDEPLOY_ADDRESS, | ||
| label="DETERMINISTIC_FACTORY_PREDEPLOY_ADDRESS", | ||
| ) | ||
|
|
||
| @classmethod | ||
| def pre_allocation(cls) -> Mapping: | ||
| """Pre-allocate the deterministic factory predeploy.""" | ||
| return { | ||
| DETERMINISTIC_FACTORY_PREDEPLOY_ADDRESS: { | ||
| "nonce": 1, | ||
| "code": DETERMINISTIC_FACTORY_PREDEPLOY_BYTECODE, | ||
| } | ||
| } | super(EIP7997, cls).pre_allocation() # type: ignore | ||
|
|
||
| @classmethod | ||
| def pre_allocation_blockchain(cls) -> Mapping: | ||
| """Pre-allocate the deterministic factory predeploy.""" | ||
| return { | ||
| DETERMINISTIC_FACTORY_PREDEPLOY_ADDRESS: { | ||
| "nonce": 1, | ||
| "code": DETERMINISTIC_FACTORY_PREDEPLOY_BYTECODE, | ||
| } | ||
| } | super(EIP7997, cls).pre_allocation_blockchain() # type: ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/amsterdam/eip7997_deterministic_factory_predeploy/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Tests for EIP-7997: Deterministic Factory Predeploy.""" |
31 changes: 31 additions & 0 deletions
31
tests/amsterdam/eip7997_deterministic_factory_predeploy/spec.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """Reference spec for [EIP-7997: Deterministic Factory Predeploy](https://eips.ethereum.org/EIPS/eip-7997).""" | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ReferenceSpec: | ||
| """Reference specification.""" | ||
|
|
||
| git_path: str | ||
| version: str | ||
|
|
||
|
|
||
| ref_spec_7997 = ReferenceSpec( | ||
| git_path="EIPS/eip-7997.md", | ||
| version="ec05b85e530a7ea97ea52a1f0312d88eb0eb1be2", | ||
| ) | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class Spec: | ||
| """Constants from EIP-7997.""" | ||
|
|
||
| FACTORY_ADDRESS: int = 0x12 | ||
| FACTORY_BYTECODE: bytes = bytes.fromhex( | ||
| "60203610602f57" | ||
| "60003560203603806020600037600034f5" | ||
| "806026573d600060003e3d6000fd" | ||
| "5b60005260206000f3" | ||
| "5b60006000fd" | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I did not know we had this functionality!
I'm not sure though how do we signal from the tests that a block is the first block in the fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marioevz I'm not sure what you mean by:
Can you clarify? AFAIK, the tests don't call
apply_fork, and AIUI, we'd have to test with a pre_alloc mutable as discussed below, for inherently not a great test. This is also highlighted in the codecov report since there is not a great way to test this method. Let me know if you see another way though! I'm happy to update.