|
| 1 | +# Partial Messages Extension |
| 2 | + |
| 3 | +| Lifecycle Stage | Maturity | Status | Latest Revision | |
| 4 | +| --------------- | ------------- | ------ | --------------- | |
| 5 | +| 1A | Working Draft | Active | r0, 2025-06-23 | |
| 6 | + |
| 7 | +Authors: [@marcopolo, @cskiraly] |
| 8 | + |
| 9 | +Interest Group: TODO |
| 10 | + |
| 11 | +[@marcopolo]: https://github.com/marcopolo |
| 12 | +[@cskiraly]: https://github.com/cskiraly |
| 13 | + |
| 14 | +See the [lifecycle document][lifecycle-spec] for context about the maturity level |
| 15 | +and spec status. |
| 16 | + |
| 17 | +[lifecycle-spec]: https://github.com/libp2p/specs/blob/master/00-framework-01-spec-lifecycle.md |
| 18 | + |
| 19 | +## Overview |
| 20 | + |
| 21 | +Partial Messages Extensions allow users to transmit only a small part of a |
| 22 | +message rather than a full message. This is especially useful in cases where |
| 23 | +there is a large messages and a peer is missing only a small part of the |
| 24 | +message. |
| 25 | + |
| 26 | +## Terms and Definitions |
| 27 | + |
| 28 | +**Full Message**: A Gossipsub Message. |
| 29 | + |
| 30 | +**Message Part**: The smallest verifiable part of a message. |
| 31 | + |
| 32 | +**Partial Message**: A group of one or more message parts. |
| 33 | + |
| 34 | +**Group ID**: An identifier to some Full Message. This must not depend on |
| 35 | +knowing the full message, so it can not simply be a hash of the full message. |
| 36 | + |
| 37 | +## Motivation |
| 38 | + |
| 39 | +The main motivation for this extension is optimizing Ethereum's Data |
| 40 | +Availability (DA) protocol. In Ethereum's upcoming fork, Fusaka, custodied data |
| 41 | +is laid out in a matrix per block, where the rows represent user data (called |
| 42 | +blobs), and the columns represent a slice across all blobs included in the block |
| 43 | +(each blob slice in the column is called a cell). These columns are propagated |
| 44 | +with Gossipsub. At the time of writing it is common for a node to already have |
| 45 | +all the blobs from its mempool, but in cases where it doesn't (~38%[1]) have |
| 46 | +_all_ of the blobs it almost always has _most_ of the blobs (today, it almost |
| 47 | +always has all but one [1]). |
| 48 | + |
| 49 | +This extension would allow nodes to only request the column message part |
| 50 | +belonging to the missing blob. Reducing the network resource usage |
| 51 | +significantly. As an example, if there are 32 blob cells in a column and the |
| 52 | +node has all but one cell, this would result in a transfer of 2KiB rather than |
| 53 | +64KiB per column. and since nodes custody at least 8 columns, the total savings |
| 54 | +per slot is around 500KiB, or 4 Megabits per slot. |
| 55 | + |
| 56 | +Later, partial messages could enable further optimizations: |
| 57 | +- If cells can be validated individually, as in the case of DAS, partial |
| 58 | + messages could also be forwarded, allowing us to reduce the store-and-forward |
| 59 | + delay [2]. |
| 60 | +- Finally, in the FullDAS construct, where both row and column topics are |
| 61 | + defined, partial messages allow cross-forwarding cells between these topics |
| 62 | + [2]. |
| 63 | + |
| 64 | +## Advantage of Partial Messages over smaller Gossipsub Messages |
| 65 | + |
| 66 | +Partial Messages within a group imply some structure and correlation. Thus, |
| 67 | +multiple partial messages can be referenced succinctly. For example, parts can |
| 68 | +be referenced by bitmaps, ranges, or a bloom filter. |
| 69 | + |
| 70 | +The structure of partial messages in a group, as well as how partial messages |
| 71 | +are referenced is application defined. |
| 72 | + |
| 73 | +If, in some application, a group only ever contained a single partial message, |
| 74 | +then partial messages would be the same as smaller messages. |
| 75 | + |
| 76 | + |
| 77 | +## Protocol Messages |
| 78 | + |
| 79 | +The following section specifies the semantics of each new protocol message. |
| 80 | + |
| 81 | +### PartialIWANT |
| 82 | + |
| 83 | +A `PartialIWANT` signal to a receiver that the sending peer only wants a part of |
| 84 | +some message. |
| 85 | + |
| 86 | +The message to which the peer is requesting a part of is identified by the |
| 87 | +`groupID` identifier. This is similar to a complete message's `MessageID`, but, |
| 88 | +in contrast to a content-based message id, does not require the full message to |
| 89 | +compute. For example, in the Ethereum use case, this could simply be the hash of |
| 90 | +the signed block header. |
| 91 | + |
| 92 | +The `topicID` references the Gossipsub topic a message, and thus its parts, |
| 93 | +belong to. |
| 94 | + |
| 95 | +The `metadata` field is opaque application defined metadata associated with this |
| 96 | +request. This can be a bitmap, a list of ranges, or a bloom filter. The |
| 97 | +application generates this and consumes this. |
| 98 | + |
| 99 | +A later `PartialIWANT` serve to refine the request of prior a prior `PartialIWANT`. |
| 100 | + |
| 101 | +Nodes SHOULD assume a `PartialIWANT` implies a `IDONTWANT` for the full message. |
| 102 | + |
| 103 | +### PartialIDONTWANT |
| 104 | + |
| 105 | +PartialIDONTWANT serves to cancel any and all pending `PartialIWANTs`. |
| 106 | + |
| 107 | +Implementations SHOULD NOT send a `PartialIHAVE` to a peer with parts that the |
| 108 | +peer has previously signaled disinterest for with a `PartialIDONTWANT`. |
| 109 | + |
| 110 | +### PartialIHAVE |
| 111 | + |
| 112 | +A `PartialIHAVE` allows nodes to signal HAVE information before receiving all |
| 113 | +segments, unlocking the use of `PartialIWANT` in more contexts. |
| 114 | + |
| 115 | +In the context of partial messages, it is more useful than IHAVE as it includes |
| 116 | +the group ID. In contrast, an IHAVE does not. A receiving peer has no way to |
| 117 | +link an IHAVE's message ID with a group ID, without having the full message. |
| 118 | + |
| 119 | +A `PartialIHAVE` message can be used both in the context of lazy push, notifying |
| 120 | +peers about available parts, and in the context of heartbeats as a replacement |
| 121 | +to IHAVEs. |
| 122 | + |
| 123 | +The structure of `PartialIHAVE` is analogous to that of `PartialIWANT`. |
| 124 | + |
| 125 | +The metadata, as in a `PartialIWANT`, is application defined. It is some encoding |
| 126 | +that represents the parts the sender has. |
| 127 | + |
| 128 | +Implementations are free to select when to send an update to their peers based |
| 129 | +on signaling bandwidth tradeoff considerations. |
| 130 | + |
| 131 | +## Application Interface |
| 132 | + |
| 133 | +Message contents are application defined. Thus splitting a message must be |
| 134 | +application defined. Applications should provide a Partial Message type that |
| 135 | +supports the following operations: |
| 136 | + |
| 137 | +1. `.GroupID() -> GroupID: bytes` |
| 138 | +2. `.PartialMessageBytesFromMetadata(metadata: bytes) -> Result<(EncodedPartialMessage: bytes, metadata: bytes), Error>` (When responding to a `PartialIWANT` or eagerly pushing a partial message) |
| 139 | + a. The returned metadata represents the still missing parts. For example, if a |
| 140 | + peer is only able to fulfill a part of the the request, the returned |
| 141 | + metadata represents the parts it couldn't fulfill. |
| 142 | +3. `.ExtendFromEncodedPartialMessage(data: bytes) -> Result<(), Error>` (When receiving a `PartialMessage`) |
| 143 | +4. `.MissingParts() -> Result<metadata: bytes, Error>` (For `PartialIWANT`) |
| 144 | +5. `.AvailableParts() -> Result<metadata: bytes, Error>` (For `PartialIHAVE`) |
| 145 | + |
| 146 | +Gossipsub in turn provides a `.PublishPartial(PartialMessage)` method. |
| 147 | + |
| 148 | +Note that this specific interface is not intended to be normative to |
| 149 | +implementations, rather, it is high level summary of what each layer should |
| 150 | +provide. |
| 151 | + |
| 152 | +## Protobuf |
| 153 | + |
| 154 | +```protobuf |
| 155 | +syntax = "proto2"; |
| 156 | +
|
| 157 | +message PartialMessagesExtension { |
| 158 | + optional bytes topicID = 1; |
| 159 | + optional bytes groupID = 2; |
| 160 | +
|
| 161 | + optional PartialMessage message = 3; |
| 162 | + optional PartialIWANT iwant = 4; |
| 163 | + optional PartialIDONTWANT idontwant = 5; |
| 164 | + optional PartialIHAVE ihave = 6; |
| 165 | +} |
| 166 | +
|
| 167 | +message PartialMessage { |
| 168 | + optional bytes data = 1; |
| 169 | +} |
| 170 | +
|
| 171 | +message PartialIWANT { |
| 172 | + optional bytes metadata = 1; |
| 173 | +} |
| 174 | +
|
| 175 | +message PartialIDONTWANT {} |
| 176 | +
|
| 177 | +message PartialIHAVE { |
| 178 | + optional bytes metadata = 1; |
| 179 | +} |
| 180 | +
|
| 181 | +``` |
| 182 | + |
| 183 | +## Open Questions |
| 184 | + |
| 185 | +- Do we want to add a TTL to PartialIWANTs? This would allow us to cancel them after some time. |
| 186 | +- Should we rename the metadata bytes to iwant and ihave? |
| 187 | +- In the bitmap usecase, iwant/ihave are simply inverses of each other. Do we need to send them both? |
| 188 | +- There's a bit of extra complexity around assuming opaque metadata, is it worth it? |
| 189 | + |
| 190 | +[1]: https://ethresear.ch/t/is-data-available-in-the-el-mempool/22329 |
| 191 | +[2]: https://ethresear.ch/t/fulldas-towards-massive-scalability-with-32mb-blocks-and-beyond/19529#possible-extensions-13 |
0 commit comments