Skip to content

Commit e129681

Browse files
committed
Add Cell Dissemination via Partial Message Specification
1 parent cd92a89 commit e129681

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

specs/fulu/p2p-interface.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,111 @@ gossip. In particular, clients MUST:
292292
- Update gossip rule related data structures (i.e. update the anti-equivocation
293293
cache).
294294

295+
#### Partial Columns
296+
297+
Gossipsub's [Partial Message
298+
Extension](https://github.com/libp2p/specs/pull/685) enables exchanging
299+
selective parts of a message rather than the whole. The specification here
300+
describes how Consensus Clients use Partial Messages to disseminate cells.
301+
302+
*Editor's Note*: This change MUST NOT be merged before the linked libp2p/specs.
303+
304+
##### `PartialDataColumnSidecar`
305+
306+
The `PartialDataColumnSidecar` is similar to the `DataColumnSidecar `container,
307+
except that only the cells and proofs identified by the bitmap are present.
308+
309+
```python
310+
class PartialDataColumnSidecar(Container):
311+
cells_present_bitmap: Bitlist[MAX_BLOB_COMMITMENTS_PER_BLOCK]
312+
partial_column: List[Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK]
313+
kzg_proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK]
314+
```
315+
316+
##### Parts Metadata
317+
318+
Peers communicate the cells available with a bitmap. A set bit (`1`) at index `i`
319+
means that the peer has cell the cell at index `i`. The bitmap is encoded as a
320+
Bitlist.
321+
322+
##### Encoding and Decoding Responses
323+
324+
All responses should be encoded and decoded with the PartialDataColumnSidecar
325+
container.
326+
327+
##### Validation
328+
329+
TODO add full validation rules
330+
331+
###### `verify_partial_data_column_sidecar_kzg_proofs`
332+
333+
```python
334+
def verify_partial_data_column_sidecar_kzg_proofs(sidecar: PartialDataColumnSidecar, all_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]) -> bool:
335+
"""
336+
Verify if the KZG proofs are correct.
337+
"""
338+
# The column index also represents the cell index
339+
cell_indices = [i for i, b in enumerate(bin(bitmap)[:1:-1]) if b == '1']
340+
341+
# Batch verify that the cells match the corresponding commitments and proofs
342+
return verify_cell_kzg_proof_batch(
343+
commitments_bytes=[all_commitments[i] for i in cell_indices],
344+
cell_indices=cell_indices,
345+
cells=sidecar.column,
346+
proofs_bytes=sidecar.kzg_proofs,
347+
)
348+
```
349+
350+
##### Eager Pushing
351+
352+
In contrast to standard Gossipsub, A client explicitly requests missing parts
353+
from a peer. A client can send its request before receiving a peer's parts metadata.
354+
This registers interest in certain parts, even if the peer doesn't have these
355+
parts yet.
356+
357+
This request can introduce extra latency compared to a peer unconditionally
358+
pushing messages, especially in the first hop of dissemination.
359+
360+
To address this tradeoff a client may choose to eagerly push some (or all) of
361+
the cells it has. clients SHOULD only do this when they are reasonably confident
362+
that a peer does not have the provided cells. For example, a proposer including
363+
private blobs SHOULD eagerly push the cells corresponding to the private blobs.
364+
365+
##### Interaction with standard Gossipsub
366+
367+
###### Requesting Partial messages
368+
369+
A peer requests partial messages for a topic by setting the `partial` field in
370+
Gossipsub's `SubOpts` RPC message to true.
371+
372+
###### Mesh
373+
374+
The Partial Message Extension uses the same mesh peers for a given topic
375+
as the standard Gossipsub topics for DataColumnSidecars.
376+
377+
###### Fanout
378+
379+
The Partial Message Extension uses the same fanout peers for a given topic
380+
as the standard Gossipsub topics for DataColumnSidecars.
381+
382+
###### Scoring
383+
384+
On receiving useful novel data from a peer, the client should report to
385+
Gossipsub a positive first message delivery.
386+
387+
On receiving invalid data, the client should report to Gossipsub an invalid
388+
message delivery.
389+
390+
###### Forwarding
391+
392+
Once Clients can construct the full DataColumnSidecar after receiving missing
393+
cells, they should forward the full DataColumnSidecar over standard Gossipsub to
394+
peers that do not support partial messages. This provides backwards
395+
compatibility with nodes that do not yet support partial messages
396+
397+
Avoid forwarding the full DataColumnSidecar message to peers that requested
398+
partial messages for that given topic. It is purely redundant information.
399+
295400
### The Req/Resp domain
296401

297402
#### Messages

0 commit comments

Comments
 (0)