Skip to content

Commit e5af917

Browse files
authored
Gossipsub v1.3: Extensions control Message
2 parents 0caf71b + e539bd6 commit e5af917

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Test Extension
2+
3+
| Lifecycle Stage | Maturity | Status | Latest Revision |
4+
| --------------- | ------------- | ------ | --------------- |
5+
| 1A | Working Draft | Active | r0, 2025-06-23 |
6+
7+
Authors: [@marcopolo]
8+
9+
Interest Group: @jxs
10+
11+
[@marcopolo]: https://github.com/marcopolo
12+
[@jxs]: https://github.com/jxs
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+
This introduces a minimal extension to Gossipsub. The only motivation is to
22+
test the interoperability of Gossipsub Extensions Control Message across
23+
implementations. One way for example, is to connect different implementations
24+
together and assert that both peers send the TestExtension message.
25+
26+
## The Protocol
27+
28+
If both Peers support the Test Extension, each peer MUST send a TestExtension
29+
Message.
30+
31+
## Protobuf
32+
33+
```protobuf
34+
syntax = "proto2";
35+
36+
message TestExtension {}
37+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
syntax = "proto2";
2+
3+
message ControlExtensions {
4+
// Initially empty. Future canonical extensions will be added here along with
5+
// a reference to their specification.
6+
7+
// Experimental extensions must use field numbers larger than 0x200000 to be
8+
// encoded with at least 4 bytes
9+
10+
optional bool testExtension = 6492434;
11+
}
12+
13+
message ControlMessage {
14+
repeated ControlIHave ihave = 1;
15+
repeated ControlIWant iwant = 2;
16+
repeated ControlGraft graft = 3;
17+
repeated ControlPrune prune = 4;
18+
repeated ControlIDontWant idontwant = 5;
19+
optional ControlExtensions extensions = 6;
20+
}
21+
22+
message RPC {
23+
message SubOpts {
24+
optional bool subscribe = 1; // subscribe or unsubcribe
25+
optional string topicid = 2;
26+
}
27+
28+
repeated SubOpts subscriptions = 1;
29+
repeated Message publish = 2;
30+
optional ControlMessage control = 3;
31+
32+
// Canonical Extensions should register their messages here.
33+
34+
// Experimental Extensions should register their messages here. They
35+
// must use field numbers larger than 0x200000 to be encoded with at least 4
36+
// bytes
37+
38+
optional TestExtension testExtension = 6492434;
39+
}

pubsub/gossipsub/gossipsub-v1.3.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# gossipsub v1.3: Extensions Control Message
2+
3+
| Lifecycle Stage | Maturity | Status | Latest Revision |
4+
| --------------- | ------------------------ | ------ | --------------- |
5+
| 3A | Candidate Recommendation | Active | r0, 2025-06-23 |
6+
7+
Authors: [@marcopolo]
8+
9+
Interest Group: [@cortze], [@cskiraly], [@ppopth], [@jxs], [@raulk], [@divagant-martian]
10+
11+
[@marcopolo]: https://github.com/marcopolo
12+
[@cortze]: https://github.com/cortze
13+
[@cskiraly]: https://github.com/cskiraly
14+
[@ppopth]: https://github.com/ppopth
15+
[@jxs]: https://github.com/jxs
16+
[@raulk]: https://github.com/raulk
17+
[@divagant-martian]: https://github.com/divagant-martian
18+
19+
See the [lifecycle document][lifecycle-spec] for context about the maturity level
20+
and spec status.
21+
22+
[lifecycle-spec]: https://github.com/libp2p/specs/blob/master/00-framework-01-spec-lifecycle.md
23+
24+
## Overview
25+
26+
This version specifies a way to for gossipsub peers to describe their
27+
characteristics to each other without requiring a new protocol ID per extension.
28+
29+
The extensions.proto file registry MUST be updated upon introducing a new
30+
extension, either canonical or experimental, to the network.
31+
32+
## Motivation
33+
34+
This version makes Gossipsub easier to extend by allowing applications to
35+
selectively make use of the extensions it would benefit from. It removes the
36+
need to make Gossipsub extensions follow a strict ordering. Finally, it allows
37+
extensions to iterate independently from Gossipsub's versioning.
38+
39+
## The Extensions Control Message
40+
41+
If a peer supports any extension, the Extensions control message MUST be
42+
included in the first message on the stream. An Extensions control message MUST
43+
NOT be sent more than once. If a peer supports no extensions, it may omit
44+
sending the Extensions control message.
45+
46+
Extensions are not negotiated; they describe characteristics of the sending peer
47+
that can be used by the receiving peer. However, a negotiation can be implied:
48+
each peer uses the Extensions control message to advertise a set of supported
49+
values. The specification of an extension describes how each peer combines the
50+
two sets to define its behavior.
51+
52+
Peers MUST ignore unknown extensions.
53+
54+
Extensions that modify or replace core protocol functionality will be difficult
55+
to combine with other extensions that modify or replace the same functionality
56+
unless the behavior of the combination is explicitly defined. Such extensions
57+
SHOULD define their interaction with previously defined extensions modifying the
58+
same protocol components.
59+
60+
## Protocol ID
61+
62+
The Gossipsub version for this specification is `v1.3.0`. The protocol ID is
63+
`/meshsub/1.3.0`.
64+
65+
## Process to add a new extensions to this spec
66+
67+
### Canonical Extensions
68+
69+
A Canonical Extension is an extension that is well defined, has multiple
70+
implementations, has shown to be useful in real networks, and has rough
71+
consensus on becoming a canonical extension. The extension specification MUST be
72+
defined in the `libp2p/specs` GitHub repo. After an extension meets the stated
73+
criteria, `extensions.proto` MUST be updated to include the extension in the
74+
`ControlExtensions` protobuf with a link to the extension's specification doc in
75+
a comment. The extension SHOULD use the next lowest available field number.
76+
77+
Any new messages defined by the extension MUST be added to `RPC` message
78+
definition in the `extensions.proto` protobuf. Extensions SHOULD minimize the
79+
number of new messages they introduce here. Try to introduce a single new
80+
message, and use that message as a container for more messages similar to the
81+
strategy used by the ControlMessage in the RPC.
82+
83+
All extension messages MUST be an `optional` field.
84+
85+
### Experimental Extensions
86+
87+
In contrast with a Canonical Extension, an Experimental Extension is still being
88+
evaluated and iterated upon. Adding an experimental extension to the
89+
`extensions.proto` lets others see what is being tried, and ensure there are no
90+
misinterpretations of messages on the wire. A patch to this `extensions.proto`
91+
is not needed if experimenting with an extension in a controlled environment. A
92+
patch to `extensions.proto` is also not needed if you are not using the
93+
`/meshsub/v1.3.0` protocol ID.
94+
95+
If the extension is being tested on a live network, a PR MUST be created that
96+
adds the extension to the `ControlExtensions` protobuf with a link to the
97+
extension's specification. Experimental extensions MUST use a large field number
98+
randomly generated to be at least 4 bytes long when varint encoded. The
99+
extension author MUST ensure this field number does not conflict with any
100+
existing field.
101+
102+
New messages defined by this extension should follow the same guidelines as new
103+
messages for canonical extensions. Field numbers MUST be randomly generated and
104+
be at least 4 bytes long when varint encoded.
105+
106+
Maintainers MUST check that the extension is well specified, in the experimental
107+
range, and that the extension will be tested on a live network. If so,
108+
maintainers SHOULD merge the change.
109+
110+
## Protobuf
111+
112+
The `extensions.proto` file can be found at
113+
(`./extensions/extensions.proto`)[./extensions/extensions.proto].
114+
115+
Implementations MUST use the protobuf messages defined in the `extensions.proto`
116+
file.

0 commit comments

Comments
 (0)