Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the gossip max chunk size to bellatrix specs #4450

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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