Skip to content
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!: napi-rs binding #149

Merged
merged 142 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
9182d12
chore: add node 22 support
wemeetagain Jun 4, 2024
a72a898
chore: release v0.2.11
wemeetagain Jun 4, 2024
56bc9f1
feat: explore napi-rs binding
wemeetagain Jun 13, 2024
2ece252
feat: use signature sets in verifyMultipleAggregateSignatures
wemeetagain Jun 13, 2024
f9f386c
chore: fix batchVerify benchmark
wemeetagain Jun 13, 2024
f22a7c0
feat: simplify signature set handling, async functions
wemeetagain Jun 13, 2024
a74c710
wip
wemeetagain Jun 14, 2024
596a302
err handling
ec2 Jun 14, 2024
68bea80
chore: more cleanup
wemeetagain Jun 14, 2024
2b61c67
chore: use threads in blst crate
wemeetagain Jun 14, 2024
d9338a8
chore: add multithread benchmarks
wemeetagain Jun 15, 2024
953cfe0
feat rough out sigVerify and perf test
matthewkeil Jun 16, 2024
f21ec91
chore: more cleanup
wemeetagain Jun 17, 2024
f2a0fbe
feat: add keyValidate
wemeetagain Jun 17, 2024
4e294e9
chore: refresh index.d.ts
wemeetagain Jun 17, 2024
573f500
feat: add eip 2333 fns
wemeetagain Jun 17, 2024
d66802c
feat: add aggregateSerialized fns
wemeetagain Jun 17, 2024
6e2b25a
feat: add validation to from_bytes
wemeetagain Jun 17, 2024
6c723ba
chore: refresh index.d.ts
wemeetagain Jun 17, 2024
62021c5
chore: more cleanup
wemeetagain Jun 17, 2024
5e56106
chore: fix blstOpts benchmark
wemeetagain Jun 17, 2024
bb8ac3a
chore: more cleanup
wemeetagain Jun 17, 2024
0fd3570
feat: add hex helpers
wemeetagain Jun 17, 2024
4913912
fix: validation in factories
wemeetagain Jun 17, 2024
8b37df3
fix: default to sig_infcheck if sig_validate
wemeetagain Jun 17, 2024
81080fa
chore: fmt
wemeetagain Jun 17, 2024
223384d
feat: stringify BLST_ERROR
matthewkeil Jun 17, 2024
db1441c
feat: async aggregate* fns
wemeetagain Jun 18, 2024
1df06d4
chore: remove stray comment
wemeetagain Jun 18, 2024
8870f3e
feat: switch blst to matthewkeil fork for multiply_by
matthewkeil Jun 19, 2024
e408fe9
chore: update blst
matthewkeil Jun 19, 2024
d8ada41
chore: add settings.json so rust displays correctly
matthewkeil Jun 19, 2024
a8700e5
feat: add aggregate_with_randomness
matthewkeil Jun 19, 2024
cae50fd
chore: update blst
matthewkeil Jun 21, 2024
208415c
refactor: change aggregate_with_randomness implementation
matthewkeil Jun 21, 2024
2fa18b1
chore: use MultiPoint ops to do aggregate_with_randomness
wemeetagain Jun 23, 2024
bede4f0
chore: bench aggregation vs aggregate_with_randomness
wemeetagain Jun 23, 2024
e6c0d60
chore: add test aggregateWithMsm fn
wemeetagain Jun 23, 2024
1e04885
chore: update blst
matthewkeil Jun 23, 2024
ae4db61
chore: use blst bindings
matthewkeil Jun 23, 2024
5773a57
feat: implement to/from affine
matthewkeil Jun 23, 2024
f002234
feat: add verify_multiple_aggregate_signatures_same_message
wemeetagain Jun 24, 2024
9ff0a1b
chore: cleanup
wemeetagain Jun 29, 2024
8f97b71
chore: sig to Uint8Array everywhere
wemeetagain Jun 29, 2024
ba0ec86
chore: update napi-rs deps
wemeetagain Jun 30, 2024
192de79
feat: add verify_multiple_signatures_same_message_with_retries
wemeetagain Jul 1, 2024
0e4dd8f
fix: fix struct definition
wemeetagain Jul 1, 2024
65d467d
feat: add verify_multiple_signatures_same_messages_with_retries
wemeetagain Jul 1, 2024
d2145c8
chore: change the shape of same message set
wemeetagain Jul 1, 2024
0657730
fix: stray ref
wemeetagain Jul 2, 2024
8057918
chore: tweak shape of same msg set
wemeetagain Jul 2, 2024
f6e3780
chore: add index.d.ts
wemeetagain Jul 2, 2024
036a4c9
chore: update same msg shape
wemeetagain Jul 2, 2024
b266ea3
chore: use Signature instead of Uint8Array
wemeetagain Jul 2, 2024
0beec38
chore: optimize aggregate fns
wemeetagain Jul 3, 2024
6f0ff04
chore: update submodule
matthewkeil Jul 3, 2024
301a304
Revert "chore: optimize aggregate fns"
wemeetagain Jul 3, 2024
582a439
chore: fmt
wemeetagain Jul 3, 2024
6faeec8
chore: move napi-rs bindings to root
wemeetagain Jul 3, 2024
43f0e41
chore: replace tests
wemeetagain Jul 4, 2024
c9f725a
chore: start package.json cleanup
wemeetagain Jul 4, 2024
3463ef2
chore: start fixing CI
wemeetagain Jul 4, 2024
d742cf5
chore: fix blst path
wemeetagain Jul 4, 2024
709ed38
chore: get spec tests passing
wemeetagain Jul 4, 2024
e699baa
chore: remove experimental fns
wemeetagain Jul 4, 2024
f10063a
chore: better error codes
wemeetagain Jul 4, 2024
05a4182
chore: cleanup
wemeetagain Jul 4, 2024
8547d5a
chore: rebuild bindings
wemeetagain Jul 4, 2024
e6bc2cf
chore: simplify spec tests
wemeetagain Jul 4, 2024
d42bdf7
chore: comments
wemeetagain Jul 4, 2024
34b75f6
chore: simplify
wemeetagain Jul 4, 2024
23a5f46
chore: start fixing tests
wemeetagain Jul 4, 2024
aeac41d
chore: more test updates
wemeetagain Jul 4, 2024
e94c726
chore: pass unit tests
wemeetagain Jul 4, 2024
fc811de
chore: fix lint
wemeetagain Jul 4, 2024
876fa3e
chore: fix perf test
wemeetagain Jul 4, 2024
5a46596
chore: fix up package.json and CI
wemeetagain Jul 4, 2024
b6c7181
chore: more CI work
wemeetagain Jul 4, 2024
1a5a1fe
chore: more ci
wemeetagain Jul 5, 2024
c513488
chore: more ci
wemeetagain Jul 5, 2024
adf4420
chore: add test console.log
wemeetagain Jul 5, 2024
59c61f8
chore: update test
wemeetagain Jul 5, 2024
9308878
chore: tweak test
wemeetagain Jul 5, 2024
2ebe609
Merge branch 'cayman/napi-rs' into m
wemeetagain Jul 5, 2024
f059d58
chore: remove unused files
wemeetagain Jul 5, 2024
80b65df
feat: add compress for to_bytes and to_hex
matthewkeil Jul 6, 2024
5e2e290
test: add back tests for compressed/uncompressed
matthewkeil Jul 6, 2024
2e41038
test: add bindings.test
matthewkeil Jul 6, 2024
c21a30c
test: add case for showing which aggregate index is invalid
matthewkeil Jul 6, 2024
8a58bc7
chore: wip spec tests
wemeetagain Jul 6, 2024
7f3e23d
Merge remote-tracking branch 'origin/cayman/napi-rs' into cayman/napi-rs
wemeetagain Jul 6, 2024
4c96f1d
feat: build to_vec and fix to_hex
matthewkeil Jul 6, 2024
9d996c7
chore: fix spec test functions
wemeetagain Jul 6, 2024
f2eb4bd
chore: fix spec tests
wemeetagain Jul 6, 2024
5d6acac
chore: fix some unit tests
wemeetagain Jul 6, 2024
659f047
chore: remove stray import
wemeetagain Jul 6, 2024
5ef0c9a
test: check aggregateWithRandomness
matthewkeil Jul 7, 2024
18aab68
test: add invalid test case to verifyMultipleAggregateSignatures.test
matthewkeil Jul 7, 2024
a74f894
test: fix fuzz tests to get working
matthewkeil Jul 8, 2024
1259012
test: fix perf tests
matthewkeil Jul 8, 2024
6bb9792
fix: remove Promise.all from runWorkRequest
matthewkeil Jul 8, 2024
d6a9ed7
chore: some cleanup
wemeetagain Jul 8, 2024
d7174dd
chore: add separate invalid hex error status
wemeetagain Jul 8, 2024
b4d9e34
chore: move fns
wemeetagain Jul 8, 2024
10f761e
chore: remove verify_multiple_signatures_same_message
wemeetagain Jul 8, 2024
44a14d6
chore: better hex error msgs
wemeetagain Jul 8, 2024
e0f3d06
fix: create_rand_slice
wemeetagain Jul 11, 2024
d5d16c7
fix: bindings test
wemeetagain Jul 11, 2024
8b853d1
chore: revert license change
wemeetagain Jul 17, 2024
7cbaa64
fix: add compress false in __fixtures__
matthewkeil Jul 17, 2024
e3398d5
Apply suggestions from code review
wemeetagain Jul 18, 2024
22d0180
chore: remove yarn files
wemeetagain Jul 18, 2024
1f2e538
chore: use napi8
wemeetagain Jul 18, 2024
1d9b36e
chore: update yarn lock
wemeetagain Jul 18, 2024
b850568
chore: remove unused scripts
wemeetagain Jul 18, 2024
e921b82
chore: remove todo
wemeetagain Jul 18, 2024
a1be5a8
chore: refactor blst_error_to_reason
wemeetagain Jul 18, 2024
d5b3442
chore: cleanup spec test compatibility layer
wemeetagain Jul 18, 2024
cfcabfc
chore: remove default
wemeetagain Jul 18, 2024
23031c4
chore: add check for unstaged changes
wemeetagain Jul 18, 2024
5a47cc4
chore: pin node 22.4
wemeetagain Jul 18, 2024
bd3c889
chore: tweak workflow
wemeetagain Jul 18, 2024
524c361
chore: use to_le_bytes
wemeetagain Jul 18, 2024
52191be
chore: remove aggregate_with_randomness_native
wemeetagain Jul 18, 2024
fef413b
chore: update release workflow
wemeetagain Jul 18, 2024
f2c1ccb
chore: tweak workflow job names
wemeetagain Jul 18, 2024
051bac9
fix: package.json engines node16+
matthewkeil Jul 19, 2024
8bb18aa
chore: remove root utils folder
matthewkeil Jul 19, 2024
53a858f
Merge branch 'cayman/napi-rs' of github.com:ChainSafe/blst-ts into ca…
matthewkeil Jul 19, 2024
3bb0210
chore: cleanup .eslintrc.js
matthewkeil Jul 19, 2024
4409af6
chore: touch up tsconfig.json
matthewkeil Jul 19, 2024
3e7c221
docs: update CONTRIBUTING.md
matthewkeil Jul 19, 2024
56280fa
Update README.md
wemeetagain Jul 19, 2024
33b4e38
Update src/lib.rs
wemeetagain Jul 19, 2024
31bb3da
chore: tweak aggregate_with
wemeetagain Jul 19, 2024
03acbf8
chore: use to_ne_bytes
wemeetagain Jul 19, 2024
8e3f9bb
Update src/lib.rs
wemeetagain Jul 22, 2024
6da455b
chore: tweak comment
wemeetagain Jul 22, 2024
b867afb
chore: remove multithreading tests
wemeetagain Jul 22, 2024
67971cf
chore: update index.d.ts
wemeetagain Jul 22, 2024
92d643b
chore: fix lint error
wemeetagain Jul 22, 2024
bba7a0a
chore: update comment
wemeetagain Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
8 changes: 0 additions & 8 deletions .clang-format

This file was deleted.

13 changes: 0 additions & 13 deletions .dockerignore

This file was deleted.

16 changes: 2 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ module.exports = {
"import/core-modules": ["node:child_process", "node:crypto", "node:fs", "node:os", "node:path", "node:util"],
},
overrides: [
{
files: ["lib/index.mjs"],
parserOptions: {
sourceType: "module"
},
rules: {
// The imports are all resolved via tsconfig.mjs.json but the root tsconfig that eslint uses
// shows them as unresolved.
"import/no-unresolved": "off",
},
},
{
files: ["test/**/*.ts"],
rules: {
Expand All @@ -101,10 +90,9 @@ module.exports = {
},
},
{
// Is a dev file and squacks about chokidar being a devDependency
files: ["scripts/watch.ts"],
files: ["test/utils/testSets.ts"],
rules: {
"import/no-extraneous-dependencies": "off"
"no-console": "off",
},
},
],
Expand Down
284 changes: 284 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
name: CI
env:
DEBUG: napi:*
APP_NAME: blst
MACOSX_DEPLOYMENT_TARGET: '10.13'
permissions:
contents: write
id-token: write

on:
pull_request:
push:
branches:
- master

jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: yarn build --target x86_64-apple-darwin
- host: windows-latest
build: yarn build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: yarn build --target x86_64-unknown-linux-gnu
- host: macos-latest
target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: yarn build --target aarch64-unknown-linux-gnu
name: Build - ${{ matrix.settings.target }} - node@22
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: '22.4.x'
cache: yarn
- name: Install
uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }}
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
with:
version: 0.11.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: yarn config set supportedArchitectures.cpu "ia32"
shell: bash
- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: '22.4.x'
cache: yarn
architecture: x86
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: ${{ matrix.settings.build }}
- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
test-macOS-windows-binding:
name: Test - ${{ matrix.settings.target }} - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
node:
- '18'
- '22.4.x'
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
architecture: x64
- name: Install dependencies
run: yarn install
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test:unit
- name: Download spec tests
run: yarn download-spec-tests
- name: Spec tests
run: yarn test:spec

test-linux-x64-gnu-binding:
name: Test - Linux-x64-gnu - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- '18'
- '22.4.x'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: yarn install
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-gnu
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Lint project
run: yarn lint
- name: Run napi version
run: yarn run version
- name: Ensure there are no unstaged changes
run: git diff --exit-code
wemeetagain marked this conversation as resolved.
Show resolved Hide resolved
- name: Test bindings
run: yarn test:unit
- name: Download spec tests
run: yarn download-spec-tests
- name: Spec tests
run: yarn test:spec

test-linux-aarch64-gnu-binding:
name: Test - aarch64-unknown-linux-gnu - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- '18'
- 22.4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-gnu
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "glibc"
yarn install
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-slim
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
run: |
set -e
yarn test:unit
yarn download-spec-tests
yarn test:spec
ls -la
publish:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
name: Publish
runs-on: ubuntu-latest
needs:
- test-macOS-windows-binding
- test-linux-x64-gnu-binding
- test-linux-aarch64-gnu-binding
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '22.4.x'
cache: yarn
- name: Create tag
id: tag
uses: butlerlogic/action-autotag@1.1.2
with:
strategy: package
tag_prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Exit if no version change
if: steps.tag.outputs.tagcreated == 'no'
uses: actions/github-script@v3
with:
script: core.setFailed('The package.json version did not change. Workflow will not create a release.')
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: yarn artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish
run: |
npm config set provenance true
if node -e "console.log(require('./package.json').version)" | grep "v[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif node -e "console.log(require('./package.json').version)" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading