feat(test-benchmark): storage initialization helper with 7702 authorization#2672
feat(test-benchmark): storage initialization helper with 7702 authorization#2672LouisTsai-Csie wants to merge 3 commits intoethereum:forks/amsterdamfrom
Conversation
|
For @jochem-brouwer and @nerolation , you could focus on |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2672 +/- ##
================================================
Coverage 86.25% 86.25%
================================================
Files 599 599
Lines 37032 37032
Branches 3795 3795
================================================
Hits 31943 31943
Misses 4525 4525
Partials 564 564
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jochem-brouwer
left a comment
There was a problem hiding this comment.
Some questions about the storage logic 😄 👍
| a storage-initializer contract (if *needs_init*), then to the | ||
| benchmark executor contract. Return the list of setup blocks. | ||
| """ | ||
| blocks: list[Block] = [] |
There was a problem hiding this comment.
Should this method be wrapped in TestPhaseManager.setup() ?
| start_iteration=1, | ||
| calldata=initializer_calldata_generator, | ||
| ) | ||
| iteration_count = max(1, tx_gas_limit // iteration_cost) |
There was a problem hiding this comment.
I think this should be ceil(tx_gas_limit // iteration_cost)?
| iteration_count = max(1, tx_gas_limit // iteration_cost) | |
| iteration_count = ceil(tx_gas_limit // iteration_cost) |
|
|
||
| # Final block: Authorize to executor | ||
| blocks.append( | ||
| Block( |
There was a problem hiding this comment.
I think this should read the nonce for the authority EOA variable. If we use a test which has to delegate again after the setup, then we must ensure the nonce is correct 🤔
🗒️ Description
In the pre-allocation phase that deploys a contract, the framework supports passing in a dictionary that represents the storage to be initialized, and then embeds the logic inside the
initcode. When the contract is created, it executes the initcode and performs the storage update.However, in most of the benchmark cases, this is too inefficient, since the initialization phase requires a huge range of storage initialization, it leads to an
initcode prefix too longissue.Solution
To resolve this issue, we create a helper for the stateful benchmark scenario. Users can define a storage init range like this:
Which means the storage would be initialized to
STORAGE[i] = i + offset, whereistarts fromstart_slottostart_slot + num_slots.We leverage the EIP-7702 authorization approach for testing. The workflow now becomes:
create_sequential_sstore_initializer).IteratingBytecodewithtransactions_by_iteration_counts.Design decisions
authority.nonce(incremented in-place) rather than hardcoded constants, ensuring compatibility with execute-remote where nonces are fetched from the live network.build_sequential_storage_init,StorageInitRange, etc.) live intests/benchmark/stateful/helpers.pyso they are reusable beyond the BAL tests.🔗 Related Issues or PRs
N/A.
✅ Checklist
just statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture