Clarify network limits (#7175)

Resolves #6811


  Rename `GOSSIP_MAX_SIZE` to `MAX_PAYLOAD_SIZE` and remove `MAX_CHUNK_SIZE` in accordance with the spec.

The spec also "clarifies"  the message size limits at different levels. The rpc limits are equivalent to what we had before imo.
The gossip limits have additional checks.

I have gotten rid of the `is_bellatrix_enabled`  checks that used a lower limit (1mb) pre-merge. Since all networks we run start from the merge, I don't think this will break any setups.
This commit is contained in:
Pawan Dhananjay
2025-04-08 19:50:45 -07:00
committed by GitHub
parent d24a4ffe30
commit 076f3f0984
17 changed files with 114 additions and 120 deletions

View File

@@ -14,7 +14,7 @@ use std::num::NonZeroU16;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use types::{ForkContext, ForkName};
use types::ForkContext;
pub const DEFAULT_IPV4_ADDRESS: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
pub const DEFAULT_TCP_PORT: u16 = 9000u16;
@@ -22,18 +22,9 @@ pub const DEFAULT_DISC_PORT: u16 = 9000u16;
pub const DEFAULT_QUIC_PORT: u16 = 9001u16;
pub const DEFAULT_IDONTWANT_MESSAGE_SIZE_THRESHOLD: usize = 1000usize;
/// The maximum size of gossip messages.
pub fn gossip_max_size(is_merge_enabled: bool, gossip_max_size: usize) -> usize {
if is_merge_enabled {
gossip_max_size
} else {
gossip_max_size / 10
}
}
pub struct GossipsubConfigParams {
pub message_domain_valid_snappy: [u8; 4],
pub gossip_max_size: usize,
pub gossipsub_max_transmit_size: usize,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -480,7 +471,6 @@ pub fn gossipsub_config(
}
}
let message_domain_valid_snappy = gossipsub_config_params.message_domain_valid_snappy;
let is_bellatrix_enabled = fork_context.fork_exists(ForkName::Bellatrix);
let gossip_message_id = move |message: &gossipsub::Message| {
gossipsub::MessageId::from(
&Sha256::digest(
@@ -499,10 +489,7 @@ pub fn gossipsub_config(
let duplicate_cache_time = Duration::from_secs(slots_per_epoch * seconds_per_slot * 2);
gossipsub::ConfigBuilder::default()
.max_transmit_size(gossip_max_size(
is_bellatrix_enabled,
gossipsub_config_params.gossip_max_size,
))
.max_transmit_size(gossipsub_config_params.gossipsub_max_transmit_size)
.heartbeat_interval(load.heartbeat_interval)
.mesh_n(load.mesh_n)
.mesh_n_low(load.mesh_n_low)