0xMiden / 0xMiden/tutorials

Issues with Rust tutorials

未关闭
#191 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
18
派生
34
PR 合并指标
30 天内没有已合并 PR

描述

### Packages versions

0.14

### Bug description

# Not compiling due to not using @note_script
In tutorials 4 (iterative notes), 5 (hash preimage note), 11 (network accounts) compiling notes WILL panic because notes are not up to date with 0.14 version are are not using @note_script notation. The panic message does not convey that so users have no way of knowing that.

```asm
# Instead of

begin
# ...
end

# note script should use

@note_script
pub proc main
# ...
end
```

# Tutorial 1 - using create_library
`create_library` should not be used like that, it should use code builder from client or use a persisted source manager. Using it like this WILL lead to un-explainable and misformed errors down the line like from issue: https://github.com/0xMiden/miden-vm/issues/2778, also referenced here: https://github.com/0xMiden/tutorials/issues/188

# Tutorial 10 - pragma oracle
- does not compile, `StorageMapKey` referenced from `miden_client::rpc::domain::account` is a private struct. It should be referenced from `miden_client::account::StorageMapKey`
- When point 1 is fixed it still dies with: thread 'main' (44407) panicked at src/main.rs:156:10:
Usage: oracle_data_query , it would be better perhaps to just hardcode it into the code example or leave a comment at that line (156), we learn we need to pass it as an argument only at the end of the tutorial even though it asks us to run the code before that point
- It seems no pragma oracles are online on the current testnet, i couldnt find a live oracle address from their offish docs (which point to their github)

# Relative imports
Even though in tutorial we create the project, folders and files - masm imports in the code are relative to the directory one above root dir. Running the tutorial code will error out with: `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }. This might be confusing for some users. I would suggest creating separate crates for tutorial maybe and referencing `env!("CARGO_MANIFEST_DIR")` when loading paths, this way you can keep a monorepo of tutorials and it will still work with `--bin tutorial_name` if referenced in a workspace Cargo.toml as members.

# Nits / General

- `Cargo.toml` imports libs not needed in the tutorials: `serde`, `serde_json` and `rand_chacha`
- a lot of types are referenced in the long format like std::sync::Arc and std::Path even though they are imported in the header making code unnecessarily bloated
- imports could be compacted, they import from miden_client on multiple lines instead in one single import

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。