2024-02-12 14:35:23 +00:00
|
|
|
from dataclasses import dataclass
|
2024-03-06 15:02:48 +00:00
|
|
|
from itertools import chain
|
2024-03-06 15:56:23 +00:00
|
|
|
from typing import List, Generator, Self
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
from eth2spec.eip7594.mainnet import Bytes32
|
|
|
|
|
|
|
|
|
|
|
|
class NodeId(Bytes32):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Chunk(Bytes32):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2024-03-05 18:02:19 +00:00
|
|
|
class Column(List[Bytes32]):
|
2024-03-06 16:53:27 +00:00
|
|
|
def as_bytes(self) -> bytes:
|
|
|
|
return bytes(chain.from_iterable(self))
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
2024-03-05 18:02:19 +00:00
|
|
|
class Row(List[Bytes32]):
|
2024-03-06 15:02:48 +00:00
|
|
|
def as_bytes(self) -> bytes:
|
|
|
|
return bytes(chain.from_iterable(self))
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
2024-03-06 16:53:27 +00:00
|
|
|
class ChunksMatrix(List[Row | Column]):
|
2024-03-05 11:16:28 +00:00
|
|
|
@property
|
2024-02-12 14:35:23 +00:00
|
|
|
def columns(self) -> Generator[List[Chunk], None, None]:
|
2024-03-06 16:53:27 +00:00
|
|
|
yield from map(Column, zip(*self))
|
2024-03-06 15:56:23 +00:00
|
|
|
|
|
|
|
def transposed(self) -> Self:
|
|
|
|
return ChunksMatrix(self.columns)
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Attestation:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Certificate:
|
|
|
|
pass
|
|
|
|
|