Skip to content

Commit 8e42e17

Browse files
committed
Simplify the fields and remove message nesting.
There is no longer a separation between iwant/ihave
1 parent 3f134d2 commit 8e42e17

File tree

2 files changed

+27
-62
lines changed

2 files changed

+27
-62
lines changed

pubsub/gossipsub/extensions/extensions.proto

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,9 @@ message PartialMessagesExtension {
5151
optional bytes topicID = 1;
5252
optional bytes groupID = 2;
5353

54-
optional PartialMessage message = 3;
55-
optional PartialIWANT iwant = 4;
56-
optional PartialIHAVE ihave = 5;
57-
}
58-
59-
message PartialMessage {
60-
optional bytes data = 1;
61-
}
62-
63-
message PartialIWANT {
64-
optional bytes metadata = 1;
65-
}
54+
// An encoded partial message
55+
optional bytes partialMessage = 3;
6656

67-
message PartialIHAVE {
68-
optional bytes metadata = 1;
57+
// An encoded representation of the parts a peer has and wants.
58+
optional bytes partsMetadata = 4;
6959
}

pubsub/gossipsub/partial-messages.md

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -80,52 +80,28 @@ then partial messages would be the same as smaller messages.
8080

8181
The following section specifies the semantics of each new protocol message.
8282

83-
### PartialIWANT
83+
### partialMessage
8484

85-
A `PartialIWANT` signal to a receiver that the sending peer only wants a part of
86-
some message.
85+
The `partialMessage` field encodes one or more parts of the full message. The
86+
encoding is application defined.
8787

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.
88+
### partsMetadata
9389

94-
The `topicID` references the Gossipsub topic a message, and thus its parts,
95-
belong to.
90+
The `partsMetadata` field encodes the parts a peer has and wants. The encoding
91+
is application defined. An unset value carries no information besides that the
92+
peer did not send a value.
9693

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.
94+
Upon receiving a `partsMetadata` a node SHOULD respond with only parts the peer
95+
wants.
10096

101-
A later `PartialIWANT` serve to refine the request of prior a prior `PartialIWANT`.
97+
A later `partsMetadata` replaces a prior one.
10298

103-
Nodes SHOULD assume a `PartialIWANT` implies a `IDONTWANT` for the full message.
104-
105-
### PartialIHAVE
106-
107-
A `PartialIHAVE` allows nodes to signal HAVE information before receiving all
108-
segments, unlocking the use of `PartialIWANT` in more contexts.
109-
110-
In the context of partial messages, it is more useful than IHAVE as it includes
111-
the group ID. In contrast, an IHAVE does not. A receiving peer has no way to
112-
link an IHAVE's message ID with a group ID, without having the full message.
113-
114-
A `PartialIHAVE` message can be used both in the context of lazy push, notifying
115-
peers about available parts, and in the context of heartbeats as a replacement
116-
to IHAVEs.
117-
118-
The structure of `PartialIHAVE` is analogous to that of `PartialIWANT`.
119-
120-
The metadata, as in a `PartialIWANT`, is application defined. It is some encoding
121-
that represents the parts the sender has.
99+
`partsMetadata` can be used during heartbeat gossip to inform non-mesh topic
100+
peers about parts this node has.
122101

123102
Implementations are free to select when to send an update to their peers based
124103
on signaling bandwidth tradeoff considerations.
125104

126-
Receivers MUST treat a `PartialIHAVE` as a signal that the peer does not want
127-
the indicated part.
128-
129105
### Changes to `SubOpts` and interaction with the existing Gossipsub mesh.
130106

131107
Partial Messages uses the same mesh as normal Gossipsub messages. It is a
@@ -144,25 +120,24 @@ The partial field value MUST be ignored when a peer sends an unsubscribe message
144120

145121
## Application Interface
146122

147-
Message contents are application defined. Thus splitting a message must be
123+
This specific interface is not intended to be normative to implementations, it
124+
is only an example of one possible API.
125+
126+
Message contents are application defined, thus splitting a message must be
148127
application defined. Applications should provide a Partial Message type that
149128
supports the following operations:
150129

151130
1. `.GroupID() -> GroupID: bytes`
152-
2. `.PartialMessageBytesFromMetadata(metadata: bytes) -> Result<(EncodedPartialMessage: bytes, metadata: bytes), Error>` (When responding to a `PartialIWANT` or eagerly pushing a partial message)
153-
a. The returned metadata represents the still missing parts. For example, if a
154-
peer is only able to fulfill a part of the the request, the returned
155-
metadata represents the parts it couldn't fulfill.
156-
3. `.ExtendFromEncodedPartialMessage(data: bytes) -> Result<(), Error>` (When receiving a `PartialMessage`)
157-
4. `.MissingParts() -> Result<metadata: bytes, Error>` (For `PartialIWANT`)
158-
5. `.AvailableParts() -> Result<metadata: bytes, Error>` (For `PartialIHAVE`)
131+
2. `.PartialMessageBytes(partsMetadata: bytes) -> Result<(EncodedPartialMessage: bytes, newPartsMetadata: bytes), Error>`
132+
a. The method should return an encoded partial message with just the parts the
133+
peer requested.
134+
b. The returned `newPartsMetadata` can be used to track parts that could not
135+
be fulfilled. This allows the GossipSub library to avoid sending duplicate
136+
parts to the same peer.
137+
3. `.PartsMetadata() -> bytes`
159138

160139
Gossipsub in turn provides a `.PublishPartial(PartialMessage)` method.
161140

162-
Note that this specific interface is not intended to be normative to
163-
implementations, rather, it is high level summary of what each layer should
164-
provide.
165-
166141
## Protobuf
167142

168143
Refer to the protobuf registry at `./extensions/extensions.proto`

0 commit comments

Comments
 (0)