0xMiden / 0xMiden/protocol

Reusable "is reclaimable" note procedure

Abierto
#3,040 4 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

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

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.