0xMiden / 0xMiden/protocol

PSWAP follow-ups from #2909

Abierto
#3,000 0 comentarios 2 reacciones 0 asignados Ver en GitHub
standards
Lenguaje dominante
Rust
Estrellas
132
Forks
167
Merge medio
1 d 23 h
PR fusionados (30 d)
110

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.