From bc1537b2abf58a86327533881bd8fdeaaf6e509f Mon Sep 17 00:00:00 2001 From: twoeths Date: Mon, 13 May 2024 10:02:58 +0300 Subject: [PATCH] feat: disable flood publish (#6755) * feat: disable flood publish * feat: add network.disableFloodPublish cli flag * chore: address PR comments --- packages/beacon-node/src/network/gossip/gossipsub.ts | 4 ++++ packages/cli/src/options/beaconNodeOptions/network.ts | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/beacon-node/src/network/gossip/gossipsub.ts b/packages/beacon-node/src/network/gossip/gossipsub.ts index c9d839292242..81e3b1b67c48 100644 --- a/packages/beacon-node/src/network/gossip/gossipsub.ts +++ b/packages/beacon-node/src/network/gossip/gossipsub.ts @@ -53,6 +53,7 @@ export type Eth2GossipsubOpts = { gossipsubDLow?: number; gossipsubDHigh?: number; gossipsubAwaitHandler?: boolean; + disableFloodPublish?: boolean; skipParamsLog?: boolean; }; @@ -128,6 +129,9 @@ export class Eth2Gossipsub extends GossipSub { maxOutboundBufferSize: MAX_OUTBOUND_BUFFER_SIZE, // serialize message once and send to all peers when publishing batchPublish: true, + // if this is false, only publish to mesh peers. If there is not enough GOSSIP_D mesh peers, + // publish to some more topic peers to make sure we always publish to at least GOSSIP_D peers + floodPublish: !opts?.disableFloodPublish, }); this.scoreParams = scoreParams; this.config = config; diff --git a/packages/cli/src/options/beaconNodeOptions/network.ts b/packages/cli/src/options/beaconNodeOptions/network.ts index 74463f9aa1ce..25ba036a5dbf 100644 --- a/packages/cli/src/options/beaconNodeOptions/network.ts +++ b/packages/cli/src/options/beaconNodeOptions/network.ts @@ -32,6 +32,7 @@ export type NetworkArgs = { "network.gossipsubDLow"?: number; "network.gossipsubDHigh"?: number; "network.gossipsubAwaitHandler"?: boolean; + "network.disableFloodPublish"?: boolean; "network.rateLimitMultiplier"?: number; "network.maxGossipTopicConcurrency"?: number; "network.useWorker"?: boolean; @@ -149,6 +150,7 @@ export function parseArgs(args: NetworkArgs): IBeaconNodeOptions["network"] { gossipsubDLow: args["network.gossipsubDLow"], gossipsubDHigh: args["network.gossipsubDHigh"], gossipsubAwaitHandler: args["network.gossipsubAwaitHandler"], + disableFloodPublish: args["network.disableFloodPublish"], mdns: args["mdns"], rateLimitMultiplier: args["network.rateLimitMultiplier"], maxGossipTopicConcurrency: args["network.maxGossipTopicConcurrency"], @@ -360,6 +362,13 @@ export const options: CliCommandOptions = { group: "network", }, + "network.disableFloodPublish": { + hidden: true, + description: "Disable gossipsub flood publish", + type: "boolean", + group: "network", + }, + "network.rateLimitMultiplier": { type: "number", description: "The multiplier to increase the rate limits. Set to zero to disable rate limiting.",