Reusable "is reclaimable" note procedure
- Vorherrschende Sprache
- Rust
- Sterne
- 132
- Forks
- 167
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 110
Beschreibung
## Problem
The reclaim check (an unconsumed note can be returned to its creator after a reclaim height) is currently inlined in `p2ide.masm` and duplicated in `pswap.masm` (`handle_reclaim`). There is no shared procedure other notes can reuse.
This matters for network notes. A network note can sit unconsumed if the ntx builder never applies it to the target account. Without a reclaim path the creator's assets are stuck. Every reclaimable network note would otherwise re-implement the same sender check.
## Proposal
Add one reusable procedure, `is_reclaimable` (or a small `reclaim` component), that any note script can call. It encapsulates the existing P2IDE logic:
1. reclaim is enabled (`reclaim_block_height != 0`),
2. `reclaim_block_height <= current_block_height`, and
3. the executing account is the note sender (`active_note::get_sender` equals `active_account::get_id` via `account_id::is_equal`).
These building blocks already exist in the protocol asm modules used by `p2ide.masm`. The procedure should return a boolean (or assert), leaving the asset move to the caller (`basic_wallet::add_assets_to_account`).
Refactor `p2ide.masm` to call this procedure instead of its inline `reclaim_note`. `pswap.masm` is a candidate for the same refactor.
## Why this pairs with network notes
A network note targets a network account and is meant to be consumed by the ntx builder. If the network account never consumes it, the creator must be able to reclaim. Building reclaim as a shared procedure lets every network note opt into "if not consumed by the target, reclaimable by the creator after height H" without duplicating the check.
## Files
- `crates/miden-standards/asm/standards/notes/p2ide.masm` (`reclaim_note` to refactor)
- `crates/miden-standards/asm/standards/notes/pswap.masm` (`handle_reclaim`, candidate)
- New shared procedure under `crates/miden-standards/asm/standards/` (location to confirm)
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.