1414)
1515from ethereum_test_tools .vm .opcode import Opcodes as Op
1616
17- from .spec import Spec , SpecHelpers
17+ from .spec import Spec
1818
1919INF_POINT = (0xC0 << 376 ).to_bytes (48 , byteorder = "big" )
2020Z = 0x623CE31CF9759A5C8DAF3A357992F9F3DD7F9339D8998BC8E68373E54F00B75E
@@ -57,12 +57,6 @@ def blobs_to_transaction_input(
5757 return (blobs , kzg_commitments , kzg_proofs )
5858
5959
60- # Simple list of blob versioned hashes ranging from bytes32(1 to 4)
61- simple_blob_hashes : list [bytes ] = add_kzg_version (
62- [(1 << x ) for x in range (SpecHelpers .max_blobs_per_block ())],
63- Spec .BLOB_COMMITMENT_VERSION_KZG ,
64- )
65-
6660# Random fixed list of blob versioned hashes
6761random_blob_hashes = add_kzg_version (
6862 [
@@ -284,7 +278,7 @@ class BlobhashScenario:
284278 """
285279
286280 @staticmethod
287- def create_blob_hashes_list (length : int ) -> list [list [bytes ]]:
281+ def create_blob_hashes_list (length : int , max_blobs_per_block : int ) -> list [list [bytes ]]:
288282 """
289283 Creates a list of MAX_BLOBS_PER_BLOCK blob hashes
290284 using `random_blob_hashes`.
@@ -293,20 +287,20 @@ def create_blob_hashes_list(length: int) -> list[list[bytes]]:
293287 length: MAX_BLOBS_PER_BLOCK * length
294288 -> [0x01, 0x02, 0x03, 0x04, ..., 0x0A, 0x0B, 0x0C, 0x0D]
295289
296- Then split list into smaller chunks of SpecHelpers. max_blobs_per_block()
290+ Then split list into smaller chunks of max_blobs_per_block
297291 -> [[0x01, 0x02, 0x03, 0x04], ..., [0x0a, 0x0b, 0x0c, 0x0d]]
298292 """
299293 b_hashes = [
300294 random_blob_hashes [i % len (random_blob_hashes )]
301- for i in range (SpecHelpers . max_blobs_per_block () * length )
295+ for i in range (max_blobs_per_block * length )
302296 ]
303297 return [
304- b_hashes [i : i + SpecHelpers . max_blobs_per_block () ]
305- for i in range (0 , len (b_hashes ), SpecHelpers . max_blobs_per_block () )
298+ b_hashes [i : i + max_blobs_per_block ]
299+ for i in range (0 , len (b_hashes ), max_blobs_per_block )
306300 ]
307301
308302 @staticmethod
309- def blobhash_sstore (index : int ):
303+ def blobhash_sstore (index : int , max_blobs_per_block : int ):
310304 """
311305 Returns an BLOBHASH sstore to the given index.
312306
@@ -315,35 +309,38 @@ def blobhash_sstore(index: int):
315309 the BLOBHASH sstore.
316310 """
317311 invalidity_check = Op .SSTORE (index , 0x01 )
318- if index < 0 or index >= SpecHelpers . max_blobs_per_block () :
312+ if index < 0 or index >= max_blobs_per_block :
319313 return invalidity_check + Op .SSTORE (index , Op .BLOBHASH (index ))
320314 return Op .SSTORE (index , Op .BLOBHASH (index ))
321315
322316 @classmethod
323- def generate_blobhash_bytecode (cls , scenario_name : str ) -> bytes :
317+ def generate_blobhash_bytecode (cls , scenario_name : str , max_blobs_per_block : int ) -> bytes :
324318 """
325319 Returns BLOBHASH bytecode for the given scenario.
326320 """
327321 scenarios = {
328322 "single_valid" : sum (
329- cls .blobhash_sstore (i ) for i in range (SpecHelpers . max_blobs_per_block () )
323+ cls .blobhash_sstore (i , max_blobs_per_block ) for i in range (max_blobs_per_block )
330324 ),
331325 "repeated_valid" : sum (
332- sum (cls .blobhash_sstore (i ) for _ in range (10 ))
333- for i in range (SpecHelpers . max_blobs_per_block () )
326+ sum (cls .blobhash_sstore (i , max_blobs_per_block ) for _ in range (10 ))
327+ for i in range (max_blobs_per_block )
334328 ),
335329 "valid_invalid" : sum (
336- cls .blobhash_sstore (i )
337- + cls .blobhash_sstore (SpecHelpers . max_blobs_per_block () )
338- + cls .blobhash_sstore (i )
339- for i in range (SpecHelpers . max_blobs_per_block () )
330+ cls .blobhash_sstore (i , max_blobs_per_block )
331+ + cls .blobhash_sstore (max_blobs_per_block , max_blobs_per_block )
332+ + cls .blobhash_sstore (i , max_blobs_per_block )
333+ for i in range (max_blobs_per_block )
340334 ),
341335 "varied_valid" : sum (
342- cls .blobhash_sstore (i ) + cls .blobhash_sstore (i + 1 ) + cls .blobhash_sstore (i )
343- for i in range (SpecHelpers .max_blobs_per_block () - 1 )
336+ cls .blobhash_sstore (i , max_blobs_per_block )
337+ + cls .blobhash_sstore (i + 1 , max_blobs_per_block )
338+ + cls .blobhash_sstore (i , max_blobs_per_block )
339+ for i in range (max_blobs_per_block - 1 )
344340 ),
345341 "invalid_calls" : sum (
346- cls .blobhash_sstore (i ) for i in range (- 5 , SpecHelpers .max_blobs_per_block () + 5 )
342+ cls .blobhash_sstore (i , max_blobs_per_block )
343+ for i in range (- 5 , max_blobs_per_block + 5 )
347344 ),
348345 }
349346 scenario = scenarios .get (scenario_name )
0 commit comments