Skip to content

Consider checking consistency between component names and library paths #2599

@PhilippGackstatter

Description

@PhilippGackstatter

We now have various kinds of "names" defined in account components:

  • Account components have names, as returned by AccountComponentMetadata::name().
  • Account components have library paths through which their procedures are accessed, e.g. miden::standards::components::access::ownable2step::get_owner.
  • Account components have named storage slots, e.g. miden::standards::access::ownable2step::owner_config.

It would be great to have these names be consistent with each other, in particular that the component's name is a prefix of the library path and the storage slot names. The main goal is to avoid having multiple names for the same thing, which is confusing.

Ensuring this by hand is basically guaranteed to fail, so if we want this, we have to enforce it somewhere.

Library Paths

#2399 proposed to check that component name is a prefix of the library path and #2593 implements this.

I now realized this may not work too well for the compiler, since it has library paths like:

::"miden:bank-account/bank-account@0.1.0"::"get-balance"

I'm not sure why the compiler uses a single colon as a separator (I'm assuming quoted strings can contain ::). Are these paths user-defined or compiler-defined based on the project name? One way or another, they could probably be changed to something like ::"miden::bank_account*" and we could check for a prefix match by stripping the root :: (which is already done in that PR) and the quotes.

Though the other question is whether users end up seeing these paths at all? Maybe MASM users calling into a rust package? If the answer is no, then for the compiler this check would just add annoyance and no real value, so we may just decide not to have it.

cc @greenhat for compiler perspective

Storage Slot Names

Storage slot names are hard to include in this consistency check, because they cannot be re-exported like procedures can.

For instance, asset callbacks define a standard slot miden::protocol::faucet::callback::on_before_asset_added_to_account. However, this slot must be added by account components themselves, and so a component with name my_project::my_component would clearly violate this.

In many cases they should be consistent, but not in all, so unfortunately I don't see a way to enforce consistency here.

Conclusion

It would be nice to have consistency, and we may be able to make it work for names and library paths, but not for storage slot names. The larger question is whether trying to do this adds enough value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    standardsRelated to standard note scripts or account components

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions