Added columns property to chunks matrix

Added test for columns
This commit is contained in:
Daniel Sanchez Quiros 2024-03-05 12:16:28 +01:00
parent a2e9382b49
commit 5d3182eace
4 changed files with 16 additions and 4 deletions

View File

@ -20,9 +20,9 @@ class Row(List[Chunk]):
class ChunksMatrix(List[Row]): class ChunksMatrix(List[Row]):
@property
def columns(self) -> Generator[List[Chunk], None, None]: def columns(self) -> Generator[List[Chunk], None, None]:
# TODO: yield columns yield from map(list, zip(*self))
yield None

View File

@ -13,7 +13,7 @@ class Dispersal:
def _prepare_data(self, encoded_data: EncodedData) -> Generator[DABlob, None, None]: def _prepare_data(self, encoded_data: EncodedData) -> Generator[DABlob, None, None]:
assert len(encoded_data.row_commitments) == len(self.nodes) assert len(encoded_data.row_commitments) == len(self.nodes)
assert len(encoded_data.row_proofs) == len(self.nodes) assert len(encoded_data.row_proofs) == len(self.nodes)
columns = encoded_data.extended_matrix.columns() columns = encoded_data.extended_matrix.columns
column_commitments = encoded_data.column_commitments column_commitments = encoded_data.column_commitments
row_commitments = encoded_data.row_commitments row_commitments = encoded_data.row_commitments
rows_proofs = encoded_data.row_proofs rows_proofs = encoded_data.row_proofs

View File

@ -3,7 +3,7 @@ from typing import List
from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof
from da.common import ChunksMatrix from da.common import ChunksMatrix
from da.kzg_rs import kzg, rs, poly
@dataclass @dataclass
class DAEncoderParams: class DAEncoderParams:

12
da/test_common.py Normal file
View File

@ -0,0 +1,12 @@
from unittest import TestCase
from da.common import ChunksMatrix
class TestCommon(TestCase):
def test_chunks_matrix_columns(self):
matrix = ChunksMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
expected = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
for c1, c2 in zip(expected, matrix.columns):
self.assertEqual(c1, c2)