@@ -292,6 +292,110 @@ 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 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+ Some fields are only set when a peer is eagerly pushing this container.
310+ Otherwise, if a peer is sending the container as a response, there is no need to
311+ include redundant fields.
312+
313+ ``` python
314+ class PartialDataColumnSidecar (Container ):
315+ cells_present_bitmap: Bitlist[MAX_BLOB_COMMITMENTS_PER_BLOCK ]
316+ partial_column: List[Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK ]
317+ kzg_proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK ]
318+ ```
319+
320+ ##### Partial IHAVE/IWANT
321+
322+ Peers communicate IHAVE and IWANTS succintly with a bitmap. For IHAVE, a set bit (` 1 ` )
323+ means that the peer has the corresponding cell. For IWANT, a set bit means the
324+ peer wants the corresponding cell. The bitmap is encoded by the following function:
325+
326+ ``` python
327+ def create_bitmap (set_indices , n ):
328+ bitmap = [0 ] * ((n + 7 ) // 8 )
329+ for i in set_indices:
330+ bitmap[i // 8 ] |= 1 << (i % 8 )
331+ return bitmap
332+ ```
333+
334+ For example, if the peer wanted cells at positions 0,3,9, the corresponding
335+ IWANT bitmap would be: ` 0000 1001 0000 0010 ` .
336+
337+ ##### Encoding and Decoding Responses
338+
339+ All responses should be encoded and decoded with the PartialDataColumnSidecar
340+ container.
341+
342+ ##### Validation
343+
344+ TODO add full validation rules
345+
346+ ###### ` verify_partial_data_column_sidecar_kzg_proofs `
347+
348+ ``` python
349+ def verify_partial_data_column_sidecar_kzg_proofs (sidecar : PartialDataColumnSidecar, all_commitments : List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK ]) -> bool :
350+ """
351+ Verify if the KZG proofs are correct.
352+ """
353+ # The column index also represents the cell index
354+ cell_indices = [i for i, b in enumerate (bin (bitmap)[:1 :- 1 ]) if b == ' 1' ]
355+
356+ # Batch verify that the cells match the corresponding commitments and proofs
357+ return verify_cell_kzg_proof_batch(
358+ commitments_bytes = [all_commitments[i] for i in cell_indices],
359+ cell_indices = cell_indices,
360+ cells = sidecar.column,
361+ proofs_bytes = sidecar.kzg_proofs,
362+ )
363+ ```
364+
365+ ##### Eager Pushing
366+
367+ In contrast to standard Gossipsub, A Client usually requests missing parts from
368+ a peer. A client can send its partial IWANT before receiving a peer's partial
369+ IHAVE to register interest in certain parts. This can introduce extra latency
370+ compared to a Client unconditionally pushing messages to a peer.
371+
372+ To address this tradeoff a Client may choose to eagerly push some (or all) of
373+ the cells it has. Clients SHOULD only do this when they are reasonably confident
374+ that a peer does not have the provided cells. For example, a proposer including
375+ private blobs SHOULD eagerly push the cells corresponding to the private blobs.
376+
377+ ##### Interaction with standard Gossipsub
378+
379+ ###### Mesh
380+
381+ The Partial Message Extension uses the same mesh peers and the same topic name
382+ as the standard Gossipsub topics for DataColumnSidecars.
383+
384+ ###### Scoring
385+
386+ TODO: this needs to be discussed in the libp2p spec first.
387+
388+ ###### Forwarding
389+
390+ Once Clients can construct the full DataColumnSidecar after receiving missing
391+ cells, they should forward the full DataColumnSidecar over standard Gossipsub to
392+ peers that do not support partial messages. This provides backwards
393+ compatibility with nodes that do not yet support partial messages
394+
395+ Avoid forwarding the full DataColumnSidecar message to peers that support
396+ partial messages. It is purely redundant information to send them a standard
397+ gossipsub message if they support partial mess
398+
295399### The Req/Resp domain
296400
297401#### Messages
0 commit comments