Skip to content

fix(spec-specs): EIP-2780 charge NEW_ACCOUNT for value transfer to zero balance precompile - #3048

Merged
danceratopz merged 5 commits into
ethereum:eips/amsterdam/eip-2780-8038from
gurukamath:fix/eip-2780-empty-precompile-new-account
Jun 25, 2026
Merged

fix(spec-specs): EIP-2780 charge NEW_ACCOUNT for value transfer to zero balance precompile#3048
danceratopz merged 5 commits into
ethereum:eips/amsterdam/eip-2780-8038from
gurukamath:fix/eip-2780-empty-precompile-new-account

Conversation

@gurukamath

@gurukamath gurukamath commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🗒️ Description

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction transfers value to a recipient that is empty per EIP-161. The top-frame charge previously carved out precompile recipients, but neither EIP-2780 nor EIP-161 authorizes that exemption:

  • EIP-2780 does not mention precompiles; its rule keys solely on "empty per EIP-161 and tx.value > 0".
  • EIP-161 defines empty structurally (no code, zero nonce, zero balance) with no precompile exception, so an unfunded precompile is empty and is created by the value transfer like any other account.

Remove the recipient_is_precompile carve-out from the top-frame charge so an empty precompile receiving value pays NEW_ACCOUNT, drop the matching special-case from the testing framework's transaction_top_frame_state_gas, and rewrite test_value_move_to_precompiles to assert the charge fires for the not-funded precompile while a pre-funded (alive) precompile remains exempt by virtue of being non-empty.

Related Issues

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
  • 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.

…pile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (eips/amsterdam/eip-2780-8038@65111df). Learn more about missing BASE report.

Additional details and impacted files
@@                       Coverage Diff                       @@
##             eips/amsterdam/eip-2780-8038    #3048   +/-   ##
===============================================================
  Coverage                                ?   93.21%           
===============================================================
  Files                                   ?      620           
  Lines                                   ?    38830           
  Branches                                ?     3348           
===============================================================
  Hits                                    ?    36197           
  Misses                                  ?     1773           
  Partials                                ?      860           
Flag Coverage Δ
unittests 93.21% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add a gas-boundary regression test for value transfers to an unfunded precompile. The transaction is one gas short of covering the top-frame NEW_ACCOUNT state charge, so implementations that incorrectly carve out precompile recipients reach the identity precompile and fail the expected post-state instead of silently filling.
Pin the sender balance for one value-moving transaction to an unfunded precompile so the source test fails if the NEW_ACCOUNT top-frame state charge is accidentally skipped. Without this check the broad precompile matrix can still fill because recipient balance and sender nonce are unchanged by the missing charge.

Use precompile 0x04 specifically because identity accepts the empty calldata already used by this test and has deterministic execution gas. The NEW_ACCOUNT rule is independent of which precompile executes, so this avoids duplicating every precompile's gas model while still catching the silent-fill regression.

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The change looks good to me! I added a new test that tests the behavior at the oog boundary, ptal here:

@danceratopz danceratopz changed the title fix(amsterdam): charge NEW_ACCOUNT for value transfer to zero balance precompile fix(tests): charge NEW_ACCOUNT for value transfer to zero balance precompile Jun 25, 2026
@danceratopz danceratopz added C-bug Category: this is a bug, deviation, or other problem A-tests Area: Consensus tests. labels Jun 25, 2026
@danceratopz danceratopz changed the title fix(tests): charge NEW_ACCOUNT for value transfer to zero balance precompile fix(tests): charge NEW_ACCOUNT for value transfer to zero balance precompile Jun 25, 2026
@gurukamath
gurukamath marked this pull request as ready for review June 25, 2026 08:56
@danceratopz danceratopz changed the title fix(tests): charge NEW_ACCOUNT for value transfer to zero balance precompile fix(spec-specs): charge NEW_ACCOUNT for value transfer to zero balance precompile Jun 25, 2026
…-new-account-suggestion

feat(tests): add empty precompile top-frame charge test
@danceratopz danceratopz changed the title fix(spec-specs): charge NEW_ACCOUNT for value transfer to zero balance precompile fix(spec-specs): EIP-2780 charge NEW_ACCOUNT for value transfer to zero balance precompile Jun 25, 2026

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @gurukamath!

@danceratopz
danceratopz merged commit d9819bb into ethereum:eips/amsterdam/eip-2780-8038 Jun 25, 2026
26 checks passed
danceratopz added a commit that referenced this pull request Jun 25, 2026
…zero balance precompile (#3048)

* fix(amsterdam): charge NEW_ACCOUNT for value transfer to empty precompile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.

Co-authored-by: danceratopz <danceratopz@gmail.com>
danceratopz added a commit that referenced this pull request Jul 2, 2026
…zero balance precompile (#3048)

* fix(amsterdam): charge NEW_ACCOUNT for value transfer to empty precompile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.

Co-authored-by: danceratopz <danceratopz@gmail.com>
danceratopz added a commit that referenced this pull request Jul 2, 2026
…zero balance precompile (#3048)

* fix(amsterdam): charge NEW_ACCOUNT for value transfer to empty precompile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.

Co-authored-by: danceratopz <danceratopz@gmail.com>
spencer-tb pushed a commit that referenced this pull request Jul 2, 2026
…zero balance precompile (#3048)

* fix(amsterdam): charge NEW_ACCOUNT for value transfer to empty precompile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.

Co-authored-by: danceratopz <danceratopz@gmail.com>
marioevz added a commit that referenced this pull request Jul 2, 2026
* feat(spec-specs, tests): add EIP-8038 state-access gas cost update (#2972)

Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com>
Co-authored-by: Mario Vega <11726710+marioevz@users.noreply.github.com>

* feat(spec-specs, tests): Implement EIP-2780 (#3017)

* chore(tests): fix failing ported static slow tests for EIP-8038 (#3019)

Co-authored-by: marioevz <marioevz@gmail.com>

* test(amsterdam): add EIP-8038 state-access gas cost tests (#3033)

Co-authored-by: danceratopz <danceratopz@gmail.com>
Co-authored-by: marioevz <marioevz@gmail.com>

* fix(tests): account for EIP-8246 in EIP-8038 selfdestruct gas test (#3044)

EIP-8246 removes the `SELFDESTRUCT` balance burn, which changes the
same-transaction self-destruct-to-self outcome. Gate the affected
expectations in `test_selfdestruct_gas.py` on `fork.is_eip_enabled(8246)`
so the test holds on forks with and without EIP-8246:

- Pre-EIP-8246: The originator balance is burnt (a `Burn` log) and the
  same-transaction-created account is deleted.
- EIP-8246 onwards: The burn is removed, so the self-send is a no-op; the
  balance stays in the (emptied) originator and no log is emitted.

`burn_log` is imported lazily in the pre-EIP-8246 branch because EIP-8246
deletes the helper from the EIP-7708 spec. The charged gas is unchanged,
so `cumulative_gas_used` is asserted identically on both sides.

* fix(spec-specs): EIP-2780 charge `NEW_ACCOUNT` for value transfer to zero balance precompile (#3048)

* fix(amsterdam): charge NEW_ACCOUNT for value transfer to empty precompile

EIP-2780 charges the NEW_ACCOUNT state cost when a transaction
transfers value to a recipient that is empty per EIP-161. The
top-frame charge previously carved out precompile recipients, but
neither EIP-2780 nor EIP-161 authorizes that exemption:

- EIP-2780 does not mention precompiles; its rule keys solely on
  "empty per EIP-161 and tx.value > 0".
- EIP-161 defines empty structurally (no code, zero nonce, zero
  balance) with no precompile exception, so an unfunded precompile
  is empty and is created by the value transfer like any other
  account.

Remove the `recipient_is_precompile` carve-out from the top-frame
charge so an empty precompile receiving value pays NEW_ACCOUNT,
drop the matching special-case from the testing framework's
`transaction_top_frame_state_gas`, and rewrite
`test_value_move_to_precompiles` to assert the charge fires for the
not-funded precompile while a pre-funded (alive) precompile remains
exempt by virtue of being non-empty.

Co-authored-by: danceratopz <danceratopz@gmail.com>

* feat(tests): add more EIP-2780 tests (#3055)

Co-authored-by: danceratopz <danceratopz@gmail.com>
Co-authored-by: Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>

* feat(specs): update EIP-8037 impl for ethereum/EIPs#11715 (#3021)

Co-authored-by: spencer-tb <spencer.tb@ethereum.org>

* fix(tests): align Amsterdam (gas) tests with EIP-2780/8037/8038 (#3088)

Co-authored-by: marioevz <marioevz@gmail.com>

* Apply suggestions from code review (packates/testing)

Co-authored-by: Mario Vega <marioevz@gmail.com>

* Apply suggestions from code review (specs)

Co-authored-by: Mario Vega <marioevz@gmail.com>

* Apply suggestions from code review (tests)

Co-authored-by: Mario Vega <marioevz@gmail.com>

* fix(specs): Lint

* fix(test-tools): Lint

---------

Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com>
Co-authored-by: Mario Vega <11726710+marioevz@users.noreply.github.com>
Co-authored-by: Guruprasad Kamath <guru241987@gmail.com>
Co-authored-by: spencer <spencer.taylor-brown@ethereum.org>
Co-authored-by: marioevz <marioevz@gmail.com>
Co-authored-by: CPerezz <37264926+CPerezz@users.noreply.github.com>
Co-authored-by: Guruprasad Kamath <48196632+gurukamath@users.noreply.github.com>
Co-authored-by: Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: spencer-tb <spencer.tb@ethereum.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tests Area: Consensus tests. C-bug Category: this is a bug, deviation, or other problem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants