Fix column computation
This commit is contained in:
parent
65be5b0556
commit
4477cc6952
|
@ -89,13 +89,22 @@ class DataColumnSidecar(Container):
|
||||||
```python
|
```python
|
||||||
def get_custody_columns(node_id: NodeID, custody_subnet_count: uint64) -> Sequence[ColumnIndex]:
|
def get_custody_columns(node_id: NodeID, custody_subnet_count: uint64) -> Sequence[ColumnIndex]:
|
||||||
assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
||||||
subnet_ids = [
|
|
||||||
bytes_to_uint64(hash(uint_to_bytes(uint64(node_id + i)))[0:8]) % DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
subnet_ids = []
|
||||||
for i in range(custody_subnet_count)
|
i = 0
|
||||||
]
|
while len(subnet_ids) < custody_subnet_count:
|
||||||
|
subnet_id = (
|
||||||
|
bytes_to_uint64(hash(uint_to_bytes(uint64(node_id + i)))[0:8])
|
||||||
|
% DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
||||||
|
)
|
||||||
|
if subnet_id not in subnet_ids:
|
||||||
|
subnet_ids.append(subnet_id)
|
||||||
|
i += 1
|
||||||
|
assert len(subnet_ids) == len(set(subnet_ids))
|
||||||
|
|
||||||
columns_per_subnet = NUMBER_OF_COLUMNS // DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
columns_per_subnet = NUMBER_OF_COLUMNS // DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
||||||
return [
|
return [
|
||||||
ColumnIndex(subnet_id + (i * columns_per_subnet))
|
ColumnIndex(DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnet_id)
|
||||||
for i in range(columns_per_subnet)
|
for i in range(columns_per_subnet)
|
||||||
for subnet_id in subnet_ids
|
for subnet_id in subnet_ids
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,9 +9,12 @@ from eth2spec.test.context import (
|
||||||
def run_get_custody_columns(spec, peer_count, custody_subnet_count):
|
def run_get_custody_columns(spec, peer_count, custody_subnet_count):
|
||||||
assignments = [spec.get_custody_columns(node_id, custody_subnet_count) for node_id in range(peer_count)]
|
assignments = [spec.get_custody_columns(node_id, custody_subnet_count) for node_id in range(peer_count)]
|
||||||
|
|
||||||
subnet_per_column = spec.NUMBER_OF_COLUMNS // spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
columns_per_subnet = spec.NUMBER_OF_COLUMNS // spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT
|
||||||
for assignment in assignments:
|
for assignment in assignments:
|
||||||
assert len(assignment) == custody_subnet_count * subnet_per_column
|
assert len(assignment) == custody_subnet_count * columns_per_subnet
|
||||||
|
print('assignment', assignment)
|
||||||
|
print('set(assignment)', set(assignment))
|
||||||
|
assert len(assignment) == len(set(assignment))
|
||||||
|
|
||||||
|
|
||||||
@with_eip7594_and_later
|
@with_eip7594_and_later
|
||||||
|
|
Loading…
Reference in New Issue