Split peer sampling spec from das-core.md
This commit is contained in:
parent
4bd2f924de
commit
376ab85406
|
@ -23,21 +23,14 @@
|
|||
- [`compute_extended_matrix`](#compute_extended_matrix)
|
||||
- [`recover_matrix`](#recover_matrix)
|
||||
- [`get_data_column_sidecars`](#get_data_column_sidecars)
|
||||
- [`get_extended_sample_count`](#get_extended_sample_count)
|
||||
- [Custody](#custody)
|
||||
- [Custody requirement](#custody-requirement)
|
||||
- [Public, deterministic selection](#public-deterministic-selection)
|
||||
- [Peer discovery](#peer-discovery)
|
||||
- [Subnet sampling](#subnet-sampling)
|
||||
- [Extended data](#extended-data)
|
||||
- [Column gossip](#column-gossip)
|
||||
- [Parameters](#parameters)
|
||||
- [Peer sampling](#peer-sampling)
|
||||
- [Sample selection](#sample-selection)
|
||||
- [Sample queries](#sample-queries)
|
||||
- [Peer scoring](#peer-scoring)
|
||||
- [Reconstruction and cross-seeding](#reconstruction-and-cross-seeding)
|
||||
- [DAS providers](#das-providers)
|
||||
- [A note on fork choice](#a-note-on-fork-choice)
|
||||
- [FAQs](#faqs)
|
||||
- [Row (blob) custody](#row-blob-custody)
|
||||
- [Subnet stability](#subnet-stability)
|
||||
|
@ -75,15 +68,14 @@ The following values are (non-configurable) constants used throughout the specif
|
|||
|
||||
| Name | Value | Description |
|
||||
| - | - | - |
|
||||
| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `32` | The number of data column sidecar subnets used in the gossipsub protocol |
|
||||
| `DATA_COLUMN_SIDECAR_SUBNET_COUNT` | `128` | The number of data column sidecar subnets used in the gossipsub protocol |
|
||||
|
||||
### Custody setting
|
||||
|
||||
| Name | Value | Description |
|
||||
| - | - | - |
|
||||
| `SAMPLES_PER_SLOT` | `8` | Number of `DataColumnSidecar` random samples a node queries per slot |
|
||||
| `CUSTODY_REQUIREMENT` | `1` | Minimum number of subnets an honest node custodies and serves samples from |
|
||||
| `TARGET_NUMBER_OF_PEERS` | `70` | Suggested minimum peer count |
|
||||
| `CUSTODY_REQUIREMENT` | `4` | Minimum number of subnets an honest node custodies and serves samples from |
|
||||
|
||||
### Containers
|
||||
|
||||
|
@ -227,48 +219,6 @@ def get_data_column_sidecars(signed_block: SignedBeaconBlock,
|
|||
return sidecars
|
||||
```
|
||||
|
||||
#### `get_extended_sample_count`
|
||||
|
||||
```python
|
||||
def get_extended_sample_count(allowed_failures: uint64) -> uint64:
|
||||
assert 0 <= allowed_failures <= NUMBER_OF_COLUMNS // 2
|
||||
"""
|
||||
Return the sample count if allowing failures.
|
||||
|
||||
This helper demonstrates how to calculate the number of columns to query per slot when
|
||||
allowing given number of failures, assuming uniform random selection without replacement.
|
||||
Nested functions are direct replacements of Python library functions math.comb and
|
||||
scipy.stats.hypergeom.cdf, with the same signatures.
|
||||
"""
|
||||
|
||||
def math_comb(n: int, k: int) -> int:
|
||||
if not 0 <= k <= n:
|
||||
return 0
|
||||
r = 1
|
||||
for i in range(min(k, n - k)):
|
||||
r = r * (n - i) // (i + 1)
|
||||
return r
|
||||
|
||||
def hypergeom_cdf(k: uint64, M: uint64, n: uint64, N: uint64) -> float:
|
||||
# NOTE: It contains float-point computations.
|
||||
# Convert uint64 to Python integers before computations.
|
||||
k = int(k)
|
||||
M = int(M)
|
||||
n = int(n)
|
||||
N = int(N)
|
||||
return sum([math_comb(n, i) * math_comb(M - n, N - i) / math_comb(M, N)
|
||||
for i in range(k + 1)])
|
||||
|
||||
worst_case_missing = NUMBER_OF_COLUMNS // 2 + 1
|
||||
false_positive_threshold = hypergeom_cdf(0, NUMBER_OF_COLUMNS,
|
||||
worst_case_missing, SAMPLES_PER_SLOT)
|
||||
for sample_count in range(SAMPLES_PER_SLOT, NUMBER_OF_COLUMNS + 1):
|
||||
if hypergeom_cdf(allowed_failures, NUMBER_OF_COLUMNS,
|
||||
worst_case_missing, sample_count) <= false_positive_threshold:
|
||||
break
|
||||
return sample_count
|
||||
```
|
||||
|
||||
## Custody
|
||||
|
||||
### Custody requirement
|
||||
|
@ -285,17 +235,9 @@ The particular columns that a node custodies are selected pseudo-randomly as a f
|
|||
|
||||
*Note*: increasing the `custody_size` parameter for a given `node_id` extends the returned list (rather than being an entirely new shuffle) such that if `custody_size` is unknown, the default `CUSTODY_REQUIREMENT` will be correct for a subset of the node's custody.
|
||||
|
||||
## Peer discovery
|
||||
## Subnet sampling
|
||||
|
||||
At each slot, a node needs to be able to readily sample from *any* set of columns. To this end, a node SHOULD find and maintain a set of diverse and reliable peers that can regularly satisfy their sampling demands.
|
||||
|
||||
A node runs a background peer discovery process, maintaining at least `TARGET_NUMBER_OF_PEERS` of various custody distributions (both `custody_size` and column assignments). The combination of advertised `custody_size` size and public node-id make this readily and publicly accessible.
|
||||
|
||||
`TARGET_NUMBER_OF_PEERS` should be tuned upward in the event of failed sampling.
|
||||
|
||||
*Note*: while high-capacity and super-full nodes are high value with respect to satisfying sampling requirements, a node SHOULD maintain a distribution across node capacities as to not centralize the p2p graph too much (in the extreme becomes hub/spoke) and to distribute sampling load better across all nodes.
|
||||
|
||||
*Note*: A DHT-based peer discovery mechanism is expected to be utilized in the above. The beacon-chain network currently utilizes discv5 in a similar method as described for finding peers of particular distributions of attestation subnets. Additional peer discovery methods are valuable to integrate (e.g., latent peer discovery via libp2p gossipsub) to add a defense in breadth against one of the discovery methods being attacked.
|
||||
At each slot, a node advertising `custody_subnet_count` downloads a minimum of `subnet_sampling_size = max(SAMPLES_PER_SLOT, custody_subnet_count)` total subnets. The corresponding set of columns is selected by `get_custody_columns(node_id, subnet_sampling_size)`, so that in particular the subset of columns to custody is consistent with the output of `get_custody_columns(node_id, custody_subnet_count)`. Sampling is considered successful if the node manages to retrieve all selected columns.
|
||||
|
||||
## Extended data
|
||||
|
||||
|
@ -309,36 +251,6 @@ For each column -- use `data_column_sidecar_{subnet_id}` subnets, where `subnet_
|
|||
|
||||
Verifiable samples from their respective column are distributed on the assigned subnet. To custody a particular column, a node joins the respective gossipsub subnet. If a node fails to get a column on the column subnet, a node can also utilize the Req/Resp protocol to query the missing column from other peers.
|
||||
|
||||
## Peer sampling
|
||||
|
||||
### Sample selection
|
||||
|
||||
At each slot, a node SHOULD select at least `SAMPLES_PER_SLOT` column IDs for sampling. It is recommended to use uniform random selection without replacement based on local randomness. Sampling is considered successful if the node manages to retrieve all selected columns.
|
||||
|
||||
Alternatively, a node MAY use a method that selects more than `SAMPLES_PER_SLOT` columns while allowing some missing, respecting the same target false positive threshold (the probability of successful sampling of an unavailable block) as dictated by the `SAMPLES_PER_SLOT` parameter. If using uniform random selection without replacement, a node can use the `get_extended_sample_count(allowed_failures) -> sample_count` helper function to determine the sample count (number of unique column IDs) for any selected number of allowed failures. Sampling is then considered successful if any `sample_count - allowed_failures` columns are retrieved successfully.
|
||||
|
||||
For reference, the table below shows the number of samples and the number of allowed missing columns assuming `NUMBER_OF_COLUMNS = 128` and `SAMPLES_PER_SLOT = 16`.
|
||||
|
||||
| Allowed missing | 0| 1| 2| 3| 4| 5| 6| 7| 8|
|
||||
|-----------------|--|--|--|--|--|--|--|--|--|
|
||||
| Sample count |16|20|24|27|29|32|35|37|40|
|
||||
|
||||
### Sample queries
|
||||
|
||||
A node SHOULD maintain a diverse set of peers for each column and each slot by verifying responsiveness to sample queries.
|
||||
|
||||
A node SHOULD query for samples from selected peers via `DataColumnSidecarsByRoot` request. A node utilizes `get_custody_columns` helper to determine which peer(s) it could request from, identifying a list of candidate peers for each selected column.
|
||||
|
||||
If more than one candidate peer is found for a given column, a node SHOULD randomize its peer selection to distribute sample query load in the network. Nodes MAY use peer scoring to tune this selection (for example, by using weighted selection or by using a cut-off threshold). If possible, it is also recommended to avoid requesting many columns from the same peer in order to avoid relying on and exposing the sample selection to a single peer.
|
||||
|
||||
If a node already has a column because of custody, it is not required to send out queries for that column.
|
||||
|
||||
If a node has enough good/honest peers across all columns, and the data is being made available, the above procedure has a high chance of success.
|
||||
|
||||
## Peer scoring
|
||||
|
||||
Due to the deterministic custody functions, a node knows exactly what a peer should be able to respond to. In the event that a peer does not respond to samples of their custodied rows/columns, a node may downscore or disconnect from a peer.
|
||||
|
||||
## Reconstruction and cross-seeding
|
||||
|
||||
If the node obtains 50%+ of all the columns, it SHOULD reconstruct the full data matrix via `recover_matrix` helper. Nodes MAY delay this reconstruction allowing time for other columns to arrive over the network. If delaying reconstruction, nodes may use a random delay in order to desynchronize reconstruction among nodes, thus reducing overall CPU load.
|
||||
|
@ -351,26 +263,6 @@ Once the node obtains a column through reconstruction, the node MUST expose the
|
|||
|
||||
*Note*: There may be anti-DoS and quality-of-service considerations around how to send samples and consider samples -- is each individual sample a message or are they sent in aggregate forms.
|
||||
|
||||
## DAS providers
|
||||
|
||||
A DAS provider is a consistently-available-for-DAS-queries, super-full (or high capacity) node. To the p2p, these look just like other nodes but with high advertised capacity, and they should generally be able to be latently found via normal discovery.
|
||||
|
||||
DAS providers can also be found out-of-band and configured into a node to connect to directly and prioritize. Nodes can add some set of these to their local configuration for persistent connection to bolster their DAS quality of service.
|
||||
|
||||
Such direct peering utilizes a feature supported out of the box today on all nodes and can complement (and reduce attackability and increase quality-of-service) alternative peer discovery mechanisms.
|
||||
|
||||
## A note on fork choice
|
||||
|
||||
*Fork choice spec TBD, but it will just be a replacement of `is_data_available()` call in Deneb with column sampling instead of full download. Note the `is_data_available(slot_N)` will likely do a `-1` follow distance so that you just need to check the availability of slot `N-1` for slot `N` (starting with the block proposer of `N`).*
|
||||
|
||||
The fork choice rule (essentially a DA filter) is *orthogonal to a given DAS design*, other than the efficiency of a particular design impacting it.
|
||||
|
||||
In any DAS design, there are probably a few degrees of freedom around timing, acceptability of short-term re-orgs, etc.
|
||||
|
||||
For example, the fork choice rule might require validators to do successful DAS on slot `N` to be able to include block of slot `N` in its fork choice. That's the tightest DA filter. But trailing filters are also probably acceptable, knowing that there might be some failures/short re-orgs but that they don't hurt the aggregate security. For example, the rule could be — DAS must be completed for slot N-1 for a child block in N to be included in the fork choice.
|
||||
|
||||
Such trailing techniques and their analysis will be valuable for any DAS construction. The question is — can you relax how quickly you need to do DA and in the worst case not confirm unavailable data via attestations/finality, and what impact does it have on short-term re-orgs and fast confirmation rules.
|
||||
|
||||
## FAQs
|
||||
|
||||
### Row (blob) custody
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
- [Introduction](#introduction)
|
||||
- [Helpers](#helpers)
|
||||
- [Modified `is_data_available`](#modified-is_data_available)
|
||||
- [New `is_chain_available`](#new-is_chain_available)
|
||||
- [Modified `get_head`](#modified-get_head)
|
||||
- [New `is_peer_sampling_required`](#new-is_peer_sampling_required)
|
||||
- [Updated fork-choice handlers](#updated-fork-choice-handlers)
|
||||
- [Modified `on_block`](#modified-on_block)
|
||||
- [Pull-up tip helpers](#pull-up-tip-helpers)
|
||||
- [Modified `compute_pulled_up_tip`](#modified-compute_pulled_up_tip)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- /TOC -->
|
||||
|
@ -29,8 +25,11 @@ This is the modification of the fork choice accompanying EIP-7594.
|
|||
|
||||
```python
|
||||
def is_data_available(beacon_block_root: Root) -> bool:
|
||||
# `retrieve_column_sidecars` is implementation and context dependent, replacing `retrieve_blobs_and_proofs`.
|
||||
# For the given block root, it returns all column sidecars to custody, or raises an exception if they are not available. # The p2p network does not guarantee sidecar retrieval outside of `MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS` epochs.
|
||||
# `retrieve_column_sidecars` is implementation and context dependent, replacing
|
||||
# `retrieve_blobs_and_proofs`. For the given block root, it returns all column
|
||||
# sidecars to custody, or raises an exception if they are not available.
|
||||
# The p2p network does not guarantee sidecar retrieval outside of
|
||||
# `MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS` epochs.
|
||||
column_sidecars = retrieve_column_sidecars(beacon_block_root)
|
||||
return all(
|
||||
verify_data_column_sidecar_kzg_proofs(column_sidecar)
|
||||
|
@ -68,7 +67,8 @@ def get_head(store: Store) -> Root:
|
|||
|
||||
### Modified `on_block`
|
||||
|
||||
*Note*: The blob data availability check is removed.
|
||||
*Note*: The blob data availability check is removed. We import blocks regardless
|
||||
of their availability status, and move all filtering to the fork-choice (`get_head`).
|
||||
|
||||
```python
|
||||
def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
# EIP-7594 -- Peer Sampling
|
||||
|
||||
**Notice**: This document is a work-in-progress for researchers and implementers.
|
||||
|
||||
## Table of contents
|
||||
|
||||
<!-- TOC -->
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
- [Helper functions](#helper-functions)
|
||||
- [`get_extended_sample_count`](#get_extended_sample_count)
|
||||
- [Peer discovery](#peer-discovery)
|
||||
- [Peer sampling](#peer-sampling)
|
||||
- [Sample selection](#sample-selection)
|
||||
- [Sample queries](#sample-queries)
|
||||
- [Peer scoring](#peer-scoring)
|
||||
- [DAS providers](#das-providers)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- /TOC -->
|
||||
|
||||
The purpose of this document is to complement [EIP-7594 -- Data Availability Sampling Core](das-core.md), by specifying the peer sampling functionality of the full PeerDAS protocol. This functionality may initially not be implemented, or only implemented by some clients, in which case it is replaced by [subnet sampling](das-core.md#subnet-sampling), an extension of the custody component of the protocol.
|
||||
|
||||
### Helper functions
|
||||
|
||||
#### `get_extended_sample_count`
|
||||
|
||||
```python
|
||||
def get_extended_sample_count(allowed_failures: uint64) -> uint64:
|
||||
assert 0 <= allowed_failures <= NUMBER_OF_COLUMNS // 2
|
||||
"""
|
||||
Return the sample count if allowing failures.
|
||||
|
||||
This helper demonstrates how to calculate the number of columns to query per slot when
|
||||
allowing given number of failures, assuming uniform random selection without replacement.
|
||||
Nested functions are direct replacements of Python library functions math.comb and
|
||||
scipy.stats.hypergeom.cdf, with the same signatures.
|
||||
"""
|
||||
|
||||
def math_comb(n: int, k: int) -> int:
|
||||
if not 0 <= k <= n:
|
||||
return 0
|
||||
r = 1
|
||||
for i in range(min(k, n - k)):
|
||||
r = r * (n - i) // (i + 1)
|
||||
return r
|
||||
|
||||
def hypergeom_cdf(k: uint64, M: uint64, n: uint64, N: uint64) -> float:
|
||||
# NOTE: It contains float-point computations.
|
||||
# Convert uint64 to Python integers before computations.
|
||||
k = int(k)
|
||||
M = int(M)
|
||||
n = int(n)
|
||||
N = int(N)
|
||||
return sum([math_comb(n, i) * math_comb(M - n, N - i) / math_comb(M, N)
|
||||
for i in range(k + 1)])
|
||||
|
||||
worst_case_missing = NUMBER_OF_COLUMNS // 2 + 1
|
||||
false_positive_threshold = hypergeom_cdf(0, NUMBER_OF_COLUMNS,
|
||||
worst_case_missing, SAMPLES_PER_SLOT)
|
||||
for sample_count in range(SAMPLES_PER_SLOT, NUMBER_OF_COLUMNS + 1):
|
||||
if hypergeom_cdf(allowed_failures, NUMBER_OF_COLUMNS,
|
||||
worst_case_missing, sample_count) <= false_positive_threshold:
|
||||
break
|
||||
return sample_count
|
||||
```
|
||||
|
||||
## Peer discovery
|
||||
|
||||
At each slot, a node needs to be able to readily sample from *any* set of columns. To this end, a node SHOULD find and maintain a set of diverse and reliable peers that can regularly satisfy their sampling demands.
|
||||
|
||||
A node runs a background peer discovery process, maintaining peers of various custody distributions (both `custody_size` and column assignments). The combination of advertised `custody_size` size and public node-id make this readily and publicly accessible. The peer set should cover the whole column space, with some redundancy. The number of peers, or at least the redundancy implied by the custody distributions over the the peer set, should be tuned upward in the event of failed sampling.
|
||||
|
||||
*Note*: while high-capacity and super-full nodes are high value with respect to satisfying sampling requirements, a node SHOULD maintain a distribution across node capacities as to not centralize the p2p graph too much (in the extreme becomes hub/spoke) and to distribute sampling load better across all nodes.
|
||||
|
||||
*Note*: A DHT-based peer discovery mechanism is expected to be utilized in the above. The beacon-chain network currently utilizes discv5 in a similar method as described for finding peers of particular distributions of attestation subnets. Additional peer discovery methods are valuable to integrate (e.g., latent peer discovery via libp2p gossipsub) to add a defense in breadth against one of the discovery methods being attacked.
|
||||
|
||||
## Peer sampling
|
||||
|
||||
### Sample selection
|
||||
|
||||
At each slot, a node SHOULD select at least `SAMPLES_PER_SLOT` column IDs for sampling. It is recommended to use uniform random selection without replacement based on local randomness. Sampling is considered successful if the node manages to retrieve all selected columns.
|
||||
|
||||
Alternatively, a node MAY use a method that selects more than `SAMPLES_PER_SLOT` columns while allowing some missing, respecting the same target false positive threshold (the probability of successful sampling of an unavailable block) as dictated by the `SAMPLES_PER_SLOT` parameter. If using uniform random selection without replacement, a node can use the `get_extended_sample_count(allowed_failures) -> sample_count` helper function to determine the sample count (number of unique column IDs) for any selected number of allowed failures. Sampling is then considered successful if any `sample_count - allowed_failures` columns are retrieved successfully.
|
||||
|
||||
For reference, the table below shows the number of samples and the number of allowed missing columns assuming `NUMBER_OF_COLUMNS = 128` and `SAMPLES_PER_SLOT = 16`.
|
||||
|
||||
| Allowed missing | 0| 1| 2| 3| 4| 5| 6| 7| 8|
|
||||
|-----------------|--|--|--|--|--|--|--|--|--|
|
||||
| Sample count |16|20|24|27|29|32|35|37|40|
|
||||
|
||||
### Sample queries
|
||||
|
||||
A node SHOULD maintain a diverse set of peers for each column and each slot by verifying responsiveness to sample queries.
|
||||
|
||||
A node SHOULD query for samples from selected peers via `DataColumnSidecarsByRoot` request. A node utilizes `get_custody_columns` helper to determine which peer(s) it could request from, identifying a list of candidate peers for each selected column.
|
||||
|
||||
If more than one candidate peer is found for a given column, a node SHOULD randomize its peer selection to distribute sample query load in the network. Nodes MAY use peer scoring to tune this selection (for example, by using weighted selection or by using a cut-off threshold). If possible, it is also recommended to avoid requesting many columns from the same peer in order to avoid relying on and exposing the sample selection to a single peer.
|
||||
|
||||
If a node already has a column because of custody, it is not required to send out queries for that column.
|
||||
|
||||
If a node has enough good/honest peers across all columns, and the data is being made available, the above procedure has a high chance of success.
|
||||
|
||||
## Peer scoring
|
||||
|
||||
Due to the deterministic custody functions, a node knows exactly what a peer should be able to respond to. In the event that a peer does not respond to samples of their custodied rows/columns, a node may downscore or disconnect from a peer.
|
||||
|
||||
## DAS providers
|
||||
|
||||
A DAS provider is a consistently-available-for-DAS-queries, super-full (or high capacity) node. To the p2p, these look just like other nodes but with high advertised capacity, and they should generally be able to be latently found via normal discovery.
|
||||
|
||||
DAS providers can also be found out-of-band and configured into a node to connect to directly and prioritize. Nodes can add some set of these to their local configuration for persistent connection to bolster their DAS quality of service.
|
||||
|
||||
Such direct peering utilizes a feature supported out of the box today on all nodes and can complement (and reduce attackability and increase quality-of-service) alternative peer discovery mechanisms.
|
Loading…
Reference in New Issue