Skip to content

Conversation

@lxfind
Copy link
Contributor

@lxfind lxfind commented Nov 24, 2025

Adds sui::protocol_config::is_feature_enabled() to allow Move code to query protocol feature flags at runtime. This enables conditional logic and fallbacks based on protocol version capabilities.

Description

Describe the changes or additions included in this PR.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

@lxfind lxfind requested a review from a team as a code owner November 24, 2025 18:34
@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sui-docs Ready Ready Preview Comment Nov 25, 2025 4:32pm
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
multisig-toolkit Ignored Ignored Preview Nov 25, 2025 4:32pm
sui-kiosk Ignored Ignored Preview Nov 25, 2025 4:32pm

Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Could you explain where you plan on using this? Previously we haven't needed any of this since we just shove this behavior in the native itself

@lxfind
Copy link
Contributor Author

lxfind commented Nov 25, 2025

I would like to gate object balance withdraw separately from address balance withdraw

@tnowacki
Copy link
Contributor

I would like to gate object balance withdraw separately from address balance withdraw

But both of those bottom out in a native function? Why not just gate within the native like we are doing currently?

@tnowacki
Copy link
Contributor

To be clear, I don't inherently dislike this PR by any means, it just seems like overkill unless we really need it.
(and I'm surprised if we do since we haven't needed it for like 3 years)

@lxfind
Copy link
Contributor Author

lxfind commented Nov 25, 2025

It's not though: https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/funds_accumulator.move#L86

I heard from Mark that he has wanted this a few times, but since there are always walkarounds (some not so ideal) so this wasn't ever a big complaint.

Comment on lines 11 to 13
#[allow(unused_const)]
#[error(code = 0)]
const EFeatureFlagNotFound: vector<u8> = b"Feature flag not found";
Copy link
Contributor

Choose a reason for hiding this comment

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

@tzakian how does this work with natives? (sorry should have added this here instead of the other PR)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm I'd err on not using a clever error for native errors as they can't really raise clever errors (since in particular there is no line number to report).

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes me a bit sad though 😢 but yea I think the best thing to do here is just a normal u64 constant error code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed all the errors and now they are just invariant violations

Copy link
Contributor

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

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

Overall LGTM, I just want to think through the error case: Both for clever errors, and for invariant violations.

I think it would be safe to just invariant violation on unknown/invalid strings? But maybe there is something tricky going on with upgrades?

Comment on lines 44 to 45
Err(_) => {
return Ok(NativeResult::err(
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should just make this an invariant violation in some way (similar with the error below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this should not happen unless we expose this to user packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made them invariants

Adds sui::protocol_config::is_feature_enabled() to allow Move code to query
protocol feature flags at runtime. This enables conditional logic and fallbacks
based on protocol version capabilities.
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.

4 participants