-
Couldn't load subscription status.
- Fork 185
feat(benchmark): add SLOAD/SSTORE benchmark test with multi-contract support #2256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
LouisTsai-Csie
merged 14 commits into
ethereum:main
from
CPerezz:feat/bloatnet-sload-sstore-benchmarks
Oct 23, 2025
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5a1a966
feat(benchmark): add SLOAD benchmark test with multi-contract support
CPerezz 4843bc3
feat(benchmark): add SSTORE benchmark test using ERC20 approve
CPerezz 5834cc6
fix(benchmark): correct SSTORE benchmark gas calculation
CPerezz b0a7aa0
feat(benchmark): add mixed SLOAD/SSTORE benchmark with configurable r…
CPerezz 552638e
refactor(benchmark): optimize SLOAD/SSTORE benchmarks per review feed…
CPerezz 91c6ebb
refactor(benchmark): simplify SLOAD benchmark memory layout and fix c…
CPerezz 07764be
refactor(benchmark): simplify SSTORE benchmark memory layout and fix …
CPerezz abcdde8
refactor(benchmark): simplify mixed SLOAD/SSTORE memory layout and fi…
CPerezz 1902c2a
refactor(benchmark): simplify mixed test to reuse memory layout consi…
CPerezz 9673f54
feat(benchmark): add parametrized contract count and stub filtering t…
CPerezz 511aaaf
fix(benchmark): add type annotations to test functions
CPerezz f25b55f
fix(benchmark): add AddressStubs type annotation to address_stubs par…
CPerezz 91a8575
feat(benchmark): add parametrized contract count, stub filtering, and…
CPerezz ae18088
feat(benchmark): add parametrized contract count, stub filtering, and…
CPerezz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # BloatNet Single-Opcode Benchmarks | ||
|
|
||
| This directory contains benchmarks for testing single EVM opcodes (SLOAD, SSTORE) under state-heavy conditions using pre-deployed contracts. | ||
|
|
||
| ## Test Setup | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| 1. Pre-deployed ERC20 contracts on the target network | ||
| 2. A JSON file containing contract addresses (stubs) | ||
|
|
||
| ### Address Stubs Format | ||
|
|
||
| Create a JSON file (`stubs.json`) mapping test-specific stub names to deployed contract addresses: | ||
|
|
||
| ```json | ||
| { | ||
| "test_sload_empty_erc20_balanceof_USDT": "0x1234567890123456789012345678901234567890", | ||
| "test_sload_empty_erc20_balanceof_USDC": "0x2345678901234567890123456789012345678901", | ||
| "test_sload_empty_erc20_balanceof_DAI": "0x3456789012345678901234567890123456789012", | ||
| "test_sload_empty_erc20_balanceof_WETH": "0x4567890123456789012345678901234567890123", | ||
| "test_sload_empty_erc20_balanceof_WBTC": "0x5678901234567890123456789012345678901234", | ||
|
|
||
| "test_sstore_erc20_approve_USDT": "0x1234567890123456789012345678901234567890", | ||
| "test_sstore_erc20_approve_USDC": "0x2345678901234567890123456789012345678901", | ||
| "test_sstore_erc20_approve_DAI": "0x3456789012345678901234567890123456789012", | ||
| "test_sstore_erc20_approve_WETH": "0x4567890123456789012345678901234567890123", | ||
| "test_sstore_erc20_approve_WBTC": "0x5678901234567890123456789012345678901234"" | ||
| } | ||
| ``` | ||
|
|
||
| **Naming Convention:** | ||
| - Stub names MUST start with the test function name | ||
| - Format: `{test_function_name}_{identifier}` | ||
| - Example: `test_sload_empty_erc20_balanceof_USDT` | ||
|
|
||
|
|
||
| ### Running the Tests | ||
|
|
||
| #### Execute Mode (Against Live Network) | ||
|
|
||
| ```bash | ||
| # Run with specific number of contracts (e.g., only the 5-contract variant) | ||
| PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run execute \ | ||
| --address-stubs /path/to/stubs.json \ | ||
| --fork=Prague \ | ||
| tests/benchmark/stateful/bloatnet/test_single_opcode.py::test_sload_empty_erc20_balanceof \ | ||
| -k "[5]" \ | ||
| -v | ||
|
|
||
| # Run all parametrized variants (1, 5, 10, 20 contracts) | ||
| PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run execute \ | ||
| --address-stubs /path/to/stubs.json \ | ||
| --fork=Prague \ | ||
| tests/benchmark/stateful/bloatnet/test_single_opcode.py \ | ||
| -v | ||
| ``` | ||
|
|
||
|
|
||
| ## Test Parametrization | ||
|
|
||
| Both tests are parametrized with `num_contracts = [1, 5, 10, 20, 100]`, generating 5 test variants each: | ||
|
|
||
| - **1 contract**: Baseline single-contract performance | ||
| - **5 contracts**: Small-scale multi-contract scenario | ||
| - **10 contracts**: Medium-scale multi-contract scenario | ||
| - **20 contracts**: Large-scale multi-contract scenario | ||
| - **100 contracts**: Very large-scale multi-contract stress test | ||
|
|
||
| ### How Stub Filtering Works | ||
|
|
||
| 1. Test extracts its function name (e.g., `test_sload_empty_erc20_balanceof`) | ||
| 2. Filters stubs starting with that name from `stubs.json` | ||
| 3. Selects the **first N** matching stubs based on `num_contracts` parameter | ||
| 4. Errors if insufficient matching stubs found | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.