0xMiden / 0xMiden/protocol

PSWAP follow-ups from #2909

Đang mở
#3,000 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
standards
Ngôn ngữ chính
Rust
Star
132
Fork
167
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
110

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.