Skip to content

Commit

Permalink
feat: add minSameMessageSignatureSetsToBatch flag
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 17, 2023
1 parent dba7af0 commit d705074
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/beacon-node/src/chain/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type IChainOptions = BlockProcessOpts &
/** Option to load a custom kzg trusted setup in txt format */
trustedSetup?: string;
broadcastValidationStrictness?: string;
minSameMessageSignatureSetsToBatch: number;
};

export type BlockProcessOpts = {
Expand Down Expand Up @@ -83,4 +84,8 @@ export const defaultChainOptions: IChainOptions = {
// for attestation validation, having this value ensures we don't have to regen states most of the time
maxSkipSlots: 32,
broadcastValidationStrictness: "warn",
// should be less than or equal to MIN_SIGNATURE_SETS_TO_BATCH_VERIFY
// batching too much may block the I/O thread
// this value is conservative, can decrease it if useWorker = true
minSameMessageSignatureSetsToBatch: 32,
};
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/validation/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function validateGossipAttestationsSameAttData(
}

let signatureValids: boolean[];
const batchableBls = signatureSets.length >= MIN_SIGNATURE_SETS_TO_BATCH_VERIFY;
const batchableBls = signatureSets.length >= chain.opts.minSameMessageSignatureSetsToBatch;
if (batchableBls) {
// all signature sets should have same signing root since we filtered in network processor
signatureValids = await chain.bls.verifySignatureSetsSameMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const MAX_GOSSIP_ATTESTATION_BATCH_SIZE = 128;
/**
* Batching signatures have the cost of signature aggregation which blocks the main thread.
* We should only batch verify when there are at least 32 signatures.
* TODO: make this configurable
*/
export const MIN_SIGNATURE_SETS_TO_BATCH_VERIFY = 32;

Expand Down
11 changes: 11 additions & 0 deletions packages/cli/src/options/beaconNodeOptions/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type ChainArgs = {
"chain.archiveStateEpochFrequency": number;
emitPayloadAttributes?: boolean;
broadcastValidationStrictness?: string;
"chain.minSameMessageSignatureSetsToBatch"?: number;
};

export function parseArgs(args: ChainArgs): IBeaconNodeOptions["chain"] {
Expand All @@ -46,6 +47,8 @@ export function parseArgs(args: ChainArgs): IBeaconNodeOptions["chain"] {
archiveStateEpochFrequency: args["chain.archiveStateEpochFrequency"],
emitPayloadAttributes: args["emitPayloadAttributes"],
broadcastValidationStrictness: args["broadcastValidationStrictness"],
minSameMessageSignatureSetsToBatch:
args["chain.minSameMessageSignatureSetsToBatch"] ?? defaultOptions.chain.minSameMessageSignatureSetsToBatch,
};
}

Expand Down Expand Up @@ -182,4 +185,12 @@ Will double processing times. Use only for debugging purposes.",
type: "string",
default: "warn",
},

"chain.minSameMessageSignatureSetsToBatch": {
hidden: true,
description: "Minimum number of same message signature sets to batch",
type: "number",
default: defaultOptions.chain.minSameMessageSignatureSetsToBatch,
group: "chain",
},
};
2 changes: 2 additions & 0 deletions packages/cli/test/unit/options/beaconNodeOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("options / beaconNodeOptions", () => {
"safe-slots-to-import-optimistically": 256,
"chain.archiveStateEpochFrequency": 1024,
"chain.trustedSetup": "",
"chain.minSameMessageSignatureSetsToBatch": 32,
emitPayloadAttributes: false,

eth1: true,
Expand Down Expand Up @@ -131,6 +132,7 @@ describe("options / beaconNodeOptions", () => {
archiveStateEpochFrequency: 1024,
emitPayloadAttributes: false,
trustedSetup: "",
minSameMessageSignatureSetsToBatch: 32,
},
eth1: {
enabled: true,
Expand Down

0 comments on commit d705074

Please sign in to comment.