-
Notifications
You must be signed in to change notification settings - Fork 106
Add reusable ownable module and refactor network fungible faucet to use it #2228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
9a73293
chore: fix `TransactionAuthenticator::get_signature()` docs
bobbinth 534aa0e
chore: fix lints
bobbinth b351216
test: simplify codebuilder creation (#2175)
igamigo 26f67f1
feat: Add From<&ExecutedTransaction> for TransactionHeader impl (#2178)
sergerad 8d70adc
chore: update protocol library docs (#2179)
PhilippGackstatter 2d6e5a0
refactor: add `SlotName` to `StorageSlotHeader` (#2160)
Farukest 822c6a0
test: move tx header test logic (#2181)
sergerad 8bb2058
ci: improve dependency control & runner disk space (#2133)
huitseeker c0c1e3e
chore: refactor `AccountStorageDelta` to use `StorageSlotDelta` (#2182)
PhilippGackstatter ac944ef
refactor: Implement component schemas (#2193)
igamigo da7a823
chore: migrate to the VM v0.20.0 (#2158)
Fumuran 67884c3
chore: prepare split into protocol and standards (#2184)
PhilippGackstatter 55909b4
chore: move protocol components from `miden-lib` to `miden-objects` (…
PhilippGackstatter c8aad1b
feat: rename `miden-objects` into `miden-protocol` and `miden-lib` in…
PhilippGackstatter e6f0573
feat: add `Clone` to `NoteConsumptionStatus` (#2209)
juan518munoz 0c26f2a
refactor: rm `OLD_MAP_ROOT` from return of `set_map_item` (#2194)
partylikeits1983 dee1d48
feat: follow-ups from #2193 (#2207)
igamigo b4ac3da
feat: implement ownership management for network fungible faucet
afa7789 4fb098b
chore: restore stack manipulation
mmagician 3d90813
refactor: simplify ownership error handling and clean up unused proce…
afa7789 07fee30
feat: add renounce ownership functionality to network fungible faucet
afa7789 65c50a4
Update crates/miden-standards/asm/standards/utils/access/ownable.masm
afa7789 2a96753
chore: fix based on PR review.
afa7789 ca83cc2
feat: implement ownership management functionality in ownable module …
afa7789 1edb039
fix: update stack handling in transfer_ownership procedure for proper…
afa7789 0aa6d68
test: add unit test for get_owner procedure in network fungible faucet
afa7789 8d74f6d
refactor: clean up ownable module documentation and error constants, …
afa7789 79be861
feat: add ownable standard module for component ownership management …
afa7789 18a7d27
feat:import constants directly instead of getter procedures (#2221)
PoulavBhowmick03 bc34aa3
fix: ensure cargo-msrv is properly installed for MSRV check (#2234)
huitseeker 1512add
feat: add AccountId::parse() for hex and bech32 formats (#2223)
Farukest 7421546
chore: organize `miden-standards` (#2227)
mmagician 17b76f9
refactor: close gap in account memory layout (#2190)
PivasDesant 34392ae
chore: add error messages to asserts (#2239)
mmagician f696d29
feat: move standard note scripts into standard library (#2255)
Farukest c430514
chore: move MSRV check from PR CI to release workflows (#2233)
huitseeker 49377cd
feat: Read foreign account inputs and witnesses from transaction inpu…
sergerad b680282
feat: insert unpadded note inputs into `advice_inputs` (#2232)
mmagician c25d8f6
feat: Refactor `NoteTag` to contain an arbitrary `u32` (#2219)
PhilippGackstatter a6a83ee
feat: add tx kernel support for `NoteAttachment` (#2249)
PhilippGackstatter 1f66663
feat: add `output_not_set_attachment` kernel API (#2252)
PhilippGackstatter 1978e6b
feat: introduce standard `NetworkAccountTarget` attachment (#2257)
PhilippGackstatter 8e47927
chore: Remove `aux` and `execution_hint` parameters from `output_note…
PhilippGackstatter 166d8c0
chore: rename `NoteAttachmentType` and `NoteAttachmentContentType` (#…
PhilippGackstatter 83dc36d
feat: add ownable standard module for component ownership management …
afa7789 fdfbfb5
refactor: simplify note creation by replacing auxiliary parameters wi…
afa7789 1d1bdf3
chore(cargo): fixing lint issues.
afa7789 c8bcbfe
Merge branch 'next' into openzeppelin/ownable
afa7789 1229dc0
Merge branch 'next' into openzeppelin/ownable
afa7789 d122730
Update crates/miden-standards/asm/standards/access/ownable.masm
afa7789 ac2374c
Update crates/miden-standards/asm/standards/access/ownable.masm
afa7789 196a491
Update crates/miden-standards/asm/standards/access/ownable.masm
afa7789 b3ae5f8
chore: Refactor error handling in faucet tests to use ERR_SENDER_NOT_…
afa7789 5428d53
chore: lint fix
afa7789 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
crates/miden-standards/asm/standards/access/ownable.masm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| # miden::standards::access::ownable | ||
| # | ||
| # Provides ownership management functionality for account components. | ||
| # This template can be imported and used by any component that needs owner controls. | ||
|
|
||
| use miden::protocol::active_account | ||
| use miden::protocol::account_id | ||
| use miden::protocol::active_note | ||
| use miden::protocol::native_account | ||
|
|
||
| # CONSTANTS | ||
| # ================================================================================================ | ||
|
|
||
| # The slot in this component's storage layout where the owner config is stored. | ||
| const OWNER_CONFIG_SLOT = word("miden::standards::access::ownable::owner_config") | ||
|
|
||
| # ZERO_ADDRESS word (all zeros) used to represent no owner | ||
| # Format: [prefix=0, suffix=0, 0, 0] as stored in account storage | ||
| const ZERO_ADDRESS = [0, 0, 0, 0] | ||
|
|
||
| # ERRORS | ||
| # ================================================================================================ | ||
|
|
||
| const ERR_SENDER_NOT_OWNER = "note sender is not the owner" | ||
|
|
||
| # INTERNAL PROCEDURES | ||
| # ================================================================================================ | ||
|
|
||
| #! Returns the owner AccountId from storage. | ||
| #! | ||
| #! Inputs: [] | ||
| #! Outputs: [owner_prefix, owner_suffix] | ||
| #! | ||
| #! Where: | ||
| #! - owner_{prefix, suffix} are the prefix and suffix felts of the owner AccountId. | ||
| proc owner | ||
| push.OWNER_CONFIG_SLOT[0..2] exec.active_account::get_item | ||
| # => [owner_prefix, owner_suffix, 0, 0] | ||
|
|
||
| # Storage format in memory: [0, 0, suffix, prefix] (word[0], word[1], word[2], word[3]) | ||
| # mem_loadw_be loads big-endian (reversed), so stack gets: [prefix, suffix, 0, 0] | ||
| # Stack: [owner_prefix (pos 0), owner_suffix (pos 1), 0 (pos 2), 0 (pos 3)] | ||
| # We want: [owner_prefix, owner_suffix] | ||
| # Move zeros to top using movup, then drop them | ||
| movup.2 | ||
| # => [0, owner_prefix, owner_suffix, 0] (moves element at pos 2 to pos 0) | ||
|
|
||
| movup.3 | ||
| # => [0, 0, owner_prefix, owner_suffix] (moves element at pos 3 to pos 0) | ||
|
|
||
| drop drop | ||
| # => [owner_prefix, owner_suffix] | ||
| end | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #! Checks if the given account ID is the owner of this component. | ||
| #! | ||
| #! Inputs: [account_id_prefix, account_id_suffix] | ||
| #! Outputs: [is_owner] | ||
| #! | ||
| #! Where: | ||
| #! - account_id_{prefix, suffix} are the prefix and suffix felts of the AccountId to check. | ||
| #! - is_owner is 1 if the account is the owner, 0 otherwise. | ||
| proc is_owner | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| exec.owner | ||
| # => [owner_prefix, owner_suffix, account_id_prefix, account_id_suffix] | ||
|
|
||
| exec.account_id::is_equal | ||
| # => [is_owner] | ||
|
|
||
| end | ||
|
|
||
| # PUBLIC INTERFACE | ||
| # ================================================================================================ | ||
|
|
||
| #! Checks if the note sender is the owner and panics if not. | ||
| #! | ||
| #! Inputs: [] | ||
| #! Outputs: [] | ||
| #! | ||
| #! Panics if: | ||
| #! - the note sender is not the owner. | ||
| pub proc verify_owner | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exec.active_note::get_sender | ||
| # => [sender_prefix, sender_suffix] | ||
|
|
||
| exec.is_owner | ||
| # => [is_owner] | ||
|
|
||
| assert.err=ERR_SENDER_NOT_OWNER | ||
| # => [] | ||
| end | ||
|
|
||
| #! Returns the owner AccountId. | ||
| #! | ||
| #! Inputs: [pad(16)] | ||
| #! Outputs: [owner_prefix, owner_suffix, pad(14)] | ||
| #! | ||
| #! Where: | ||
| #! - owner_{prefix, suffix} are the prefix and suffix felts of the owner AccountId. | ||
| #! | ||
| #! Invocation: call | ||
| pub proc get_owner | ||
| exec.owner | ||
| # => [owner_prefix, owner_suffix, pad(14)] | ||
| end | ||
|
|
||
| #! Transfers ownership to a new account. | ||
| #! | ||
| #! Can only be called by the current owner. | ||
| #! | ||
| #! Inputs: [new_owner_prefix, new_owner_suffix, pad(14)] | ||
| #! Outputs: [pad(16)] | ||
| #! | ||
| #! Where: | ||
| #! - new_owner_{prefix, suffix} are the prefix and suffix felts of the new owner AccountId. | ||
| #! | ||
| #! Panics if: | ||
| #! - the note sender is not the owner. | ||
| #! | ||
| #! Invocation: call | ||
| pub proc transfer_ownership | ||
| # Check that the caller is the owner | ||
| exec.verify_owner | ||
| # => [new_owner_prefix, new_owner_suffix, pad(14)] | ||
|
|
||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| push.0 movdn.2 push.0 movdn.2 | ||
| # => [new_owner_prefix, new_owner_suffix, 0, 0, pad(14)] | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| push.OWNER_CONFIG_SLOT[0..2] | ||
| # => [slot_prefix, slot_suffix, new_owner_prefix, new_owner_suffix, 0, 0, pad(14)] | ||
|
|
||
| exec.native_account::set_item | ||
| # => [OLD_OWNER_WORD, pad(14)] | ||
|
|
||
| # When the stack has 16 elements, dropw will shift in zeros from the right, | ||
| # resulting in [pad(16)]. So dropw is sufficient here. | ||
| dropw | ||
| # => [pad(16)] | ||
| end | ||
|
|
||
| #! Renounces ownership, leaving the component without an owner. | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #! | ||
| #! Can only be called by the current owner. | ||
| #! | ||
| #! Inputs: [pad(16)] | ||
| #! Outputs: [pad(16)] | ||
| #! | ||
| #! Panics if: | ||
| #! - the note sender is not the owner. | ||
| #! | ||
| #! Invocation: call | ||
| #! | ||
| #! Important Note! | ||
| #! This feature allows the owner to relinquish administrative privileges, a common pattern | ||
| #! after an initial stage with centralized administration is over. Once ownership is renounced, | ||
| #! the component becomes permanently ownerless and cannot be managed by any account. | ||
| pub proc renounce_ownership | ||
mmagician marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exec.verify_owner | ||
| # => [pad(16)] | ||
|
|
||
| # ---- Push ZERO_ADDRESS to storage ---- | ||
| push.ZERO_ADDRESS | ||
| # => [0, 0, 0, 0, pad(16)] | ||
|
|
||
| push.OWNER_CONFIG_SLOT[0..2] | ||
afa7789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # => [slot_prefix, slot_suffix, 0, 0, 0, 0, pad(16)] | ||
|
|
||
| exec.native_account::set_item | ||
| # => [OLD_OWNER_WORD, pad(16)] | ||
|
|
||
| dropw | ||
| # => [pad(16)] | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.