0xMiden / 0xMiden/protocol

Reusable "is reclaimable" note procedure

Đang mở
#3,040 4 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ả

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

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.