-
Notifications
You must be signed in to change notification settings - Fork 2
feat(wasm-privacy-coin): wasm java packaging #293
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,65 @@ jobs: | |
|
|
||
| - name: Release (multi-semantic-release) | ||
| run: npx multi-semantic-release --ignore-private-packages | ||
|
|
||
| publish-maven: | ||
| name: Publish Maven Artifact | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| environment: publish | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: corretto | ||
| java-version: '17' | ||
|
|
||
| - name: Download wasm-privacy-coin build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: wasm-privacy-coin-build | ||
| path: packages/wasm-privacy-coin/dist/ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JAR ends up double-nested here — v4 extracts artifact paths relative to this destination, so it lands at |
||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws-region: us-west-2 | ||
|
|
||
| - name: Get CodeArtifact token | ||
| run: | | ||
| TOKEN=$(aws codeartifact get-authorization-token \ | ||
| --domain private \ | ||
| --domain-owner 199765120567 \ | ||
| --query authorizationToken \ | ||
| --output text) | ||
| echo "::add-mask::$TOKEN" | ||
| echo "AWS_CODEARTIFACT_TOKEN=$TOKEN" >> "$GITHUB_ENV" | ||
| - name: Read version from pom.xml | ||
| id: version | ||
| run: | | ||
| VERSION=$(grep '<version>' packages/wasm-privacy-coin/pom.xml | head -1 | sed 's/.*<version>\(.*\)<\/version>.*/\1/') | ||
| if [ -z "$VERSION" ]; then echo "Failed to parse version from pom.xml" && exit 1; fi | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| - name: Deploy JAR to CodeArtifact | ||
| working-directory: packages/wasm-privacy-coin | ||
| run: | | ||
| mvn deploy:deploy-file \ | ||
| -s .settings.xml \ | ||
| -Pcodeartifact-deploy \ | ||
| -DgroupId=com.bitgo \ | ||
| -DartifactId=wasm-privacy-coin \ | ||
| -Dversion=${{ steps.version.outputs.version }} \ | ||
| -Dpackaging=jar \ | ||
| -Dfile=dist/wasm-privacy-coin.jar \ | ||
| -DrepositoryId=codeartifact-central \ | ||
| -Durl=https://private-199765120567.d.codeartifact.us-west-2.amazonaws.com/maven/bitgo-maven-libs-release/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <settings | ||
| xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" | ||
| xmlns="http://maven.apache.org/SETTINGS/1.1.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| <servers> | ||
| <server> | ||
| <id>codeartifact-central</id> | ||
| <username>aws</username> | ||
| <password>${env.AWS_CODEARTIFACT_TOKEN}</password> | ||
| </server> | ||
| </servers> | ||
| </settings> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [package] | ||
| name = "wasm-privacy-coin" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib", "lib"] | ||
|
|
||
| [dependencies] | ||
| # Core tree crates — pinned to exact versions for deterministic builds. | ||
| # These must stay in sync with the zcash ecosystem (NU6-compatible). | ||
| shardtree = "=0.6.2" | ||
| incrementalmerkletree = "=0.8.2" | ||
| orchard = { version = "=0.14.0", default-features = false } | ||
|
|
||
| # IPC protocol | ||
| serde = { version = "1", features = ["derive"] } | ||
| serde_json = "1" | ||
| hex = "0.4" | ||
|
|
||
| [profile.release] | ||
| opt-level = 3 | ||
| lto = true | ||
| strip = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| WASM_TARGET = wasm32-unknown-unknown | ||
|
|
||
| .PHONY: build | ||
| build: | ||
| cargo build --release --target $(WASM_TARGET) | ||
| mkdir -p dist | ||
| cp target/$(WASM_TARGET)/release/wasm_privacy_coin.wasm dist/wasm-privacy-coin.wasm | ||
|
|
||
| .PHONY: jar | ||
| jar: build | ||
| mkdir -p jar-staging/wasm | ||
| cp dist/wasm-privacy-coin.wasm jar-staging/wasm/privacy_coin.wasm | ||
| cd jar-staging && jar cf ../dist/wasm-privacy-coin.jar wasm/ | ||
| rm -rf jar-staging | ||
|
|
||
| .PHONY: clean | ||
| clean: | ||
| cargo clean | ||
| rm -rf dist jar-staging |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # wasm-privacy-coin | ||
|
|
||
| Orchard commitment tree (Zcash NU6) compiled to WebAssembly for use by the | ||
| indexer-utxo Java service via the Chicory WASM runtime. | ||
|
|
||
| ## Building | ||
|
|
||
| ```bash | ||
| rustup target add wasm32-unknown-unknown | ||
| make build | ||
| ``` | ||
|
|
||
| The compiled WASM binary will be at `dist/wasm-privacy-coin.wasm`. | ||
|
|
||
| ## Architecture | ||
|
|
||
| This module exposes a C-style FFI interface (no wasm-bindgen, no WASI). | ||
| The host allocates memory via `alloc()`, writes JSON input, calls a function, | ||
| then reads JSON output via `last_result_ptr()`/`last_result_len()`. | ||
|
|
||
| ## Exported Functions | ||
|
|
||
| | Function | Signature | Description | | ||
| |---|---|---| | ||
| | `alloc` | `(len: u32) -> *mut u8` | Allocate buffer in WASM memory | | ||
| | `dealloc` | `(ptr: *mut u8, len: u32)` | Free allocated buffer | | ||
| | `ping` | `() -> i32` | Health check | | ||
| | `init_from_frontier` | `(ptr, len) -> i32` | Initialize from z_gettreestate frontier | | ||
| | `load_state` | `(ptr, len) -> i32` | Load persisted JSON state | | ||
| | `save` | `() -> i32` | Serialize tree to JSON | | ||
| | `get_info` | `() -> i32` | Return tip height, leaf count, checkpoint count | | ||
| | `append_commitments` | `(ptr, len) -> i32` | Append Orchard commitments, verify root | | ||
| | `truncate_to_checkpoint` | `(ptr, len) -> i32` | Reorg handling | | ||
| | `last_result_ptr` | `() -> *const u8` | Pointer to last result buffer | | ||
| | `last_result_len` | `() -> u32` | Length of last result buffer | | ||
|
|
||
| ## Pinned Dependencies | ||
|
|
||
| The `shardtree`, `incrementalmerkletree`, and `orchard` crate versions are | ||
| pinned to exact versions to ensure deterministic builds and compatibility with | ||
| the NU6 Zcash protocol upgrade. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "name": "@bitgo/wasm-privacy-coin", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "build": "make build", | ||
| "lint": "cargo fmt --check && cargo clippy --all-targets --all-features -- -D warnings", | ||
| "check-fmt": "cargo fmt -- --check", | ||
| "test": "cargo test --workspace" | ||
| }, | ||
| "files": [ | ||
| "dist/wasm-privacy-coin.wasm" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.bitgo</groupId> | ||
| <artifactId>wasm-privacy-coin</artifactId> | ||
| <version>0.1.0</version> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This version is read statically so every master merge will attempt to publish |
||
| <packaging>jar</packaging> | ||
|
|
||
| <description>WASM module for Orchard merkle tree operations</description> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>codeartifact-deploy</id> | ||
| <distributionManagement> | ||
| <repository> | ||
| <id>codeartifact-central</id> | ||
| <name>BitGo CodeArtifact Release Repository</name> | ||
| <url>https://private-199765120567.d.codeartifact.us-west-2.amazonaws.com/maven/bitgo-maven-libs-release/</url> | ||
| </repository> | ||
| </distributionManagement> | ||
| </profile> | ||
| </profiles> | ||
| </project> | ||
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.
pkg/is wasm-pack output and won't exist here since this package hasneeds-wasm-pack: false. Safe to remove this path.