|
13 | 13 |
|
14 | 14 | from ethereum_test_base_types.base_types import Bytes, Hash |
15 | 15 | from ethereum_test_base_types.pydantic import CamelModel |
16 | | -from ethereum_test_forks import ( |
17 | | - Cancun, |
18 | | - Fork, |
19 | | - Osaka, |
20 | | - Prague, |
21 | | -) |
| 16 | +from ethereum_test_forks import Cancun, CancunToPragueAtTime15k, Fork, Osaka, Prague |
| 17 | +from ethereum_test_forks.forks.transition import PragueToOsakaAtTime15k |
| 18 | +from ethereum_test_forks.transition_base_fork import TransitionBaseClass |
22 | 19 |
|
23 | 20 | CACHED_BLOBS_DIRECTORY: Path = ( |
24 | 21 | Path(platformdirs.user_cache_dir("ethereum-execution-spec-tests")) / "cached_blobs" |
25 | 22 | ) |
26 | 23 |
|
27 | 24 |
|
| 25 | +def clear_blob_cache(cached_blobs_folder_path: Path): |
| 26 | + """Delete all cached blobs.""" |
| 27 | + if not cached_blobs_folder_path.is_dir(): |
| 28 | + return |
| 29 | + for f in cached_blobs_folder_path.glob("*.json"): # only delete .json files |
| 30 | + try: |
| 31 | + f.unlink() # permanently delete this file |
| 32 | + except OSError as e: |
| 33 | + print( |
| 34 | + f"Critical error while trying to delete file {f}:{e}.. " |
| 35 | + "Aborting clearing of blob cache folder." |
| 36 | + ) |
| 37 | + return |
| 38 | + |
| 39 | + |
28 | 40 | def fork_string_to_object(fork_name: str) -> type[Cancun] | type[Prague] | type[Osaka]: |
29 | 41 | """Take a fork string and return the respective fork as object.""" |
30 | 42 | fork_name = fork_name.lower() |
@@ -201,21 +213,21 @@ def get_cells(fork: Fork, data: Bytes) -> List[Bytes] | None: |
201 | 213 | f"cell proofs {amount_cell_proofs} but expected 128." |
202 | 214 | ) |
203 | 215 |
|
204 | | - assert fork.supports_blobs(), f"Provided fork {fork.name()} does not support blobs!" |
205 | | - |
206 | 216 | # if this blob already exists then load from file |
207 | 217 | blob_location: Path = Blob.get_filepath(fork, seed) |
208 | 218 | if blob_location.exists(): |
209 | 219 | print(f"Blob exists already, reading it from file {blob_location}") |
210 | 220 | return Blob.from_file(Blob.get_filename(fork, seed)) |
211 | 221 |
|
212 | | - # loaded trusted setup if it is not already loaded |
213 | | - Blob.trusted_setup() |
214 | | - |
215 | 222 | # handle transition forks (not needed when default timestamp of 0 is used) |
216 | 223 | if timestamp > 0: |
217 | 224 | fork = fork.fork_at(timestamp=timestamp) |
218 | 225 |
|
| 226 | + assert fork.supports_blobs(), f"Provided fork {fork.name()} does not support blobs!" |
| 227 | + |
| 228 | + # loaded trusted setup if it is not already loaded |
| 229 | + Blob.trusted_setup() |
| 230 | + |
219 | 231 | # get data for blob parameters |
220 | 232 | data: Bytes = generate_blob_data(seed) |
221 | 233 | commitment: Bytes = get_commitment(data) |
@@ -435,20 +447,3 @@ def corrupt_byte(b: bytes) -> Bytes: |
435 | 447 | self.proof = Bytes(bytes(len(self.proof))) |
436 | 448 | elif mode == self.ProofCorruptionMode.CORRUPT_ALL_BYTES: |
437 | 449 | self.proof = Bytes(b"".join(corrupt_byte(bytes([byte])) for byte in self.proof)) |
438 | | - |
439 | | - |
440 | | -# test fork_at for when timestamp > 0 |
441 | | -# transitionfork: Fork = Cancun |
442 | | -# new_timestamp = 15000 # is supposed to return prague, but still returns cancun.. TODO: ? |
443 | | -# transitionforkblob: Blob = Blob.from_fork(transitionfork, timestamp=new_timestamp) |
444 | | -# transitionforkblob.write_to_file() |
445 | | -# restored_transitionforkblob: Blob = Blob.from_file("blob_0_cell_proofs_0") |
446 | | -# assert transitionforkblob.data == restored_transitionforkblob.data |
447 | | -# assert transitionforkblob.commitment == restored_transitionforkblob.commitment |
448 | | -# assert transitionforkblob.proof == restored_transitionforkblob.proof |
449 | | -# assert transitionforkblob.cells == restored_transitionforkblob.cells |
450 | | -# assert transitionforkblob.versioned_hash == restored_transitionforkblob.versioned_hash |
451 | | -# assert transitionforkblob.name == restored_transitionforkblob.name |
452 | | -# assert transitionforkblob.fork == restored_transitionforkblob.fork |
453 | | -# assert transitionforkblob.seed == restored_transitionforkblob.seed |
454 | | -# assert transitionforkblob.timestamp == restored_transitionforkblob.timestamp |
0 commit comments