PSWAP follow-ups from #2909
- 主要语言
- Rust
- 星标
- 132
- 派生
- 167
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 110
描述
Tracking the deferred refactors and follow-ups identified during review of
#2909 (PSWAP discovery attachment).
## A. Finish the `AssetAmount` / `NonZeroU32` migration
- [ ] `PswapNoteStorage::requested_asset_amount()` returns `AssetAmount`
(currently `u64`, `pswap.rs:119`)
- [ ] `PswapNote::create_args(account_fill, note_fill)` takes `AssetAmount`
on both args (currently `u64`, `pswap.rs:336`)
- [ ] `PswapNoteAttachment::new(.., depth: NonZeroU32)` so `new` is infallible
- [ ] Propagate `depth: NonZeroU32` through `parent_depth`, `payback_note`,
`remainder_note`, and the MASM-bridge call sites
## B. Harden `PswapNoteAttachment` parsing
- [ ] Add `TryFrom<&NoteAttachment> for PswapNoteAttachment` that asserts
scheme == `PSWAP_ATTACHMENT_SCHEME`, `num_words == 1`, `depth != 0`,
and extracts `[amount, order_id, depth, 0]`
- [ ] Replace the manual `attachment_word[OFFSET]` indexing in
`PswapNote::parent_depth` (`pswap.rs:391`) with the new `TryFrom`
- [ ] Replace `first_attachment_word(...)` usages in
`crates/miden-testing/tests/scripts/pswap.rs` (9 sites) with
`PswapNoteAttachment::try_from(...)`
- [ ] Delete the free `pswap_output_attachment(...)` helper at
`pswap.rs:728` once `PswapNoteAttachment::new` +
`From for NoteAttachment` cover all call sites
## C. MASM safety asserts
- [ ] `assert num_words == 1` (via a named constant) in `get_current_depth`
before relying on the write into `@locals(4)` (`pswap.masm:517`)
- [ ] `u32assert` on the depth value before the `loc_load` /
`add.1` at `pswap.masm:520`
- [ ] Sharpen the doc: explicitly state that the initial (depth-0) PSWAP
carries no PSWAP-scheme attachment; only payback / remainder notes do
## D. Module / type structure
- [ ] Split `crates/miden-standards/src/note/pswap.rs` (1222 lines) into
`pswap/mod.rs`, `pswap/attachment.rs`, `pswap/storage.rs`,
`pswap/tests.rs`
- [ ] Introduce an `OrderId` newtype (currently bare `Felt`)
- [ ] Combine `(faucet_id, asset_id)` into a 2-element `AssetId`
representation
---
Source: https://github.com/0xMiden/protocol/pull/2909
贡献指南
评估
这个 Issue 还没有评估数据。