Skip to content

feat: add defaults and public functions in clarity-vm for better tooling #6268

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

Merged
merged 9 commits into from
Jul 15, 2025

Conversation

hugocaillard
Copy link
Contributor

@hugocaillard hugocaillard commented Jul 8, 2025

Description

Fix: #5891

With the PR, the clarity-vm can be compiled to wasm32-unknown-unknown, as it is being using the clarinet JS SDK.

It mostly hide a few things behind compilation flags.

This PR also includes a few changes that are need for clarinet. Mostly by making public certain functions.

WIth this PR, this command passes:

cargo check -p clarity --no-default-features --target wasm32-unknown-unknown

Once this is merged, this check should be added to the CI.

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo
  • New integration test(s) added to bitcoin-tests.yml

@hugocaillard hugocaillard requested review from a team as code owners July 8, 2025 18:44
@hugocaillard
Copy link
Contributor Author

hugocaillard commented Jul 8, 2025

I just saw #6239, which is super promising for clarinet.

The two PRs enable similar things (compile to wasm), but also, this specific one (6268) add some changes needed specifically for clarinet.
I'm happy to move it in an other PR if needed

obycode
obycode previously approved these changes Jul 9, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

🎉

@hugocaillard hugocaillard force-pushed the chore/build-for-wasm32 branch from 7ece404 to 94c13c9 Compare July 9, 2025 08:33
@hugocaillard hugocaillard force-pushed the chore/build-for-wasm32 branch from 94c13c9 to 101a3bb Compare July 9, 2025 08:34
@hugocaillard
Copy link
Contributor Author

@obycode
I pushed an other commit, adding #[serde(default)] to symbolic expression developer-mode properties.
That useful when the vm with developer-mode enabled fetches data from the api (eg: clarinet mainnet execution simulation), and the api doesn't return the span.

obycode
obycode previously approved these changes Jul 9, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

👍

@aldur aldur requested a review from Jiloc July 10, 2025 14:48
@hugocaillard hugocaillard requested a review from Jiloc July 11, 2025 12:37
@hugocaillard
Copy link
Contributor Author

Thanks @Jiloc!

Jiloc
Jiloc previously approved these changes Jul 11, 2025
Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 16 lines in your changes missing coverage. Please review.

Project coverage is 64.82%. Comparing base (d185f2d) to head (117b7ac).
Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
clarity/src/vm/costs/mod.rs 0.00% 13 Missing ⚠️
clarity/src/vm/representations.rs 0.00% 3 Missing ⚠️

❌ Your project status has failed because the head coverage (64.82%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6268      +/-   ##
===========================================
- Coverage    67.41%   64.82%   -2.60%     
===========================================
  Files          545      545              
  Lines       347403   347411       +8     
  Branches       323      323              
===========================================
- Hits        234210   225217    -8993     
- Misses      113185   122186    +9001     
  Partials         8        8              
Files with missing lines Coverage Δ
clarity/src/vm/analysis/type_checker/v2_05/mod.rs 87.33% <100.00%> (-0.15%) ⬇️
clarity/src/vm/docs/mod.rs 71.16% <100.00%> (+26.98%) ⬆️
clarity/src/vm/mod.rs 90.38% <ø> (-0.26%) ⬇️
clarity/src/vm/representations.rs 81.17% <0.00%> (+2.44%) ⬆️
clarity/src/vm/costs/mod.rs 78.00% <0.00%> (-0.66%) ⬇️

... and 374 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d185f2d...117b7ac. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hugocaillard hugocaillard requested a review from Jiloc July 14, 2025 11:30
obycode
obycode previously approved these changes Jul 14, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

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

I tested it on my end and unfortunately cargo check -p clarity --no-default-features --target wasm32-unknown-unknown is currently now working. #6238 made into develop before this PR and removed all unnecessary default-features of the crates for supporting both wasm32 in javascript and deterministic environments.

In the comments I laid out a possible fix, which is to propagate the wasm-web feature from the clarity create to the stacks-common one and use the following command to built it:

cargo check -p clarity --no-default-features --features wasm-web --target wasm32-unknown-unknown

Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

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

Great, LGTM!

@hugocaillard hugocaillard requested a review from obycode July 15, 2025 10:12
@hugocaillard hugocaillard changed the title chore: build clarity for wasm32-unknown-unknown feat: add defaults and public functions in clarity-vm for better tooling Jul 15, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

lgtm

@obycode obycode added this pull request to the merge queue Jul 15, 2025
Merged via the queue into stacks-network:develop with commit 7c07804 Jul 15, 2025
237 of 241 checks passed
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants