Skip to content

Commit 3d6a684

Browse files
committed
removed manual fork checks in favor of abstracted, dynamic checks
1 parent f5d5820 commit 3d6a684

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/ethereum_test_types/blob.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ def write_to_file(self):
263263

264264
def verify_cell_kzg_proof_batch(self, cell_indices: list) -> bool:
265265
"""Check whether all cell proofs are valid and returns True only if that is the case."""
266-
assert self.fork in ["osaka"], (
267-
f"verify_cell_kzg_proof_batch() is not available for fork: {self.fork}"
266+
fork_obj = fork_string_to_object(self.fork)
267+
amount_cell_proofs: int = cast(int, fork_obj.get_blob_constant("AMOUNT_CELL_PROOFS"))
268+
269+
assert amount_cell_proofs > 0, (
270+
f"verify_cell_kzg_proof_batch() is not available for your fork: {self.fork}."
268271
)
269272

270273
assert self.cells is not None, "self.cells is None, critical error."
@@ -294,7 +297,10 @@ def delete_cells_then_recover_them(self, deletion_indices: list[int]):
294297
the ckzg recovery mechanism is used to repair the missing cells.
295298
If no assertion is triggered the reconstruction was successful.
296299
"""
297-
assert self.fork in ["osaka"], (
300+
fork_obj = fork_string_to_object(self.fork)
301+
amount_cell_proofs: int = cast(int, fork_obj.get_blob_constant("AMOUNT_CELL_PROOFS"))
302+
303+
assert amount_cell_proofs > 0, (
298304
f"delete_cells_then_recover_them() is not available for fork: {self.fork}"
299305
)
300306

@@ -370,7 +376,9 @@ def corrupt_byte(b: bytes) -> Bytes:
370376
return Bytes(bytes([b[0] ^ 0xFF]))
371377

372378
# osaka and later
373-
if self.fork in ["osaka"]:
379+
fork_obj = fork_string_to_object(self.fork)
380+
amount_cell_proofs: int = cast(int, fork_obj.get_blob_constant("AMOUNT_CELL_PROOFS"))
381+
if amount_cell_proofs > 0:
374382
assert isinstance(self.proof, list), (
375383
"proof was expected to be a list but it isn't"
376384
) # make mypy happy
@@ -396,7 +404,7 @@ def corrupt_byte(b: bytes) -> Bytes:
396404
return
397405

398406
# pre-osaka (cancun and prague)
399-
assert self.fork in ["cancun", "prague"], (
407+
assert amount_cell_proofs == 0, (
400408
f"You need to adjust corrupt_proof to handle fork {self.fork}"
401409
)
402410
assert isinstance(self.proof, Bytes), "proof was expected to be Bytes but it isn't"

0 commit comments

Comments
 (0)