|
4 | 4 | from hashlib import sha256 |
5 | 5 | from os.path import realpath |
6 | 6 | from pathlib import Path |
7 | | -from typing import List, Mapping, Optional, Sized, Tuple |
| 7 | +from typing import List, Literal, Mapping, Optional, Sized, Tuple |
8 | 8 |
|
9 | 9 | from semver import Version |
10 | 10 |
|
@@ -894,6 +894,27 @@ def valid_opcodes( |
894 | 894 | class Cancun(Shanghai): |
895 | 895 | """Cancun fork.""" |
896 | 896 |
|
| 897 | + BLOB_CONSTANTS = { # every value is an int or a Literal |
| 898 | + "FIELD_ELEMENTS_PER_BLOB": 4096, |
| 899 | + "BYTES_PER_FIELD_ELEMENT": 32, |
| 900 | + "CELL_LENGTH": 2048, |
| 901 | + "BLS_MODULUS": 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001, # EIP-2537: Main subgroup order = q, due to this BLS_MODULUS every blob byte (uint256) must be smaller than 116 # noqa: E501 |
| 902 | + # https://github.com/ethereum/consensus-specs/blob/cc6996c22692d70e41b7a453d925172ee4b719ad/specs/deneb/polynomial-commitments.md?plain=1#L78 |
| 903 | + "BYTES_PER_PROOF": 48, |
| 904 | + "BYTES_PER_COMMITMENT": 48, |
| 905 | + "KZG_ENDIANNESS": "big", |
| 906 | + "AMOUNT_CELL_PROOFS": 0, |
| 907 | + } |
| 908 | + |
| 909 | + @classmethod |
| 910 | + def get_blob_constant(cls, name: str) -> int | Literal["big"]: |
| 911 | + """Return blob constant if it exists.""" |
| 912 | + retrieved_constant = cls.BLOB_CONSTANTS.get(name) |
| 913 | + assert retrieved_constant is not None, ( |
| 914 | + f"You tried to retrieve the blob constant {name} but it does not exist!" |
| 915 | + ) |
| 916 | + return retrieved_constant |
| 917 | + |
897 | 918 | @classmethod |
898 | 919 | def solc_min_version(cls) -> Version: |
899 | 920 | """Return minimum version of solc that supports this fork.""" |
@@ -1077,6 +1098,16 @@ def valid_opcodes( |
1077 | 1098 | class Prague(Cancun): |
1078 | 1099 | """Prague fork.""" |
1079 | 1100 |
|
| 1101 | + # update some blob constants |
| 1102 | + BLOB_CONSTANTS = { |
| 1103 | + **Cancun.BLOB_CONSTANTS, # same base constants as cancun |
| 1104 | + "MAX_BLOBS_PER_BLOCK": 9, # but overwrite or add these |
| 1105 | + "TARGET_BLOBS_PER_BLOCK": 6, |
| 1106 | + "MAX_BLOB_GAS_PER_BLOCK": 1179648, |
| 1107 | + "TARGET_BLOB_GAS_PER_BLOCK": 786432, |
| 1108 | + "BLOB_BASE_FEE_UPDATE_FRACTION": 5007716, |
| 1109 | + } |
| 1110 | + |
1080 | 1111 | @classmethod |
1081 | 1112 | def is_deployed(cls) -> bool: |
1082 | 1113 | """ |
@@ -1328,6 +1359,12 @@ def engine_forkchoice_updated_version( |
1328 | 1359 | class Osaka(Prague, solc_name="cancun"): |
1329 | 1360 | """Osaka fork.""" |
1330 | 1361 |
|
| 1362 | + # update some blob constants |
| 1363 | + BLOB_CONSTANTS = { |
| 1364 | + **Prague.BLOB_CONSTANTS, # same base constants as prague |
| 1365 | + "AMOUNT_CELL_PROOFS": 128, |
| 1366 | + } |
| 1367 | + |
1331 | 1368 | @classmethod |
1332 | 1369 | def engine_get_payload_version( |
1333 | 1370 | cls, block_number: int = 0, timestamp: int = 0 |
|
0 commit comments