Skip to content

Switch apache milagro with herumi/bls-wasm - #570

Merged
mpetrunic merged 8 commits into
masterfrom
mpetrunic/bls-wasm
Dec 3, 2019
Merged

Switch apache milagro with herumi/bls-wasm#570
mpetrunic merged 8 commits into
masterfrom
mpetrunic/bls-wasm

Conversation

@mpetrunic

Copy link
Copy Markdown
Member
  • api is still intact (thank you wrappers haha)
  • there are some additional methods like (PrivateKey.from(int)) - should replace that custom pk generation
  • still needs arguments checking and exception catching
  • It should be possible to turn off order checking (big performance improvement) but I can't figure out how to call that wasm method)

resolves #566

@mpetrunic
mpetrunic requested a review from a team November 28, 2019 11:27
@github-actions github-actions Bot added the BLS label Nov 28, 2019
@codecov

codecov Bot commented Nov 28, 2019

Copy link
Copy Markdown

Codecov Report

Merging #570 into master will decrease coverage by 1.28%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master     #570      +/-   ##
==========================================
- Coverage   64.83%   63.54%   -1.29%     
==========================================
  Files         199      196       -3     
  Lines        3609     3454     -155     
  Branches      329      318      -11     
==========================================
- Hits         2340     2195     -145     
+ Misses       1172     1165       -7     
+ Partials       97       94       -3

Comment thread packages/bls/package.json
ec2
ec2 previously approved these changes Nov 28, 2019
@ec2

ec2 commented Nov 28, 2019

Copy link
Copy Markdown
Contributor

Other than the thing about versioning, lgtm

@wemeetagain wemeetagain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Much simpler.

Separate thought, if we simplify our code (eg: validator and keystore code), we probably won't even need to use the OO interface to bls, maybe just use a simple IKeypair interface :)

interface IKeypair {
  private: Buffer;
  public: Buffer;
}

and the functional interface exported here in this file

function getPublicKey(priv: Buffer): Buffer;
function sign(priv: Buffer, msg: Buffer, domain: Buffer): Buffer;
function aggregateSignatures(sigs: Buffer[]): Buffer;
function aggregatePublicKeys(pubs: Buffer[]): Buffer;
function verify(pub: Buffer, msg: Buffer, sig: Buffer, domain: Buffer): boolean;
function verifyMultiple(pubs: Buffer[], msgs: Buffer[], sig: Buffer, domain: Buffer): boolean;

Comment thread packages/bls/src/index.ts Outdated
@mpetrunic

mpetrunic commented Nov 28, 2019

Copy link
Copy Markdown
Member Author

Looks great! Much simpler.

Separate thought, if we simplify our code (eg: validator and keystore code), we probably won't even need to use the OO interface to bls, maybe just use a simple IKeypair interface :)

interface IKeypair {
  private: Buffer;
  public: Buffer;
}

and the functional interface exported here in this file

function getPublicKey(priv: Buffer): Buffer;
function sign(priv: Buffer, msg: Buffer, domain: Buffer): Buffer;
function aggregateSignatures(sigs: Buffer[]): Buffer;
function aggregatePublicKeys(pubs: Buffer[]): Buffer;
function verify(pub: Buffer, msg: Buffer, sig: Buffer, domain: Buffer): boolean;
function verifyMultiple(pubs: Buffer[], msgs: Buffer[], sig: Buffer, domain: Buffer): boolean;

Actually, I was thinking of removing those functional interfaces as they are somewhat slower and much less optimized (you have to deserialize buffer and allocate new array to create internal wasm implementation format). Example, keeping PrivateKey instance and using sign method on that instance removes unnecessary deserialization and allocation.

We could see potential speed up if we convert, our validator registry public keys into PublicKey instances once and just use instances. It would shave ~20-30% time on every aggregation and verification

@wemeetagain

Copy link
Copy Markdown
Member

I see, good point. Public keys would be a good thing to store with an "optimized beacon state", along with the committees and other things.
We definitely shouldn't remove the functional interface though, as its convenient in the naive case. Buffer in, buffer out.

@mpetrunic
mpetrunic merged commit 37f269f into master Dec 3, 2019
@mpetrunic
mpetrunic deleted the mpetrunic/bls-wasm branch December 3, 2019 15:15
lodekeeper added a commit to lodekeeper/lodestar that referenced this pull request Feb 16, 2026
End-to-end proposer preferences implementation:

**Beacon Node:**
- New gossip topic `proposer_preferences` with validation, scoring, queue config
- ProposerPreferencesPool + SeenProposerPreferences (with pruning)
- Validation: epoch+1 check, proposer lookahead match, dedup, BLS signature
- Bid validation: require matching preferences (fee_recipient + gas_limit)
- API: POST /eth/v1/validator/proposer_preferences (submit)
- API: GET /eth/v1/beacon/pool/proposer_preferences (query)
- SSE event: proposer_preferences
- Metrics: pool size, gossip/api insert outcomes

**Validator Client:**
- pollProposerPreferences: epoch-boundary polling, queries next-epoch proposer
  duties, signs preferences with fee_recipient/gas_limit, submits to BN
- ValidatorStore.signProposerPreferences with DOMAIN_PROPOSER_PREFERENCES
- External signer support (PROPOSER_PREFERENCES message type)

**State Transition:**
- getProposerPreferencesSigningRoot helper

Addresses beacon-APIs ChainSafe#570 and ChainSafe#435.
Resolves TODO GLOAS comments in bid validation.

Generated with assistance from AI (Codex CLI + Claude).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLS herumi wasm

3 participants