Skip to content

Commit ccfedf8

Browse files
committed
rebased on top of main, needs more testing don't approve yet
1 parent afda1e6 commit ccfedf8

File tree

3 files changed

+36
-584
lines changed

3 files changed

+36
-584
lines changed

src/ethereum_test_forks/forks/forks.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,9 @@ def pre_allocation_blockchain(cls) -> Mapping:
544544
return {}
545545

546546
@classmethod
547-
def blobs_supported(cls) -> bool:
548-
"""Return whether blobs are supported in this fork."""
549-
return False
547+
def engine_get_blobs_version(cls, block_number: int = 0, timestamp: int = 0) -> Optional[int]:
548+
"""At genesis, blobs cannot be retrieved through the engine API."""
549+
return None
550550

551551

552552
class Homestead(Frontier):
@@ -1046,9 +1046,9 @@ def valid_opcodes(
10461046
] + super(Cancun, cls).valid_opcodes()
10471047

10481048
@classmethod
1049-
def blobs_supported(cls) -> bool:
1050-
"""Return whether blobs are supported in this fork."""
1051-
return True
1049+
def engine_get_blobs_version(cls, block_number: int = 0, timestamp: int = 0) -> int:
1050+
"""At Cancun, the engine get blobs version is 1."""
1051+
return 1
10521052

10531053

10541054
class Prague(Cancun):
@@ -1325,6 +1325,11 @@ def solc_min_version(cls) -> Version:
13251325
"""Return minimum version of solc that supports this fork."""
13261326
return Version.parse("1.0.0") # set a high version; currently unknown
13271327

1328+
@classmethod
1329+
def engine_get_blobs_version(cls, block_number: int = 0, timestamp: int = 0) -> int:
1330+
"""At Osaka, the engine get blobs version is 2."""
1331+
return 2
1332+
13281333

13291334
class EOFv1(Prague, solc_name="cancun"):
13301335
"""EOF fork."""

src/ethereum_test_types/blob.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def get_filepath(fork: str, seed: int, timestamp: int):
9696
@staticmethod
9797
def NewBlob(fork: Fork, seed: int = 0, timestamp: int = 0) -> "Blob": # noqa: N802
9898
"""Construct Blob instances. Fork-specific logic is encapsulated within nested functions.""" # noqa: E501
99-
assert fork.blobs_supported(), (
99+
assert fork.engine_get_blobs_version() is not None, (
100100
f"You provided fork {fork.name()} but it does not support blobs!"
101-
) # TODO: why does mypy complain? this line works
101+
) # TODO: why does mypy say '"type[BaseFork]" has no attribute "engine_get_blobs_version"'?
102102

103103
fork_str: str = fork.name().lower()
104104

@@ -419,39 +419,39 @@ def corrupt_byte(b: bytes) -> Bytes:
419419
print(type(b.proof), len(b.proof))
420420
print(BYTES_PER_FIELD_ELEMENT)
421421
print(len(b.data))
422-
b.write_to_file()
423-
c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp))
424-
assert b.data == c.data
425-
assert b.commitment == c.commitment
426-
assert b.proof == c.proof
427-
assert b.cells == c.cells
428-
assert b.versioned_hash == c.versioned_hash
429-
assert b.name == c.name
430-
assert b.fork == c.fork
431-
assert b.timestamp == c.timestamp
422+
# b.write_to_file()
423+
# c: Blob = Blob.LoadBlobFromFile("blob_" + "osaka" + "_" + str(myseed) + "_" + str(mytimestamp))
424+
# assert b.data == c.data
425+
# assert b.commitment == c.commitment
426+
# assert b.proof == c.proof
427+
# assert b.cells == c.cells
428+
# assert b.versioned_hash == c.versioned_hash
429+
# assert b.name == c.name
430+
# assert b.fork == c.fork
431+
# assert b.timestamp == c.timestamp
432432
d: Blob = Blob.NewBlob(myprague, myseed, 123)
433-
d.write_to_file()
433+
# d.write_to_file()
434434
e: Blob = Blob.NewBlob(myprague, myseed, 123)
435435
print("Line above should say blob already existed and was loaded from file")
436436
ee: Blob = Blob.NewBlob(myprague, myseed, 1234)
437437
newtimestamp = 999999
438438
f: Blob = Blob.NewBlob(mycancun, 1337, newtimestamp)
439-
f.write_to_file()
439+
# f.write_to_file()
440440
h: Blob = Blob.NewBlob(myosaka, myseed)
441-
h.write_to_file()
441+
# h.write_to_file()
442442
zz: Blob = Blob.NewBlob(myosaka, myseed)
443443
print("Line above should say blob already existed and was loaded from file")
444444
# you can load a blob either via just filename or via absolute path or via relative path (cwd is ./src/ethereum_test_types) # noqa: E501
445-
yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json")
446-
# yyyy: Blob = Blob.LoadBlobFromFile(
447-
# "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501
448-
# ) # you must replace user with ur actual username as $USER not supported here
449-
yyyyy: Blob = Blob.LoadBlobFromFile(
450-
"tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
451-
)
452-
zzzzzzz: Blob = Blob.LoadBlobFromFile(
453-
"./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
454-
)
445+
# yyy: Blob = Blob.LoadBlobFromFile("blob_cancun_1337_999999.json")
446+
# # yyyy: Blob = Blob.LoadBlobFromFile(
447+
# # "/home/user/Documents/execution-spec-tests/tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337.json" # noqa: E501
448+
# # ) # you must replace user with ur actual username as $USER not supported here
449+
# yyyyy: Blob = Blob.LoadBlobFromFile(
450+
# "tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
451+
# )
452+
# zzzzzzz: Blob = Blob.LoadBlobFromFile(
453+
# "./tests/cancun/eip4844_blobs/static_blobs/blob_cancun_1337_999999.json"
454+
# )
455455

456456

457457
# test proof corruption

0 commit comments

Comments
 (0)