0xMiden / 0xMiden/protocol

Consider checking consistency between component names and library paths

オープン
#2,599 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
standards
主要言語
Rust
スター
132
フォーク
167
平均マージ
1日 23時間
マージ済み PR(30日)
110

説明

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

https://github.com/0xMiden/protocol/issues/2399 proposed to check that component name is a prefix of the library path and https://github.com/0xMiden/protocol/pull/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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。