fix(test-forks): treat transition fork variants as equal to canonical#2782
fix(test-forks): treat transition fork variants as equal to canonical#2782danceratopz merged 3 commits intoethereum:forks/amsterdamfrom
Conversation
Cover the case where `with_env_gas_limit` variants of a transition fork compare unequal to their canonical class and to each other, breaking pre-alloc group reuse during fill.
`TransitionBaseClass.with_env_gas_limit` produced new class objects that compared unequal via the default `type.__eq__`, breaking pre-alloc group reuse during fill (assertion in `add_test_pre`). Mirror `BaseForkMeta` by adding `__eq__`/`__hash__` on `TransitionBaseMetaClass` keyed on the canonical identity, and set `_base_fork` on the variant inside `with_env_gas_limit`. Widen `_identity`/`_maybe_transitioned` signatures to `type` so the metaclass can reuse them.
36394ac to
d0dc280
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2782 +/- ##
================================================
Coverage 88.17% 88.17%
================================================
Files 577 577
Lines 35659 35659
Branches 3490 3490
================================================
Hits 31442 31442
Misses 3654 3654
Partials 563 563
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
felix314159
left a comment
There was a problem hiding this comment.
lgtm, fill with --generate-all-formats passed for bal and the unit test passed too.
but we also have to be a bit careful because a footgun for e.g. transition forks would be sth like:
from execution_testing.forks import Amsterdam
# transition from bpo2 to amsterdam to get post with gas limit 120 mil
if post == Amsterdam:
post = Amsterdam # replaces variant with canonical Amsterdam (`_env_gas_limit=0`)
basically just cuz you have the same canonical fork identity it does not mean u have the same variant state
👍
Agreed. If this becomes commonplace, we could look into protecting ourselves against this (something like wrapping |
…ent` Revert "fix(test-forks): treat transition fork variants as equal to canonical (ethereum#2782)" This reverts commit 9d18733. This reverts commit c3462e0.
Description
TransitionBaseClass.with_env_gas_limitproduced fresh class objects that compared unequal via the defaulttype.__eq__, breaking pre-alloc group reuse duringfill --generate-pre-alloc-groupsand tripping theadd_test_preassertion (Incompatible fork: CancunToPragueAtTime15k!=CancunToPragueAtTime15k).Mirror
BaseForkMetaby adding__eq__/__hash__onTransitionBaseMetaClasskeyed on the canonical identity, set_base_forkon the variant insidewith_env_gas_limit, and widen_identity/_maybe_transitionedsignatures totypeso the metaclass can reuse them. Adds a regression test covering transition fork variant equality.Related Issues or PRs
Bug introduced by #2690 (
feat(test-forks): Gas-limit-aware Fork, fork-aware Environment).Checklist
just statictype(scope):.