You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/phase0/p2p-interface.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,12 +268,21 @@ This defines both the type of data being sent on the topic and how the data fiel
268
268
-`Encoding` - the encoding strategy describes a specific representation of bytes that will be transmitted over the wire.
269
269
See the [Encodings](#Encodings) section for further details.
270
270
271
+
Messages with unknown `topic` must be ignored.
272
+
271
273
*Note*: `ForkDigestValue` is composed of values that are not known until the genesis block/state are available.
272
274
Due to this, clients SHOULD NOT subscribe to gossipsub topics until these genesis values are known.
273
275
274
-
Each gossipsub [message](https://github.com/libp2p/go-libp2p-pubsub/blob/master/pb/rpc.proto#L17-L24) has a maximum size of `GOSSIP_MAX_SIZE`.
275
-
Clients MUST reject (fail validation) messages that are over this size limit.
276
-
Likewise, clients MUST NOT emit or propagate messages larger than this limit.
276
+
The uncompressed payload in the [`data`](https://github.com/libp2p/go-libp2p-pubsub/blob/c06df2f9a38e9382e644b241adf0e96e5ca00955/pb/rpc.proto#L19)
277
+
must have has a length no greater than `GOSSIP_MAX_SIZE`.
278
+
279
+
After compression, the payload in the `data` field must have a size no greater than
280
+
`32 + GOSSIP_MAX_SIZE + GOSSIP_MAX_SIZE / 6` (rounded down), as given by the
281
+
[snappy maximum compressed length function](https://github.com/google/snappy/blob/32ded457c0b1fe78ceb8397632c416568d6714a0/snappy.cc#L218C1-L218C47).
282
+
283
+
Clients MUST reject (fail validation) messages with payloads that are over these size limits.
284
+
Likewise, clients MUST NOT emit or propagate messages larger than these limits.
285
+
Clients MAY reject messages whose maximum uncompressed size exceed the maximum possible encoded length of the payload based on its SSZ encoding, when this limit is lower than `GOSSIP_MAX_SIZE`.
277
286
278
287
The optional `from` (1), `seqno` (3), `signature` (5) and `key` (6) protobuf fields are omitted from the message,
279
288
since messages are identified by content, anonymous, and signed where necessary in the application layer.
@@ -288,6 +297,8 @@ The `message-id` of a gossipsub message MUST be the following 20 byte value comp
288
297
the concatenation of `MESSAGE_DOMAIN_INVALID_SNAPPY` with the raw message data,
289
298
i.e. `SHA256(MESSAGE_DOMAIN_INVALID_SNAPPY + message.data)[:20]`.
290
299
300
+
Messages with `message-id` values of lengths other than 20 bytes must be rejects.
301
+
291
302
*Note*: The above logic handles two exceptional cases:
292
303
(1) multiple snappy `data` can decompress to the same value,
293
304
and (2) some message `data` can fail to snappy decompress altogether.
0 commit comments