Skip to content

Commit

Permalink
Merge pull request #3887 from jtraglia/no-extended-matrix
Browse files Browse the repository at this point in the history
Remove matrix specific configuration value
  • Loading branch information
hwwhww committed Aug 20, 2024
2 parents 5c44de2 + 121a3b7 commit d7abcdf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
1 change: 0 additions & 1 deletion configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pysetup/spec_builders/eip7594.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> str:
'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
Expand Down
35 changes: 16 additions & 19 deletions specs/_features/eip7594/das-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,19 +53,19 @@ 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])

# Given the partial matrix, recover the missing entries
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7abcdf

Please sign in to comment.