mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Grow the yamux buffers to exceed the maximum message size
This commit is contained in:
@@ -211,6 +211,9 @@ impl fmt::Debug for LibP2p {
|
|||||||
impl LibP2p {
|
impl LibP2p {
|
||||||
#[allow(clippy::new_without_default)]
|
#[allow(clippy::new_without_default)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
// Block size limit + 1 KB of space for signatures/metadata
|
||||||
|
const MAX_LIBP2P_MESSAGE_SIZE: usize = tributary::BLOCK_SIZE_LIMIT + 1024;
|
||||||
|
|
||||||
log::info!("creating a libp2p instance");
|
log::info!("creating a libp2p instance");
|
||||||
|
|
||||||
let throwaway_key_pair = Keypair::generate_ed25519();
|
let throwaway_key_pair = Keypair::generate_ed25519();
|
||||||
@@ -218,9 +221,6 @@ impl LibP2p {
|
|||||||
|
|
||||||
let behavior = Behavior {
|
let behavior = Behavior {
|
||||||
gossipsub: {
|
gossipsub: {
|
||||||
// Block size limit + 1 KB of space for signatures/metadata
|
|
||||||
const MAX_LIBP2P_MESSAGE_SIZE: usize = tributary::BLOCK_SIZE_LIMIT + 1024;
|
|
||||||
|
|
||||||
let heartbeat_interval = tributary::tendermint::LATENCY_TIME / 2;
|
let heartbeat_interval = tributary::tendermint::LATENCY_TIME / 2;
|
||||||
let heartbeats_per_block =
|
let heartbeats_per_block =
|
||||||
usize::try_from(tributary::tendermint::TARGET_BLOCK_TIME / heartbeat_interval).unwrap();
|
usize::try_from(tributary::tendermint::TARGET_BLOCK_TIME / heartbeat_interval).unwrap();
|
||||||
@@ -276,7 +276,15 @@ impl LibP2p {
|
|||||||
// TODO: Relay client?
|
// TODO: Relay client?
|
||||||
let mut swarm = SwarmBuilder::with_existing_identity(throwaway_key_pair)
|
let mut swarm = SwarmBuilder::with_existing_identity(throwaway_key_pair)
|
||||||
.with_tokio()
|
.with_tokio()
|
||||||
.with_tcp(TcpConfig::default().nodelay(true), noise::Config::new, yamux::Config::default)
|
.with_tcp(TcpConfig::default().nodelay(true), noise::Config::new, || {
|
||||||
|
let mut config = yamux::Config::default();
|
||||||
|
// 1 MiB default + max message size
|
||||||
|
config.set_max_buffer_size((1024 * 1024) + MAX_LIBP2P_MESSAGE_SIZE);
|
||||||
|
// 256 KiB default + max message size
|
||||||
|
config
|
||||||
|
.set_receive_window_size(((256 * 1024) + MAX_LIBP2P_MESSAGE_SIZE).try_into().unwrap());
|
||||||
|
config
|
||||||
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_behaviour(|_| behavior)
|
.with_behaviour(|_| behavior)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
Reference in New Issue
Block a user