Skip to content

Commit b90b21b

Browse files
committed
Add supportsPartial field to subopts
Let's a peer signal support for partial messages on a per-topic basis. This makes future rollouts of partial messages on new topics much easier as nodes can explicitly signal their support of partial messages per topic.
1 parent 442f51a commit b90b21b

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

pubsub/gossipsub/extensions/extensions.proto

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ message RPC {
2525
optional string topicid = 2;
2626

2727
// Used with Partial Messages extension.
28-
// If set, the receiver of this message MUST send partial messages to the
29-
// sender instead of full messages.
30-
optional bool partial = 3;
28+
// If set, signals to the receiver that the sender prefers partial messages.
29+
optional bool requestsPartial = 3;
30+
// If set, signals to the receiver that the sender supports sending partial
31+
// messages on this topic. If requestsPartial is true, this is assumed to be
32+
// true.
33+
optional bool supportsPartial = 4;
3134
}
3235

3336
repeated SubOpts subscriptions = 1;

pubsub/gossipsub/partial-messages.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,53 @@ on signaling bandwidth tradeoff considerations.
104104

105105
### Changes to `SubOpts` and interaction with the existing Gossipsub mesh.
106106

107-
Partial Messages uses the same mesh as normal Gossipsub messages. It is a
108-
replacement to "full" messages. A node requests a peer to use partial messages
109-
for a specific topic by setting the `partial` field in the `SubOpts` message.
110107
The `SubOpts` message is how a peer subscribes to a topic.
111108

112-
If a node receives a subscribe request with the `partial` field set to true, and
113-
it supports the partial message extension, it MUST send partial messages instead
114-
of full messages.
109+
Partial Messages uses the same mesh as normal Gossipsub messages. It is a
110+
replacement to "full" messages. A node requests a peer to send partial messages
111+
for a specific topic by setting the `requestsPartial` field in the `SubOpts`
112+
message to true. A node signals support for sending partial messages on a given
113+
topic by setting the `supportsPartial` field in `SubOpts` to true. A node can
114+
support sending partial messages without wanting to receive them.
115+
116+
If a node requests partial messages, it MUST support partial messages.
117+
118+
A node uses a peer's `supportsPartial` setting to know if it can send a partial
119+
message request to a peer. It uses its `requestsPartial` setting to know whether
120+
to send send the peer a full message or a partial message.
121+
122+
If a peer supports partial messages on a topic but did not request them, a node
123+
MUST omit the `partialMessage` field of the `PartialMessagesExtension` message.
115124

116125
If a node does not support the partial message extension, it MUST ignore the
117-
`partial` field. This is the default behavior of protobuf parsers.
126+
`request_partial` and `supports_partial` fields. This is the default behavior of
127+
protobuf parsers.
128+
129+
The `request_partial` and `supports_partial` fields value MUST be ignored when a
130+
peer sends an unsubscribe message `SubOpts.subscribe=false`.
131+
132+
#### Behavior table
133+
134+
The following table describes the expected behavior of receiver of a `SubOpts`
135+
message for a given topic.
136+
137+
| SubOpts.requests_partial | behavior of receiver that supports partial messages for the topic |
138+
| ------------------------ | ------------------------------------------------------------------------------------------------- |
139+
| true | The receiver SHOULD send partial messages (data and metadata) to this peer. |
140+
| false | receiver MUST NOT send partial message data to this peer. The receiver SHOULD send full messages. |
141+
142+
| SubOpts.requests_partial | behavior of receiver that does not support partial messages for the topic |
143+
| ------------------------ | ------------------------------------------------------------------------- |
144+
| \* | The receiver SHOULD send full messages. |
145+
146+
| SubOpts.supports_partial | behavior of receiver that requested partial messages for the topic |
147+
| ------------------------ | ---------------------------------------------------------------------------------------------------------------- |
148+
| true | The receiver expects the peer to respond to partial message requests, and receive `partsMetadata` from the peer. |
149+
| false | The receiver expects full messages. |
118150

119-
The partial field value MUST be ignored when a peer sends an unsubscribe message
120-
`SubOpts.subscribe=false`.
151+
| SubOpts.supports_partial | behavior of receiver that did not request partial messages for the topic |
152+
| ------------------------ | ------------------------------------------------------------------------ |
153+
| \* | The receiver expects full messages |
121154

122155
## Application Interface
123156

0 commit comments

Comments
 (0)