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
feat: use @chainsafe/blst directly #6706
base: unstable
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #6706 +/- ##
============================================
- Coverage 61.87% 61.87% -0.01%
============================================
Files 557 562 +5
Lines 59209 59305 +96
Branches 1915 1916 +1
============================================
+ Hits 36635 36694 +59
- Misses 22531 22568 +37
Partials 43 43 |
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
@@ -31,7 +40,11 @@ export const testFnByType: Record<string, "skip" | ((data: any) => any)> = { | |||
*/ | |||
function aggregate_verify(input: {pubkeys: string[]; messages: string[]; signature: string}): boolean { | |||
const {pubkeys, messages, signature} = input; | |||
return bls.verifyMultiple(pubkeys.map(fromHexString), messages.map(fromHexString), fromHexString(signature)); | |||
try { |
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.
@wemeetagain I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.
try { | ||
return _verify(fromHexString(message), fromHexString(pubkey), fromHexString(signature)); | ||
} catch { | ||
return false; | ||
} |
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.
@wemeetagain I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.
try { | ||
return aggregateVerify(messages.map(fromHexString), pubkeys.map(fromHexString), fromHexString(signature)); | ||
} catch { | ||
return false; | ||
} |
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.
@wemeetagain I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.
try { | ||
return _verify(fromHexString(message), fromHexString(pubkey), fromHexString(signature)); | ||
} catch { | ||
return false; | ||
} |
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.
@wemeetagain I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.
Metrics on feat2-mainnet do not look great. They should be equal to unstable/stable but seems to be performing worse for some reason... Will try and swap for another feat group tomorrow and see if its the machine |
After running for a while it seems like this branch is actually fine. @tuyennhv would love your opinion as well but I'm going to approve |
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.
Looks good to me, had a suggestion for signatureFromBytes()
util
also signatureFromBytesNoCheck()
should be moved to @lodestar/utils
instead so that both could be consumed by different packages
Added them both to |
@twoeths @philknows Spoke with @wemeetagain and we will merge this one after interop. Should not be an issue but why add more complexity to an already moving target. Can sit for the week and get merged when we get back. All is ready and just waiting for reapproval after the last update for the comment @twoeths had |
let isAllValid = true; | ||
// validate signature = true | ||
const signatures = sets.map((set) => { | ||
try { | ||
return bls.Signature.fromBytes(set.signature, CoordType.affine, true); | ||
const sig = Signature.deserialize(set.signature, CoordType.affine); | ||
sig.sigValidate(); |
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.
use signatureFromBytes() here
pubkeys.map((hex) => bls.PublicKey.fromBytes(fromHexString(hex), CoordType.jacobian, true)), | ||
fromHexString(message) | ||
const sig = Signature.deserialize(fromHexString(signature), undefined); | ||
sig.sigValidate(); |
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.
need to search for all sigValidate()
and replace with signatureFromBytes()
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.
Ok. Good idea!
Motivation
In order to do some optimizations, we want to remove the
@chainsafe/bls
abstraction layer. We know we won't be running the beacon node or validator in node only. In the future, we may relax this restriction if a usecase presents itself.Description
@chainsafe/bls
throughout the monorepo, with the exception of the light client package.toBytes()
->.serialize()
.keyValidate()
or.sigValidate()
.fromBytes()
->.deserialize()
Pubkey.aggregate
,bls.aggregatePubkeys
->aggregatePubkeys
Signature.verifyAggregate
->fastVerifyAggregate