@@ -292,6 +292,122 @@ 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 ` ) means that
319+ the peer has the corresponding cell. The bitmap is encoded with the following
320+ function:
321+
322+ ``` python
323+ def create_bitmap (available_cells , n ):
324+ bitmap = [0 ] * ((n + 7 ) // 8 )
325+ for i in available_cell:
326+ bitmap[i // 8 ] |= 1 << (i % 8 )
327+ return bitmap
328+ ```
329+
330+ For example, if the peer had cells 0,3,9, the corresponding bitmap would be:
331+ ` 0000 1001 0000 0010 ` .
332+
333+ ##### Encoding and Decoding Responses
334+
335+ All responses should be encoded and decoded with the PartialDataColumnSidecar
336+ container.
337+
338+ ##### Validation
339+
340+ TODO add full validation rules
341+
342+ ###### ` verify_partial_data_column_sidecar_kzg_proofs `
343+
344+ ``` python
345+ def verify_partial_data_column_sidecar_kzg_proofs (sidecar : PartialDataColumnSidecar, all_commitments : List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK ]) -> bool :
346+ """
347+ Verify if the KZG proofs are correct.
348+ """
349+ # The column index also represents the cell index
350+ cell_indices = [i for i, b in enumerate (bin (bitmap)[:1 :- 1 ]) if b == ' 1' ]
351+
352+ # Batch verify that the cells match the corresponding commitments and proofs
353+ return verify_cell_kzg_proof_batch(
354+ commitments_bytes = [all_commitments[i] for i in cell_indices],
355+ cell_indices = cell_indices,
356+ cells = sidecar.column,
357+ proofs_bytes = sidecar.kzg_proofs,
358+ )
359+ ```
360+
361+ ##### Eager Pushing
362+
363+ In contrast to standard Gossipsub, A client explicitly requests missing parts
364+ from a peer. A client can send its request before receiving a peer's parts metadata.
365+ This registers interest in certain parts, even if the peer doesn't have these
366+ parts yet.
367+
368+ This request can introduce extra latency compared to a peer unconditionally
369+ pushing messages, especially in the first hop of dissemination.
370+
371+ To address this tradeoff a client may choose to eagerly push some (or all) of
372+ the cells it has. clients SHOULD only do this when they are reasonably confident
373+ that a peer does not have the provided cells. For example, a proposer including
374+ private blobs SHOULD eagerly push the cells corresponding to the private blobs.
375+
376+ ##### Interaction with standard Gossipsub
377+
378+ ###### Requesting Partial messages
379+
380+ A peer requests partial messages for a topic by setting the ` partial ` field in
381+ Gossipsub's ` SubOpts ` RPC message to true.
382+
383+ ###### Mesh
384+
385+ The Partial Message Extension uses the same mesh peers for a given topic
386+ as the standard Gossipsub topics for DataColumnSidecars.
387+
388+ ###### Fanout
389+
390+ The Partial Message Extension uses the same fanout peers for a given topic
391+ as the standard Gossipsub topics for DataColumnSidecars.
392+
393+ ###### Scoring
394+
395+ On receiving useful novel data from a peer, the client should report to
396+ Gossipsub a positive first message delivery.
397+
398+ On receiving invalid data, the client should report to Gossipsub an invalid
399+ message delivery.
400+
401+ ###### Forwarding
402+
403+ Once Clients can construct the full DataColumnSidecar after receiving missing
404+ cells, they should forward the full DataColumnSidecar over standard Gossipsub to
405+ peers that do not support partial messages. This provides backwards
406+ compatibility with nodes that do not yet support partial messages
407+
408+ Avoid forwarding the full DataColumnSidecar message to peers that requested
409+ partial messages for that given topic. It is purely redundant information.
410+
295411### The Req/Resp domain
296412
297413#### Messages
0 commit comments