From 450f8b8b8033bfc606c34edb82a7a2299b428961 Mon Sep 17 00:00:00 2001 From: Hendrik Eeckhaut Date: Thu, 14 Dec 2023 21:37:40 +0100 Subject: [PATCH 1/2] Build tlsn-core, tlsn-prover and tls-client for wasm --- .github/workflows/wasm.yml | 47 ++++++++++++++++++++++++++++ components/tls/tls-client/Cargo.toml | 4 +++ tlsn/tlsn-core/Cargo.toml | 3 ++ tlsn/tlsn-prover/Cargo.toml | 6 +++- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/wasm.yml diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 0000000000..6b87afb181 --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,47 @@ +name: wasm-build + +on: + push: + branches: + - dev + tags: + - "[v]?[0-9]+.[0-9]+.[0-9]+*" + pull_request: + branches: + - dev + +env: + CARGO_TERM_COLOR: always + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + +jobs: + build_and_test: + name: Build for target wasm32-unknown-unknown + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - tlsn/tlsn-core + - tlsn/tlsn-prover + - components/tls/tls-client + defaults: + run: + working-directory: ${{ matrix.package }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install stable rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + toolchain: stable + + - name: Use caching + uses: Swatinem/rust-cache@v2.5.0 + with: + workspaces: ${{ matrix.package }} -> ../target + + - name: "Build" + run: cargo build --target wasm32-unknown-unknown diff --git a/components/tls/tls-client/Cargo.toml b/components/tls/tls-client/Cargo.toml index 06f6d11fb4..8bc3100c54 100644 --- a/components/tls/tls-client/Cargo.toml +++ b/components/tls/tls-client/Cargo.toml @@ -55,3 +55,7 @@ path = "examples/internal/bench.rs" [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[target.'cfg(target_arch = "wasm32")'.dependencies] +ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] } +getrandom = { version = "0.2", features = ["js"] } diff --git a/tlsn/tlsn-core/Cargo.toml b/tlsn/tlsn-core/Cargo.toml index a4be0fd783..48f00da151 100644 --- a/tlsn/tlsn-core/Cargo.toml +++ b/tlsn/tlsn-core/Cargo.toml @@ -45,3 +45,6 @@ bincode.workspace = true [[test]] name = "api" required-features = ["fixtures"] + +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { version = "0.2", features = ["js"] } diff --git a/tlsn/tlsn-prover/Cargo.toml b/tlsn/tlsn-prover/Cargo.toml index d1e80220cf..a1e6763bb7 100644 --- a/tlsn/tlsn-prover/Cargo.toml +++ b/tlsn/tlsn-prover/Cargo.toml @@ -44,6 +44,10 @@ derive_builder.workspace = true opaque-debug.workspace = true bytes.workspace = true -tracing = { workspace = true, optional = true} +tracing = { workspace = true, optional = true } web-time.workspace = true + +[target.'cfg(target_arch = "wasm32")'.dependencies] +ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] } +getrandom = { version = "0.2", features = ["js"] } From c49a1c8395946371bab15cfa0b09a75639f6e5d8 Mon Sep 17 00:00:00 2001 From: Hendrik Eeckhaut Date: Mon, 18 Dec 2023 15:02:08 +0100 Subject: [PATCH 2/2] Add explicit ring dependency with "wasm32_unknown_unknown_js" feature --- tlsn/tlsn-core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tlsn/tlsn-core/Cargo.toml b/tlsn/tlsn-core/Cargo.toml index 48f00da151..b5ec854b4e 100644 --- a/tlsn/tlsn-core/Cargo.toml +++ b/tlsn/tlsn-core/Cargo.toml @@ -47,4 +47,5 @@ name = "api" required-features = ["fixtures"] [target.'cfg(target_arch = "wasm32")'.dependencies] +ring = { version = "0.17", features = ["wasm32_unknown_unknown_js"] } getrandom = { version = "0.2", features = ["js"] }