mirror of
https://github.com/logos-co/nomos-node.git
synced 2026-08-27 09:31:10 +00:00
fix(network): gossipsub max transmit size
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<usize, TestConfigError> {
|
||||
Ok(channels)
|
||||
}
|
||||
|
||||
fn inscription_payload_bytes_from_env() -> Result<usize, TestConfigError> {
|
||||
let raw = env::var("LOGOS_INSCRIPTION_PAYLOAD_BYTES")
|
||||
.unwrap_or_else(|_| DEFAULT_PAYLOAD_BYTES.to_string());
|
||||
|
||||
let payload_bytes = raw
|
||||
.parse::<usize>()
|
||||
.map_err(|source| TestConfigError::InvalidPayloadBytes { raw, source })?;
|
||||
|
||||
if payload_bytes == 0 {
|
||||
return Err(TestConfigError::ZeroPayloadBytes);
|
||||
}
|
||||
|
||||
Ok(payload_bytes)
|
||||
}
|
||||
|
||||
fn run_duration_from_env() -> Result<Duration, TestConfigError> {
|
||||
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<dyn std::error::
|
||||
|
||||
let external_nodes = external_nodes_from_env()?;
|
||||
let inscription_channels = channels_from_env()?;
|
||||
let inscription_payload_bytes = inscription_payload_bytes_from_env()?;
|
||||
let run_duration = run_duration_from_env()?;
|
||||
|
||||
let deployer = LbcLocalDeployer::new();
|
||||
@@ -118,7 +142,11 @@ async fn external_urls_inscription_workload() -> Result<(), Box<dyn std::error::
|
||||
|
||||
let mut scenario = builder
|
||||
.with_external_only_sources()
|
||||
.inscriptions_with(|inscriptions| inscriptions.channels(inscription_channels))
|
||||
.inscriptions_with(|inscriptions| {
|
||||
inscriptions
|
||||
.channels(inscription_channels)
|
||||
.inscription_payload_bytes(inscription_payload_bytes)
|
||||
})
|
||||
.with_run_duration(run_duration)
|
||||
.build()?;
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ use crate::{
|
||||
workloads::{ClusterForkMonitor, ConsensusLiveness, inscription, transaction},
|
||||
};
|
||||
|
||||
const DEFAULT_PAYLOAD_BYTES: usize = 128;
|
||||
|
||||
pub type ScenarioBuilder = CoreScenarioBuilder<LbcEnv>;
|
||||
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> {
|
||||
NonZeroUsize::new(users)
|
||||
const fn nonzero_usize(value: usize) -> Option<NonZeroUsize> {
|
||||
NonZeroUsize::new(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user