Skip to content

fix(skills): update Rust SDK skills with Miden Day feedback#36

Merged
greenhat merged 3 commits intomainfrom
fix/rust-sdk-skills-miden-day-feedback
Apr 15, 2026
Merged

fix(skills): update Rust SDK skills with Miden Day feedback#36
greenhat merged 3 commits intomainfrom
fix/rust-sdk-skills-miden-day-feedback

Conversation

@Keinberger
Copy link
Copy Markdown
Collaborator

Context

During Miden Day (2025-03-17), 11 builders used the agentic template and found incorrect API references, missing patterns, and misleading guidance in the Rust SDK skill files. Issues #28, #29, #30 capture the verified corrections. All changes validated against local source repos on main.

Changes

rust-sdk-pitfalls (#28)

  • Add 7 new pitfalls (P8-P14): Felt::new() Result type, Value read annotations, NoteType construction, AccountId.prefix() type, Felt conversion limits, note-to-component call boundary, note input immutability
  • Update P1 with max Felt value warning (p-1 vs u64::MAX)
  • Update P7 with NoteType::Private requirement for P2ID notes

rust-sdk-patterns (#29)

  • Rewrite P2ID section: fix Recipient::compute signature (Digest not Word), add Digest no-Copy note, link to miden-bank
  • Add Asset::new(Word) to asset handling, add alloc requirement to note inputs
  • Add asset receiving via component methods section with miden-bank links

rust-sdk-testing-patterns (#30)

  • Fix FungibleAsset import path, faucet total_issuance param, add_output_note builder clarification
  • Add block numbering, note construction rule, multi-transaction test pattern sections
  • Add dedicated asset-bearing note example section with NoteAssets + FungibleAsset guidance

Closes #28, closes #29, closes #30

@Keinberger Keinberger requested a review from greenhat April 8, 2026 16:14
@Keinberger Keinberger mentioned this pull request Apr 8, 2026
4 tasks
Copy link
Copy Markdown
Contributor

@greenhat greenhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Please check my notes.


**Constructor**: `Asset::new(word)` creates an Asset from a Word.

See [miden-bank bank-account](../../../../miden-bank/contracts/bank-account/src/lib.rs) for complete asset handling patterns including deposit, withdrawal, and balance tracking.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the path here. Do we expect an agent to clone miden-bank there?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for the same paths introduced below.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the idea is to have agents have access to the miden-bank code, working examples turn out to be incredibly helpful for them. I'll update the path to a Github link.

**Key details:**

- `Recipient::compute(serial_num: Word, script_digest: Digest, inputs: Vec<Felt>)` — the second parameter is `Digest`, not `Word`.
- `Digest` does not implement `Copy`. Use `.clone()` when reusing a digest in loops or across calls.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to do that much hand-holding in our skills? I mean, if some weak model is incapable of figuring this out, I bet it would fail to build any meaningful solution anyway. SOTA models were capable of fixing it a year ago from the compiler build errors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, removing the padding detail.

```
**Key details:**

- `Recipient::compute(serial_num: Word, script_digest: Digest, inputs: Vec<Felt>)` — the second parameter is `Digest`, not `Word`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recipient::compute is replaced with note::build_recipient in #37 in this piece of code. I suggest removing this change in favor of #37.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, removing the entire Recipient::compute section in favor of #37's note::build_recipient.


- `Recipient::compute(serial_num: Word, script_digest: Digest, inputs: Vec<Felt>)` — the second parameter is `Digest`, not `Word`.
- `Digest` does not implement `Copy`. Use `.clone()` when reusing a digest in loops or across calls.
- P2ID inputs must be padded to 8 elements: `[suffix, prefix, 0, 0, 0, 0, 0, 0]`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not true with note::build_recipient.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing, only applies to the old API.

- `Recipient::compute(serial_num: Word, script_digest: Digest, inputs: Vec<Felt>)` — the second parameter is `Digest`, not `Word`.
- `Digest` does not implement `Copy`. Use `.clone()` when reusing a digest in loops or across calls.
- P2ID inputs must be padded to 8 elements: `[suffix, prefix, 0, 0, 0, 0, 0, 0]`.
- In host/test code, use `NoteRecipient` (from miden-client) instead of `Recipient` for constructing notes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have NoteRecipient used in code in #37. I would rather not put in skills what can be deduced from the code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the code examples show it.

Notes receive data via inputs (Vec<Felt>), accessed with `active_note::get_inputs()`:
Notes receive data via inputs (Vec<Felt>), accessed with `active_note::get_inputs()`.

**Requires alloc**: Since `get_inputs()` returns `Vec<Felt>`, you must have `extern crate alloc;` and `use alloc::vec::Vec;` in your `#![no_std]` contract. See the [no-std setup in any contract](../../../contracts/counter-account/src/lib.rs).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, we should not cater to models that cannot figure this out on their own.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, removing.


**NoteType for P2ID**: P2ID output notes created in contract code should use `NoteType::Private` (value 2, see P10). Using `NoteType::Public` triggers an opaque "missing details in advice provider" error at execution time. See [miden-bank withdraw](../../../../miden-bank/contracts/bank-account/src/lib.rs) for the working pattern.

## P8: Felt::new() Returns Result in Contract Code
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore. Now it's in sync with the off-chain API and wraparound.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, removing P8.


**Severity**: Medium -- causes compilation errors

`Value::read()` is generic over `V: From<Word>`, so an explicit type annotation is mandatory. Omitting it causes a type inference error.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer relevant for the new account storage API.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing P9.


**Severity**: Medium -- causes compilation errors

In contract code (compiler SDK), only `as_u64()` exists for converting Felt to integer. `as_int()` is available in host/test code only. `as_u32()` does not exist. For construction, `Felt::from_u32()` is available.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer true with the new Felt API.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing P12.


**Severity**: Low -- causes incorrect architecture

Note inputs (`active_note::get_inputs()`) are baked at note creation time and cannot be modified after creation. Design note input layouts carefully before deployment.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note inputs (`active_note::get_inputs()`) are baked at note creation time and cannot be modified after creation. Design note input layouts carefully before deployment.
Note inputs (`active_note::note_storage()`) are baked at note creation time and cannot be modified after creation. Design note input layouts carefully before deployment.

Copy link
Copy Markdown
Collaborator Author

@Keinberger Keinberger Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey, keeping P14 with updated active_note::get_storage() wording.

@Keinberger
Copy link
Copy Markdown
Collaborator Author

Looks good overall. Please check my notes.

Hey @greenhat, thanks for the review!

I'll push an updated commit that strips the outdated content. Here's what I'm planning:

Updating:

  • Replacingmiden-bank relative paths with GitHub links to the tutorials repo
  • The entire Recipient::compute / P2ID section (superseded by note::build_recipient in Migrate to the client v0.14 #37)
  • Pitfalls P8, P9, P12 (outdated with the new Felt and storage APIs)
  • The hand-holding tips (padding details, alloc requirement, Digest Copy)
  • Raw note storage access pattern

Keeping (unique content not in #37):

  • P13 (note scripts can't call native_account): still valid
  • P14 (note inputs immutable): updated wording to use active_note::get_storage()
  • Testing patterns: multi-transaction flow, block numbering, note construction, asset-bearing notes

I'll also double-check P10 and P11 against v0.14 and remove them if they're no longer relevant.

Thanks!

@Keinberger Keinberger requested a review from greenhat April 14, 2026 13:26
Copy link
Copy Markdown
Contributor

@greenhat greenhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@greenhat greenhat merged commit 700222c into main Apr 15, 2026
3 of 5 checks passed
@greenhat greenhat deleted the fix/rust-sdk-skills-miden-day-feedback branch April 15, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants