Skip to content

Pausable#2793

Open
onurinanc wants to merge 12 commits intonextfrom
pausable
Open

Pausable#2793
onurinanc wants to merge 12 commits intonextfrom
pausable

Conversation

@onurinanc
Copy link
Copy Markdown
Collaborator

Closes issue including the design discussion provided here: #2241

This PR adds a Pausable component without Access Control mechanism included as we split this work into small PRs.

In the next PRs, we'll integrate the following features:

  • Pausing is controlled by the owner.
  • Pausing is controlled by some role in an RBAC setup.

Related Issues:

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth 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! Thank you! I left just a few questions/comments inline.

Comment on lines +56 to +57
#! This procedure does not verify the caller. Wrap with access control in the account component
#! composition if only privileged accounts should pause.
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.

This will be changed in a follow-up PR, right? (i.e., we'll have owner-based or RBAC-based checks)

Comment on lines +119 to +120
#! Invocation: exec
pub proc assert_not_paused
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 related to this PR, but we now technically have two types of procedures exposed by a component:

  • Procedures that form the public interface - these procedures are the ones included in the account's code commitment and they must be invoked using the call instruction.
  • Procedures that can be invoked by other components deployed in the account - usually, via the exec instruction.

The above distinction doesn't matter too much for the components that just re-export functionality from the standard library, but for non-standardized components it would make a difference. And so, it may be a good idea to make this destination explicity.

One way to do it is by switching to attributes to identify exported procedures. This would follow the approach we've taken with note scripts (and soon will take with transaction scripts). For example, we could have @interface(external) and @interface(internal) attributes to identify these two types - though, better naming would probably be needed.

cc @mmagician, @greenhat, @bitwalker in case you guys have thoughts on this.

Comment on lines +170 to +186
pub proc on_before_asset_added_to_account
exec.assert_not_paused
# => [ASSET_KEY, ASSET_VALUE, pad(8)]

dropw
# => [ASSET_VALUE, pad(12)]
end

#! Callback when a callbacks-enabled asset is added to an output note.
#!
#! Panics if this faucet account is paused.
#!
#! Inputs: [ASSET_KEY, ASSET_VALUE, note_idx, pad(7)]
#! Outputs: [ASSET_VALUE, pad(12)]
#!
#! Invocation: call
pub proc on_before_asset_added_to_note
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.

Why do we need these callbacks here? I was imagining that they'd be defined in more specific contexts (e.g., in regulated stablecoin).

Comment on lines +68 to +69
/// Component library path (merged account module name).
pub const NAME: &'static str = "miden::standards::components::utils::pausable";
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.

Similar to my comments in another PR: I don't think we should include components in component name. I think this could probably be just:

miden::standards::utils::pausable

Though, if we find something more descriptive than just utils, that would be better.

In either case, we should make sure that slot and component names are consistent - i.e., component name is a prefix of the slot names within that component.

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.

2 participants