1- # gossipsub v1.4: Message preamble to limit duplicate transmissions of large messages
1+ # gossipsub v1.4: PREAMBLE and IMRECEIVING to limit duplicate transmissions of large messages
22
33| Lifecycle Stage | Maturity | Status | Latest Revision |
44| -----------------| ---------------------------| --------| -----------------|
5- | 1A | Working Draft | Active | r0, 2024-12-17 |
5+ | 1A | Working Draft | Active | r1, 2025-05-01 |
66
77Authors: [ @ufarooqstatus ] , [ @kaiserd ]
88
@@ -31,18 +31,19 @@ Under the current arrangement, if IHAVE announcements are received for a message
3131the receiver may generate multiple IWANT requests, triggering unnecessary retransmissions of the same message.
3232Higher message reception time also increases the probability of simultaneously receiving the same message from many peers.
3333
34- Prepending a preamble while sending a large message can allow receivers
35- to immediately gain insights into the IDs and lengths of the messages they are receiving.
36- This can allow receivers to defer IWANT requests for messages they are currently receiving,
34+ Sending a short control message, called PREAMBLE, before every large message transmission
35+ can allow receivers to immediately gain insights into the IDs and lengths of the messages they are receiving.
36+ This allows receivers to defer IWANT requests for messages they are already receiving,
3737thereby reducing the number of unnecessary IWANT requests.
3838
3939At the same time, receivers may inform their mesh members about ongoing message reception.
40- For this purpose, a new control message (IMReceiving ) is introduced,
41- indicating that the peer sending IMReceiving message is currently receiving messages identified by their message IDs ,
40+ For this purpose, a new control message (IMRECEIVING ) is introduced,
41+ indicating that the peer sending IMRECEIVING is currently receiving a message identified by the announced message ID ,
4242and sending duplicates might be unnecessary.
4343
44- On receiving an IMReceiving message, a peer should defer sending of messages identified by the message IDs in IMReceiving message.
45- This can lead to a significant reduction in bandwidth utilization and message latency.
44+ On receiving an IMRECEIVING message, a peer should refrain from sending the message identified by the announced message ID.
45+ This can lead to a significant reduction in bandwidth utilization and message latency.
46+ The [ Safety Strategy] ( #safety-strategy ) below safeguards against malicious behavior.
4647
4748# Specification
4849
@@ -57,81 +58,113 @@ prefix, by default this is `meshsub` giving the default protocol id:
5758
5859This section lists the configuration parameters that clients need to agree on to avoid peer penalizations.
5960
60- | Parameter | Description | Reasonable Default |
61- | --------------------------| ------------------------------------------------------------------| -------------- |
62- | ` peer_preamble_announcements ` | The maximum number of preamble announcements for unfinished transfers per peer | 1??? |
63- | ` mesh_preamble_announcements ` | The maximum number of preamble announcements to accept for unfinished transfers per topic per heartbeat interval | 3??? |
64- | ` max_iwant_requests ` | The maximum number of simultaneous IWANT requests for a message | 1??? |
65- | ` preamble_threshold ` | The smallest message size to use message preamble | 200KB??? |
61+ | Parameter | Description |
62+ | --------------------------| ------------------------------------------------------------------|
63+ | ` peer_preamble_announcements ` | The maximum number of PREAMBLE announcements for unfinished transfers per peer |
64+ | ` max_iwant_requests ` | The maximum number of simultaneous IWANT requests for a message |
65+ | ` preamble_threshold ` | The minimum message size (in bytes) required to enable the use of a message PREAMBLE |
66+ | ` fallback_mode ` | Message fetching strategy (pull or push) to use when a peer fails to deliver the message after sending a PREAMBLE. |
6667
6768
6869
69- ## Message Preamble
70+ ## Message PREAMBLE
7071
7172### Basic scenario
7273
7374When a peer starts relaying a message that exceeds the preamble_threshold size,
74- it may include a control message ( called message preamble) at the start of the message .
75+ it should transmit a preceding control message called PREAMBLE .
7576
76- The purpose of the preamble is to allow receivers to instantly learn about the incoming message.
77- The preamble must include the message ID and length,
77+ PREAMBLE serves as a commitment from the sender,
78+ indicating that the promised data message will follow without delay.
79+ A PREAMBLE must include the message ID and length,
7880providing receivers with immediate access to critical information about the incoming message.
79- The receiver must immediately process a message preamble without waiting to download the entire message.
81+ The receiver must immediately process a PREAMBLE without waiting to download the entire message.
8082
81- On receiving a preamble that advertises a message ID not present in the seen cache,
83+ On receiving a PREAMBLE that advertises a message ID not present in the seen cache,
8284a receiver should add that message ID to the ongoing_receives list.
83- The ongoing_receives list is crucial in limiting IWANT requests and simultaneous reception of the same message from mesh peers.
84-
85- The receiver may use message length to leniently estimate message download time .
86- If the message is successfully downloaded before the estimated download time has elapsed,
85+ The ongoing_receives list is crucial in limiting IWANT requests and simultaneous receptions of the same message from mesh peers.
86+
87+ The receiver may use message length to conservatively estimate message download duration .
88+ If the message is successfully downloaded before the estimated download duration has elapsed,
8789the message ID is removed from the ongoing_receives list and added to the seen cache.
8890
8991If the download takes longer than the estimated download time,
90- the sender may be penalized through P4 to discourage peers from intentionally delaying message transmission.
92+ the sender may be penalized through a behavioral penalty to discourage peers from intentionally delaying message transmission.
93+ See also [ Safety Strategy] ( #safety-strategy ) below.
9194
92- The message preamble is considered _ optional_ for both the sender and the receiver.
93- This means that the sender may choose not to prepend the preamble ,
94- and the receiver may also opt to ignore it.
95- Adding a message preamble may increase control overhead for small messages.
95+ PREAMBLE is considered _ optional_ for both the sender and the receiver.
96+ This means that the sender can choose not to send the PREAMBLE ,
97+ and the receiver can also opt to ignore it.
98+ Adding a PREAMBLE may increase control overhead for small messages.
9699Therefore, it is preferable to use it only for messages that exceed the preamble_threshold.
97100
98101
99102### Limiting IWANT Requests
100103
101104When a peer receives an IHAVE announcement for a message ID not present in the seen cache,
102- the peer must also check the ongoing_receives list before making an IWANT request.
105+ the peer must also check the ongoing_receives list before making an IWANT request.
103106
104107If the message ID is found in the ongoing_receives list,
105108the peer should postpone sending the IWANT request for a defer_interval.
106- The defer_interval may be based on the message download time .
109+ The defer_interval may be based on the estimated message download duration .
107110
108111If the message download completes before the defer_interval expires,
109112the IWANT request for that message will not be generated.
110113However, if the defer_interval elapses and the download has not completed,
111114the peer can proceed to make the IWANT request for the missing message.
112115
113- The total number of outstanding IWANT requests for a single message should not exceed max_iwant_requests.
114- Every peer must respond to the received IWANT requests.
115- Failing to do so may result in behavioural penalty through P7.
116+ The total number of outstanding IWANT requests for a single message must not exceed max_iwant_requests.
117+ Every peer must respond to incoming IWANT requests as long as the number of responses remains within the limits
118+ defined by [ gossipsub v1.1] ( https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md ) .
119+ Failing to do so should result in a behavioral penalty.
116120This will discourage peers from intentionally not replying to IWANT requests.
117121
118- ### IMReceiving Message
122+ ### IMRECEIVING Message
119123
120- The IMReceiving message serves a distinct purpose compared to the IDONTWANT message.
124+ The IMRECEIVING message serves a distinct purpose compared to the IDONTWANT message.
121125An IDONTWANT can only be transmitted after receiving the entire message.
122- In contrast, an IMReceiving should be transmitted immediately after receiving a preamble indicating a large message transfer.
123- The IMReceiving message requests peers to refrain from resending a large message that is already being received.
126+ In contrast, an IMRECEIVING should be transmitted immediately after receiving a PREAMBLE, indicating an ongoing large message reception.
127+ The IMRECEIVING message requests peers in the full message mesh to refrain from resending a large message that is already being received.
124128
125- When a peer receives a message preamble indicating a message ID that is not present in the seen cache,
126- it should send an IMReceiving message to the nodes in its full message mesh.
129+ When a peer receives a PREAMBLE indicating a message ID that is not present in the seen cache and ongoing_receives list ,
130+ it should send IMRECEIVING messages to the nodes in its full message mesh.
127131On receiving an IMReceiving from a peer,
128- a node should postpone sending the messages indicated by the IMReceiving to that peer.
129- The defer_interval can be leniently estimated based on the message length.
130-
131- An IDONTWANT from the peer will indicate successful reception of the message.
132- If an IDONTWANT for the deferred message is not received and the defer_interval has elapsed,
133- the node may proceed to transmit the message.
134-
132+ a node should refrain from sending the message indicated by the IMRECEIVING to that peer.
133+
134+ A corresponding IDONTWANT from the peer that issued IMRECEIVING will indicate successful reception of the message.
135+ Otherwise, the peers in the full message may proceed with a push-based or a pull-based operation depending upon the selected fallback_mode.
136+ See [ Safety Strategy] ( #safety-strategy ) below.
137+
138+
139+ ## Safety Strategy
140+
141+ A malicious peer can attempt to exploit this approach by sending a PREAMBLE but
142+ never completing (or deliberately delaying) the promised message transfer or
143+ by misrepresenting the message size,
144+ potentially hindering the message propagation across the network.
145+ A simple defense mechanism can remedy this problem.
146+
147+ - A peer must accept and process a PREAMBLE only from mesh members and only once for any message ID.
148+ - A peer must limit the maximum number of PREAMBLE announcements for unfinished message transfers to peer_preamble_announcements.
149+ - A peer must extract the message ID and length from PREAMBLE to report in IMRECEIVING announcements.
150+ - A peer must ignore a received IMRECEIVING message if the reported length field does not correspond to the announced message ID.
151+ - If a peer identifies a misrepresented length field in a received PREAMBLE, it must penalize the sender for an invalid message.
152+
153+ Upon receiving a PREAMBLE, a peer uses the length field to conservatively estimate message transfer duration,
154+ ensuring sufficient time allocation for message reception.
155+ If a message transfer is not complete during the estimated duration,
156+ the sender is penalized through a behavioral penalty,
157+ and message retrieval is performed based on a pull-based or a push-based strategy,
158+ as selected by the fallback_mode.
159+
160+ In a pull-based strategy, the peer receiving the message uses an IWANT request to fetch the message.
161+ The peer can infer message availability at mesh members through received IDONTWANT announcements.
162+ In a push-based model, mesh members proactively send the message
163+ if they do not receive a corresponding IDONTWANT announcement within the estimated message transfer duration.
164+ Mesh members can derive a conservative estimate for duration based on the length field.
165+
166+ Negative scoring helps prune non-conforming peers,
167+ whereas the fallback strategy helps recover from incomplete message transfers.
135168
136169## Protobuf Extension
137170
0 commit comments