Skip to content

refactor(test-benchmark): update test_account_access, add keccak256 overhead scenario#2947

Open
LouisTsai-Csie wants to merge 7 commits into
ethereum:forks/amsterdamfrom
LouisTsai-Csie:refactor-account-access-bench
Open

refactor(test-benchmark): update test_account_access, add keccak256 overhead scenario#2947
LouisTsai-Csie wants to merge 7 commits into
ethereum:forks/amsterdamfrom
LouisTsai-Csie:refactor-account-access-bench

Conversation

@LouisTsai-Csie

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

Copy link
Copy Markdown
Collaborator

🗒️ Description

The original test_account_access targets contracts created by the Bittrex controller factory. This requires CREATE address calculations, introducing significant overhead and it is hard to precisely control over EXP and KECCAK256 inputs.

We introduced several changes in this PR:

  • Move the test_account_access from test_single_opcode.py to test_account_query.py
  • Remove the EXISTING_CONTRACT parametrization, adding EXISTING_CONTRACT_MINIMAL, EXISTING_CONTRACT_SAME and EXISTING_CONTRACT_DIFF parametrization.
  • Add two helper files under tests/benchmark/helper: account_creator.py and account_sender_receiver.py -> we should remove tests/benchmark/{compute, stateful}/helpers.py in the future to share the helper function.
  • Add test_deploy_existing_contracts that would be used for contract deployment, this includes deploying EXISTING_CONTRACT_* instance and necessary delegation.

deployed contract and initcode for each parametrization:

EXISTING_CONTRACT_MINIMAL
initcode: RETURN(PUSH1(0), PUSH1(1))
deployed code: STOP

EXISTING_CONTRACT_SAME
initcode:

seed 32 bytes of JUMPDEST (5b) at mem[0]
for size in 32, 64, ..., 16384:
    MCOPY mem[0:size] -> mem[size:2*size] # doubles filled region

mem[0] = 0x00 # MSTORE8: STOP

RETURN mem[0:max_code_size]

deployed code:

STOP JUMPDEST JUMPDEST ... ... ... JUMPDEST (fill until max code size)

EXISTING_CONTRACT_DIFF
initcode:

seed 32 bytes of JUMPDEST (5b) at mem[0]
for size in 32, 64, ..., 16384:
    MCOPY mem[0:size] -> mem[size:2*size] # doubles filled region

mem[0] = ADDRESS # MSTORE: ADDRESS

RETURN mem[0:max_code_size]

deployed code:

STOP STOP ... STOP ADDRESS JUMPDEST ... ... ... JUMPDEST (fill until max code size)

  • code[0:12] = STOP
  • code[12:32] = code address, which should be different for each contract

🔗 Related Issues or PRs

N/A.

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

@LouisTsai-Csie LouisTsai-Csie self-assigned this Jun 2, 2026
@LouisTsai-Csie LouisTsai-Csie added C-refactor Category: refactor A-test-benchmark Area: execution_testing.benchmark and tests/benchmark labels Jun 2, 2026
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.21%. Comparing base (45fb08e) to head (e6ad6ea).
⚠️ Report is 11 commits behind head on forks/amsterdam.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #2947      +/-   ##
===================================================
+ Coverage            90.32%   93.21%   +2.88%     
===================================================
  Files                  620      620              
  Lines                36686    38793    +2107     
  Branches              3341     3342       +1     
===================================================
+ Hits                 33138    36160    +3022     
+ Misses                2979     1773    -1206     
- Partials               569      860     +291     
Flag Coverage Δ
unittests 93.21% <ø> (+2.88%) ⬆️

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.

@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review June 9, 2026 09:33
@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch from 9561e54 to b5832cd Compare June 9, 2026 09:37
@LouisTsai-Csie

Copy link
Copy Markdown
Collaborator Author

I've rebased the PR and updated the description, please review and integrate contract deployment into state-actor. cc @jochem-brouwer

@LouisTsai-Csie LouisTsai-Csie requested review from marioevz and spencer-tb and removed request for marioevz June 9, 2026 13:31
@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch 6 times, most recently from 6ef4781 to 4f7cf29 Compare June 12, 2026 10:29
@LouisTsai-Csie LouisTsai-Csie marked this pull request as draft June 12, 2026 12:34
@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch from 4f7cf29 to e45bc6d Compare June 15, 2026 09:33
@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch from 00a346c to 8525c02 Compare June 16, 2026 10:03

@jochem-brouwer jochem-brouwer 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.

Some small comments!

Comment thread tests/benchmark/stateful/helpers.py Outdated
Comment thread tests/benchmark/stateful/helpers.py Outdated
Comment thread tests/benchmark/stateful/helpers.py Outdated
Comment thread tests/benchmark/stateful/helpers.py Outdated
# Runtime only uses MEM[0:0x6000].
code = Op.MSTORE(0, bytes(Op.JUMPDEST * 32))
for size in (1 << s for s in range(5, 15)):
code += Op.MCOPY(size, 0, size)

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.

It helps if this has the hint 1 << 5 = 32 (so the first MCOPY is Op.MCOPY(32, 0, 32) (so it copies the just MSTOREd 32 bytes of JUMPDEST from 0-32 to offset 32, i.e. doubles the memory which has JUMPDEST, and the initial code for this is correct)

@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch from 8525c02 to 7ea7b98 Compare June 17, 2026 14:24
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review June 17, 2026 15:28
Comment on lines +20 to +22
# Runtime code size of the jochemnet contract (EIP-170 limit).
JOCHEMNET_RUNTIME_SIZE = 0x6000

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.

Based on my current understanding, we want to do the repricing based on the old max code size value (0x6000), could you please confirm? cc @jochem-brouwer

This is applied to all the following contract variants. Note that if i use fork.max_code_size() instead, this would be affected by eip-7954.

Comment on lines +22 to +26
# Deterministic EIP-7702 delegate authorities:
# Authority i delegates to EXISTING_CONTRACT_DIFF receiver i.
DELEGATE_BASE_KEY = int.from_bytes(
keccak256(b"gas-repricings-7702-delegate"), "big"
)

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.

Starting from this range, we delegate to EXISTING_CONTRACT_DIFF contracts for a certain count. See test_deploy_existing_contracts. I need to verify if the current count is sufficient.

@LouisTsai-Csie LouisTsai-Csie force-pushed the refactor-account-access-bench branch from 7c586e4 to 7ea7b98 Compare June 18, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-benchmark Area: execution_testing.benchmark and tests/benchmark C-refactor Category: refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants