Skip to content

Commit 865d3aa

Browse files
MarcoPolocskiraly
andcommitted
Partial Messages Extension
Co-authored-by: Csaba Kiraly <[email protected]>
1 parent e5af917 commit 865d3aa

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed

pubsub/gossipsub/extensions/extensions.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ message ControlExtensions {
88
// encoded with at least 4 bytes
99

1010
optional bool testExtension = 6492434;
11+
12+
optional bool partialMessages = 16418754;
1113
}
1214

1315
message ControlMessage {
@@ -36,4 +38,6 @@ message RPC {
3638
// bytes
3739

3840
optional TestExtension testExtension = 6492434;
41+
42+
optional PartialMessagesExtension partial = 16418754;
3943
}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
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]). More details of how this integrates with Ethereum
48+
can be found at the [consensus-specs
49+
repo](https://github.com/ethereum/consensus-specs/pull/4558)
50+
51+
This extension would allow nodes to only request the column message part
52+
belonging to the missing blob. Reducing the network resource usage
53+
significantly. As an example, if there are 32 blob cells in a column and the
54+
node has all but one cell, this would result in a transfer of 2KiB rather than
55+
64KiB per column. and since nodes custody at least 8 columns, the total savings
56+
per slot is around 500KiB.
57+
58+
Later, partial messages could enable further optimizations:
59+
- If cells can be validated individually, as in the case of DAS, partial
60+
messages could also be forwarded, allowing us to reduce the store-and-forward
61+
delay [2].
62+
- Finally, in the FullDAS construct, where both row and column topics are
63+
defined, partial messages allow cross-forwarding cells between these topics
64+
[2].
65+
66+
## Advantage of Partial Messages over smaller Gossipsub Messages
67+
68+
Partial Messages within a group imply some structure and correlation. Thus,
69+
multiple partial messages can be referenced succinctly. For example, parts can
70+
be referenced by bitmaps, ranges, or a bloom filter.
71+
72+
The structure of partial messages in a group, as well as how partial messages
73+
are referenced is application defined.
74+
75+
If, in some application, a group only ever contained a single partial message,
76+
then partial messages would be the same as smaller messages.
77+
78+
79+
## Protocol Messages
80+
81+
The following section specifies the semantics of each new protocol message.
82+
83+
### PartialIWANT
84+
85+
A `PartialIWANT` signal to a receiver that the sending peer only wants a part of
86+
some message.
87+
88+
The message to which the peer is requesting a part of is identified by the
89+
`groupID` identifier. This is similar to a complete message's `MessageID`, but,
90+
in contrast to a content-based message id, does not require the full message to
91+
compute. For example, in the Ethereum use case, this could simply be the hash of
92+
the signed block header.
93+
94+
The `topicID` references the Gossipsub topic a message, and thus its parts,
95+
belong to.
96+
97+
The `metadata` field is opaque application defined metadata associated with this
98+
request. This can be a bitmap, a list of ranges, or a bloom filter. The
99+
application generates this and consumes this.
100+
101+
A later `PartialIWANT` serve to refine the request of prior a prior `PartialIWANT`.
102+
103+
Nodes SHOULD assume a `PartialIWANT` implies a `IDONTWANT` for the full message.
104+
105+
### PartialIDONTWANT
106+
107+
PartialIDONTWANT serves to cancel any and all pending `PartialIWANTs`.
108+
109+
Implementations SHOULD NOT send a `PartialIHAVE` to a peer with parts that the
110+
peer has previously signaled disinterest for with a `PartialIDONTWANT`.
111+
112+
### PartialIHAVE
113+
114+
A `PartialIHAVE` allows nodes to signal HAVE information before receiving all
115+
segments, unlocking the use of `PartialIWANT` in more contexts.
116+
117+
In the context of partial messages, it is more useful than IHAVE as it includes
118+
the group ID. In contrast, an IHAVE does not. A receiving peer has no way to
119+
link an IHAVE's message ID with a group ID, without having the full message.
120+
121+
A `PartialIHAVE` message can be used both in the context of lazy push, notifying
122+
peers about available parts, and in the context of heartbeats as a replacement
123+
to IHAVEs.
124+
125+
The structure of `PartialIHAVE` is analogous to that of `PartialIWANT`.
126+
127+
The metadata, as in a `PartialIWANT`, is application defined. It is some encoding
128+
that represents the parts the sender has.
129+
130+
Implementations are free to select when to send an update to their peers based
131+
on signaling bandwidth tradeoff considerations.
132+
133+
## Application Interface
134+
135+
Message contents are application defined. Thus splitting a message must be
136+
application defined. Applications should provide a Partial Message type that
137+
supports the following operations:
138+
139+
1. `.GroupID() -> GroupID: bytes`
140+
2. `.PartialMessageBytesFromMetadata(metadata: bytes) -> Result<(EncodedPartialMessage: bytes, metadata: bytes), Error>` (When responding to a `PartialIWANT` or eagerly pushing a partial message)
141+
a. The returned metadata represents the still missing parts. For example, if a
142+
peer is only able to fulfill a part of the the request, the returned
143+
metadata represents the parts it couldn't fulfill.
144+
3. `.ExtendFromEncodedPartialMessage(data: bytes) -> Result<(), Error>` (When receiving a `PartialMessage`)
145+
4. `.MissingParts() -> Result<metadata: bytes, Error>` (For `PartialIWANT`)
146+
5. `.AvailableParts() -> Result<metadata: bytes, Error>` (For `PartialIHAVE`)
147+
148+
Gossipsub in turn provides a `.PublishPartial(PartialMessage)` method.
149+
150+
Note that this specific interface is not intended to be normative to
151+
implementations, rather, it is high level summary of what each layer should
152+
provide.
153+
154+
## Protobuf
155+
156+
```protobuf
157+
syntax = "proto2";
158+
159+
message PartialMessagesExtension {
160+
optional bytes topicID = 1;
161+
optional bytes groupID = 2;
162+
163+
optional PartialMessage message = 3;
164+
optional PartialIWANT iwant = 4;
165+
optional PartialIDONTWANT idontwant = 5;
166+
optional PartialIHAVE ihave = 6;
167+
}
168+
169+
message PartialMessage {
170+
optional bytes data = 1;
171+
}
172+
173+
message PartialIWANT {
174+
optional bytes metadata = 1;
175+
}
176+
177+
message PartialIDONTWANT {}
178+
179+
message PartialIHAVE {
180+
optional bytes metadata = 1;
181+
}
182+
183+
```
184+
185+
## Open Questions
186+
187+
- Do we want to add a TTL to PartialIWANTs? This would allow us to cancel them after some time.
188+
- Should we rename the metadata bytes to iwant and ihave?
189+
- In the bitmap usecase, iwant/ihave are simply inverses of each other. Do we need to send them both?
190+
- There's a bit of extra complexity around assuming opaque metadata, is it worth it?
191+
192+
[1]: https://ethresear.ch/t/is-data-available-in-the-el-mempool/22329
193+
[2]: https://ethresear.ch/t/fulldas-towards-massive-scalability-with-32mb-blocks-and-beyond/19529#possible-extensions-13

0 commit comments

Comments
 (0)