Skip to content

refactor(forks): pass fork overrides to clone#2769

Open
JackCC703 wants to merge 3 commits into
ethereum:forks/amsterdamfrom
JackCC703:fork-overrides-clone
Open

refactor(forks): pass fork overrides to clone#2769
JackCC703 wants to merge 3 commits into
ethereum:forks/amsterdamfrom
JackCC703:fork-overrides-clone

Conversation

@JackCC703
Copy link
Copy Markdown
Contributor

🗒️ Description

Move the fork override dataclass from ethereum_spec_tools.evm_tools.t8n into ethereum_spec_tools.forks, and pass it directly into Hardfork.clone.

This keeps the existing ForkCache.get(...) call surface unchanged while reducing the long Hardfork.clone(...) parameter list.

🔗 Related Issues or PRs

Follow-up to #2738.

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
    just was not installed locally, so I ran the equivalent commands from the static recipe manually.
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.
  • Tests: For PRs implementing a missed test case, update the post-mortem document to add an entry the list.
  • Ported Tests: All converted JSON/YML tests from ethereum/tests or tests/static have been assigned @ported_from marker.

Cute Animal Picture

Cute dog

default_value = _override_defaults(template)[field]
changed_value = type(default_value)(int(default_value) + 1)
cloned = DummyTemporaryFork()
seen: dict[str, Any] = {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that Hardfork.clone has a fixed parameter list (just template and overrides), I don't think we need the dict of kwargs anymore? Could simplify the test a bit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

assert not (fork_dir / "trie.py").exists()


def test_hardfork_clone_applies_overrides(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like this is covered by test_end_to_end, but I could be convinced otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, removed

Comment on lines +189 to +190
finally:
fork.__exit__(None, None, None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use this construction instead of:

with Hardfork.clone("osaka", overrides=overrides) as fork:
    ...

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test was removed per your second comment since it overlaps with test_end_to_end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants