Skip to content

Conversation

obycode
Copy link
Contributor

@obycode obycode commented Sep 18, 2025

Implements contract post-conditions as described in #6396 and SIP PR stacksgov/sips#218.

@obycode obycode force-pushed the feat/restrict-assets branch 2 times, most recently from 9a75478 to e02ca38 Compare September 18, 2025 21:39
@obycode
Copy link
Contributor Author

obycode commented Sep 19, 2025

In implementing this, I'm wondering if it might be better to make a small change to the with-nft allowance. Currently, it is:

(with-nft contract-id:principal token-name:(string-ascii 128 identifier:T)

I'm wondering if it makes more sense to change that to allow a list of identifiers:

(with-nft contract-id:principal token-name:(string-ascii 128 identifier:(list T 128))

This would allow the list to be built within the code and then passed to a single allowance expression for each NFT.

@obycode obycode force-pushed the feat/restrict-assets branch 4 times, most recently from efeeab5 to b922ae9 Compare September 21, 2025 13:19
@obycode obycode force-pushed the feat/restrict-assets branch from 663c1e9 to b450cd1 Compare September 22, 2025 16:10
@obycode obycode marked this pull request as ready for review September 22, 2025 17:47
@obycode obycode requested review from a team as code owners September 22, 2025 17:47
@obycode obycode requested review from kantai and removed request for kantai September 22, 2025 17:56
That infrastructure is not setup for handling PoX state, and the
stacking tracking in the asset maps is not setup yet any way.
@obycode
Copy link
Contributor Author

obycode commented Sep 22, 2025

Remaining work is to handle the with-stacking allowances, but the rest of this can be reviewed now.

@obycode obycode requested review from hstove and kantai September 22, 2025 18:09
@obycode obycode requested a review from hstove October 1, 2025 20:12
@obycode
Copy link
Contributor Author

obycode commented Oct 1, 2025

@hstove TODOs resolved, additional tests added, and merge conflicts resolved.

hstove
hstove previously approved these changes Oct 7, 2025
Copy link
Contributor

@hstove hstove 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
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.

This looks good to me, just have a few comments

This replaces a `HashSet<String>` which was using the serialized value
for quick lookups, but added the extra overhead on setup and use of
serializing the values. With this new design, the value is used
directly, with no new allocations, and then a linear search is required
through the `Vec`, but in the common case, the number of entries will be
very low.
This is necessary because the costs-4 contract was updated. I verified
that the consensus tests passed if I removed the new functions in that
contract.
@brice-stacks
Copy link

The consensus tests fail because this branch adds new functions into costs-4.clar, so it should be consensus-breaking. I validated that if I removed those new functions, the chainstate matched.

kantai
kantai previously approved these changes Oct 10, 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!

@obycode obycode linked an issue Oct 10, 2025 that may be closed by this pull request
@obycode obycode added this pull request to the merge queue Oct 13, 2025
Merged via the queue into stacks-network:develop with commit 0efc005 Oct 13, 2025
303 of 307 checks passed
@obycode obycode deleted the feat/restrict-assets branch October 13, 2025 16:08
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 96.59349% with 135 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.08%. Comparing base (4c652ad) to head (a74c5f8).
⚠️ Report is 39 commits behind head on develop.

Files with missing lines Patch % Lines
stacks-node/src/tests/nakamoto_integrations.rs 97.23% 56 Missing ⚠️
clarity/src/vm/functions/post_conditions.rs 86.56% 43 Missing ⚠️
...lysis/type_checker/v2_1/natives/post_conditions.rs 93.05% 15 Missing ⚠️
clarity/src/vm/contexts.rs 88.88% 5 Missing ⚠️
pox-locking/src/pox_4.rs 77.77% 4 Missing ⚠️
clarity-types/src/errors/analysis.rs 62.50% 3 Missing ⚠️
stackslib/src/clarity_vm/tests/costs.rs 90.32% 3 Missing ⚠️
clarity-types/src/types/mod.rs 71.42% 2 Missing ⚠️
stackslib/src/clarity_vm/tests/analysis_costs.rs 85.71% 2 Missing ⚠️
...y/src/vm/analysis/type_checker/v2_1/natives/mod.rs 80.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6516      +/-   ##
===========================================
+ Coverage    80.03%   80.08%   +0.04%     
===========================================
  Files          568      571       +3     
  Lines       347679   351593    +3914     
===========================================
+ Hits        278280   281574    +3294     
- Misses       69399    70019     +620     
Files with missing lines Coverage Δ
clarity-types/src/errors/mod.rs 75.30% <ø> (ø)
clarity-types/src/types/signatures.rs 92.66% <ø> (ø)
clarity/src/vm/analysis/arithmetic_checker/mod.rs 92.48% <100.00%> (ø)
clarity/src/vm/analysis/read_only_checker/mod.rs 88.67% <100.00%> (+1.11%) ⬆️
.../src/vm/analysis/type_checker/v2_05/natives/mod.rs 89.47% <ø> (ø)
clarity/src/vm/analysis/type_checker/v2_1/mod.rs 90.34% <ø> (ø)
...c/vm/analysis/type_checker/v2_1/tests/contracts.rs 95.74% <100.00%> (ø)
...ity/src/vm/analysis/type_checker/v2_1/tests/mod.rs 99.84% <ø> (ø)
clarity/src/vm/costs/cost_functions.rs 100.00% <100.00%> (ø)
clarity/src/vm/costs/costs_1.rs 100.00% <100.00%> (ø)
... and 21 more

... and 52 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 4c652ad...a74c5f8. 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

None yet

Development

Successfully merging this pull request may close these issues.

[Clarity-4] restrict-assets?

4 participants