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

Rename light-client to web-client and improve logging for wasm #1277

Merged
merged 2 commits into from
Jan 23, 2023

Conversation

jsdanielh
Copy link
Member

  • Rename the light-client crate to web-client and re-write the
    client code to be wasm friendly.
  • Add a web logging feature to the nimiq-lib crate that makes use of
    the tracing-web crate.

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@@ -1,9 +1,9 @@
[package]
name = "nimiq-light-client"
name = "nimiq-web-client"
Copy link
Member

Choose a reason for hiding this comment

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

I think we should specify this crate only builds for wasm32

Copy link
Member

Choose a reason for hiding this comment

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

[build]
target = "wasm32-unknown-unknown"

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, AFAIK this is not supported

Copy link
Member

Choose a reason for hiding this comment

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

Tracking issue: rust-lang/cargo#6179

web-client/src/lib.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 20, 2023

Codecov Report

Base: 67.56% // Head: 67.57% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (a5acd75) compared to base (26c8a84).
Patch coverage: 0.90% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##           albatross    #1277      +/-   ##
=============================================
+ Coverage      67.56%   67.57%   +0.01%     
=============================================
  Files            396      397       +1     
  Lines          50557    50565       +8     
=============================================
+ Hits           34157    34170      +13     
+ Misses         16400    16395       -5     
Flag Coverage Δ
unittests 67.57% <0.90%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/src/extras/logging.rs 0.00% <ø> (ø)
lib/src/extras/web_logging.rs 0.00% <0.00%> (ø)
log/src/lib.rs 9.73% <0.00%> (ø)
web-client/src/lib.rs 1.42% <1.42%> (ø)
...twork-libp2p/src/discovery/message_codec/reader.rs 68.75% <0.00%> (-0.79%) ⬇️
validator/src/micro.rs 93.02% <0.00%> (-0.78%) ⬇️
handel/src/aggregation.rs 90.85% <0.00%> (-0.59%) ⬇️
consensus/src/sync/live/block_queue/mod.rs 82.84% <0.00%> (+0.24%) ⬆️
blockchain/src/blockchain/verify.rs 72.72% <0.00%> (+0.60%) ⬆️
network-mock/src/network.rs 85.11% <0.00%> (+2.23%) ⬆️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sisou
Copy link
Member

sisou commented Jan 20, 2023

Is the reason to rename, as @viquezclaudio indicates, that with the recent changes, this crate only builds for WASM, not for regular targets? Or any other reasoning?

@jsdanielh
Copy link
Member Author

Is the reason to rename, as @viquezclaudio indicates, that with the recent changes, this crate only builds for WASM, not for regular targets? Or any other reasoning?

It will build for other targets but won't run

@viquezclaudio
Copy link
Member

viquezclaudio commented Jan 21, 2023

Yup... it will panic during runtime if somebody tries to run the binary in not wasm targets, that's why I wanted (if possible) some way or forcing to compile it only for wasm

@sisou
Copy link
Member

sisou commented Jan 21, 2023

As an alternative to restricting valid targets for cargo, we should at least add a README file to the crate that specifies this incompatibility with non-wasm targets as a major warning.

@jsdanielh
Copy link
Member Author

As an alternative to restricting valid targets for cargo, we should at least add a README file to the crate that specifies this incompatibility with non-wasm targets as a major warning.

Done.

Add a web logging feature to the `nimiq-lib` crate that makes use of
the `tracing-web` crate.
@@ -0,0 +1,24 @@
# Nimiq web client

This client is a very light client that only includes the necessary dependencies and constructs
Copy link
Member

Choose a reason for hiding this comment

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

I think I will re phrase this:
This is a web-client intended to be used in web browsers only (no WASI support).
Although it can be built for other targets, it will panic if it is executed outside a web browser.

Rename the `light-client` crate to `web-client` and re-write the
client code to be `wasm` friendly.
@jsdanielh jsdanielh merged commit a5acd75 into albatross Jan 23, 2023
@jsdanielh jsdanielh deleted the jsdanielh/crate_features_2 branch January 23, 2023 23:49
@jsdanielh jsdanielh added this to the Nimiq 2.0 Testnet milestone Jan 25, 2023
@sisou sisou added the WASM label Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants