Merge pull request #3887 from jtraglia/no-extended-matrix

Remove matrix specific configuration value
This commit is contained in:
Hsiao-Wei Wang 2024-08-20 23:52:20 +08:00 committed by GitHub
commit d7abcdfb58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 30 deletions

View File

@ -161,7 +161,6 @@ WHISK_PROPOSER_SELECTION_GAP: 2
# EIP7594
NUMBER_OF_COLUMNS: 128
MAX_CELLS_IN_EXTENDED_MATRIX: 768
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
SAMPLES_PER_SLOT: 8

View File

@ -160,7 +160,6 @@ WHISK_PROPOSER_SELECTION_GAP: 1
# EIP7594
NUMBER_OF_COLUMNS: 128
MAX_CELLS_IN_EXTENDED_MATRIX: 768
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
SAMPLES_PER_SLOT: 8

View File

@ -27,7 +27,6 @@ def retrieve_column_sidecars(beacon_block_root: Root) -> Sequence[DataColumnSide
'FIELD_ELEMENTS_PER_CELL': spec_object.preset_vars['FIELD_ELEMENTS_PER_CELL'].value,
'FIELD_ELEMENTS_PER_EXT_BLOB': spec_object.preset_vars['FIELD_ELEMENTS_PER_EXT_BLOB'].value,
'NUMBER_OF_COLUMNS': spec_object.config_vars['NUMBER_OF_COLUMNS'].value,
'MAX_CELLS_IN_EXTENDED_MATRIX': spec_object.config_vars['MAX_CELLS_IN_EXTENDED_MATRIX'].value,
}
@classmethod

View File

@ -20,7 +20,7 @@
- [`MatrixEntry`](#matrixentry)
- [Helper functions](#helper-functions)
- [`get_custody_columns`](#get_custody_columns)
- [`compute_extended_matrix`](#compute_extended_matrix)
- [`compute_matrix`](#compute_matrix)
- [`recover_matrix`](#recover_matrix)
- [`get_data_column_sidecars`](#get_data_column_sidecars)
- [Custody](#custody)
@ -62,7 +62,6 @@ The following values are (non-configurable) constants used throughout the specif
| Name | Value | Description |
| - | - | - |
| `NUMBER_OF_COLUMNS` | `uint64(CELLS_PER_EXT_BLOB)` (= 128) | Number of columns in the extended data matrix |
| `MAX_CELLS_IN_EXTENDED_MATRIX` | `uint64(MAX_BLOBS_PER_BLOCK * NUMBER_OF_COLUMNS)` (= 768) | The data size of `ExtendedMatrix` |
### Networking
@ -133,54 +132,52 @@ def get_custody_columns(node_id: NodeID, custody_subnet_count: uint64) -> Sequen
])
```
### `compute_extended_matrix`
### `compute_matrix`
```python
def compute_extended_matrix(blobs: Sequence[Blob]) -> List[MatrixEntry, MAX_CELLS_IN_EXTENDED_MATRIX]:
def compute_matrix(blobs: Sequence[Blob]) -> Sequence[MatrixEntry]:
"""
Return the full ``ExtendedMatrix``.
Return the full, flattened sequence of matrix entries.
This helper demonstrates the relationship between blobs and ``ExtendedMatrix``.
The data structure for storing cells is implementation-dependent.
This helper demonstrates the relationship between blobs and the matrix of cells/proofs.
The data structure for storing cells/proofs is implementation-dependent.
"""
extended_matrix = []
matrix = []
for blob_index, blob in enumerate(blobs):
cells, proofs = compute_cells_and_kzg_proofs(blob)
for cell_index, (cell, proof) in enumerate(zip(cells, proofs)):
extended_matrix.append(MatrixEntry(
matrix.append(MatrixEntry(
cell=cell,
kzg_proof=proof,
row_index=blob_index,
column_index=cell_index,
))
return extended_matrix
return matrix
```
### `recover_matrix`
```python
def recover_matrix(partial_matrix: Sequence[MatrixEntry],
blob_count: uint64) -> List[MatrixEntry, MAX_CELLS_IN_EXTENDED_MATRIX]:
def recover_matrix(partial_matrix: Sequence[MatrixEntry], blob_count: uint64) -> Sequence[MatrixEntry]:
"""
Return the recovered extended matrix.
Recover the full, flattened sequence of matrix entries.
This helper demonstrates how to apply ``recover_cells_and_kzg_proofs``.
The data structure for storing cells is implementation-dependent.
The data structure for storing cells/proofs is implementation-dependent.
"""
extended_matrix = []
matrix = []
for blob_index in range(blob_count):
cell_indices = [e.column_index for e in partial_matrix if e.row_index == blob_index]
cells = [e.cell for e in partial_matrix if e.row_index == blob_index]
recovered_cells, recovered_proofs = recover_cells_and_kzg_proofs(cell_indices, cells)
for cell_index, (cell, proof) in enumerate(zip(recovered_cells, recovered_proofs)):
extended_matrix.append(MatrixEntry(
matrix.append(MatrixEntry(
cell=cell,
kzg_proof=proof,
row_index=blob_index,
column_index=cell_index,
))
return extended_matrix
return matrix
```
### `get_data_column_sidecars`
@ -241,7 +238,7 @@ At each slot, a node advertising `custody_subnet_count` downloads a minimum of `
## Extended data
In this construction, we extend the blobs using a one-dimensional erasure coding extension. The matrix comprises maximum `MAX_BLOBS_PER_BLOCK` rows and fixed `NUMBER_OF_COLUMNS` columns, with each row containing a `Blob` and its corresponding extension. `compute_extended_matrix` demonstrates the relationship between blobs and custom type `ExtendedMatrix`.
In this construction, we extend the blobs using a one-dimensional erasure coding extension. The matrix comprises maximum `MAX_BLOBS_PER_BLOCK` rows and fixed `NUMBER_OF_COLUMNS` columns, with each row containing a `Blob` and its corresponding extension. `compute_matrix` demonstrates the relationship between blobs and the matrix, a potential method of storing cells/proofs.
## Column gossip

View File

@ -19,15 +19,15 @@ def chunks(lst, n):
@with_eip7594_and_later
@spec_test
@single_phase
def test_compute_extended_matrix(spec):
def test_compute_matrix(spec):
rng = random.Random(5566)
blob_count = 2
input_blobs = [get_sample_blob(spec, rng=rng) for _ in range(blob_count)]
extended_matrix = spec.compute_extended_matrix(input_blobs)
assert len(extended_matrix) == spec.CELLS_PER_EXT_BLOB * blob_count
matrix = spec.compute_matrix(input_blobs)
assert len(matrix) == spec.CELLS_PER_EXT_BLOB * blob_count
rows = chunks(extended_matrix, spec.CELLS_PER_EXT_BLOB)
rows = chunks(matrix, spec.CELLS_PER_EXT_BLOB)
assert len(rows) == blob_count
for row in rows:
assert len(row) == spec.CELLS_PER_EXT_BLOB
@ -53,11 +53,11 @@ def test_recover_matrix(spec):
# Compute an extended matrix with two blobs
blob_count = 2
blobs = [get_sample_blob(spec, rng=rng) for _ in range(blob_count)]
extended_matrix = spec.compute_extended_matrix(blobs)
matrix = spec.compute_matrix(blobs)
# Construct a matrix with some entries missing
partial_matrix = []
for blob_entries in chunks(extended_matrix, spec.CELLS_PER_EXT_BLOB):
for blob_entries in chunks(matrix, spec.CELLS_PER_EXT_BLOB):
rng.shuffle(blob_entries)
partial_matrix.extend(blob_entries[:N_SAMPLES])
@ -65,7 +65,7 @@ def test_recover_matrix(spec):
recovered_matrix = spec.recover_matrix(partial_matrix, blob_count)
# Ensure that the recovered matrix matches the original matrix
assert recovered_matrix == extended_matrix
assert recovered_matrix == matrix
@with_eip7594_and_later

View File

@ -18,7 +18,6 @@ def test_invariants(spec):
assert spec.config.MAX_REQUEST_DATA_COLUMN_SIDECARS == (
spec.config.MAX_REQUEST_BLOCKS_DENEB * spec.config.NUMBER_OF_COLUMNS
)
assert spec.config.MAX_CELLS_IN_EXTENDED_MATRIX == spec.config.MAX_BLOBS_PER_BLOCK * spec.config.NUMBER_OF_COLUMNS
@with_eip7594_and_later