Skip to content

refactor: centralize dependencies and feature-gate stacks-common #6238

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

Conversation

Jiloc
Copy link
Contributor

@Jiloc Jiloc commented Jul 1, 2025

Description

This PR is the first of two (?) aiming at modularizing the clarity crate to enable a lightweight serialization/deserialization mode AND building on Wasm32 target, in two flavors:

  • wasm-web, with js support for the entire VM
  • wasm-deterministic for deterministc environments like CosmWasm, where rand is not supported.

This initial step focuses on preparing the workspace and refactoring stacks-common and feature-gate a couple of non-necessary features in stacks-common.

The key changes are:

  • Centralizing common dependencies (like serde, slog, lazy_static..) in the root Cargo.toml under [workspace.dependencies]. Some of those dependencies are only used by the stacks-common create in this PR, but will be used by the clarity create in the following.
  • Making nix optional in stacks-common via new ctrlc-handler feature flag.
  • Removed time from the dependencies, as it's not currently used (directly at least).
  • Remove default-features to chrono so to prevent pulling in additional dependencies that don't compile on CosmWasm and we don't use.

Extra, not mandatory (open to move in another PR):

  • Upgraded chrono to 0.4.41 from 0.4.19 to fix a known (minor for us) vulnerability https://osv.dev/vulnerability/RUSTSEC-2020-0159. We only use chrono for adding the timestamp to the logs.
  • Remove default-features for other dependencies we are not using.
  • Fix a clippy::let_and_return warning

This change is fully backward compatible. The default features have been updated to preserve the existing behavior, so no changes are required for downstream crates.

Super open to suggestions for improvements/gating additional features!

Applicable issues

Additional info (benefits, drawbacks, caveats)

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

@Jiloc Jiloc added this to the 3.1.0.0.13 milestone Jul 1, 2025
@Jiloc Jiloc self-assigned this Jul 1, 2025
@Jiloc Jiloc requested review from a team as code owners July 1, 2025 17:39
@obycode obycode modified the milestones: 3.1.0.0.13, 3.1.0.0.14 Jul 1, 2025
@Jiloc Jiloc moved this to Status: In Review in Stacks Core Eng Jul 2, 2025
@Jiloc Jiloc requested a review from a team as a code owner July 3, 2025 15:57
@aldur aldur requested review from kantai and fdefelici July 7, 2025 15:24
Copy link
Contributor

@fdefelici fdefelici left a comment

Choose a reason for hiding this comment

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

Looks good!

About the http-parser flag, I generally prefer keeping the number of feature flags to a minimum for simplicity 😊
That said, if we were to remove this flag, do you have a specific alternative in mind?

kantai
kantai previously approved these changes Jul 8, 2025
Copy link
Contributor

@kantai kantai left a comment

Choose a reason for hiding this comment

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

LGTM!

@Jiloc
Copy link
Contributor Author

Jiloc commented Jul 9, 2025

Looks good!

About the http-parser flag, I generally prefer keeping the number of feature flags to a minimum for simplicity 😊 That said, if we were to remove this flag, do you have a specific alternative in mind?

In the end the comment you made convinced me to remove it. The feature was small, and didn't add additional dependencies to the mix, no need to find a workaround :)

@Jiloc Jiloc requested review from fdefelici and kantai July 9, 2025 11:57
fdefelici
fdefelici previously approved these changes Jul 10, 2025
kantai
kantai previously approved these changes Jul 10, 2025
@github-project-automation github-project-automation bot moved this from Status: In Review to Status: 💻 In Progress in Stacks Core Eng Jul 10, 2025
@Jiloc Jiloc dismissed stale reviews from kantai and fdefelici via dc7be7b July 11, 2025 08:48
@Jiloc Jiloc requested review from kantai and fdefelici July 11, 2025 11:21
@Jiloc Jiloc moved this from Status: 💻 In Progress to Status: In Review in Stacks Core Eng Jul 11, 2025
@github-project-automation github-project-automation bot moved this from Status: In Review to Status: 💻 In Progress in Stacks Core Eng Jul 11, 2025
@Jiloc Jiloc added this pull request to the merge queue Jul 11, 2025
Merged via the queue into stacks-network:develop with commit 7d63003 Jul 11, 2025
236 of 240 checks passed
@Jiloc Jiloc deleted the chore/stacks-common-optional-requirements branch July 11, 2025 19:35
@github-project-automation github-project-automation bot moved this from Status: 💻 In Progress to Status: ✅ Done in Stacks Core Eng Jul 11, 2025
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.80%. Comparing base (381ee9b) to head (222096b).
Report is 16 commits behind head on develop.

Files with missing lines Patch % Lines
stacks-common/src/util/secp256k1/native.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6238      +/-   ##
===========================================
- Coverage    81.91%   81.80%   -0.11%     
===========================================
  Files          546      545       -1     
  Lines       347235   347218      -17     
  Branches       323      323              
===========================================
- Hits        284441   284057     -384     
- Misses       62786    63153     +367     
  Partials         8        8              
Files with missing lines Coverage Δ
stacks-common/src/deps_common/bitcoin/util/mod.rs 0.00% <ø> (ø)
stacks-common/src/libcommon.rs 75.00% <ø> (ø)
stacks-common/src/types/chainstate.rs 85.37% <100.00%> (ø)
stacks-common/src/util/chunked_encoding.rs 95.16% <ø> (ø)
stacks-common/src/util/mod.rs 88.88% <ø> (ø)
stacks-common/src/util/pipe.rs 86.25% <ø> (ø)
stacks-common/src/util/vrf.rs 88.15% <100.00%> (+0.52%) ⬆️
stackslib/src/burnchains/tests/burnchain.rs 99.86% <100.00%> (+<0.01%) ⬆️
stacks-common/src/util/secp256k1/native.rs 78.27% <0.00%> (+0.34%) ⬆️

... and 55 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 381ee9b...222096b. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants