-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add maxMessageSize option to pubsub #634
Changes from all commits
7be8bf1
652084b
eeecf76
df67e96
0ec65c1
cf04783
67f06e9
eba4e4c
c6d0d52
568c8c6
7e8fdcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,14 @@ type | |
anonymize*: bool # if we omit fromPeer and seqno from RPC messages we send | ||
subscriptionValidator*: SubscriptionValidator # callback used to validate subscriptions | ||
topicsHigh*: int # the maximum number of topics a peer is allowed to subscribe to | ||
maxMessageSize*: int ##\ | ||
## the maximum raw message size we'll globally allow | ||
## for finer tuning, check message size on topic validator | ||
## | ||
## sending a big message to a peer with a lower size limit can | ||
## lead to issues, from descoring to connection drops | ||
## | ||
## defaults to 1mB | ||
rng*: ref BrHmacDrbgContext | ||
|
||
knownTopics*: HashSet[string] | ||
|
@@ -285,7 +293,7 @@ proc getOrCreatePeer*( | |
p.onPubSubPeerEvent(peer, event) | ||
|
||
# create new pubsub peer | ||
let pubSubPeer = PubSubPeer.new(peerId, getConn, dropConn, onEvent, protos[0]) | ||
let pubSubPeer = PubSubPeer.new(peerId, getConn, dropConn, onEvent, protos[0], p.maxMessageSize) | ||
debug "created new pubsub peer", peerId | ||
|
||
p.peers[peerId] = pubSubPeer | ||
|
@@ -540,6 +548,7 @@ proc init*[PubParams: object | bool]( | |
sign: bool = true, | ||
msgIdProvider: MsgIdProvider = defaultMsgIdProvider, | ||
subscriptionValidator: SubscriptionValidator = nil, | ||
maxMessageSize: int = 1024 * 1024, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is the 1mb limit from? we used to have 64 kb - ideally we'd use the same limit as "Defaults" in other impls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec half-says it, and it's the default in go-libp2p. |
||
rng: ref BrHmacDrbgContext = newRng(), | ||
parameters: PubParams = false): P | ||
{.raises: [Defect, InitializationError].} = | ||
|
@@ -553,6 +562,7 @@ proc init*[PubParams: object | bool]( | |
sign: sign, | ||
msgIdProvider: msgIdProvider, | ||
subscriptionValidator: subscriptionValidator, | ||
maxMessageSize: maxMessageSize, | ||
rng: rng, | ||
topicsHigh: int.high) | ||
else: | ||
|
@@ -565,6 +575,7 @@ proc init*[PubParams: object | bool]( | |
msgIdProvider: msgIdProvider, | ||
subscriptionValidator: subscriptionValidator, | ||
parameters: parameters, | ||
maxMessageSize: maxMessageSize, | ||
rng: rng, | ||
topicsHigh: int.high) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs a deeper explanation, for the risk of getting descored on networks with different limits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But note that this limit doesn't apply to sending message, even with a low
maxRecvMessageSize
, you could still send big messages