refactor(standards): rename the config note selector to the note variant - #3838
Conversation
| - [BREAKING] Updated the Miden VM and crypto crate family to v0.30.0 and `midenc-hir-type` to v0.12.0. `LocalTransactionProver::new` now takes `miden_prover::Prover`, `CoreLibrary` exposes one merged package, and `TransactionVerifier::verify` now returns `VerificationOutcome` so callers can handle outstanding precompile work ([#3782](https://github.com/0xMiden/protocol/pull/3782)). | ||
| - [BREAKING] Removed the `BlockProof` placeholder in favor of `ExecutionProof` on `ProvenBlock`, matching `ProvenTransaction` and `ProvenBatch`, and `LocalBlockProver::prove` now takes an `ExecutedBlock` ([#3703](https://github.com/0xMiden/protocol/pull/3703)). | ||
| - Added the `miden::protocol::tx::before_block_witness_load` kernel event, emitted before a block other than the reference block is read from the partial blockchain ([#3699](https://github.com/0xMiden/protocol/pull/3699)). | ||
| - [BREAKING] Renamed the config note dispatch selector to the note variant, which renames the `VARIANT_*` and `ERR_*_UNKNOWN_VARIANT` constants and changes the config note script roots ([#3838](https://github.com/0xMiden/protocol/pull/3838)). |
There was a problem hiding this comment.
| - [BREAKING] Renamed the config note dispatch selector to the note variant, which renames the `VARIANT_*` and `ERR_*_UNKNOWN_VARIANT` constants and changes the config note script roots ([#3838](https://github.com/0xMiden/protocol/pull/3838)). | |
| - [BREAKING] Renamed the config note dispatch selector to the note variant; the config note script roots change ([#3838](https://github.com/0xMiden/protocol/pull/3838)). |
nit: the constants are more like implementation details that we don't really need to include imo
PhilippGackstatter
left a comment
There was a problem hiding this comment.
LGTM! Left a few optional suggestions.
| # ================================================================================================= | ||
|
|
||
| const ERR_NETWORK_ACCOUNT_CONFIG_UNKNOWN_SELECTOR = "network account config note selector does not match a known action" | ||
| const ERR_NETWORK_ACCOUNT_CONFIG_UNKNOWN_VARIANT = "network account config note variant does not match a known action" |
There was a problem hiding this comment.
nit: I think the situation is now that we use both "variant" and "action" synonymously, so two terms for the same thing and ideally it would be just one. But I'm not sure how to fix it since just using "variant" isn't always clear. Feel free to ignore.
There was a problem hiding this comment.
Agreed, it seems similar, but I would keep this for now as the "variant" is more like the discriminator in the storage for an "action" note.
| //! - Mirrors the variant in a Rust enum over the actions, with the `VARIANT_*` constants the note | ||
| //! script dispatches on kept in sync with the constants in its `.masm` file. |
There was a problem hiding this comment.
| //! - Mirrors the variant in a Rust enum over the actions, with the `VARIANT_*` constants the note | |
| //! script dispatches on kept in sync with the constants in its `.masm` file. |
nit: Not meaningful information I think.
| //! Two notes predate the first-item rule and keep the variant in the item following a word-sized | ||
| //! payload ([`FaucetPolicyConfig`] and [`NetworkAccountConfig`]), so that payload stays | ||
| //! word-aligned and loadable with a single `mem_loadw_le`; [`FaucetMetadataConfig`] instead keeps | ||
| //! the variant first and pads it out to a full word. Moving them onto the first item is tracked | ||
| //! separately, since it changes their storage layout. |
There was a problem hiding this comment.
nit: I think this belongs in a GH issue, not in a code comment. Consider removing.
mmagician
left a comment
There was a problem hiding this comment.
Overall LGTM ✅ but I'd slightly adapt the docs
|
|
||
| #! NetworkAccountConfig script: mutates a network account's script allowlists and allowed fee policy | ||
| #! roots, dispatched on a selector stored in the first note storage item. | ||
| #! roots, dispatched on the note variant stored in the note storage item after the root. |
There was a problem hiding this comment.
nit: I actually think the position in storage is irrelevant for the procedure docs altogether
There was a problem hiding this comment.
For this PR, we should leave it as is, but I wonder if more generally we want the variant item to always be the first item in the storage. If we do decide to do this, this can be done in a follow-up PR.
There was a problem hiding this comment.
I wonder if more generally we want the variant item to always be the first item in the storage
Why would we want that? I don't see any added benefit.
In fact, it makes some things more complicated: e.g. for some notes, there is also a root passed in. And if the layout is [variant, ROOT], then we cannot use an aligned mem_loadw for the root anymore, we'd need to read it in element-by-element.
There was a problem hiding this comment.
I think this could simplify parsing downstream (e.g., in the wallet, explorer etc.) - but I agree there are trade-offs. So, maybe just create an issue for now and then we can discuss pros/cons. In any case, not a priority for v0.17 release trunk.
| //! variant value in its storage. The variant is never inferred from the number of storage items | ||
| //! the note carries, nor from the procedures the consuming account happens to expose: the first | ||
| //! overloads one number to both select the path and size the payload, and the second makes the | ||
| //! path depend on the account the note is consumed against rather than on what the note was |
There was a problem hiding this comment.
let's avoid describing the non-behavior and focus on how the variant is conveyed
| //! | ||
| //! A note adopting the convention: | ||
| //! | ||
| //! - Carries the variant as a single felt in its first storage item, so reading it requires neither |
There was a problem hiding this comment.
is this true? some of the notes have the variant after the root
and as mentioned in other comments, I don't think we should put emphasis on the position in storage. So I'd drop that line entirely
There was a problem hiding this comment.
As mentioned in another comment, I think having the variant always be the first storage element would be a good property to have - but if it is not already the case, I'd do it separately.
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left a couple of comments inline - but these are for potential future changes.
|
|
||
| #! NetworkAccountConfig script: mutates a network account's script allowlists and allowed fee policy | ||
| #! roots, dispatched on a selector stored in the first note storage item. | ||
| #! roots, dispatched on the note variant stored in the note storage item after the root. |
There was a problem hiding this comment.
For this PR, we should leave it as is, but I wonder if more generally we want the variant item to always be the first item in the storage. If we do decide to do this, this can be done in a follow-up PR.
| //! | ||
| //! A note adopting the convention: | ||
| //! | ||
| //! - Carries the variant as a single felt in its first storage item, so reading it requires neither |
There was a problem hiding this comment.
As mentioned in another comment, I think having the variant always be the first storage element would be a good property to have - but if it is not already the case, I'd do it separately.
Summary
SELECTOR_*constants andselector()helpers toVARIANT_*andvariant(), and theERR_*_UNKNOWN_SELECTORerror constants toERR_*_UNKNOWN_VARIANT.note::config, including the three notes that do not keep the variant in the first storage item.NetworkAccountConfigscript and type docs, which placed the variant in the first storage item instead of the item after the root.Closes #3834.