From 78cc0a6e9162e7a48d3debd3ca3046b27942c42b Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 30 Aug 2024 12:25:26 -0700 Subject: [PATCH 1/2] Change csc types to uint64 --- specs/_features/eip7594/das-core.md | 10 +++++----- specs/_features/eip7594/p2p-interface.md | 10 +++++----- .../eip7594/networking/test_get_custody_columns.py | 2 +- .../test/eip7594/unittests/test_config_invariants.py | 4 +--- .../eth2spec/test/eip7594/unittests/test_custody.py | 4 ++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index 59011cdcd1..25e58a1334 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -67,7 +67,7 @@ The following values are (non-configurable) constants used throughout the specif | Name | Value | Description | | - | - | - | -| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `uint8(128)` | The number of data column sidecar subnets used in the gossipsub protocol | +| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `uint64(128)` | The number of data column sidecar subnets used in the gossipsub protocol | ### Custody setting @@ -105,7 +105,7 @@ class MatrixEntry(Container): ### `get_custody_columns` ```python -def get_custody_columns(node_id: NodeID, custody_subnet_count: uint8) -> Sequence[ColumnIndex]: +def get_custody_columns(node_id: NodeID, custody_subnet_count: uint64) -> Sequence[ColumnIndex]: assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT subnet_ids: List[uint64] = [] @@ -113,7 +113,7 @@ def get_custody_columns(node_id: NodeID, custody_subnet_count: uint8) -> Sequenc while len(subnet_ids) < custody_subnet_count: subnet_id = ( bytes_to_uint64(hash(uint_to_bytes(uint256(current_id)))[0:8]) - % int(DATA_COLUMN_SIDECAR_SUBNET_COUNT) + % DATA_COLUMN_SIDECAR_SUBNET_COUNT ) if subnet_id not in subnet_ids: subnet_ids.append(subnet_id) @@ -124,9 +124,9 @@ def get_custody_columns(node_id: NodeID, custody_subnet_count: uint8) -> Sequenc assert len(subnet_ids) == len(set(subnet_ids)) - columns_per_subnet = NUMBER_OF_COLUMNS // int(DATA_COLUMN_SIDECAR_SUBNET_COUNT) + columns_per_subnet = NUMBER_OF_COLUMNS // DATA_COLUMN_SIDECAR_SUBNET_COUNT return sorted([ - ColumnIndex(int(DATA_COLUMN_SIDECAR_SUBNET_COUNT) * i + subnet_id) + ColumnIndex(DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnet_id) for i in range(columns_per_subnet) for subnet_id in subnet_ids ]) diff --git a/specs/_features/eip7594/p2p-interface.md b/specs/_features/eip7594/p2p-interface.md index 38797a2fb0..7f68f7ba60 100644 --- a/specs/_features/eip7594/p2p-interface.md +++ b/specs/_features/eip7594/p2p-interface.md @@ -119,14 +119,14 @@ The `MetaData` stored locally by clients is updated with an additional field to seq_number: uint64 attnets: Bitvector[ATTESTATION_SUBNET_COUNT] syncnets: Bitvector[SYNC_COMMITTEE_SUBNET_COUNT] - custody_subnet_count: uint8 # csc + custody_subnet_count: uint64 # csc ) ``` Where - `seq_number`, `attnets`, and `syncnets` have the same meaning defined in the Altair document. -- `csc` represents the node's custody subnet count. Clients MAY reject ENRs with a value less than `CUSTODY_REQUIREMENT`. +- `custody_subnet_count` represents the node's custody subnet count. Clients MAY reject peers with a value less than `CUSTODY_REQUIREMENT`. ### The gossip domain: gossipsub @@ -322,6 +322,6 @@ Requests the MetaData of a peer, using the new `MetaData` definition given above A new field is added to the ENR under the key `csc` to facilitate custody data column discovery. -| Key | Value | -|--------|-------------------------------------| -| `csc` | Custody subnet count, uint8 integer | +| Key | Value | +|--------|------------------------------------------| +| `csc` | Custody subnet count, big endian integer | diff --git a/tests/core/pyspec/eth2spec/test/eip7594/networking/test_get_custody_columns.py b/tests/core/pyspec/eth2spec/test/eip7594/networking/test_get_custody_columns.py index 692b73e49d..b41f19a6ca 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/networking/test_get_custody_columns.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/networking/test_get_custody_columns.py @@ -20,7 +20,7 @@ def _run_get_custody_columns(spec, rng, node_id=None, custody_subnet_count=None) assert len(result) == len(set(result)) assert len(result) == ( - int(custody_subnet_count) * spec.config.NUMBER_OF_COLUMNS // int(spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT) + custody_subnet_count * spec.config.NUMBER_OF_COLUMNS // spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT ) assert all(i < spec.config.NUMBER_OF_COLUMNS for i in result) python_list_result = [int(i) for i in result] diff --git a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_config_invariants.py b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_config_invariants.py index fbbae4e8f8..fc54cc3088 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_config_invariants.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_config_invariants.py @@ -3,7 +3,6 @@ spec_test, with_eip7594_and_later, ) -from eth2spec.utils.ssz.ssz_typing import uint8 @with_eip7594_and_later @@ -13,10 +12,9 @@ def test_invariants(spec): assert spec.FIELD_ELEMENTS_PER_BLOB % spec.FIELD_ELEMENTS_PER_CELL == 0 assert spec.FIELD_ELEMENTS_PER_EXT_BLOB % spec.config.NUMBER_OF_COLUMNS == 0 assert spec.config.SAMPLES_PER_SLOT <= spec.config.NUMBER_OF_COLUMNS - assert spec.config.NUMBER_OF_COLUMNS == uint8(spec.config.NUMBER_OF_COLUMNS) # ENR field is uint8 assert spec.config.CUSTODY_REQUIREMENT <= spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT assert spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT <= spec.config.NUMBER_OF_COLUMNS - assert spec.config.NUMBER_OF_COLUMNS % int(spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT) == 0 + assert spec.config.NUMBER_OF_COLUMNS % spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT == 0 assert spec.config.MAX_REQUEST_DATA_COLUMN_SIDECARS == ( spec.config.MAX_REQUEST_BLOCKS_DENEB * spec.config.NUMBER_OF_COLUMNS ) diff --git a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_custody.py b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_custody.py index 27aee3457a..5db3635a8e 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_custody.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/unittests/test_custody.py @@ -9,9 +9,9 @@ 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)] - columns_per_subnet = spec.config.NUMBER_OF_COLUMNS // int(spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT) + columns_per_subnet = spec.config.NUMBER_OF_COLUMNS // spec.config.DATA_COLUMN_SIDECAR_SUBNET_COUNT for assignment in assignments: - assert len(assignment) == int(custody_subnet_count) * columns_per_subnet + assert len(assignment) == custody_subnet_count * columns_per_subnet assert len(assignment) == len(set(assignment)) From 88a76574b6f6ee3ee63c2e433f67de50d32762e5 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:35:02 -0500 Subject: [PATCH 2/2] Update csc description Co-authored-by: Anton Nashatyrev --- specs/_features/eip7594/p2p-interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/_features/eip7594/p2p-interface.md b/specs/_features/eip7594/p2p-interface.md index 7f68f7ba60..9087a8210c 100644 --- a/specs/_features/eip7594/p2p-interface.md +++ b/specs/_features/eip7594/p2p-interface.md @@ -324,4 +324,4 @@ A new field is added to the ENR under the key `csc` to facilitate custody data c | Key | Value | |--------|------------------------------------------| -| `csc` | Custody subnet count, big endian integer | +| `csc` | Custody subnet count, `uint64` big endian integer with no leading zero bytes (`0` is encoded as empty byte string) |