Skip to content

Commit 0a55700

Browse files
committed
added helper methods
1 parent ea1b812 commit 0a55700

File tree

11 files changed

+153
-96
lines changed

11 files changed

+153
-96
lines changed

configs/mainnet.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ SUBNETS_PER_NODE: 2
180180
ATTESTATION_SUBNET_COUNT: 64
181181
# 0 bits
182182
ATTESTATION_SUBNET_EXTRA_BITS: 0
183-
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS (= 6 + 0) bits
184-
ATTESTATION_SUBNET_PREFIX_BITS: 6
185183

186184
# Deneb
187185
# 2**7 (= 128) blocks
@@ -192,24 +190,18 @@ MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
192190
BLOB_SIDECAR_SUBNET_COUNT: 6
193191
# 6 blobs
194192
MAX_BLOBS_PER_BLOCK: 6
195-
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK (= 128 * 6) sidecars
196-
MAX_REQUEST_BLOB_SIDECARS: 768
197193

198194
# Electra
199195
# 9 subnets
200196
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9
201197
# 9 blobs
202198
MAX_BLOBS_PER_BLOCK_ELECTRA: 9
203-
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA (= 128 * 9) sidecars
204-
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152
205199

206200
# Fulu
207201
# 2**7 (= 128) groups
208202
NUMBER_OF_CUSTODY_GROUPS: 128
209203
# 2**7 (= 128) subnets
210204
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
211-
# MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS (= 128 * 128) sidecars
212-
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
213205
# 2**3 (= 8) samples
214206
SAMPLES_PER_SLOT: 8
215207
# 2**2 (= 4) sidecars

configs/minimal.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ SUBNETS_PER_NODE: 2
177177
ATTESTATION_SUBNET_COUNT: 64
178178
# 0 bits
179179
ATTESTATION_SUBNET_EXTRA_BITS: 0
180-
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS (= 6 + 0) bits
181-
ATTESTATION_SUBNET_PREFIX_BITS: 6
182180

183181
# Deneb
184182
# 2**7 (= 128) blocks
@@ -189,24 +187,18 @@ MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
189187
BLOB_SIDECAR_SUBNET_COUNT: 6
190188
# 6 blobs
191189
MAX_BLOBS_PER_BLOCK: 6
192-
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK (= 128 * 6) sidecars
193-
MAX_REQUEST_BLOB_SIDECARS: 768
194190

195191
# Electra
196192
# 9 subnets
197193
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9
198194
# 9 blobs
199195
MAX_BLOBS_PER_BLOCK_ELECTRA: 9
200-
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA (= 128 * 9) sidecars
201-
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152
202196

203197
# Fulu
204198
# 2**7 (= 128) groups
205199
NUMBER_OF_CUSTODY_GROUPS: 128
206200
# 2**7 (= 128) subnets
207201
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
208-
# MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS (= 128 * 128) sidecars
209-
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
210202
# 2**3 (= 8) samples
211203
SAMPLES_PER_SLOT: 8
212204
# 2**2 (= 4) sidecars

pysetup/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def finalized_spec_object(spec_object: SpecObject) -> SpecObject:
395395
custom_types = {}
396396
ssz_objects = spec_object.ssz_objects
397397
for name, value in spec_object.custom_types.items():
398-
if any(k in name for k in all_config_dependencies):
398+
if any(name in k for k in all_config_dependencies):
399399
custom_types[name] = value
400400
else:
401401
ssz_objects[name] = gen_new_type_definition(name, value)

specs/deneb/p2p-interface.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
- [Introduction](#introduction)
66
- [Modifications in Deneb](#modifications-in-deneb)
7+
- [Helper functions](#helper-functions)
8+
- [Modified `compute_fork_version`](#modified-compute_fork_version)
9+
- [New `compute_max_request_blob_sidecars`](#new-compute_max_request_blob_sidecars)
710
- [Preset](#preset)
811
- [Configuration](#configuration)
912
- [Containers](#containers)
@@ -43,6 +46,36 @@ specifications of previous upgrades, and assumes them as pre-requisite.
4346

4447
## Modifications in Deneb
4548

49+
### Helper functions
50+
51+
#### Modified `compute_fork_version`
52+
53+
```python
54+
def compute_fork_version(epoch: Epoch) -> Version:
55+
"""
56+
Return the fork version at the given ``epoch``.
57+
"""
58+
if epoch >= DENEB_FORK_EPOCH:
59+
return DENEB_FORK_VERSION
60+
if epoch >= CAPELLA_FORK_EPOCH:
61+
return CAPELLA_FORK_VERSION
62+
if epoch >= BELLATRIX_FORK_EPOCH:
63+
return BELLATRIX_FORK_VERSION
64+
if epoch >= ALTAIR_FORK_EPOCH:
65+
return ALTAIR_FORK_VERSION
66+
return GENESIS_FORK_VERSION
67+
```
68+
69+
#### New `compute_max_request_blob_sidecars`
70+
71+
```python
72+
def compute_max_request_blob_sidecars() -> uint64:
73+
"""
74+
Return the maximum number of blob sidecars in a single request.
75+
"""
76+
return uint64(MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK)
77+
```
78+
4679
### Preset
4780

4881
*[New in Deneb:EIP4844]*
@@ -55,12 +88,11 @@ specifications of previous upgrades, and assumes them as pre-requisite.
5588

5689
*[New in Deneb:EIP4844]*
5790

58-
| Name | Value | Description |
59-
| --------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------ |
60-
| `MAX_REQUEST_BLOCKS_DENEB` | `2**7` (= 128) | Maximum number of blocks in a single request |
61-
| `MAX_REQUEST_BLOB_SIDECARS` | `MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK` | Maximum number of blob sidecars in a single request |
62-
| `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve blob sidecars |
63-
| `BLOB_SIDECAR_SUBNET_COUNT` | `6` | The number of blob sidecar subnets used in the gossipsub protocol. |
91+
| Name | Value | Description |
92+
| --------------------------------------- | --------------------------------- | ------------------------------------------------------------------ |
93+
| `MAX_REQUEST_BLOCKS_DENEB` | `2**7` (= 128) | Maximum number of blocks in a single request |
94+
| `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve blob sidecars |
95+
| `BLOB_SIDECAR_SUBNET_COUNT` | `6` | The number of blob sidecar subnets used in the gossipsub protocol. |
6496

6597
### Containers
6698

@@ -365,7 +397,7 @@ Response Content:
365397

366398
```
367399
(
368-
List[BlobSidecar, MAX_REQUEST_BLOB_SIDECARS]
400+
List[BlobSidecar, compute_max_request_blob_sidecars()]
369401
)
370402
```
371403

@@ -406,7 +438,7 @@ and/or temporarily ban such an un-synced or semi-synced client.
406438

407439
Clients MUST respond with at least the blob sidecars of the first blob-carrying
408440
block that exists in the range, if they have it, and no more than
409-
`MAX_REQUEST_BLOB_SIDECARS` sidecars.
441+
`compute_max_request_blob_sidecars()` sidecars.
410442

411443
Clients MUST include all blob sidecars of each block from which they include
412444
blob sidecars.
@@ -456,15 +488,15 @@ Request Content:
456488

457489
```
458490
(
459-
List[BlobIdentifier, MAX_REQUEST_BLOB_SIDECARS]
491+
List[BlobIdentifier, compute_max_request_blob_sidecars()]
460492
)
461493
```
462494

463495
Response Content:
464496

465497
```
466498
(
467-
List[BlobSidecar, MAX_REQUEST_BLOB_SIDECARS]
499+
List[BlobSidecar, compute_max_request_blob_sidecars()]
468500
)
469501
```
470502

@@ -476,7 +508,7 @@ Before consuming the next response chunk, the response reader SHOULD verify the
476508
blob sidecar is well-formatted, has valid inclusion proof, and is correct w.r.t.
477509
the expected KZG commitments through `verify_blob_kzg_proof`.
478510

479-
No more than `MAX_REQUEST_BLOB_SIDECARS` may be requested at a time.
511+
No more than `compute_max_request_blob_sidecars()` may be requested at a time.
480512

481513
`BlobSidecarsByRoot` is primarily used to recover recent blobs (e.g. when
482514
receiving a block with a transaction whose corresponding blob is missing).

specs/electra/p2p-interface.md

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Configuration](#configuration)
88
- [Helpers](#helpers)
99
- [Modified `compute_fork_version`](#modified-compute_fork_version)
10+
- [Modified `compute_max_request_blob_sidecars`](#modified-compute_max_request_blob_sidecars)
1011
- [The gossip domain: gossipsub](#the-gossip-domain-gossipsub)
1112
- [Topics and messages](#topics-and-messages)
1213
- [Global topics](#global-topics)
@@ -64,6 +65,17 @@ def compute_fork_version(epoch: Epoch) -> Version:
6465
return GENESIS_FORK_VERSION
6566
```
6667

68+
#### Modified `compute_max_request_blob_sidecars`
69+
70+
```python
71+
def compute_max_request_blob_sidecars() -> uint64:
72+
"""
73+
Return the maximum number of blob sidecars in a single request.
74+
"""
75+
# [Modified in Electra:EIP7691]
76+
return uint64(MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA)
77+
```
78+
6779
### The gossip domain: gossipsub
6880

6981
Some gossip meshes are upgraded in the fork of Electra to support upgraded
@@ -187,51 +199,14 @@ beacon block type.
187199

188200
*[Modified in Electra:EIP7691]*
189201

190-
Request Content:
191-
192-
```
193-
(
194-
start_slot: Slot
195-
count: uint64
196-
)
197-
```
198-
199-
Response Content:
200-
201-
```
202-
(
203-
List[BlobSidecar, MAX_REQUEST_BLOB_SIDECARS_ELECTRA]
204-
)
205-
```
206-
207-
*Updated validation*
208-
209-
Clients MUST respond with at least the blob sidecars of the first blob-carrying
210-
block that exists in the range, if they have it, and no more than
211-
`MAX_REQUEST_BLOB_SIDECARS_ELECTRA` sidecars.
202+
*Note*: The `compute_max_request_blob_sidecars` function has been modified which
203+
affects the request, response, and validation logic.
212204

213205
##### BlobSidecarsByRoot v1
214206

215207
**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_root/1/`
216208

217209
*[Modified in Electra:EIP7691]*
218210

219-
Request Content:
220-
221-
```
222-
(
223-
List[BlobIdentifier, MAX_REQUEST_BLOB_SIDECARS_ELECTRA]
224-
)
225-
```
226-
227-
Response Content:
228-
229-
```
230-
(
231-
List[BlobSidecar, MAX_REQUEST_BLOB_SIDECARS_ELECTRA]
232-
)
233-
```
234-
235-
*Updated validation*
236-
237-
No more than `MAX_REQUEST_BLOB_SIDECARS_ELECTRA` may be requested at a time.
211+
*Note*: The `compute_max_request_blob_sidecars` function has been modified which
212+
affects the request, response, and validation logic.

specs/fulu/p2p-interface.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
- [Introduction](#introduction)
66
- [Modifications in Fulu](#modifications-in-fulu)
7+
- [Helper functions](#helper-functions)
8+
- [Modified `compute_fork_version`](#modified-compute_fork_version)
9+
- [New `compute_max_request_data_column_sidecars`](#new-compute_max_request_data_column_sidecars)
710
- [Preset](#preset)
811
- [Configuration](#configuration)
912
- [Containers](#containers)
@@ -50,6 +53,40 @@ specifications of previous upgrades, and assumes them as pre-requisite.
5053

5154
## Modifications in Fulu
5255

56+
### Helper functions
57+
58+
#### Modified `compute_fork_version`
59+
60+
```python
61+
def compute_fork_version(epoch: Epoch) -> Version:
62+
"""
63+
Return the fork version at the given ``epoch``.
64+
"""
65+
if epoch >= FULU_FORK_EPOCH:
66+
return FULU_FORK_VERSION
67+
if epoch >= ELECTRA_FORK_EPOCH:
68+
return ELECTRA_FORK_VERSION
69+
if epoch >= DENEB_FORK_EPOCH:
70+
return DENEB_FORK_VERSION
71+
if epoch >= CAPELLA_FORK_EPOCH:
72+
return CAPELLA_FORK_VERSION
73+
if epoch >= BELLATRIX_FORK_EPOCH:
74+
return BELLATRIX_FORK_VERSION
75+
if epoch >= ALTAIR_FORK_EPOCH:
76+
return ALTAIR_FORK_VERSION
77+
return GENESIS_FORK_VERSION
78+
```
79+
80+
#### New `compute_max_request_data_column_sidecars`
81+
82+
```python
83+
def compute_max_request_data_column_sidecars() -> uint64:
84+
"""
85+
Return the maximum number of data column sidecars in a single request.
86+
"""
87+
return uint64(MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS)
88+
```
89+
5390
### Preset
5491

5592
| Name | Value | Description |
@@ -60,11 +97,10 @@ specifications of previous upgrades, and assumes them as pre-requisite.
6097

6198
*[New in Fulu:EIP7594]*
6299

63-
| Name | Value | Description |
64-
| ---------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------- |
65-
| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `128` | The number of data column sidecar subnets used in the gossipsub protocol |
66-
| `MAX_REQUEST_DATA_COLUMN_SIDECARS` | `MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS` | Maximum number of data column sidecars in a single request |
67-
| `MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve data column sidecars |
100+
| Name | Value | Description |
101+
| ---------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------- |
102+
| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `128` | The number of data column sidecar subnets used in the gossipsub protocol |
103+
| `MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve data column sidecars |
68104

69105
### Containers
70106

@@ -382,7 +418,7 @@ Response Content:
382418

383419
```
384420
(
385-
List[DataColumnSidecar, MAX_REQUEST_DATA_COLUMN_SIDECARS]
421+
List[DataColumnSidecar, compute_max_request_data_column_sidecars()]
386422
)
387423
```
388424

@@ -428,7 +464,7 @@ and/or temporarily ban such an un-synced or semi-synced client.
428464

429465
Clients MUST respond with at least the data column sidecars of the first
430466
blob-carrying block that exists in the range, if they have it, and no more than
431-
`MAX_REQUEST_DATA_COLUMN_SIDECARS` sidecars.
467+
`compute_max_request_data_column_sidecars()` sidecars.
432468

433469
Clients MUST include all data column sidecars of each block from which they
434470
include data column sidecars.
@@ -488,7 +524,7 @@ Response Content:
488524

489525
```
490526
(
491-
List[DataColumnSidecar, MAX_REQUEST_DATA_COLUMN_SIDECARS]
527+
List[DataColumnSidecar, compute_max_request_data_column_sidecars()]
492528
)
493529
```
494530

@@ -504,7 +540,8 @@ valid inclusion proof through `verify_data_column_sidecar_inclusion_proof`, and
504540
is correct w.r.t. the expected KZG commitments through
505541
`verify_data_column_sidecar_kzg_proofs`.
506542

507-
No more than `MAX_REQUEST_DATA_COLUMN_SIDECARS` may be requested at a time.
543+
No more than `compute_max_request_data_column_sidecars()` may be requested at a
544+
time.
508545

509546
The response MUST consist of zero or more `response_chunk`. Each _successful_
510547
`response_chunk` MUST contain a single `DataColumnSidecar` payload.

0 commit comments

Comments
 (0)