Skip to content

Commit f83a2c9

Browse files
committed
Migrating to latest crypto APIs
1 parent 9a4496d commit f83a2c9

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

pysetup/helpers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ def dependency_order_class_objects(objects: Dict[str, str], custom_types: Dict[s
203203
for item in [dep, key] + key_list[key_list.index(dep)+1:]:
204204
objects[item] = objects.pop(item)
205205

206-
207-
def combine_ssz_objects(old_objects: Dict[str, str], new_objects: Dict[str, str], custom_types) -> Dict[str, str]:
206+
def combine_ssz_objects(old_objects: Dict[str, str], new_objects: Dict[str, str]) -> Dict[str, str]:
208207
"""
209208
Takes in old spec and new spec ssz objects, combines them,
210209
and returns the newer versions of the objects in dependency order.
@@ -226,7 +225,7 @@ def combine_spec_objects(spec0: SpecObject, spec1: SpecObject) -> SpecObject:
226225
config_vars = combine_dicts(spec0.config_vars, spec1.config_vars)
227226
ssz_dep_constants = combine_dicts(spec0.ssz_dep_constants, spec1.ssz_dep_constants)
228227
func_dep_presets = combine_dicts(spec0.func_dep_presets, spec1.func_dep_presets)
229-
ssz_objects = combine_ssz_objects(spec0.ssz_objects, spec1.ssz_objects, custom_types)
228+
ssz_objects = combine_ssz_objects(spec0.ssz_objects, spec1.ssz_objects)
230229
dataclasses = combine_dicts(spec0.dataclasses, spec1.dataclasses)
231230
return SpecObject(
232231
functions=functions,

pysetup/md_doc_paths.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
BELLATRIX: "sync/optimistic.md"
3636
}
3737

38+
DEFAULT_ORDER = (
39+
"beacon-chain",
40+
"polynomial-commitments",
41+
)
42+
3843

3944
def is_post_fork(a, b) -> bool:
4045
"""
@@ -62,15 +67,25 @@ def get_fork_directory(fork):
6267
raise FileNotFoundError(f"No directory found for fork: {fork}")
6368

6469

70+
def sort_key(s):
71+
for index, key in enumerate(DEFAULT_ORDER):
72+
if key in s:
73+
return (index, s)
74+
return (len(DEFAULT_ORDER), s)
75+
76+
6577
def get_md_doc_paths(spec_fork: str) -> str:
6678
md_doc_paths = ""
6779

6880
for fork in ALL_FORKS:
6981
if is_post_fork(spec_fork, fork):
7082
# Append all files in fork directory recursively
71-
for root, dirs, files in os.walk(get_fork_directory(fork)):
83+
for root, _, files in os.walk(get_fork_directory(fork)):
84+
filepaths = []
7285
for filename in files:
7386
filepath = os.path.join(root, filename)
87+
filepaths.append(filepath)
88+
for filepath in sorted(filepaths, key=sort_key):
7489
if filepath.endswith('.md') and filepath not in IGNORE_SPEC_FILES:
7590
md_doc_paths += filepath + "\n"
7691
# Append extra files if any

pysetup/spec_builders/eip7594.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> str:
1818
return {
1919
'FIELD_ELEMENTS_PER_CELL': spec_object.preset_vars['FIELD_ELEMENTS_PER_CELL'].value,
2020
'NUMBER_OF_COLUMNS': spec_object.preset_vars['NUMBER_OF_COLUMNS'].value,
21-
'FIELD_ELEMENTS_PER_CELL': spec_object.preset_vars['FIELD_ELEMENTS_PER_CELL'].value,
2221
}
2322

2423
@classmethod

specs/_features/eip7594/das-core.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
- [`get_custody_lines`](#get_custody_lines)
1717
- [`compute_extended_data`](#compute_extended_data)
1818
- [`compute_extended_matrix`](#compute_extended_matrix)
19-
- [`compute_samples_and_proofs`](#compute_samples_and_proofs)
2019
- [`get_data_column_sidecars`](#get_data_column_sidecars)
2120
- [Custody](#custody)
2221
- [Custody requirement](#custody-requirement)
@@ -43,9 +42,8 @@ We define the following Python custom types for type hinting and readability:
4342

4443
| Name | SSZ equivalent | Description |
4544
| - | - | - |
46-
| `DataCell` | `Vector[BLSFieldElement, FIELD_ELEMENTS_PER_CELL]` | The data unit of a cell in the extended data matrix |
47-
| `DataColumn` | `List[DataCell, MAX_BLOBS_PER_BLOCK]` | The data of each column in EIP7594 |
48-
| `ExtendedMatrix` | `List[DataCell, MAX_BLOBS_PER_BLOCK * NUMBER_OF_COLUMNS]` | The full data with blobs and one-dimensional erasure coding extension |
45+
| `DataColumn` | `List[Cell, MAX_BLOBS_PER_BLOCK]` | The data of each column in EIP7594 |
46+
| `ExtendedMatrix` | `List[Cell, MAX_BLOBS_PER_BLOCK * NUMBER_OF_COLUMNS]` | The full data with blobs and one-dimensional erasure coding extension |
4947
| `FlatExtendedMatrix` | `List[BLSFieldElement, MAX_BLOBS_PER_BLOCK * FIELD_ELEMENTS_PER_BLOB * NUMBER_OF_COLUMNS]` | The flattened format of `ExtendedMatrix` |
5048
| `LineIndex` | `uint64` | The index of the rows or columns in `FlatExtendedMatrix` matrix |
5149

@@ -55,7 +53,6 @@ We define the following Python custom types for type hinting and readability:
5553

5654
| Name | Value | Description |
5755
| - | - | - |
58-
| `FIELD_ELEMENTS_PER_CELL` | `uint64(2**6)` (= 64) | Elements per `DataCell` |
5956
| `NUMBER_OF_COLUMNS` | `uint64((FIELD_ELEMENTS_PER_BLOB * 2) // FIELD_ELEMENTS_PER_CELL)` (= 128) | Number of columns in the extended data matrix. |
6057

6158
### Custody setting
@@ -95,19 +92,6 @@ def compute_extended_matrix(blobs: Sequence[Blob]) -> FlatExtendedMatrix:
9592
return FlatExtendedMatrix(matrix)
9693
```
9794

98-
#### `compute_samples_and_proofs`
99-
100-
```python
101-
def compute_samples_and_proofs(blob: Blob) -> Tuple[
102-
Vector[DataCell, NUMBER_OF_COLUMNS],
103-
Vector[KZGProof, NUMBER_OF_COLUMNS]]:
104-
"""
105-
Defined in polynomial-commitments-sampling.md
106-
"""
107-
# pylint: disable=unused-argument
108-
...
109-
```
110-
11195
#### `get_data_column_sidecars`
11296

11397
```python
@@ -119,7 +103,7 @@ def get_data_column_sidecars(signed_block: SignedBeaconBlock,
119103
block.body,
120104
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'),
121105
)
122-
cells_and_proofs = [compute_samples_and_proofs(blob) for blob in blobs]
106+
cells_and_proofs = [compute_cells_and_proofs(blob) for blob in blobs]
123107
blob_count = len(blobs)
124108
cells = [cells_and_proofs[i][0] for i in range(blob_count)]
125109
proofs = [cells_and_proofs[i][1] for i in range(blob_count)]

0 commit comments

Comments
 (0)