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

Full Light Client WASM support #809

Open
1 of 2 tasks
Tracked by #958
thanethomson opened this issue Feb 11, 2021 · 3 comments
Open
1 of 2 tasks
Tracked by #958

Full Light Client WASM support #809

thanethomson opened this issue Feb 11, 2021 · 3 comments
Labels
enhancement New feature or request light-client Issues/features which involve the light client wasm

Comments

@thanethomson
Copy link
Contributor

thanethomson commented Feb 11, 2021

Follows from #463. I've modified this issue to turn it into a tracking issue for WASM support for the Light Client.

At present, the tendermint-light-client-js crate just exposes the Light Client's verify method to JavaScript, but leaves networking and the verification algorithm (e.g. forward bisection, or backwards verification) up to the implementer to implement in JavaScript.

In order to achieve a fully functional, WASM-compatible Light Client, we probably need several issues to be addressed:

There may be more issues that pop up in this process.

What's the definition of "done" for this issue?

When we can compile the tendermint-light-client crate to WASM and use all of its primary functionality (including networking, the verification algorithms, fork detection and evidence reporting) from JavaScript.

@shravanshetty1
Copy link

shravanshetty1 commented Aug 21, 2021

I have been trying to get this to work. I Implemented custom IO and EvidenceReporter traits using in memory store, however I am not able to figure out how to make requests in the trait methods.

fn fetch_light_block(&self, height: AtHeight) -> Result<LightBlock, IoError> {

let res = block_on(self.timeout, async move {

In the current implementation, when a request has to be made it blocks the thread until the call is complete, however I am not sure how this can be done in wasm since it does not allow any kind of blocking.

Also other than networking I see alot of blocking functionality being used in the crate such as message passing with crossbeam - I am not sure how we can make it wasm compatible.

@thanethomson
Copy link
Contributor Author

@shravanshetty1 you're right. So right now there are two options here:

  1. Use the fetch API to do the low-level networking, and then figure out how to make the async code play nicely with the non-async code.
  2. Implement all I/O and the forwards verification algorithm in JavaScript and just make use of the verify method from the tendermint-light-client-js crate. This wraps the verification functionality from the tendermint-light-client crate without any I/O support.

@shravanshetty1
Copy link

For now on my fork, I made everything async and removed send+sync conditions, the tests pass. Seems to atleast get initialized but its panicing because the crate is using std::Time. Probably need to port it to https://github.com/chronotope/chrono for wasm support

@thanethomson thanethomson changed the title Network I/O support for WASM build of Light Client Full Light Client WASM support Aug 25, 2021
@thanethomson thanethomson removed the rpc label Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request light-client Issues/features which involve the light client wasm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants