Skip to content

fix(test-benchmark): account access subcall OOG issue#2614

Merged
spencer-tb merged 2 commits intoethereum:forks/amsterdamfrom
LouisTsai-Csie:fix-account-access-bench
Apr 3, 2026
Merged

fix(test-benchmark): account access subcall OOG issue#2614
spencer-tb merged 2 commits intoethereum:forks/amsterdamfrom
LouisTsai-Csie:fix-account-access-bench

Conversation

@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented Apr 2, 2026

🗒️ Description

Fix test_account_access benchmark: the While loop lacked an exit condition, causing every transaction and subcall to OOG and revert all value transfers. This made the value_sent=1 variants (CALL/CALLCODE × 3 account modes × 3 cache strategies = 18 test cases) fail with BalanceMismatchError.

  • Add gas threshold to While loop (condition=Op.GT(Op.GAS, 0x9000)) for value_sent > 0 so the loop terminates cleanly before running out of gas. The threshold (36,864) is just above the worst-case single-iteration cost (CALL + cold + value + new_account = 36,600).

  • Skip Bittrex Controller nonce=1 contract via calldata_offset for EXISTING_CONTRACT mode. The nonce=1 child contract has a non-payable fallback (INVALID at offset 44) that reverts when receiving ETH. Nonce ≥ 2 contracts (545 bytes, identical bytecode) have a payable fallback that STOP immediately.

  • Remove hardcoded gas=1 from CALL/CALLCODE and gas=1, args_size=1024 from STATICCALL/DELEGATECALL parameters that were limiting subcall gas, which leads to OOG.

  • Compute total_iterations for future balance verification; replace expected_benchmark_gas_used with skip_gas_used_validation=True + expected_receipt_status=1, since we could not correctly calculate the gas cost here.

🔗 Related Issues or PRs

✅ 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.
  • 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

Put a link to a cute animal picture inside the parenthesis-->

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.24%. Comparing base (89d153d) to head (39365df).

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2614   +/-   ##
================================================
  Coverage            86.24%   86.24%           
================================================
  Files                  599      599           
  Lines                36984    36984           
  Branches              3795     3795           
================================================
  Hits                 31895    31895           
  Misses                4525     4525           
  Partials               564      564           
Flag Coverage Δ
unittests 86.24% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.


if value_sent > 0:
post[attack_address] = Account(
balance=initial_balance - total_iterations * value_sent,
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.

This assumes that we calculated the total_iterations correctly.
Note that we cannot do this, because we do not know how much gas the unknown contract will consume (yes, for repricing we target Bittrex, but we could target any contract). So our gas cost estimation will be lower than the actual cost, and therefore our total_iterations might be higher.
I think the correct test here is that the balance has decreased. Then at least one transaction succeeded and one value transfer succeeded there also.
Note that this verification does not work for contracts blocking ether sends (they will always revert/OOG)

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.

Will merge for now. Can follow up in another if still needs addressed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My refactor does not calculate the total_iterations for the post verification now.
The current workaround is to add an exit condition for the while loop, i calculate approximate the execution cost for all account mode variants (EXISTING_EOA, NON_EXISTING_EOA and EXISTING_CONTRACT).

The current approach is far from perfect, since we still lacking the verifcation to the test, i will continue on the validation part in a follow up PR.

@LouisTsai-Csie LouisTsai-Csie force-pushed the fix-account-access-bench branch 2 times, most recently from 71ea7c4 to 52cd483 Compare April 3, 2026 12:30
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review April 3, 2026 12:30
@LouisTsai-Csie LouisTsai-Csie force-pushed the fix-account-access-bench branch from 52cd483 to 708941d Compare April 3, 2026 12:43
Copy link
Copy Markdown
Contributor

@spencer-tb spencer-tb left a comment

Choose a reason for hiding this comment

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

LGTM from myside!

@spencer-tb spencer-tb merged commit 4bf8bbe into ethereum:forks/amsterdam Apr 3, 2026
18 checks passed
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.

3 participants