Skip to content

feat(l1): backward cap compatibility#2823

Closed
Mechanix97 wants to merge 34 commits into
mainfrom
feat/backward-cap-compatibility
Closed

feat(l1): backward cap compatibility#2823
Mechanix97 wants to merge 34 commits into
mainfrom
feat/backward-cap-compatibility

Conversation

@Mechanix97

@Mechanix97 Mechanix97 commented May 16, 2025

Copy link
Copy Markdown
Contributor

Motivation

A new version of the eth protocol has been released (eth/69) and some clients are supporting both eth/68 and eth/69 at the same time. We need a way of being able to encode/decode the msg from both versions of the protocol. Also, we need a way to remove easily the old version when it becomes deprecated.

Description

A new file structure was created to accommodate the new implementation:
crates/networking/p2p/rlpx/eth/
crates/networking/p2p/rlpx/eth/eth68/ -> (status.rs and receipt.rs)
crates/networking/p2p/rlpx/eth/eth69/ -> (status.rs and receipt.rs)

The implementation in the folder eth69 is the same as the one in eth68 for the moment. All the parts where it is going to be called are commented to illustrate the new implementation. It's going to be implemented in future PRs. Also, it's not activated as the SUPPORTED_ETH_CAPABILITIES is set to only support eth/68.

In the new eth/69 protocol the messages status and receipts have been changed. So a new intermediate structure was created. The encode for each version is decided by the type of the inner struct. But the decode is not that simple, as we don't know what kind of msg we received.

For the status msg was a little easier, as we received the eth version inside the msg we can decide which version of the protocol we are using.

For the receipt msg, the only difference is the bloom field. A new function has_bloom has been implemented to detect when a msg have the bloom field to process it as a eth/68. The newer eth/69 receipts msg won't have the bloom field (it can be calculated from the logs).

Also, as the new structure is a proxy to the different version of the structure some new getters were needed.

Closes #2805

References:
EIP-7642
geth implementation
eth/69

@github-actions

github-actions Bot commented May 16, 2025

Copy link
Copy Markdown

Lines of code report

Total lines added: 323
Total lines removed: 26
Total lines changed: 349

Detailed view
+--------------------------------------------------------+-------+------+
| File                                                   | Lines | Diff |
+--------------------------------------------------------+-------+------+
| ethrex/crates/common/rlp/error.rs                      | 27    | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/peer_handler.rs           | 579   | +1   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection.rs        | 546   | +3   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/error.rs             | 78    | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/backend.rs       | 93    | -26  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/mod.rs     | 2     | +2   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/receipt.rs | 40    | +40  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth68/status.rs  | 59    | +59  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/mod.rs     | 1     | +1   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/receipt.rs | 40    | +40  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/eth69/status.rs  | 59    | +59  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/mod.rs           | 7     | +7   |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/receipts.rs      | 189   | +77  |
+--------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/status.rs        | 89    | +30  |
+--------------------------------------------------------+-------+------+

@Mechanix97 Mechanix97 self-assigned this May 19, 2025
@Mechanix97 Mechanix97 marked this pull request as ready for review May 20, 2025 19:56
@Mechanix97 Mechanix97 requested a review from a team as a code owner May 20, 2025 19:56
@Mechanix97 Mechanix97 added p2p Issues related to p2p network L1 Ethereum client labels May 21, 2025
@Mechanix97 Mechanix97 marked this pull request as draft May 23, 2025 21:04
@Mechanix97 Mechanix97 closed this May 26, 2025
edg-l added a commit that referenced this pull request May 11, 2026
…UNT (bal-devnet-7)

EELS PR #2823 (commit eb80b438a) extends Policy A's top-level failure
refund so that a CREATE transaction that reverts or halts also returns
the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × cost_per_state_byte`
charge — paid via `add_intrinsic_gas` at tx start — back to the
reservoir. Mirrors the long-standing inner-CREATE failure rule.

Spec (fork.py::process_transaction):
  if tx_output.error is not None:
      tx_output.state_gas_left += tx_output.state_gas_used    # Policy A
      tx_output.state_gas_used = Uint(0)
      if isinstance(tx.to, Bytes0):
          new_account_refund = STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE
          tx_output.state_gas_left += new_account_refund      # to reservoir
          tx_output.state_refund   += new_account_refund      # block-level

ethrex impl in `finalize_execution`, after the Policy A
execution-portion refund, when `is_create()`:
- `state_gas_reservoir += new_account_refund` (sender gets gas back)
- `state_gas_refund_absorbed += new_account_refund` (net block-level
  state_gas_used drops to 0 via the existing `net_state_gas_used`
  subtraction)
- `intrinsic_state_gas_charged -= new_account_refund` so
  `refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
  formula doesn't double-deduct the now-refunded amount; the gas that
  was actually burned remains in the regular dimension where it sits.

Updates the existing `test_top_halt_phantom_drain_with_real_spill_under_policy_a`
test to assert the post-#2823 behavior: state_gas_used = 0 for a halted
CREATE tx (was state_new before).
edg-l added a commit that referenced this pull request May 11, 2026
…ate_gas_charged

Initial item-5 impl decremented `intrinsic_state_gas_charged` by
`new_account_refund` on top-level CREATE-tx failure, on the theory that
the refunded gas should not be subtracted from `raw_consumed` in the
regular-gas formula. That was wrong.

Per the EELS test_failed_create_tx_refunds_intrinsic_new_account
expectation:
  expected_gas_used = intrinsic_regular + regular_consumed
                    = gas_limit - create_state_gas
For an INVALID halt: expected = gas_limit - state_new.

`refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
produces exactly that when `intrinsic_state_gas_charged` is left intact.
Clearing it overcounts regular by state_new (drops gas_used by state_new
in the wrong direction). Conceptually: the intrinsic burn is still in
`raw_consumed`, the refund returns it via the reservoir to the user,
and the regular-gas subtraction keeps it out of the regular dimension —
neither dimension counts it, which matches the spec.

Reservoir credit and `state_gas_refund_absorbed` bump (the two genuine
behavior changes from #2823) remain.
edg-l added a commit that referenced this pull request May 11, 2026
…-devnet-7)

Two fixes for the tx-level CREATE-collision path required by EELS
bal@v7.0.0:

1. Burn the forwarded gas in the regular dimension. EIP-684 + EELS
   `process_message_call` mark a CREATE-tx collision as
   `regular_gas_used = message.gas`. ethrex's collision branch in
   `handle_create_transaction` was returning with
   `current_call_frame.gas_remaining` still holding the
   post-intrinsic leftover, which leaked back to the sender as unused
   gas and never reached the regular dimension via
   `refund_sender`'s `raw_consumed - … + reclassified` formula. Now
   we zero `gas_remaining` so `raw_consumed = gas_limit` downstream.

2. Refund the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` on
   collision. Previously the `!is_collision()` gate in
   `finalize_execution` excluded collision from BOTH Policy A and the
   item-5 NEW_ACCOUNT refund. Per EELS PR #2823 (commit eb80b438a)
   `process_transaction`, a tx-CREATE collision is just another
   failure variant that gets the intrinsic NEW_ACCOUNT refund:
       if tx_output.error is not None and isinstance(tx.to, Bytes0):
           tx_output.state_refund += create_state_gas
   Restructure the failure branch so Policy A still skips on
   collision (no execution state-gas to recover), but the
   `is_create()` intrinsic refund fires on every non-success.

After both: `regular_gas = gas_limit - intrinsic_state`,
`state_gas = 0`, header `gas_used = gas_limit - state_new` ✓
(matches EELS `test_create_tx_collision_refunds_intrinsic_new_account`).

Closes the 7-fixture CREATE-collision cluster in the bal-devnet-7
ef-test failures.
edg-l added a commit that referenced this pull request May 11, 2026
…t-7)

EELS PR #2823 (commit eb80b438a) simplifies `incorporate_child_on_error`
to:
    evm.state_gas_left += child_evm.state_gas_used + child_evm.state_gas_left

Removes the pre-#2823 subtraction of `child_evm.state_gas_refund` (the
"unwind on revert" of inline credits the child applied) on the rationale
that any inline credits the child applied are keyed to charges (its own
SSTORE or CREATE pre-charge) that are themselves rolled back, so the
matching `state_gas_left + state_gas_used` sum already reflects the
correct amount to return to the parent.

In ethrex's clamp-and-spill model the analogous tracking is the
`state_gas_refund_absorbed_snapshot` restore and the
`credit_against_drain_delta` subtraction in handle_return_call /
handle_return_create's Revert arms. Drop both.

Behavior change: an SSTORE 0→x→0 credit applied in a frame that later
reverts now leaks up to the parent's reservoir, matching the bal-7
test inversions:
- test_sstore_restoration_sub_frame_revert
- test_sstore_restoration_ancestor_revert
- test_subcall_set_clear_revert_pays_no_state_gas
and the broader stSStoreTest port group whose sub-contract calls
exercise this revert path.

Leaves `state_gas_used = state_gas_used_snapshot` (gross charges undone
on revert — same as before, matches EELS `state_gas_used` not flowing
to parent on error) and `state_gas_refund_pending = pending_snapshot`
(pending credits discarded with the child, per #2823 docstring).
edg-l added a commit that referenced this pull request May 11, 2026
The zkevm@v0.3.3 fixture bundle (the only bundle that ships
executionWitness, used by test-stateless-zkevm) is filled against an
older bal spec and disagrees with bal@v7.0.0 gas accounting:
storage_set/new_account/cpsb constants pre-recalibration plus pre-
EELS-#2815/#2816/#2823/#2827/#2828 refund-channel semantics.

Skips the 21 remaining gas mismatches in the eip8025_optional_proofs
filter (witness_codes_*, witness_state_*, validation_state_*),
analogous to the bal@v5.6.1 block already at the top of the list.
Re-enable once the zkevm bundle is regenerated against bal-7.
edg-l added a commit that referenced this pull request May 13, 2026
…UNT (bal-devnet-7)

EELS PR #2823 (commit eb80b438a) extends Policy A's top-level failure
refund so that a CREATE transaction that reverts or halts also returns
the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × cost_per_state_byte`
charge — paid via `add_intrinsic_gas` at tx start — back to the
reservoir. Mirrors the long-standing inner-CREATE failure rule.

Spec (fork.py::process_transaction):
  if tx_output.error is not None:
      tx_output.state_gas_left += tx_output.state_gas_used    # Policy A
      tx_output.state_gas_used = Uint(0)
      if isinstance(tx.to, Bytes0):
          new_account_refund = STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE
          tx_output.state_gas_left += new_account_refund      # to reservoir
          tx_output.state_refund   += new_account_refund      # block-level

ethrex impl in `finalize_execution`, after the Policy A
execution-portion refund, when `is_create()`:
- `state_gas_reservoir += new_account_refund` (sender gets gas back)
- `state_gas_refund_absorbed += new_account_refund` (net block-level
  state_gas_used drops to 0 via the existing `net_state_gas_used`
  subtraction)
- `intrinsic_state_gas_charged -= new_account_refund` so
  `refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
  formula doesn't double-deduct the now-refunded amount; the gas that
  was actually burned remains in the regular dimension where it sits.

Updates the existing `test_top_halt_phantom_drain_with_real_spill_under_policy_a`
test to assert the post-#2823 behavior: state_gas_used = 0 for a halted
CREATE tx (was state_new before).
edg-l added a commit that referenced this pull request May 13, 2026
…ate_gas_charged

Initial item-5 impl decremented `intrinsic_state_gas_charged` by
`new_account_refund` on top-level CREATE-tx failure, on the theory that
the refunded gas should not be subtracted from `raw_consumed` in the
regular-gas formula. That was wrong.

Per the EELS test_failed_create_tx_refunds_intrinsic_new_account
expectation:
  expected_gas_used = intrinsic_regular + regular_consumed
                    = gas_limit - create_state_gas
For an INVALID halt: expected = gas_limit - state_new.

`refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
produces exactly that when `intrinsic_state_gas_charged` is left intact.
Clearing it overcounts regular by state_new (drops gas_used by state_new
in the wrong direction). Conceptually: the intrinsic burn is still in
`raw_consumed`, the refund returns it via the reservoir to the user,
and the regular-gas subtraction keeps it out of the regular dimension —
neither dimension counts it, which matches the spec.

Reservoir credit and `state_gas_refund_absorbed` bump (the two genuine
behavior changes from #2823) remain.
edg-l added a commit that referenced this pull request May 13, 2026
…-devnet-7)

Two fixes for the tx-level CREATE-collision path required by EELS
bal@v7.0.0:

1. Burn the forwarded gas in the regular dimension. EIP-684 + EELS
   `process_message_call` mark a CREATE-tx collision as
   `regular_gas_used = message.gas`. ethrex's collision branch in
   `handle_create_transaction` was returning with
   `current_call_frame.gas_remaining` still holding the
   post-intrinsic leftover, which leaked back to the sender as unused
   gas and never reached the regular dimension via
   `refund_sender`'s `raw_consumed - … + reclassified` formula. Now
   we zero `gas_remaining` so `raw_consumed = gas_limit` downstream.

2. Refund the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` on
   collision. Previously the `!is_collision()` gate in
   `finalize_execution` excluded collision from BOTH Policy A and the
   item-5 NEW_ACCOUNT refund. Per EELS PR #2823 (commit eb80b438a)
   `process_transaction`, a tx-CREATE collision is just another
   failure variant that gets the intrinsic NEW_ACCOUNT refund:
       if tx_output.error is not None and isinstance(tx.to, Bytes0):
           tx_output.state_refund += create_state_gas
   Restructure the failure branch so Policy A still skips on
   collision (no execution state-gas to recover), but the
   `is_create()` intrinsic refund fires on every non-success.

After both: `regular_gas = gas_limit - intrinsic_state`,
`state_gas = 0`, header `gas_used = gas_limit - state_new` ✓
(matches EELS `test_create_tx_collision_refunds_intrinsic_new_account`).

Closes the 7-fixture CREATE-collision cluster in the bal-devnet-7
ef-test failures.
edg-l added a commit that referenced this pull request May 13, 2026
…t-7)

EELS PR #2823 (commit eb80b438a) simplifies `incorporate_child_on_error`
to:
    evm.state_gas_left += child_evm.state_gas_used + child_evm.state_gas_left

Removes the pre-#2823 subtraction of `child_evm.state_gas_refund` (the
"unwind on revert" of inline credits the child applied) on the rationale
that any inline credits the child applied are keyed to charges (its own
SSTORE or CREATE pre-charge) that are themselves rolled back, so the
matching `state_gas_left + state_gas_used` sum already reflects the
correct amount to return to the parent.

In ethrex's clamp-and-spill model the analogous tracking is the
`state_gas_refund_absorbed_snapshot` restore and the
`credit_against_drain_delta` subtraction in handle_return_call /
handle_return_create's Revert arms. Drop both.

Behavior change: an SSTORE 0→x→0 credit applied in a frame that later
reverts now leaks up to the parent's reservoir, matching the bal-7
test inversions:
- test_sstore_restoration_sub_frame_revert
- test_sstore_restoration_ancestor_revert
- test_subcall_set_clear_revert_pays_no_state_gas
and the broader stSStoreTest port group whose sub-contract calls
exercise this revert path.

Leaves `state_gas_used = state_gas_used_snapshot` (gross charges undone
on revert — same as before, matches EELS `state_gas_used` not flowing
to parent on error) and `state_gas_refund_pending = pending_snapshot`
(pending credits discarded with the child, per #2823 docstring).
edg-l added a commit that referenced this pull request May 13, 2026
The zkevm@v0.3.3 fixture bundle (the only bundle that ships
executionWitness, used by test-stateless-zkevm) is filled against an
older bal spec and disagrees with bal@v7.0.0 gas accounting:
storage_set/new_account/cpsb constants pre-recalibration plus pre-
EELS-#2815/#2816/#2823/#2827/#2828 refund-channel semantics.

Skips the 21 remaining gas mismatches in the eip8025_optional_proofs
filter (witness_codes_*, witness_state_*, validation_state_*),
analogous to the bal@v5.6.1 block already at the top of the list.
Re-enable once the zkevm bundle is regenerated against bal-7.
edg-l added a commit that referenced this pull request May 13, 2026
…UNT (bal-devnet-7)

EELS PR #2823 (commit eb80b438a) extends Policy A's top-level failure
refund so that a CREATE transaction that reverts or halts also returns
the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × cost_per_state_byte`
charge — paid via `add_intrinsic_gas` at tx start — back to the
reservoir. Mirrors the long-standing inner-CREATE failure rule.

Spec (fork.py::process_transaction):
  if tx_output.error is not None:
      tx_output.state_gas_left += tx_output.state_gas_used    # Policy A
      tx_output.state_gas_used = Uint(0)
      if isinstance(tx.to, Bytes0):
          new_account_refund = STATE_BYTES_PER_NEW_ACCOUNT * COST_PER_STATE_BYTE
          tx_output.state_gas_left += new_account_refund      # to reservoir
          tx_output.state_refund   += new_account_refund      # block-level

ethrex impl in `finalize_execution`, after the Policy A
execution-portion refund, when `is_create()`:
- `state_gas_reservoir += new_account_refund` (sender gets gas back)
- `state_gas_refund_absorbed += new_account_refund` (net block-level
  state_gas_used drops to 0 via the existing `net_state_gas_used`
  subtraction)
- `intrinsic_state_gas_charged -= new_account_refund` so
  `refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
  formula doesn't double-deduct the now-refunded amount; the gas that
  was actually burned remains in the regular dimension where it sits.

Updates the existing `test_top_halt_phantom_drain_with_real_spill_under_policy_a`
test to assert the post-#2823 behavior: state_gas_used = 0 for a halted
CREATE tx (was state_new before).
edg-l added a commit that referenced this pull request May 13, 2026
…ate_gas_charged

Initial item-5 impl decremented `intrinsic_state_gas_charged` by
`new_account_refund` on top-level CREATE-tx failure, on the theory that
the refunded gas should not be subtracted from `raw_consumed` in the
regular-gas formula. That was wrong.

Per the EELS test_failed_create_tx_refunds_intrinsic_new_account
expectation:
  expected_gas_used = intrinsic_regular + regular_consumed
                    = gas_limit - create_state_gas
For an INVALID halt: expected = gas_limit - state_new.

`refund_sender`'s `regular_gas = raw_consumed - intrinsic_state - ...`
produces exactly that when `intrinsic_state_gas_charged` is left intact.
Clearing it overcounts regular by state_new (drops gas_used by state_new
in the wrong direction). Conceptually: the intrinsic burn is still in
`raw_consumed`, the refund returns it via the reservoir to the user,
and the regular-gas subtraction keeps it out of the regular dimension —
neither dimension counts it, which matches the spec.

Reservoir credit and `state_gas_refund_absorbed` bump (the two genuine
behavior changes from #2823) remain.
edg-l added a commit that referenced this pull request May 13, 2026
…-devnet-7)

Two fixes for the tx-level CREATE-collision path required by EELS
bal@v7.0.0:

1. Burn the forwarded gas in the regular dimension. EIP-684 + EELS
   `process_message_call` mark a CREATE-tx collision as
   `regular_gas_used = message.gas`. ethrex's collision branch in
   `handle_create_transaction` was returning with
   `current_call_frame.gas_remaining` still holding the
   post-intrinsic leftover, which leaked back to the sender as unused
   gas and never reached the regular dimension via
   `refund_sender`'s `raw_consumed - … + reclassified` formula. Now
   we zero `gas_remaining` so `raw_consumed = gas_limit` downstream.

2. Refund the intrinsic `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` on
   collision. Previously the `!is_collision()` gate in
   `finalize_execution` excluded collision from BOTH Policy A and the
   item-5 NEW_ACCOUNT refund. Per EELS PR #2823 (commit eb80b438a)
   `process_transaction`, a tx-CREATE collision is just another
   failure variant that gets the intrinsic NEW_ACCOUNT refund:
       if tx_output.error is not None and isinstance(tx.to, Bytes0):
           tx_output.state_refund += create_state_gas
   Restructure the failure branch so Policy A still skips on
   collision (no execution state-gas to recover), but the
   `is_create()` intrinsic refund fires on every non-success.

After both: `regular_gas = gas_limit - intrinsic_state`,
`state_gas = 0`, header `gas_used = gas_limit - state_new` ✓
(matches EELS `test_create_tx_collision_refunds_intrinsic_new_account`).

Closes the 7-fixture CREATE-collision cluster in the bal-devnet-7
ef-test failures.
edg-l added a commit that referenced this pull request May 13, 2026
…t-7)

EELS PR #2823 (commit eb80b438a) simplifies `incorporate_child_on_error`
to:
    evm.state_gas_left += child_evm.state_gas_used + child_evm.state_gas_left

Removes the pre-#2823 subtraction of `child_evm.state_gas_refund` (the
"unwind on revert" of inline credits the child applied) on the rationale
that any inline credits the child applied are keyed to charges (its own
SSTORE or CREATE pre-charge) that are themselves rolled back, so the
matching `state_gas_left + state_gas_used` sum already reflects the
correct amount to return to the parent.

In ethrex's clamp-and-spill model the analogous tracking is the
`state_gas_refund_absorbed_snapshot` restore and the
`credit_against_drain_delta` subtraction in handle_return_call /
handle_return_create's Revert arms. Drop both.

Behavior change: an SSTORE 0→x→0 credit applied in a frame that later
reverts now leaks up to the parent's reservoir, matching the bal-7
test inversions:
- test_sstore_restoration_sub_frame_revert
- test_sstore_restoration_ancestor_revert
- test_subcall_set_clear_revert_pays_no_state_gas
and the broader stSStoreTest port group whose sub-contract calls
exercise this revert path.

Leaves `state_gas_used = state_gas_used_snapshot` (gross charges undone
on revert — same as before, matches EELS `state_gas_used` not flowing
to parent on error) and `state_gas_refund_pending = pending_snapshot`
(pending credits discarded with the child, per #2823 docstring).
edg-l added a commit that referenced this pull request May 13, 2026
The zkevm@v0.3.3 fixture bundle (the only bundle that ships
executionWitness, used by test-stateless-zkevm) is filled against an
older bal spec and disagrees with bal@v7.0.0 gas accounting:
storage_set/new_account/cpsb constants pre-recalibration plus pre-
EELS-#2815/#2816/#2823/#2827/#2828 refund-channel semantics.

Skips the 21 remaining gas mismatches in the eip8025_optional_proofs
filter (witness_codes_*, witness_state_*, validation_state_*),
analogous to the bal@v5.6.1 block already at the top of the list.
Re-enable once the zkevm bundle is regenerated against bal-7.
edg-l added a commit that referenced this pull request May 13, 2026
Two hand-rolled tests asserting specific `gas_used` values for
top-level CREATE-tx halt scenarios. Both encoded "Policy A" semantics
hard-coded to v7.0.0 numbers; the second one drifted after EELS
PR #2823's intrinsic NEW_ACCOUNT refund and again after the v7.1.x
spec series. ef-tests at tests-bal@v7.1.1 (2,145/2,145 green) cover
the same scenarios with fewer footguns, and the bespoke "Policy A"
shorthand wasn't carrying its weight.
edg-l added a commit that referenced this pull request May 13, 2026
Two hand-rolled tests asserting specific `gas_used` values for
top-level CREATE-tx halt scenarios. Both encoded "Policy A" semantics
hard-coded to v7.0.0 numbers; the second one drifted after EELS
PR #2823's intrinsic NEW_ACCOUNT refund and again after the v7.1.x
spec series. ef-tests at tests-bal@v7.1.1 (2,145/2,145 green) cover
the same scenarios with fewer footguns, and the bespoke "Policy A"
shorthand wasn't carrying its weight.
akshay-ap pushed a commit to akshay-ap/ethrex that referenced this pull request May 19, 2026
**Motivation**

Bring ethrex up to bal-devnet-7 (BAL fixtures `bal@v7.1.1`). Stacked
on top of #bal-devnet-6-pr (now in main).

**Description**

Aligns EIP-8037 state-gas accounting with bal-devnet-7 spec progression
(EELS PRs lambdaclass#2815 / lambdaclass#2816 / lambdaclass#2823 / lambdaclass#2827 / lambdaclass#2828 / lambdaclass#2836 / lambdaclass#2845 /
lambdaclass#2848),
bumps Amsterdam fixtures from `snobal-devnet-6@v1.1.0` to `bal@v7.1.1`,
and bumps the pinned hive version past the ethrex `--http.api` fix.

Main changes:

- EIP-8037 state-gas alignment with bal-devnet-7:
  - System-call state-gas reservoir.
  - Halt refunds spilled state gas (Policy A).
  - Tx-level CREATE failure refunds intrinsic `NEW_ACCOUNT`;
    `intrinsic_state_gas_charged` preserved across the failure path.
  - Tx-CREATE collision refund with regular-gas burn; billing matches
    EELS.
  - Cross-frame revert leaks inline credits.
  - Cross-frame revert reservoir formula fix.
  - Block-level `state_gas_used` subtracts `state_refund`.
- Remove same-tx SELFDESTRUCT state-gas refund (EELS PR lambdaclass#2845, v7.1.0).
- EIP-7702:
  - `set_delegation` refund via dedicated `state_refund` channel.
  - `set_delegation` refunds `AUTH_BASE` on existing delegation
    (EELS PR lambdaclass#2836).
  - `set_delegation` refunds `AUTH_BASE` on delegation clear
    (EELS PR lambdaclass#2848, v7.1.1).
- levm fixes pulled from main:
  - `revert` doesn't unmark the account as existing (lambdaclass#6592).
  - Account erroneously considered as existing after zero-value transfer
    (lambdaclass#6591).
- Tooling / tests:
  - Per-tx gas-dimension dump on block `gas_used` mismatch.
  - Bump Amsterdam fixtures to `bal@v7.1.1`.
  - Annotate BAL balance-mismatch errors with gas-equivalent diff and
    recognised state-gas constant multiples.
  - Unskip 74 bal-devnet-6 Amsterdam fixtures now passing.
  - Skip 21 stale EIP-8025 fixtures pinned at `bal@v5.7.0`
    (zkevm@v0.3.3 bundle, pre-bal-7).
  - Drop stale bal-devnet-6 known-issues entries from
    `docs/known_issues.md` and hive `KNOWN_EXCLUDED_TESTS`.
- CI:
  - Bump pinned hive version past the ethrex `--http.api` flag
    feature-detect fix (`c4d839b3`, hive lambdaclass#1485). Without this, hive
    starts ethrex with the default HTTP namespace allowlist
    (`eth,net,web3`) and tests touching `admin_*`/`debug_*`/`txpool_*`
    fail.

**Local test run**

`./run_test.sh` against `tests-bal@v7.1.1`: 2,145 / 2,145 pass.
`cargo test -p ethrex-test --tests`: 453 / 453 pass.

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
  includes breaking changes to the `Store` requiring a re-sync.

---------

Co-authored-by: Lucas Fiegl <iovoid@users.noreply.github.com>
Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client p2p Issues related to p2p network

Projects

None yet

Development

Successfully merging this pull request may close these issues.

L1: implement backward compatibility of eth capabilities

1 participant