Skip to content
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

Compile the tendermint and light-client crates to WASM #553

Merged
merged 18 commits into from
Sep 9, 2020
Merged

Conversation

romac
Copy link
Member

@romac romac commented Sep 2, 2020

See: #463

This PR also adds a job to the CI to test that both crates can compile to WASM.

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md

@brapse brapse mentioned this pull request Sep 2, 2020
5 tasks
It is currently unclear why this error has appeared, though I suspect it
is a bug in Cargo related to the combination of doc tests and features
flags.

       Doc-tests tendermint-light-client
    error[E0460]: found possibly newer version of crate `tendermint` which `tendermint_rpc` depends on
     --> /Users/coromac/Informal/Code/Current/tendermint-rs/light-client/src/components/io.rs:7:5
      |
    7 | use tendermint_rpc as rpc;
      |     ^^^^^^^^^^^^^^
      |
      = note: perhaps that crate needs to be recompiled?
      = note: the following crate versions were found:
              crate `tendermint`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint.rlib
              crate `tendermint`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint-735716e8d731096d.rmeta
              crate `tendermint_rpc`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint_rpc-ad41c355acf2752f.rlib

    error: aborting due to previous error
@romac
Copy link
Member Author

romac commented Sep 3, 2020

I had to disable the only previously enabled acceptance test of the light node CLI for the test suite to pass (7c07134). Without this commit, cargo test --all-features --no-fail-fast would fail with:

       Doc-tests tendermint-light-client
    error[E0460]: found possibly newer version of crate `tendermint` which `tendermint_rpc` depends on
     --> /Users/coromac/Informal/Code/Current/tendermint-rs/light-client/src/components/io.rs:7:5
      |
    7 | use tendermint_rpc as rpc;
      |     ^^^^^^^^^^^^^^
      |
      = note: perhaps that crate needs to be recompiled?
      = note: the following crate versions were found:
              crate `tendermint`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint.rlib
              crate `tendermint`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint-735716e8d731096d.rmeta
              crate `tendermint_rpc`: /Users/coromac/Informal/Code/Current/tendermint-rs/target/debug/deps/libtendermint_rpc-ad41c355acf2752f.rlib

    error: aborting due to previous error

It is currently unclear why this error has appeared, though I suspect it is a bug in Cargo related to features flags (which we now use to disable non WASM-compatible code).

EDIT: The reason for why disabling this test resolves the issue above, is that there is no more a need to rebuild the light node crate to run the light node binary with cargo run. It's not clear why rebuilding the crate is necessary when running cargo run as part of the test (when everything should have been compiled already, though perhaps not with the same flags) but I suspect that doing so in the middle of running (doc)tests is causing the issue.

@romac romac marked this pull request as ready for review September 3, 2020 12:10
@romac romac requested review from liamsi, xla and brapse September 3, 2020 12:10
@romac
Copy link
Member Author

romac commented Sep 3, 2020

Since the test I had to comment out was just testing that the version number emitted by the light-node CLI was correct, I feel like this should not be a blocker to merge this PR, though we will at some point need to figure out how to fix the issue anyhow (or just hope that a Cargo update will resolve it, might open an issue on the Rust bugtracker or post on /r/rust in the meantime).

@romac
Copy link
Member Author

romac commented Sep 8, 2020

Light Client Browser

Comment on lines +161 to +173
light-client-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: wasm32-unknown-unknown
- name: Build Tendermint for WASM
run: cd tendermint && cargo build --target wasm32-unknown-unknown --release --no-default-features
- name: Build Light Client for WASM
run: cd light-client && cargo build --target wasm32-unknown-unknown --release --no-default-features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wohoooo 🎉

melekes
melekes previously approved these changes Sep 9, 2020
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

brapse
brapse previously approved these changes Sep 9, 2020
Copy link
Contributor

@brapse brapse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this 👍

Copy link
Contributor

@brapse brapse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brapse brapse merged commit 76d5e82 into master Sep 9, 2020
@brapse brapse deleted the romain/wasm branch September 9, 2020 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants