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