0xMiden / 0xMiden/protocol

Reusable "is reclaimable" note procedure

Ouverte
#3,040 4 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
standards
Langage dominant
Rust
Étoiles
132
Forks
167
Merge moyen
1 j 23 h
PR mergées (30 j)
110

Description

## 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)

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.