-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify signatures on both main thread and worker threads (#3793)
* Implement and use BlsMixedVerifier * useMultiThreadVerifier flag * Add useMainThead option * Add blsVerifyAllMultiThread and blsVerifyAllMultiThread flag * Add blsVerifyMainThread flag to block processor * Remove BlsMixedVerifier * Add BLS time metrics * Refactor to verifyOnMainThread and blsVerifyOnMainThread * Use metric.startTimer() * Add comments for blsVerifyOnMainThread usage * Update chain.ts Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>
- Loading branch information
Showing
17 changed files
with
123 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import {ISignatureSet} from "@chainsafe/lodestar-beacon-state-transition"; | ||
import {IMetrics} from "../../metrics"; | ||
import {IBlsVerifier} from "./interface"; | ||
import {verifySignatureSetsMaybeBatch} from "./maybeBatch"; | ||
import {getAggregatedPubkey} from "./utils"; | ||
|
||
export class BlsSingleThreadVerifier implements IBlsVerifier { | ||
private readonly metrics: IMetrics | null; | ||
|
||
constructor({metrics = null}: {metrics: IMetrics | null}) { | ||
this.metrics = metrics; | ||
} | ||
|
||
async verifySignatureSets(sets: ISignatureSet[]): Promise<boolean> { | ||
return verifySignatureSetsMaybeBatch( | ||
sets.map((set) => ({ | ||
publicKey: getAggregatedPubkey(set), | ||
message: set.signingRoot.valueOf() as Uint8Array, | ||
signature: set.signature, | ||
})) | ||
); | ||
const timer = this.metrics?.blsThreadPool.mainThreadDurationInThreadPool.startTimer(); | ||
try { | ||
return verifySignatureSetsMaybeBatch( | ||
sets.map((set) => ({ | ||
publicKey: getAggregatedPubkey(set), | ||
message: set.signingRoot.valueOf() as Uint8Array, | ||
signature: set.signature, | ||
})) | ||
); | ||
} finally { | ||
if (timer) timer(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters