Skip to content

Commit

Permalink
feat: make aggregateWithRandomness async
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed Oct 29, 2024
1 parent e2e634d commit 0e8b55e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/bls/multithread/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
try {
// Note: This can throw, must be handled per-job.
// Pubkey and signature aggregation is defered here
workReq = jobItemWorkReq(job, this.metrics);
workReq = await jobItemWorkReq(job, this.metrics);
} catch (e) {
this.metrics?.blsThreadPool.errorAggregateSignatureSetsCount.inc({type: job.type});

Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/src/chain/bls/multithread/jobItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PublicKey, aggregateWithRandomness} from "@chainsafe/blst";
import {PublicKey, asyncAggregateWithRandomness} from "@chainsafe/blst";
import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition";
import {VerifySignatureOpts} from "../interface.js";
import {getAggregatedPubkey} from "../utils.js";
Expand Down Expand Up @@ -48,7 +48,7 @@ export function jobItemSigSets(job: JobQueueItem): number {
* Prepare BlsWorkReq from JobQueueItem
* WARNING: May throw with untrusted user input
*/
export function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null): BlsWorkReq {
export async function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null): Promise<BlsWorkReq> {
switch (job.type) {
case JobQueueItemType.default:
return {
Expand All @@ -70,7 +70,7 @@ export function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null): BlsW
// and not a problem in the near future
// this is monitored on v1.21.0 https://github.com/ChainSafe/lodestar/pull/6894/files#r1687359225
const timer = metrics?.blsThreadPool.aggregateWithRandomnessMainThreadDuration.startTimer();
const {pk, sig} = aggregateWithRandomness(job.sets.map((set) => ({pk: set.publicKey, sig: set.signature})));
const {pk, sig} = await asyncAggregateWithRandomness(job.sets.map((set) => ({pk: set.publicKey, sig: set.signature})));
timer?.();

return {
Expand Down

0 comments on commit 0e8b55e

Please sign in to comment.