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

Fix WASM #99

Merged
merged 4 commits into from
Oct 25, 2024
Merged

Conversation

uncomputable
Copy link
Collaborator

This crate was broken on WASM; make it compile again. Check WASM compilation in CI. Fix broken debug symbols on WASM.

@uncomputable
Copy link
Collaborator Author

Fixed how the value of dbg!(x) is printed when using debug symbols.

uncomputable added a commit to uncomputable/simfony-webide that referenced this pull request Oct 20, 2024
Patch secp256k1-zkp to work in WASM.

Use my local branch until
BlockstreamResearch/simfony#99 is merged.
@apoelstra
Copy link
Contributor

My local CI cannot handle patches in Cargo.toml. Can you just PR to rust-secp-zkp to do a new minor release?

@uncomputable
Copy link
Collaborator Author

The CMR used in debug symbols was a hash of the literal span of the
affected function call expression. It turns out that the spans from the
PEST library differ on x86 and WASM. This resulted in entirely different
debug symbols and entirely different root CMRs of programs with debug
symbols.

To fix this, we assign each span an index. Instead of hashing the span,
we hash its index. Because the PEST parser maintains identity and order
of spans on all architectures, the resulting debug symbols are the same
on all architectures.
The debug symbol for `dbg!(x)` used the span of `x`. If `x` was an
expression with its own debug symbol, then there would be a conflict.
For example, `dbg!(jet::bip_0340_verify(...))` would have one debug
symbol instead of two.

An easy fix is to use the whole span of `dbg!(x)` for its debug symbol.
We have to trim the `dbg!(` prefix and `)` suffix for the text of the
debug symbol.
@uncomputable
Copy link
Collaborator Author

Updated this PR to use the latest version of rust-secp256k1-sys. Remove the Cargo.toml [patch].

Copy link
Contributor

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 7c91cab; successfully ran local tests

@apoelstra apoelstra merged commit 21ce1a5 into BlockstreamResearch:master Oct 25, 2024
12 checks passed
@uncomputable uncomputable deleted the 2024-10-fix-wasm branch October 25, 2024 14:40
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.

2 participants