Commit 675f1a7
feat(tests): multi opcode bloatnet ext cases (#2186)
* Add BloatNet tests
Signed-off-by: Guillaume Ballet <[email protected]>
* try building the contract
Signed-off-by: Guillaume Ballet <[email protected]>
* fix: SSTORE 0 -> 1 match all values in the state
Signed-off-by: Guillaume Ballet <[email protected]>
* add the tx for 0 -> 1 and 1 -> 2
Signed-off-by: Guillaume Ballet <[email protected]>
* fix: linter issues
Signed-off-by: Guillaume Ballet <[email protected]>
* remove more whitespaces
Signed-off-by: Guillaume Ballet <[email protected]>
remove leftover single whitespace :|
* fix formatting
* move to benchmarks
Signed-off-by: Guillaume Ballet <[email protected]>
* fix linter value
* use the gas limit from the environment
* parameterize the written value in SSTORE
* fix linter issues
* update CHANGELOG.md
* fix format
* simplify syntax
* fix: start with an empty contract storage
* more fixes, but the result is still incorrect
* fix: finally fix the tests
* linter fix
* add SLOAD tests
* test(benchmark): implement CREATE2 addressing for bloatnet tests
- Add CREATE2 deterministic address calculation to overcome 24KB bytecode limit
- Fix While loop condition to properly iterate through contracts
- Account for memory expansion costs in gas calculations
- Add safety margins (50k gas reserve, 98% utilization) for stability
- Tests now scale to any gas limit without bytecode constraints
- Achieve 98% gas utilization with 10M and 20M gas limits
* refactor(benchmark): optimize gas calculations in bloatnet tests
- Remove gas reserve and 98% utilization logic for contract calculations
- Directly calculate the number of contracts based on available gas
- Introduce precise expected gas usage calculations for better accuracy
- Ensure tests scale effectively without unnecessary constraints
* refactor(benchmark): bloatnet tests with unique bytecode for I/O optimization
- Update tests to generate unique bytecode for each contract, maximizing I/O reads during benchmarks.
- Clarify comments regarding bytecode generation and its impact on gas costs.
- Ensure CREATE2 addresses are calculated consistently using a base bytecode template.
- Improve test descriptions to reflect the changes in contract deployment strategy.
* refactor(benchmark): replace custom CREATE2 address calculation with utility function
- Remove the custom `calculate_create2_address` function in favor of the `compute_create2_address` utility.
- Update tests to utilize the new utility for consistent CREATE2 address calculations.
- Simplify code by eliminating unnecessary complexity in address calculation logic.
- Ensure that the CREATE2 prefix is directly set to 0xFF in the memory operation for clarity.
* CREATE2 factory approach working
* Version with EIP-7997 model working
* refactor(benchmark): imrpove contract deployment script with interactive selection and bytecode generation
- Introduced interactive contract type selection for deploying contracts in the bloatnet benchmark.
- Added support for multiple contract types: max_size_24kb, sload_heavy, storage_heavy, and custom.
- Refactored bytecode generation functions to improve clarity and maintainability.
- Updated README to reflect changes in deployment process and contract types.
- Ensured proper handling of factory deployment and transaction receipt checks.
* delete: remove obsolete test_create2.py script
This was commited unintentionally
* refactor(benchmark): optimize gas calculations for BALANCE + EXTCODECOPY pattern
- Updated the README to reflect the optimized gas cost for the BALANCE + EXTCODECOPY pattern, reducing it from ~5,007 to ~2,710 gas per contract.
- Modified the test_bloatnet_balance_extcodecopy function to read only 1 byte from the end of the bytecode, minimizing gas costs while maximizing contract targeting.
- Adjusted calculations for the number of contracts needed based on the new cost per contract, ensuring accurate benchmarks.
* refactor(benchmark): support non-fixed max_codesize
* chore: Remove all 24kB "hardcoded" refs
* fix: pre-commit lint hooks
* push updated deploy_create2_factory refactored with EEST as dep
* refactor(benchmark): enhance CREATE2 factory deployment and testing
- Updated the deploy_create2_factory_refactored.py script to improve the deployment of a CREATE2 factory with an initcode template, allowing for dynamic contract address generation.
- Modified test_bloatnet.py to support on-the-fly CREATE2 address generation, optimizing gas costs and improving test accuracy.
- Adjusted gas cost calculations in the README to reflect the new deployment approach, ensuring accurate benchmarks for BloatNet tests.
* remove: old_deploy_factory script
* chore: address PR review fixes
* fix(benchmark): correct import path for ethereum_test_vm
* chore(benchmark): update according to review comments
Also, renamed the test file to include only multi-opcode tests there and have a more clean directory for future test inclusions.
* refactor(benchmark): remove hardcoded parameters storing inside factory stub
- Fixed offset at which we COPYCODE
- Removed hardcoded values and added comments for clarity on factory storage layout and contract generation.
* chore: update pyproject.toml configuration
* refactor: rename test_mutiopcode.py to test_muti_opcode.py for consistency
* fix: correct import sorting in test_muti_opcode.py to fix CI lint error
* fix(benchmark): rename test file to fix typo
Rename test_muti_opcode.py to test_multi_opcode.py to fix filename typo
* fix(benchmark): update BloatNet tests to use factory's getConfig() method
Replace direct storage access with STATICCALL to factory's getConfig() method
in both test_bloatnet_balance_extcodesize and test_bloatnet_balance_extcodecopy.
Changes:
- Use STATICCALL to retrieve configuration from factory instead of SLOAD
- Add proper error handling for failed configuration calls
- Remove gas-limiting calculations, allowing tests to run until gas exhaustion
- Store configuration data in memory positions 96 and 128 for cleaner access
This makes the tests more robust and better aligned with the factory's
public interface, avoiding direct storage access assumptions.
* refactor(benchmark): enhance BloatNet test documentation and gas cost calculations
* revert: restore pyproject.toml to match main branch
Remove all changes to pyproject.toml to align with upstream main branch.
This ensures CI compatibility and prevents configuration conflicts.
* fix(benchmark): resolve W505 doc line length issues in test_multi_opcode.py
Fixed all documentation and comment lines exceeding 79 characters to comply
with lint requirements.
* refactor(benchmark): simplify STATICCALL usage in BloatNet tests.
* feat(benchmark): add gas exhaustion validation using expected_receipt
Implement solution to address reviewer's concern about test validation by using
EEST's expected_receipt feature to validate that benchmarks consume all gas.
Changes:
- Add TransactionReceipt import
- Add expected_receipt to both test transactions validating gas_used equals gas_limit
- Remove skip_gas_used_validation flag as validation is now explicit
This ensures tests can distinguish between:
- Early failure from invalid jump (~50K gas) indicating setup issues
- Full gas exhaustion (all gas consumed) indicating successful benchmark run
The invalid jump remains as a fail-fast mechanism for STATICCALL failures,
while expected_receipt validates the benchmark actually executed.
* fix(benchmark): restore skip_gas_used_validation flag
Re-add skip_gas_used_validation=True to both blockchain_test calls
as it was accidentally removed. This flag is still needed alongside
the expected_receipt validation.
* refactor(benchmark): improve readability using kwargs syntax for opcodes
Apply reviewer suggestions to use more readable kwargs syntax for memory
and stack operations throughout both test functions.
Changes:
- Use Op.MLOAD(offset) instead of Op.PUSH1(offset) + Op.MLOAD
- Use Op.MSTORE(offset, value) for cleaner memory writes
- Use Op.SHA3(offset, length) for hash operations
- Use Op.POP(Op.BALANCE) and Op.POP(Op.EXTCODESIZE) for cleaner stack ops
- Combine increment operations into single Op.MSTORE(32, Op.ADD(Op.MLOAD(32), 1))
This makes the bytecode generation more concise and easier to understand.
* fix(benchmark): shorten comment lines to meet doc length limit
* fix(benchmark): correct MSTORE operation to store init_code_hash properly
* fix(benchmark): address review comments - remove redundant validation and fix ADD syntax
---------
Signed-off-by: Guillaume Ballet <[email protected]>
Co-authored-by: Guillaume Ballet <[email protected]>1 parent 31a9089 commit 675f1a7
File tree
3 files changed
+318
-1
lines changed- docs
- tests/benchmark/bloatnet
3 files changed
+318
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
0 commit comments