Skip to content

Commit

Permalink
simplify to just bump coefficient
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Dec 6, 2024
1 parent bfece62 commit 553c5f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const ATTESTATION_PROPAGATION_SLOT_RANGE = 32;

/** 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;
export const GOSSIP_MAX_SIZE_BELLATRIX = 15 * 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;
export const MAX_CHUNK_SIZE_BELLATRIX = 15 * MAX_CHUNK_SIZE;

export enum GoodByeReasonCode {
CLIENT_SHUTDOWN = 1,
Expand Down
9 changes: 1 addition & 8 deletions packages/beacon-node/src/network/gossip/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export function msgIdFn(gossipTopicCache: GossipTopicCache, msg: Message): Uint8
export class DataTransformSnappy implements DataTransform {
constructor(
private readonly gossipTopicCache: GossipTopicCache,
/** size of the compressed message */
private readonly maxSizePerMessage: number
) {}

Expand All @@ -80,13 +79,7 @@ export class DataTransformSnappy implements DataTransform {
* - `outboundTransform()`: compress snappy payload
*/
inboundTransform(topicStr: string, data: Uint8Array): Uint8Array {
if (data.length > this.maxSizePerMessage) {
throw Error(`ssz_snappy data length ${data.length} > maxSizePerMessage`);
}

// snappy compression efficiency is around ~36% so the max uncompressed bound
// should be 3X
const uncompressedData = uncompress(data, 3 * this.maxSizePerMessage);
const uncompressedData = uncompress(data, this.maxSizePerMessage);

// check uncompressed data length before we extract beacon block root, slot or
// attestation data at later steps
Expand Down

0 comments on commit 553c5f3

Please sign in to comment.