2424
2525import time
2626from pathlib import Path
27- from typing import Any , List , Self
27+ from typing import Annotated , Any , List , Self
2828
2929import pytest
3030from execution_testing import (
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
5050WORST_CASE_MINER_SUBMODULE_PATH = Path (__file__ ).parent / ".worst_case_miner"
@@ -94,15 +94,17 @@ class SaltedContractInstance(BaseModel):
9494
9595class 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)
170186def 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