Skip to content

Commit e290743

Browse files
spencer-tbmarioevz
authored andcommitted
chore(forks): osaka tweak and fix blob schedule logic (ethereum#1438)
* chore(forks): osaka tweak and fix blob schedule logic. * refactor and add unit test --------- Co-authored-by: Mario Vega <[email protected]>
1 parent e528948 commit e290743

File tree

5 files changed

+40
-68
lines changed

5 files changed

+40
-68
lines changed

src/ethereum_test_forks/forks/forks.py

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -964,19 +964,13 @@ def blob_schedule(cls, block_number: int = 0, timestamp: int = 0) -> BlobSchedul
964964
"""
965965
parent_fork = cls.parent()
966966
assert parent_fork is not None, "Parent fork must be defined"
967-
blob_schedule = parent_fork.blob_schedule(block_number, timestamp)
968-
if blob_schedule is None:
969-
last_blob_schedule = None
970-
blob_schedule = BlobSchedule()
971-
else:
972-
last_blob_schedule = blob_schedule.last()
967+
blob_schedule = parent_fork.blob_schedule(block_number, timestamp) or BlobSchedule()
973968
current_blob_schedule = ForkBlobSchedule(
974969
target_blobs_per_block=cls.target_blobs_per_block(block_number, timestamp),
975970
max_blobs_per_block=cls.max_blobs_per_block(block_number, timestamp),
976971
base_fee_update_fraction=cls.blob_base_fee_update_fraction(block_number, timestamp),
977972
)
978-
if last_blob_schedule is None or last_blob_schedule != current_blob_schedule:
979-
blob_schedule.append(fork=cls.__name__, schedule=current_blob_schedule)
973+
blob_schedule.append(fork=cls.name(), schedule=current_blob_schedule)
980974
return blob_schedule
981975

982976
@classmethod
@@ -1287,60 +1281,6 @@ def engine_forkchoice_updated_version(
12871281
return 3
12881282

12891283

1290-
class CancunEIP7692( # noqa: SC200
1291-
Cancun,
1292-
transition_tool_name="Prague", # Evmone enables (only) EOF at Prague
1293-
blockchain_test_network_name="Prague", # Evmone enables (only) EOF at Prague
1294-
solc_name="cancun",
1295-
):
1296-
"""Cancun + EIP-7692 (EOF) fork (Deprecated)."""
1297-
1298-
@classmethod
1299-
def evm_code_types(cls, block_number: int = 0, timestamp: int = 0) -> List[EVMCodeType]:
1300-
"""EOF V1 is supported starting from this fork."""
1301-
return super(CancunEIP7692, cls).evm_code_types( # noqa: SC200
1302-
block_number,
1303-
timestamp,
1304-
) + [EVMCodeType.EOF_V1]
1305-
1306-
@classmethod
1307-
def call_opcodes(
1308-
cls, block_number: int = 0, timestamp: int = 0
1309-
) -> List[Tuple[Opcodes, EVMCodeType]]:
1310-
"""EOF V1 introduces EXTCALL, EXTSTATICCALL, EXTDELEGATECALL."""
1311-
return [
1312-
(Opcodes.EXTCALL, EVMCodeType.EOF_V1),
1313-
(Opcodes.EXTSTATICCALL, EVMCodeType.EOF_V1),
1314-
(Opcodes.EXTDELEGATECALL, EVMCodeType.EOF_V1),
1315-
] + super(
1316-
CancunEIP7692,
1317-
cls, # noqa: SC200
1318-
).call_opcodes(block_number, timestamp)
1319-
1320-
@classmethod
1321-
def create_opcodes(
1322-
cls, block_number: int = 0, timestamp: int = 0
1323-
) -> List[Tuple[Opcodes, EVMCodeType]]:
1324-
"""EOF V1 introduces `EOFCREATE`."""
1325-
return [(Opcodes.EOFCREATE, EVMCodeType.EOF_V1)] + super(
1326-
CancunEIP7692,
1327-
cls, # noqa: SC200
1328-
).create_opcodes(block_number, timestamp)
1329-
1330-
@classmethod
1331-
def is_deployed(cls) -> bool:
1332-
"""
1333-
Flag that the fork has not been deployed to mainnet; it is under active
1334-
development.
1335-
"""
1336-
return False
1337-
1338-
@classmethod
1339-
def solc_min_version(cls) -> Version:
1340-
"""Return minimum version of solc that supports this fork."""
1341-
return Version.parse("1.0.0") # set a high version; currently unknown
1342-
1343-
13441284
class Osaka(Prague, solc_name="cancun"):
13451285
"""Osaka fork."""
13461286

src/ethereum_test_forks/tests/test_forks.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@ def test_tx_intrinsic_gas_functions(fork: Fork, calldata: bytes, create_tx: bool
320320
)
321321

322322

323+
class FutureFork(Prague):
324+
"""
325+
Dummy fork used for testing.
326+
327+
Contains no changes to the blob parameters from the parent fork in order to confirm that
328+
it's added to the blob schedule even if it doesn't have any changes.
329+
"""
330+
331+
pass
332+
333+
323334
@pytest.mark.parametrize(
324335
"fork,expected_schedule",
325336
[
@@ -367,6 +378,27 @@ def test_tx_intrinsic_gas_functions(fork: Fork, calldata: bytes, create_tx: bool
367378
},
368379
id="CancunToPragueAtTime15k",
369380
),
381+
pytest.param(
382+
FutureFork,
383+
{
384+
"Cancun": {
385+
"target_blobs_per_block": 3,
386+
"max_blobs_per_block": 6,
387+
"baseFeeUpdateFraction": 3338477,
388+
},
389+
"Prague": {
390+
"target_blobs_per_block": 6,
391+
"max_blobs_per_block": 9,
392+
"baseFeeUpdateFraction": 5007716,
393+
},
394+
"FutureFork": {
395+
"target_blobs_per_block": 6,
396+
"max_blobs_per_block": 9,
397+
"baseFeeUpdateFraction": 5007716,
398+
},
399+
},
400+
id="FutureFork",
401+
),
370402
],
371403
)
372404
def test_blob_schedules(fork: Fork, expected_schedule: Dict | None):

src/ethereum_test_specs/static_state/expect_section.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def parse_networks(fork_with_operand: str) -> List[str]:
8686
idx = all_forks_by_name.index(fork)
8787
# ['Frontier', 'Homestead', 'Byzantium', 'Constantinople', 'ConstantinopleFix',
8888
# 'Istanbul', 'MuirGlacier', 'Berlin', 'London', 'ArrowGlacier', 'GrayGlacier',
89-
# 'Paris', 'Shanghai', 'Cancun', 'Prague', 'CancunEIP7692', 'Osaka']
89+
# 'Paris', 'Shanghai', 'Cancun', 'Prague', 'Osaka']
9090
except ValueError:
9191
raise ValueError(f"Unsupported fork: {fork}") from Exception
9292

tests/osaka/eip7692_eof_v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
- [ethpandaops/eof-devnet-0](https://notes.ethereum.org/@ethpandaops/eof-devnet-0).
2020
""" # noqa: E501
2121

22-
EOF_FORK_NAME = "CancunEIP7692,Osaka"
22+
EOF_FORK_NAME = "Osaka"

tests/osaka/eip7692_eof_v1/eof_tracker.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
- [x] Container without code sections ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py::test_section_order`](./eip3540_eof_v1/test_section_order/index.md) `-k 'SectionTest.MISSING-section_kind_CODE'`)
6565
- [x] Container without data section ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_section_order.py::test_section_order`](./eip3540_eof_v1/test_section_order/index.md) `-k 'SectionTest.MISSING-section_kind_DATA'`)
6666
- [x] Valid containers without data section and with subcontainers ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_Osaka-eof_test-single_subcontainer_without_data]`)
67-
- [x] Valid containers with data section and with subcontainers ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_CancunEIP7692-eof_test-single_subcontainer_with_data]`)
68-
- [x] Valid container with maximum number of subcontainers ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_wide_container`](./eip7620_eof_create/test_subcontainer_validation/test_wide_container.md)`[fork_CancunEIP7692-eof_test-256]`)
69-
- [x] Container with number of subcontainers above the limit ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_wide_container`](./eip7620_eof_create/test_subcontainer_validation/test_wide_container.md)`[fork_CancunEIP7692-eof_test-257]`)
67+
- [x] Valid containers with data section and with subcontainers ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_Osaka-eof_test-single_subcontainer_with_data]`)
68+
- [x] Valid container with maximum number of subcontainers ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_wide_container`](./eip7620_eof_create/test_subcontainer_validation/test_wide_container.md)`[fork_Osaka-eof_test-256]`)
69+
- [x] Container with number of subcontainers above the limit ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_wide_container`](./eip7620_eof_create/test_subcontainer_validation/test_wide_container.md)`[fork_Osaka-eof_test-257]`)
7070
- [x] Subcontainer section header truncated before subcontainer number ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k no_container_section_count`)
7171
- [x] Subcontainer section header truncated before subcontainer size ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k incomplete_container_section_count`)
7272
- [x] Truncated subcontainer size ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k no_container_section_size`, [`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k incomplete_container_section_size`)
@@ -76,7 +76,7 @@
7676
- [x] Multiple container section headers ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k multiple_container_headers`)
7777
- [x] Invalid subcontainer ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py`](./eip7620_eof_create/test_subcontainer_validation/index.md)`-k invalid`)
7878
- [x] Invalid subcontainer on a deep nesting level ([`tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py::test_deep_container`](./eip7620_eof_create/test_subcontainer_validation/test_deep_container.md))
79-
- [x] Max number of inputs/outputs in a section ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_CancunEIP7692-eof_test-code_section_input_maximum]`, [`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_CancunEIP7692-eof_test-code_section_output_maximum]`)
79+
- [x] Max number of inputs/outputs in a section ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_Osaka-eof_test-code_section_input_maximum]`, [`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers`](./eip3540_eof_v1/test_container_validation/test_valid_containers.md)`[fork_Osaka-eof_test-code_section_output_maximum]`)
8080
- [x] Number of inputs/outputs in a section above the limit ([`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k code_section_input_too_large`, [`tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py`](./eip3540_eof_v1/test_container_validation/index.md)`-k code_section_output_too_large`)
8181

8282
### Execution

0 commit comments

Comments
 (0)