-
Notifications
You must be signed in to change notification settings - Fork 8
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
Vc/io1 2884 improvements #37
Conversation
src/lib/SSVKeys.ts
Outdated
} | ||
async extractKeys(data: string, password: string): Promise<ExtractedKeys> { | ||
const privateKey = await new EthereumKeyStore(data).getPrivateKey(password); | ||
await bls.init(bls.BLS12_381); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I look inside of bls.init method and it's heavy. If we need parallel workers to be fast we should init it only once. Please implement this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meshin-blox please review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadiminc I don't see it is initializing only once, did you commit it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i did, it ones. extractKeys always works as "entry point". just as exception is that someone will want to work with Threshold directly, on that case we have "try catch" to understand if need to init anyway in low level @meshin-blox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you take a look here:
https://github.com/bloxapp/ssv-keys/pull/37/files#diff-c127a9a3b0b9b65b6bb86b567f9cd4013f3f8b0bb89019301c2846b3882e7157L56
extractKeys is called inside of expressjs route, it means that each time you run this endpoint in parallel nature it will run bls.init, and inside of it it will do that heavy work each time, even more - with the same instance of bls object.
Regarding the fact that ssv-keys strictly works with only one BLS type (12_381), to initialize it only once and bring simple check:
if (!this.initialized) bls.init()
examples/server-worker/index.ts
Outdated
const ssvKeys = new SSVKeys(SSVKeys.VERSION.V3); | ||
const privateKey = await ssvKeys.getPrivateKeyFromKeystoreData(keystore, password) | ||
const encryptedShares = await ssvKeys.buildShares(privateKey, operators_ids, operators_keys); | ||
const ssvKeys = new SSVKeys(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if you will init bls only once, you still need to extract new SSVKeys
into level outside of express route
Fixes #<issue_number_goes_here>