-
-
Notifications
You must be signed in to change notification settings - Fork 289
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: switch bls to napi rebuild #6616
Conversation
… matches for toEqual
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6616 +/- ##
=========================================
Coverage 61.87% 61.87%
=========================================
Files 557 557
Lines 59201 59209 +8
Branches 1915 1915
=========================================
+ Hits 36628 36635 +7
- Misses 22530 22531 +1
Partials 43 43 |
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.
this looks great, looking forward to a release of bls
to move this forward
Co-authored-by: Nico Flaig <nflaig@protonmail.com>
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.
LGTM
@matthewkeil sim tests failed consistently, looks good to me other than that |
Finding lots and lots of tcp errors in the sim test logs.... [node-1-beacon-lodestar] [60618]: 2024-04-24T09:00:53.776Z libp2p:tcp:socket:error encrypting inbound connection to Error: Error occurred during XX handshake: read ECONNRESET failed
[node-1-beacon-lodestar] [60618]: 2024-04-24T09:00:53.776Z libp2p:tcp:socket:error failed to upgrade inbound connection CodeError: Error occurred during XX handshake: read ECONNRESET
at DefaultUpgrader._encryptInbound (file:///Users/matthewkeil/Documents/dev/chainsafe/lodestar/node_modules/libp2p/dist/src/upgrader.js:492:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async DefaultUpgrader.upgradeInbound (file:///Users/matthewkeil/Documents/dev/chainsafe/lodestar/node_modules/libp2p/dist/src/upgrader.js:113:25) {
code: 'ERR_ENCRYPTION_FAILED',
props: {}
} |
@nflaig your wish is my command. Moved the logging of libuv size back to the worker. Wasnt getting logged during tests and that needs to happen so its back "home" now |
@tuyennhv I merged in unstable again to get the old version of libp2p-tcp Fixed the issues I was seeing in the logs |
0b8b4e8
to
b720eab
Compare
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.
Behind this PR is hard work that's been honed and polished for months.
Great work @matthewkeil !
Culmination of: (not including any intermediate branches or PR's, abandoned attempts or unused implementations) |
This reverts commit 97d9aa8.
This reverts commit 97d9aa8.
* chore: n-historical state - track state persist count per epoch (#6699) * feat: add lodestar binaries to release (#6666) * feat: added binaries creation support * feat: added sanity checks * chore: define reusable workflow * chore: fix sanity check,; disable arm64 * chore: added workflow_dispatch * fix: needs cleanup * chore: update old space size Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments * chore: address comments * chore: fixed typo * chore: typo Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments * chore: wording Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: use frozen lock file Co-authored-by: Nico Flaig <nflaig@protonmail.com> --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * feat: switch bls to napi rebuild (#6616) * chore: update package.json deps and run yarn * feat: remove unused blst config from vitest.browser.*.config.ts * test: move G2@INF test to base blst repo. No longer exported. * fix: add Uint8Array.from for Buffer return value in unit test so type matches for toEqual * refactor: update imports of CoordType to use bls instead of blst * feat: add blsAddVerificationRandomness cli option * feat: add randomBytesNonZero to utils * feat: implement verification randomness for same message * feat: implement napi blst and switch to libuv worker pool * chore: lint * fix: update comments for availableParallelism * feat: set UV_THREADPOOL_SIZE for perf tests * feat: set UV_THREADPOOL_SIZE=$(nproc) in lodestar entrance script * feat: remove case for serialized PublicKey in deserializeSet * feat: add back workBusy count logic to canAcceptWork * feat: automatically set threadpool size in beaconHandler * refactor: rename flag to disableSameMessageVerificationRandomness * fix: remove UV_THREADPOOL_SIZE from ./lodestar * docs: add TODO about updating metrics * fix: make benchmark multi threading cross-compatible * chore: add bls@8.0.0 * feat: default to added randomness * feat: add warning for no same message randomness * fix: passing to updated bls functions * feat: add blst peerDep * fix: default to same message randomness * chore: update yarn.lock * chore: remove unused function to clear lint * feat: break out setThreadPoolSize * docs: update packages/cli/src/cmds/beacon/setThreadPoolSize.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: update location for blst dep * chore: run lint again * fix: remove peerDep from light-client * test: fix browser based tests * fix: bad relative imports * docs: add note to readme about switchable bls * docs: typo * chore: lint readme * fix: light-client unit tests * fix: light-client e2e test * feat: remove disableSameMessageVerificationRandomness * refactor: remove unused type * docs: update wordlist * fix: e2e tests * Lint package.json * Revert "fix: e2e tests" This reverts commit f71acd7. * Revert "fix: light-client e2e test" This reverts commit 23c11f0. * Revert "fix: light-client unit tests" This reverts commit fa7893e. * Revert "test: fix browser based tests" This reverts commit 98d04ab. * docs: update readme to remove switchable bls argument * fix: replace optimizeDeps in vitest.browser.config * chore: updated to bls 8.1.0 * feat: move setting threadpool size and warnings to applyPreset.ts * fix: remove setThreadpoolSize from beacon handler * feat: move libuv size logging into handler to use logger * refactor: rename applyPreset to preInitialization * refactor: logging about pool size * Update packages/cli/src/options/globalOptions.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * refactor: rename prover applyPreset * docs: change comment in cli/index * fix: update logging for * fix: throw error for invalid uvThreadpoolSize * Update packages/cli/src/preInitialization.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Fix lint issues * Remove unused import * refactor: move bls pool logging back to multithread.ts * fix: log of threadcount --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: update references to consensus spec to v1.4.0 (#6704) * chore: update references to consensus spec to v1.4.0 * Remove unintended formatting changes * chore: update consensus spec version in README (#6705) * docs: correct plausible url (#6709) fix: correct plausible url * docs: incorrect scripts location (#6710) fix: incorrect scripts location * docs: no more broken images (#6708) * fix: no more broken images * fix: incorrect paths * feat: check aggregationBits length of `SignedAggregateAndProof` in gossip validation (#6700) * Add unit test * Update packages/beacon-node/src/chain/validation/aggregateAndProof.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com> --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * feat: add and track blob source for metrics (#6628) * feat: add and track blob source for metrics * adding blobsSource for blobsPromise * address feedback * apply feedback * updates * only allow non blobspromise blocks to be imported * feat: add support for browser bundle for lightclient (#6673) * Reorganize the code so it is accessible from one package * Add support for browser build for lightclient * Update the build config * Improve the bls vite plugin * Restructure the vite and vitest scripts * Simplify vite config * Remove unused polyfill * Fix the doc lint error * Add support for bundle test * Update the package json files * Add dist build to default build task * Fix spelling in the docs * Fix the lint error * Fix type error * Disable eslint errors * Increase the timeout for bundle test * Fix eslint bundle * Fix lint warning * Remove the unused config * Add the default export to bundle * Enable compression on th build * Update packages/light-client/README.md Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Increase timeout for one test * Optimize package build task * Update the readme --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * docs: fix plausible domain (#6712) * ci: add paths-ignore to workflows (#6713) * chore: added paths-ignore * chore: address comments * feat: add arm64 binary support (#6707) * feat: add arm64 binary support * chore: workaround yarn * chore: add comment * chore: workaround runner limitations * ci: publish binaries for release candidates (#6714) * feat: add types support to esm bundle for lightclient (#6685) * Add vite dts plugin * Restructure types export * Update vite build config * Remove unused file * Update the build process * Fix doc formatting * Build the dist for type tests * chore: update vitest (#6718) Update vitest * chore: do not build all binaries atomically (#6719) * feat: update libp2p deps (#6711) * feat: update libp2p deps * chore: fix linter/type errors * chore(deps): bump ejs from 3.1.9 to 3.1.10 (#6721) Bumps [ejs](https://github.com/mde/ejs) from 3.1.9 to 3.1.10. - [Release notes](https://github.com/mde/ejs/releases) - [Commits](mde/ejs@v3.1.9...v3.1.10) --- updated-dependencies: - dependency-name: ejs dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: revert "ci: add paths-ignore to workflows (#6713)" (#6730) Revert "ci: add paths-ignore to workflows (#6713)" This reverts commit e460bb1. * docs: restore docs pages lost during docusaurus migration (#6725) * ci: fix incorrect build caching (#6731) fix: incorrect build caching * fix: build error log during esm bundle build (#6737) Fix build error * chore: update fastify to v4.27.0 (#6740) * deps: upgrade vitest minor version (#6745) Upgrade vitest * chore: warn when heap limit is too low (#6722) * chore: warn when heap limit is too low * chore: units Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments * chore: added faq element * chore: address comments Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * feat: disable flood publish (#6755) * feat: disable flood publish * feat: add network.disableFloodPublish cli flag * chore: address PR comments * test: allow compact diff for test failures (#6783) * Allow the compact diff for tests * Update the doc * Update docs/pages/contribution/testing/index.md Co-authored-by: Julien <jeluard@users.noreply.github.com> * Fix linting on docs * Fix linting --------- Co-authored-by: Julien <jeluard@users.noreply.github.com> * chore: upgrade classic-level (#6793) * chore: upgrade classic-level * chore: address comments * feat(prover): support non-mutated verification provider in prover (#6727) * Restructure the assertions * Add an inspector to run the logic to detect providers * Update web3 provdier logic to use inspetor * Fix the types for proxy * Make the default type for mutation * Rename elrpc to elrpcprovider * Apply suggestions from code review Co-authored-by: Julien <jeluard@users.noreply.github.com> * Fix build error * Update the readme doc * Apply suggestions from code review Co-authored-by: Julien <jeluard@users.noreply.github.com> * Fix the docs linting * Add missing words --------- Co-authored-by: Julien <jeluard@users.noreply.github.com> * docs: added debugging section (#6743) * docs: added debugging section * chore: spell checks * chore: added extra docs * chore: address comments * chore: added extra configuration * chore: updated docs * chore: added extra configuration * chore: fix lint * chore: fix typos * chore: .gitignore * chore: address comments * chore: address comments * chore: review debugging section PR (#6807) * chore: update the naming conventions used in sim tests (#6805) * Rename simulation test to crucible * Rename SimulationEnvironment to Simulation * Use consistent function names * Update readme * Rename interfaces for consistent pattern * Fix lint error * feat: recognize grandine from agentVersion (#6808) * Add grandine * add grandine to wordlist * chore: refactor event loop interactions (#6806) * chore: refactor sleep(0) usage * chore: refactor setTimeout * chore: address comments * chore: cleanup * Apply suggestions from code review --------- Co-authored-by: Cayman <caymannava@gmail.com> * chore: fix broken docker (#6813) * chore: log newPayload engine api (#6810) * chore: add `get_proposer_head` check in fork choice spec test (#6814) * Check get_proposer_head * Fix enum typo * lint * chore: consolidate classic-level usage (#6795) * chore: do not rely on leveldown * chore: replace level with classic-level * chore: added docker support for osx (#6696) * chore: added docker support for osx * chore: address comments * chore: address comments * Update docker-compose.yml Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: address comments --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com> * chore: fix vitest performance with spec tests artifacts in place (#6817) Fix vitest performance with spec tests in place * chore: clean up yarn lockfile (#6816) * feat: disable flood publish by default (#6815) * feat: use @chainsafe/blst directly (#6706) * feat: use @chainsafe/blst directly * chore: update to blst@1.0.1 * refactor: remove randomBytesNonZero and user blst exported version * chore: update blst references * test: catch invalid deserialization in spec tests and return false * feat: create signatureFromBytes and signatureFromBytesNoCheck in utils package * feat: implement signatureFromBytes from utils package * feat: implement signatureFromBytes everywhere * fix: light-client empty module for blst --------- Co-authored-by: matthewkeil <me@matthewkeil.com> * fix: avoid Buffer.from copies (#6723) * fix: avoid Buffer.from copies * chore: simplify shuffling * fix: use subarray instead of slice in shuffling * chore: remove unnecessary devDependencies * chore: rely on fastify 4.x behavior * chore: avoid copy in verifyMerkleBranch * use toBase64 * relax assertions in shuffle function * Update packages/state-transition/src/util/shuffle.ts Co-authored-by: twoeths <tuyen@chainsafe.io> --------- Co-authored-by: twoeths <tuyen@chainsafe.io> * chore: update nodejs to latest 22 (#6729) * Upgrade node js version to 22 * Update node types * Revert action config * Add package from git hash * Fix the build error * Update the docs for node-22 * Update docker version for Nodejs to 22 * Update package.json * Update package.json Co-authored-by: Nico Flaig <nflaig@protonmail.com> * Update readme docs * Add word in dictionary * Add word in dictionary --------- Co-authored-by: Cayman <caymannava@gmail.com> Co-authored-by: Nico Flaig <nflaig@protonmail.com> * deps: update systeminformation to 5.22.9 (#6823) * chore: add distutils to build phase of Dockerfile (#6845) * test: increase timeout of keystore tests (#6846) * test: increase timeout of keystore cache tests * Increase hook timeout * Consistent number formatting * chore: only log warning if media type is not supported (415) (#6847) * fix: revert napi bls (#6853) * Revert "feat: use @chainsafe/blst directly (#6706)" This reverts commit 66fe753. * Revert "feat: switch bls to napi rebuild (#6616)" This reverts commit 97d9aa8. * chore: bump package versions to 1.19.0 * chore: bump @chainsafe/blst to v0.2.11 (#6856) * fix: arm64 binaries creation issue (#6858) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tuyennhv <tuyen@chainsafe.io> Co-authored-by: Julien <jeluard@users.noreply.github.com> Co-authored-by: Nico Flaig <nflaig@protonmail.com> Co-authored-by: Matthew Keil <me@matthewkeil.com> Co-authored-by: NC <adrninistrator1@protonmail.com> Co-authored-by: g11tech <develop@g11tech.io> Co-authored-by: Nazar Hussain <nazarhussain@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
🎉 This PR is included in v1.19.0 🎉 |
Motivation
Swaps out SWIG/Herumi implementation of blst with Napi implementation.
Currently deployed on
feat1
group and is developing metrics. Will post below as they progress.DO NOT MERGE until the package version for bls is added. Needs to be merged and published first thoughDescription
@chainsafe/blst
@chainsafe/bls
that uses the updated@chainsafe/blst
under the hoodAddSetexport UV_THREADPOOL_SIZE=$(nproc)
to ./lodestar entrance script and benchmark commands to ensure adequate performanceprocess.env.UV_THREADPOOL_SIZE = os.availableParallelism().toString()
incli/src/cmds/beacon/beaconHandler.ts
G2_POINT_AT_INFINITY
is_inf test to@chainsafe/blst
chain.blsAddVerificationRandomness
CLI option for applyingmult
randomness to same message verification. Defaults totrue
unless explicitly set asfalse
via the CLImult
randomness for same message verificationbeacon-node/src/chain/bls
directory structure by removingmultithread
folderaddVerificationRandomness
to verification options of queued jobs. Not available via the external function signature and is set via the CLI options and merged with options passed to the call toIBls.verifySignatureSets
BlsMultiThreadWorkerPool
for Herumi implementation. (see notes below)"./maybeBatch.js"
to"./verifySets.js"
"./worker.js"
to"./runBlsWorkReq.js"
beacon-node/src/chain/bls/multithread/utils.ts
withbeacon-node/src/chain/bls/utils.ts
Uint8Arry.from
NOTES
@chainsafe/blst
and@chainsafe/bls
need to both be published and the package version needs to be swapped in thepackage.json
files in here. For now a sha is being used to target the head of the feature branch of@chainsafe/bls
canAcceptWork()
functions to optimize performance. Possibly should remove queue functionality and only use queue on the gossipsub side or vice versa and only use queue in bls so that there are not two queues introducing throttlingThe functionality to testNeed to importis_inf
forG2_POINT_AT_INFINITY
is not longer exported from the deps so no way to test from the Lodestar side. Potentially should export that constant from@chainsafe/bls
and move the test to there so that the value and unit test for it are in the same place. Unfortunately theis_inf
in not available from Herumi so it really should be in@chainsafe/blst
however if that is where the test and value live it will no longer be apeerDependency
which is not great@chainsafe/blst
as adependency
to lodestar now and we are maintaining it as apeerDependency
in@chainsafe/bls
, so its possible to use the value from the blst repo now.@chainsafe/bls
to even allow for using Herumi. Removing inaccessible, unused and unnecessary option greatly simplified class structure ofBlsMultiThreadWorkerPool
because workers should no longer be used realistically. The only case were workers would have been beneficial to retain would be to run Herumi on-thread in a worker. It would not be ideal to run napi on-thread in workers and is better to run it via libuv schedulingrandomBytesNonZero
is exported by@chainsafe/blst
now but not via@chainsafe/bls
because re-exporting would cause the samepeerDependency
issue as re-exportingG2_POINT_AT_INFINITY
. This need to be resolved but highlighting here to get the teams' feelings on the best way to handle this