Skip to content
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

feat(gossipsub): apply max_transmit_size to the published message #5642

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ libp2p-core = { version = "0.42.0", path = "core" }
libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" }
libp2p-dns = { version = "0.42.0", path = "transports/dns" }
libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.47.1", path = "protocols/gossipsub" }
libp2p-gossipsub = { version = "0.48.0", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.45.1", path = "protocols/identify" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
Expand Down
5 changes: 5 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.48.0

- Apply `max_transmit_size` to the inner message instead of the final payload.
See [PR 5642](https://github.com/libp2p/rust-libp2p/pull/5642).

## 0.47.1

- Attempt to publish to at least mesh_n peers when flood publish is disabled.
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = { workspace = true }
description = "Gossipsub protocol for libp2p"
version = "0.47.1"
version = "0.48.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
10 changes: 5 additions & 5 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ where
.data_transform
.outbound_transform(&topic, data.clone())?;

// check that the size doesn't exceed the max transmission size.
if transformed_data.len() > self.config.max_transmit_size() {
return Err(PublishError::MessageTooLarge);
}

let raw_message = self.build_raw_message(topic, transformed_data)?;

// calculate the message id from the un-transformed data
Expand All @@ -593,11 +598,6 @@ where
topic: raw_message.topic.clone(),
});

// check that the size doesn't exceed the max transmission size
if raw_message.raw_protobuf_len() > self.config.max_transmit_size() {
return Err(PublishError::MessageTooLarge);
}

// Check the if the message has been published before
if self.duplicate_cache.contains(&msg_id) {
// This message has already been seen. We don't re-publish messages that have already
Expand Down
3 changes: 2 additions & 1 deletion protocols/gossipsub/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ impl Config {

/// The maximum byte size for each gossipsub RPC (default is 65536 bytes).
///
/// This represents the maximum size of the entire protobuf payload. It must be at least
/// This represents the maximum size of the published message. It is additionally wrapped
/// in a protobuf struct, so the actual wire size may be a bit larger. It must be at least
/// large enough to support basic control messages. If Peer eXchange is enabled, this
/// must be large enough to transmit the desired peer information on pruning. It must be at
/// least 100 bytes. Default is 65536 bytes.
Expand Down
Loading