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
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! Mainly I see that you have some unwritten integration test TODOs, but otherwise everything looks really well tested.

@obycode
Copy link
Contributor Author

obycode commented Sep 30, 2025

LGTM! Mainly I see that you have some unwritten integration test TODOs, but otherwise everything looks really well tested.

Thanks @hstove! I actually forgot about those TODOs I had at the bottom. The remaining tests I planned to add were:

  1. Replicate the existing checks in check_with_stacking_allowances but with calls to stack-stx instead of delegate-stx
  2. Duplicate check_restrict_assets_rollback but using as-contract?

Do you see any others that should get added?

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