Skip to content

Commit

Permalink
feat: add wasm compatibility (#378)
Browse files Browse the repository at this point in the history
* try for min wasm compat

* ci: wasm compatibility

* configure getrandom behind wasm feature flag
  • Loading branch information
ratankaliani authored Sep 18, 2024
1 parent 0cc5a34 commit a8c61f0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ jobs:
with:
command: clippy
args: --all -- -D warnings
wasm-compatibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown
- name: Check wasm compatibility for common and consensus-core
uses: actions-rs/cargo@v1
with:
command: check
args: --target wasm32-unknown-unknown -p common -p consensus-core --no-default-features
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion consensus-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ name = "consensus-core"
edition = "2021"

[dependencies]
alloy = { version = "0.2.1", features = ["consensus", "rpc-types", "ssz", "rlp", "k256"] }
alloy = { version = "0.2.1", features = [
"consensus",
"rpc-types",
"ssz",
"rlp",
"k256",
] }
bls12_381.workspace = true
ssz_types.workspace = true
ethereum_ssz_derive.workspace = true
Expand All @@ -19,3 +25,8 @@ superstruct.workspace = true
thiserror.workspace = true
tracing.workspace = true
zduny-wasm-timer.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
# Building consensus-core for wasm requires getrandom with the js feature.
# Source: https://github.com/alloy-rs/core?tab=readme-ov-file#wasm-support
getrandom = { version = "0.2", features = ["js"] }

0 comments on commit a8c61f0

Please sign in to comment.