Skip to content

Commit

Permalink
feat: refactor core into simplified WASM module
Browse files Browse the repository at this point in the history
  • Loading branch information
artifex11 committed Aug 23, 2023
1 parent 3c02311 commit dac4f1c
Show file tree
Hide file tree
Showing 12 changed files with 1,019 additions and 2,892 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
# Move the compiled package to the root for better paths in the npm module.
# We also automatically populate the version with the given tag.
run: >
./asyncify.sh &&
make package &&
sed -i "/\"version\": \"0.0.1\"/s/\"0.0.1\"/\"${GITHUB_REF:11}\"/" package.json &&
npm publish
env:
Expand Down Expand Up @@ -124,6 +124,8 @@ jobs:
command: check
args: --all-targets

- run: make wasm

- name: Test project
if: ${{ matrix.os != 'ubuntu-latest' || matrix.toolchain != 'nightly' }}
uses: actions-rs/cargo@v1
Expand Down
33 changes: 20 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@ edition = "2021"
description = "The core functionality of the Dusk wallet"
license = "MPL-2.0"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
rand_core = "^0.6"
rand_chacha = { version = "^0.3", default-features = false }
sha2 = { version = "^0.10", default-features = false }
phoenix-core = { version = "0.20.0-rc.0", default-features = false, features = ["alloc", "rkyv-impl"] }
dusk-pki = { version = "0.12", default-features = false }
dusk-bytes = "^0.1"
dusk-schnorr = { version = "0.13", default-features = false }
bytecheck = { version = "0.6", default-features = false }
dusk-bls12_381-sign = { version = "0.4", default-features = false }
dusk-jubjub = { version = "0.12", default-features = false }
dusk-merkle = { version = "0.5", features = ["rkyv-impl"] }
dusk-pki = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-poseidon = { version = "0.30", default-features = false }
dusk-schnorr = { version = "0.13", default-features = false }
phoenix-core = { version = "0.20.0-rc.0", default-features = false, features = ["alloc", "rkyv-impl"] }
poseidon-merkle = { version = "0.2.1-rc.0", features = ["rkyv-impl"] }
dusk-plonk = { version = "0.14", default-features = false }
rand_core = "^0.6"
rand_chacha = { version = "^0.3", default-features = false }
rkyv = { version = "^0.7", default-features = false }
rusk-abi = { version = "0.10.0-piecrust.0.6", default-features = false }
sha2 = { version = "^0.10", default-features = false }

[target.'cfg(target_family = "wasm")'.dependencies]
rusk-abi = "0.10.0-piecrust.0.6"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
rusk-abi = { version = "0.10.0-piecrust.0.6", default-features = false }
dusk-bls12_381-sign = { version = "0.4", default-features = false }
rkyv = { version = "0.7", default-features = false }

[dev-dependencies]
rand = "^0.8"

[lib]
crate-type = ["cdylib", "rlib"]
wasmer = "=3.1"
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
help: ## Display this help screen
@grep -h \
-E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

test: wasm ## Run the wasmer tests
@cargo test

wasm: ## Build the WASM files
@RUSTFLAGS="$(RUSTFLAGS) --remap-path-prefix $(HOME)= -C link-args=-zstack-size=65536" \
cargo build \
--release \
--color=always \
-Z build-std=core,alloc,panic_abort \
-Z build-std-features=panic_immediate_abort \
--target wasm32-unknown-unknown

package: ## Prepare the WASM npm package
wasm-opt -O4 \
--output-target/wasm32-unknown-unknown/release/dusk_wallet_core.wasm \
-o mod.wasm

.PHONY: test wasm help
19 changes: 0 additions & 19 deletions asyncify.sh

This file was deleted.

Loading

0 comments on commit dac4f1c

Please sign in to comment.