Page MenuHomePhabricator

[ecash-lib] Add ecash-lib-wasm, a WebAssembly module for ecash-lib
ClosedPublic

Authored by tobias_ruck on Wed, Apr 10, 03:27.

Details

Summary

Builds a WebAssemby module using Rust for secp256k1 and hashing functions.

This currently uses https://github.com/raipay/secp256k1-abc to get libsecp256k1 to compile to WebAssembly using Rust, but in the future we could use the secp256k1 library within the monorepo to get rid of that external dependency.

ecash-lib in the repo now won't typecheck until the WebAssembly is built, but it seems better to not commit compiled binaries than users having to have to build the .wasm file.

In the future, we might want to check the hash of the built wasm file so we get a deterministic build, maybe even provide a signature like we do for the release of bitcoind.

The wasm can be built using either dockerbuild.sh or build-wasm.sh, the former just requires docker, the latter requires some wasm toolchains to be installed.

Test Plan
  1. cd ecash-lib-wasm && ./dockerbuild.sh
  2. cd ../ecash-lib && npm run test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

modules/ecash-lib-wasm/.gitignore
2 ↗(On Diff #46970)

add newline at end of file

add tests, rebase, simplify docker

remove .dockerignore, actually just makes things slower

tobias_ruck retitled this revision from [ecash-lib] Add ecash-lib-wasm, a WASM compiled secp256k1 for ecash-lib to [ecash-lib] Add ecash-lib-wasm, a WebAssembly module for ecash-lib.Wed, Apr 10, 15:47
tobias_ruck edited the summary of this revision. (Show Details)
modules/ecash-lib-wasm/Cargo.toml
31 ↗(On Diff #46995)

do we have some way of checking that this repo has not changed since the last build, e.g. a sha256 hash of what we are getting from this?

It's ok to get this ready with the external dependency but we need some kind of check against a supply chain issue

need to get ecash-lib-wasm to build in CI before building ecash-lib in CI

This revision now requires changes to proceed.Wed, Apr 10, 16:27

add wasm build to CI before testing ecash-lib

pin secp256k1-abc revision commit

modules/ecash-lib-wasm/.gitignore
1 ↗(On Diff #46995)

I get this dir after building ecash-lib locally -- assuming we do not want it in the repo?

1 ↗(On Diff #46995)

...never mind I get this in ecash-lib/

./contrib/teamcity/build-configurations.py ecash-lib-tests passes locally

CI failures are ongoing across all diffs

Since this diff does not build and deploy anywhere, imo ok to land it so we can start on the next step while CI issue is resolved

modules/ecash-lib-wasm/src/ecc.rs
89 ↗(On Diff #46998)

🔥

This revision is now accepted and ready to land.Wed, Apr 10, 18:43
This revision was landed with ongoing or failed builds.Wed, Apr 10, 19:25
This revision was automatically updated to reflect the committed changes.