Skip to content

fix(standards): declare faucet callback slots in TokenPolicyManager schema - #3648

Merged
mmagician merged 5 commits into
nextfrom
fix-add-missing-callback-slots
Aug 28, 2026
Merged

fix(standards): declare faucet callback slots in TokenPolicyManager schema#3648
mmagician merged 5 commits into
nextfrom
fix-add-missing-callback-slots

Conversation

@onurinanc

Copy link
Copy Markdown
Collaborator

Closes: #3647

@mmagician mmagician left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall LGTM, but this simple change should not be accompanied by that much code comments IMO

Comment thread crates/miden-standards/src/account/policies/manager.rs Outdated
Comment thread crates/miden-standards/src/account/policies/manager.rs Outdated
Comment thread crates/miden-standards/src/account/policies/manager.rs Outdated
Comment thread crates/miden-standards/src/account/policies/manager.rs Outdated

@bobbinth bobbinth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Thank you! I left a couple of comments inline.

Comment on lines +585 to +588
WordSchema::new_simple_with_default(
SchemaType::native_word(),
Self::invoke_receive_policy_root().as_word(),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but we should introduce a new SchemaType which specifically indicates that we are storing a root of a procedure in this storage slot. Let's create an issue for this.

Comment on lines 661 to 667
if self.has_transfer_policy() {
let callback_slots = AssetCallbacks::new()
.on_before_asset_added_to_account(Self::invoke_receive_policy_root().as_word())
.on_before_asset_added_to_note(Self::invoke_send_policy_root().as_word())
.into_storage_slots();
slots.extend(callback_slots);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, this would cause a divergence between the actual storage of an account the storage schema. Specifically, when has_transfer_policy() == false, the storage would not contain these 2 slots, while the storage schema will (since we add it unconditionally). So, I don't know if we've actually fixed the issue:

  • Before this PR, storage and schema would diverge when has_transfer_policy() == true.
  • After this PR, storage and schema would diverge when has_transfer_policy() == false.

I think there are two potential ways to fix it:

  • Add these two storage slots unconditionally (same as we do with the schema). The downside is that this would waste 2 slots for components that don't need callbacks.
  • Change how we build component metadata - instead of making it struct-based, we can make it instance based (i.e., component_metadata() would take &self as a parameter).

The second option a more "correct" fix - but I haven't thought through of all the downstream impacts of this (i.e., don't know how difficult it is to implement).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not directly related to this PR, but I think this problem is also present in #3587, since we can't express conditionals in the toml structure. So we'd probably have to define all slots that could be present in the toml and then selectively remove them some of them from Rust code if they are not present for a particular configuration (i.e. in the component_metadata accessor). For example, Authority wouldn't have the RBAC procedure roots slot if it was configured as OwnerControlled.

Not very clean, but I can't think of a better solution. cc @TomasArrachea

@bobbinth bobbinth Aug 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure this comment was addressed - we still have divergence between storage and storage schema (now this happens when has_transfer_policy() == false) - or am I missing something?

Created #3772 for this.

@mmagician mmagician left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM thanks!

…lots

# Conflicts:
#	crates/miden-standards/src/account/policies/manager.rs
@mmagician
mmagician added this pull request to the merge queue Aug 28, 2026
Merged via the queue into next with commit 886ec97 Aug 28, 2026
19 checks passed
@mmagician
mmagician deleted the fix-add-missing-callback-slots branch August 28, 2026 10:35
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.

TokenPolicyManager Schema Omits Its Own Callback Slots, So Schema-Built Faucets Deploy With Transfer Policies That Never Run

4 participants