From 91dd6b362e1d12678017e7100b3cc35b0957542f Mon Sep 17 00:00:00 2001 From: Andrus Salumets Date: Mon, 2 Mar 2026 21:02:46 +0700 Subject: [PATCH] fix(network): gossipsub max transmit size --- libp2p/src/behaviour/mod.rs | 2 +- .../external_urls_inscription.rs | 30 ++++++++++++++++++- tests/testing_framework/src/framework/mod.rs | 29 +++++++++++------- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/libp2p/src/behaviour/mod.rs b/libp2p/src/behaviour/mod.rs index bbdb7cc7b..5564e8a15 100644 --- a/libp2p/src/behaviour/mod.rs +++ b/libp2p/src/behaviour/mod.rs @@ -21,7 +21,7 @@ pub mod gossipsub; pub mod kademlia; pub mod nat; -const DATA_LIMIT: usize = 1 << 16; // Do not serialize/deserialize more than 256 KiB +const DATA_LIMIT: usize = 16 * 1024 * 1024; // 16 MiB (gossipsub default is 64 KiB) pub(crate) struct BehaviourConfig { pub gossipsub_config: libp2p::gossipsub::Config, diff --git a/tests/src/tests/testing_framework/external_urls_inscription.rs b/tests/src/tests/testing_framework/external_urls_inscription.rs index fff86eef4..be68263e7 100644 --- a/tests/src/tests/testing_framework/external_urls_inscription.rs +++ b/tests/src/tests/testing_framework/external_urls_inscription.rs @@ -10,6 +10,7 @@ use testing_framework_core::scenario::{Deployer as _, ExternalNodeSource}; use thiserror::Error; const DEFAULT_CHANNELS: usize = 8; +const DEFAULT_PAYLOAD_BYTES: usize = 128; const DEFAULT_RUN_DURATION_SECS: u64 = 60 * 60; #[derive(Debug, Error)] @@ -25,6 +26,13 @@ enum TestConfigError { }, #[error("inscription channel count must be > 0")] ZeroChannels, + #[error("invalid --inscription-payload-bytes value '{raw}': {source}")] + InvalidPayloadBytes { + raw: String, + source: std::num::ParseIntError, + }, + #[error("inscription payload bytes must be > 0")] + ZeroPayloadBytes, #[error("invalid --run-duration-secs value '{raw}': {source}")] InvalidRunDuration { raw: String, @@ -71,6 +79,21 @@ fn channels_from_env() -> Result { Ok(channels) } +fn inscription_payload_bytes_from_env() -> Result { + let raw = env::var("LOGOS_INSCRIPTION_PAYLOAD_BYTES") + .unwrap_or_else(|_| DEFAULT_PAYLOAD_BYTES.to_string()); + + let payload_bytes = raw + .parse::() + .map_err(|source| TestConfigError::InvalidPayloadBytes { raw, source })?; + + if payload_bytes == 0 { + return Err(TestConfigError::ZeroPayloadBytes); + } + + Ok(payload_bytes) +} + fn run_duration_from_env() -> Result { let raw = env::var("LOGOS_WORKLOAD_DURATION_SECS") .unwrap_or_else(|_| DEFAULT_RUN_DURATION_SECS.to_string()); @@ -103,6 +126,7 @@ async fn external_urls_inscription_workload() -> Result<(), Box Result<(), Box; pub type ScenarioBuilderWith = ScenarioBuilder; @@ -205,7 +207,8 @@ impl ScenarioBuilderExt for ScenarioBuilderWith { InscriptionFlowBuilder { builder: self, channels: NonZeroUsize::MIN, - payload_bytes: NonZeroUsize::new(128).expect("constant is non-zero"), + inscription_payload_bytes: NonZeroUsize::new(DEFAULT_PAYLOAD_BYTES) + .expect("constant is non-zero"), } } @@ -225,7 +228,7 @@ impl ScenarioBuilderExt for ScenarioBuilderWith { } fn initialize_wallet(self, total_funds: u64, users: usize) -> Self { - let Some(user_count) = nonzero_users(users) else { + let Some(user_count) = nonzero_usize(users) else { tracing::warn!( users, "wallet user count must be non-zero; ignoring initialize_wallet" @@ -269,7 +272,7 @@ impl TransactionFlowBuilder { } pub fn users(mut self, users: usize) -> Self { - if let Some(value) = nonzero_users(users) { + if let Some(value) = nonzero_usize(users) { self.users = Some(value); } else { tracing::warn!( @@ -290,12 +293,12 @@ impl TransactionFlowBuilder { pub struct InscriptionFlowBuilder { builder: ScenarioBuilderWith, channels: NonZeroUsize, - payload_bytes: NonZeroUsize, + inscription_payload_bytes: NonZeroUsize, } impl InscriptionFlowBuilder { pub fn channels(mut self, channels: usize) -> Self { - if let Some(value) = nonzero_users(channels) { + if let Some(value) = nonzero_usize(channels) { self.channels = value; } else { tracing::warn!( @@ -307,9 +310,9 @@ impl InscriptionFlowBuilder { self } - pub fn payload_bytes(mut self, payload_bytes: usize) -> Self { - if let Some(value) = nonzero_users(payload_bytes) { - self.payload_bytes = value; + pub fn inscription_payload_bytes(mut self, payload_bytes: usize) -> Self { + if let Some(value) = nonzero_usize(payload_bytes) { + self.inscription_payload_bytes = value; } else { tracing::warn!( payload_bytes, @@ -320,14 +323,18 @@ impl InscriptionFlowBuilder { self } + pub fn payload_bytes(self, payload_bytes: usize) -> Self { + self.inscription_payload_bytes(payload_bytes) + } + pub fn apply(self) -> ScenarioBuilderWith { let workload = inscription::Workload::default() .with_channel_count(self.channels) - .with_payload_bytes(self.payload_bytes); + .with_payload_bytes(self.inscription_payload_bytes); self.builder.with_workload(workload) } } -const fn nonzero_users(users: usize) -> Option { - NonZeroUsize::new(users) +const fn nonzero_usize(value: usize) -> Option { + NonZeroUsize::new(value) }