Skip to content

Commit ac66326

Browse files
committed
fix: Review comments
1 parent a806383 commit ac66326

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
abstract: BloatNet worst-case attack benchmark for maximum SSTORE stress.
3+
"""

tests/benchmark/stateful/bloatnet/depth_benchmarks/test_deep_branch.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import time
2626
from pathlib import Path
27-
from typing import Any, List, Self
27+
from typing import Annotated, Any, List, Self
2828

2929
import pytest
3030
from execution_testing import (
@@ -44,7 +44,7 @@
4444
TransactionWithCost,
4545
While,
4646
)
47-
from pydantic import BaseModel, Field
47+
from pydantic import BaseModel, BeforeValidator, Field
4848

4949
# Folder path to the submodule and mined assets
5050
WORST_CASE_MINER_SUBMODULE_PATH = Path(__file__).parent / ".worst_case_miner"
@@ -94,15 +94,17 @@ class SaltedContractInstance(BaseModel):
9494

9595
class MinedContractFile(BaseModel):
9696
"""
97-
Model to load information about a contract mined using using
97+
Model to load information about a contract mined using
9898
https://github.com/CPerezz/worst_case_miner.
9999
"""
100100

101101
deployer: Address
102102
initcode_hash: Hash = Field(..., alias="init_code_hash")
103103
initcode: Bytes = Field(..., alias="init_code")
104104
deploy_code: Bytes
105-
storage_keys: List[Address]
105+
storage_keys: List[
106+
Annotated[Hash, BeforeValidator(lambda v: Hash(v, left_padding=True))]
107+
]
106108
target_depth: int
107109
num_contracts: int
108110
total_time: float
@@ -114,8 +116,9 @@ def model_post_init(self, __context: Any) -> None:
114116
"""
115117
if len(self.contracts) != self.num_contracts:
116118
raise ValueError(
117-
f"Number of storage keys ({len(self.storage_keys)}) does "
118-
f"not match number of contracts ({self.num_contracts})"
119+
f"Number of contracts specified in the `num_contracts` field, "
120+
f"({self.num_contracts})does not match number of "
121+
f"contracts ({len(self.contracts)})."
119122
)
120123
if self.initcode_hash != self.initcode.keccak256():
121124
raise ValueError(
@@ -164,7 +167,20 @@ def attack_value(request: pytest.FixtureRequest) -> int:
164167
@pytest.mark.parametrize(
165168
"storage_depth,account_depth",
166169
[
167-
(10, 6), # From .worst_case_miner/mined_assets
170+
# From .worst_case_miner/mined_assets
171+
(10, 3),
172+
(10, 4),
173+
(10, 5),
174+
(10, 6),
175+
(10, 7),
176+
(11, 3),
177+
(11, 4),
178+
(11, 5),
179+
(11, 6),
180+
(11, 7),
181+
(12, 3),
182+
(12, 4),
183+
(12, 5),
168184
],
169185
)
170186
def test_worst_depth_stateroot_recomp(
@@ -187,9 +203,8 @@ def test_worst_depth_stateroot_recomp(
187203
188204
Args:
189205
blockchain_test: The blockchain test filler
190-
pre: Pre-state allocation
191206
fork: The fork to test on
192-
env: Environment object that will be used to fill/execute
207+
pre: Pre-state allocation
193208
gas_benchmark_value: Gas budget for benchmark
194209
storage_depth: Depth of storage slots in the contract (e.g., 9)
195210
account_depth: Depth of account address prefix sharing (e.g., 5)

0 commit comments

Comments
 (0)