Skip to content

Update EIP-8037: Fix bugs from bal-devnet-6#11611

Merged
eth-bot merged 6 commits into
ethereum:masterfrom
misilva73:update-eip-8037
May 13, 2026
Merged

Update EIP-8037: Fix bugs from bal-devnet-6#11611
eth-bot merged 6 commits into
ethereum:masterfrom
misilva73:update-eip-8037

Conversation

@misilva73

@misilva73 misilva73 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Address four bugs surfaced by the bal-devnet-6 implementation and tests:

  • Tx-level CREATE failure (fix): explicit refund rule for the STATE_BYTES_PER_NEW_ACCOUNT × CPSB portion of intrinsic_state_gas when a contract-creation transaction reverts or halts, mirroring the existing inner-CREATE rule.
  • Tx-boundary halts/reverts (clarification): the existing child-frame revert/halt rules apply identically when the top-level frame reverts or halts.
  • Address collision (fix): spelled out as a special case of the tx-boundary rule — gas_left consumed in full, execution_regular_gas_used updated, new-account state-gas refunded.
  • EIP-7702 refund (clarification): noted that execution_state_gas_used may go below zero, and offered the equivalent implementation pattern of tracking the refill separately and subtracting it from tx_state_gas.

In addition, we remove the state refills originally provided for SELFDESTRUCT.

@github-actions github-actions Bot added c-update Modifies an existing proposal s-draft This EIP is a Draft t-core labels May 6, 2026
@eth-bot

eth-bot commented May 6, 2026

Copy link
Copy Markdown
Collaborator

✅ All reviewers have approved.

@eth-bot eth-bot changed the title EIP 8037: Fix bugs from bal-devnet-6 Update EIP-8037: Fix bugs from bal-devnet-6 May 6, 2026
Comment thread EIPS/eip-8037.md
@@ -139,7 +139,9 @@ State-gas accounting for `SSTORE` is performed at the end of the opcode executio
| `CREATE`/`CREATE2` with bytecode size of `L` | `(STATE_BYTES_PER_NEW_ACCOUNT + L) × CPSB` charged |
| `SELFDESTRUCT` where balance transfer creates a new account | `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` charged |

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.

You should add a case where SELFDESTRUCT occurs within the CREATE/CREATE2 frame but without transferring ether to create a new account, to clarify the gas effect.

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.

Can you given more details on this example? From my understanding, if there is no transfer to new account, there are no state gas charges or refills

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.

What I mean is, how would you handle the SELFDESTRUCT case in the CREATE/CREATE2 constructor? Would you still charge the state gas and then defer it until the end of the transaction, or would you not charge it because the net state is zero (gas for transfer to new account via SELFDESTRUCT are not discussed here)? I looked at the latest bal devnet and it seems they intend to delay charging/refunding when creating the state, so the second option is most likely more reasonable.

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.

If I understand correctly, that case fits within the sections "State gas refills for SELFDESTRUCT" -> state gas is charged during CREATE/CREATE2 and then if there is a SELFDESTRUCT on those accounts, refills are provided at the end of the transaction.

@abc-123-c abc-123-c May 8, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've viewed through the ethrex implementation notes, and if I understand correctly, does that mean gas calculation in the latest version will be deferred instead of being calculated upfront at the start of a frame? In the case of SELFDESTRUCT in the CREATEx's constructor, the net state accounting is 0 when end frame instead of calculating the upfront fee and then refunding it at the transaction end, right?

- Deferred-on-success state-gas charging for CREATE/CREATE2/CALL* (would require deleting most of the state_gas_spill* / credit_state_gas_refund plumbing in vm.rs:449-510 and default_hook.rs:240-280, 360-420)
- Parameter-table rename (state-gas vs regular-gas split column naming)

lambdaclass/ethrex#6583

Comment thread EIPS/eip-8037.md Outdated

##### Gas accounting for authorizations

For [EIP-7702](./eip-7702.md) authorizations, the intrinsic state-gas assumes account creation for each authorization, i.e., `(STATE_BYTES_PER_NEW_ACCOUNT + STATE_BYTES_PER_AUTH_BASE) × CPSB` per authorization. When the `authority` is not empty (i.e., non-zero nonce, non-zero balance, or non-empty code), the `STATE_BYTES_PER_NEW_ACCOUNT × CPSB` portion is refilled directly to `state_gas_reservoir` during authorization processing and `execution_state_gas_used` decreases by the corresponding amount.

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.

If an account only resets the authorization indicator, it doesn't create additional state, meaning it must include the refund of STATE_BYTES_PER_AUTH_BASE * cpsb when the EOA's codeHash is not emptyHash, right?

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.

You are correct. Will fix it in the next push 🙏

Comment thread EIPS/eip-8037.md Outdated

##### Gas accounting for authorizations

For [EIP-7702](./eip-7702.md) authorizations, the intrinsic state-gas assumes account creation for each authorization, i.e., `(STATE_BYTES_PER_NEW_ACCOUNT + STATE_BYTES_PER_AUTH_BASE) × CPSB` per authorization. During authorization processing:

@Helkomine Helkomine May 8, 2026

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.

According to EIP-7702, when authorization resolving fails, it consumes the entire gas allocated to that authorization tuple. However, this EIP separates the cost of creating the state from the cost of execution, so it is necessary to consider refilling that entire cost, similar to invalid in the EVM runtime.

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.

In this EIP, we are not changing on refunds happen for the regular gas components. I will add a comment to clarify this

@misilva73 misilva73 marked this pull request as ready for review May 13, 2026 16:10
@misilva73 misilva73 requested a review from eth-bot as a code owner May 13, 2026 16:10
@misilva73

Copy link
Copy Markdown
Contributor Author

@eth-bot rerun

@eth-bot eth-bot enabled auto-merge (squash) May 13, 2026 16:12

@eth-bot eth-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All Reviewers Have Approved; Performing Automatic Merge...

@eth-bot eth-bot merged commit b549622 into ethereum:master May 13, 2026
15 of 16 checks passed
@misilva73 misilva73 deleted the update-eip-8037 branch May 20, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-update Modifies an existing proposal s-draft This EIP is a Draft t-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants