Skip to content

Commit

Permalink
Update the gossip max chunk size to bellatrix specs (#4450)
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech authored Aug 19, 2022
1 parent 31a8368 commit 7b3134e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/beacon-node/src/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export type RpcResponseStatusError = Exclude<RespStatus, RespStatus.SUCCESS>;

/** The maximum allowed size of uncompressed gossip messages. */
export const GOSSIP_MAX_SIZE = 2 ** 20;
export const GOSSIP_MAX_SIZE_BELLATRIX = 10 * GOSSIP_MAX_SIZE;
/** The maximum allowed size of uncompressed req/resp chunked responses. */
export const MAX_CHUNK_SIZE = 2 ** 20;
export const MAX_CHUNK_SIZE_BELLATRIX = 10 * MAX_CHUNK_SIZE;
/** The maximum time to wait for first byte of request response (time-to-first-byte). */
export const TTFB_TIMEOUT = 5 * 1000; // 5 sec
/** The maximum time for complete response transfer. */
Expand Down
13 changes: 10 additions & 3 deletions packages/beacon-node/src/network/gossip/gossipsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Map2d, Map2dArr} from "../../util/map.js";
import {Eth2Context} from "../../chain/index.js";
import {PeersData} from "../peers/peersData.js";
import {ClientKind} from "../peers/client.js";
import {GOSSIP_MAX_SIZE} from "../../constants/network.js";
import {GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_BELLATRIX} from "../../constants/network.js";
import {
GossipJobQueues,
GossipTopic,
Expand Down Expand Up @@ -97,6 +97,7 @@ export class Eth2Gossipsub extends Gossipsub {
const gossipTopicCache = new GossipTopicCache(modules.config);

const scoreParams = computeGossipPeerScoreParams(modules);
const {config, logger, metrics, signal, gossipHandlers, peersData} = modules;

// Gossipsub parameters defined here:
// https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#the-gossip-domain-gossipsub
Expand All @@ -119,13 +120,19 @@ export class Eth2Gossipsub extends Gossipsub {
gossipsubIWantFollowupMs: 12 * 1000, // 12s
fastMsgIdFn: fastMsgIdFn,
msgIdFn: msgIdFn.bind(msgIdFn, gossipTopicCache),
dataTransform: new DataTransformSnappy(GOSSIP_MAX_SIZE),
// Use the bellatrix max size if the merge is configured. pre-merge using this size
// could only be an issue on outgoing payloads, its highly unlikely we will send out
// a chunk bigger than GOSSIP_MAX_SIZE pre merge even on mainnet network.
//
// TODO: figure out a way to dynamically transition to the size
dataTransform: new DataTransformSnappy(
isFinite(config.BELLATRIX_FORK_EPOCH) ? GOSSIP_MAX_SIZE_BELLATRIX : GOSSIP_MAX_SIZE
),
metricsRegister: modules.metrics ? ((modules.metrics.register as unknown) as MetricsRegister) : null,
metricsTopicStrToLabel: modules.metrics ? getMetricsTopicStrToLabel(modules.config) : undefined,
asyncValidation: true,
});
this.scoreParams = scoreParams;
const {config, logger, metrics, signal, gossipHandlers, peersData} = modules;
this.config = config;
this.logger = logger;
this.peersData = peersData;
Expand Down

0 comments on commit 7b3134e

Please sign in to comment.