Skip to content

Validate metadata extraction helpers#2351

Closed
Copilot wants to merge 48 commits intommagician-network-target-helpersfrom
copilot/validate-attachment-kind-account-id-again
Closed

Validate metadata extraction helpers#2351
Copilot wants to merge 48 commits intommagician-network-target-helpersfrom
copilot/validate-attachment-kind-account-id-again

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

The issue calls for stricter validation when extracting note metadata, specifically validating attachment_kind and the sender account_id, and documenting panic conditions. This ensures metadata helpers are safe by default.

  • Implementation

    • No code changes in this PR; validation updates are still pending.
  • Documentation

    • No documentation updates included.

No code snippet included because no changes were applied.

Original prompt

This section details on the original issue you should resolve

<issue_title>Validate attachment_kind and account_id in metadata extraction helpers</issue_title>
<issue_description>We should validate attachment_kind as well here, i.e.:

https://github.com/0xMiden/miden-base/blob/fda68e1008f8b7b7633b8c3dfc6a0fe4e150dd32/crates/miden-protocol/asm/kernels/transaction/lib/output_note.masm#L375-L378

And looking at the neighboring extract_sender_from_metadata, it doesn't validate the account ID which it probably should also do. Would you mind adding a account_id::validate line there and add a Panics if section? If not, lmk and I'll open an issue or address it.

In general, I think the procedures we provide should provide as much safety as they can and if users want to work with potentially invalid metadata, they likely know what they're doing and can write their own procedures. But for 95% of users, validation should be the safer option.

Originally posted by @PhilippGackstatter in #2338 (comment)

TODOs:

  • add account_id::validate check to extract_sender_from_metadata
  • check that attachment kind is valid, like output_note.masm does it
  • add Panics section to the docs of both procedures</issue_description>

<agent_instructions>make sure tests pass with cargo test --profile=test-dev</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

avorylli and others added 30 commits January 17, 2026 09:47
* Add ExecError wrapper for better error reporting

* Add errors module to tx_context

* Refactor execute_code to use ExecError

Updated error handling in execute_code function to use ExecError instead of ExecutionError.

* Wrap ExecutionError in ExecError for assertions

* Refactor error handling to use 'anyhow' in tests

Refactor error handling in tests to use 'anyhow' for better context management. Update function signatures to return 'anyhow::Result' instead of 'miette::Result'.

* Replace miette with anyhow for error handling

* Update lib.rs

* Update Cargo.toml

* chore: rename `ExecError` method names

* chore: remove anyhow::anyhow! error mapping

---------

Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
* chore: share serde across the workspace

* chore: share tokio

* chore: unify fs-err
Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com>
* feat: rename NoteInputs to NoteStorage

This commit renames the NoteInputs type to NoteStorage throughout the codebase
to better reflect that these values represent stored data associated with a note
rather than inputs.

Changes include:
- Renamed NoteInputs struct to NoteStorage
- Renamed inputs.rs to storage.rs
- Updated MAX_INPUTS_PER_NOTE to MAX_NOTE_STORAGE_ITEMS
- Updated all related method names: inputs() -> storage(), num_values() -> len(), values() -> items()
- Updated all variable names: note_inputs -> note_storage
- Updated Assembly files with new terminology
- Updated error messages and constants
- Updated documentation

Closes #1662

* chore: complete note inputs to note storage rename

Address review feedback:
- Rename INPUT_NOTE_NUM_INPUTS_OFFSET to INPUT_NOTE_STORAGE_LENGTH_OFFSET
- Rename INPUT_NOTE_INPUTS_COMMITMENT_OFFSET to INPUT_NOTE_STORAGE_COMMITMENT_OFFSET
- Rename *_NUM_INPUTS constants to *_STORAGE_LENGTH
- Rename ERR_*_WRONG_NUMBER_OF_INPUTS to ERR_*_UNEXPECTED_STORAGE_LENGTH
- Rename mint_inputs.rs to mint_storage.rs
- Update function names: parse_p2id_inputs -> parse_p2id_storage
- Update error messages to use 'note storage items' terminology
- Update test helpers and assertions

* fix: rename remaining num_expected_inputs to expected_storage_length

* chore: rename remaining note inputs references to note storage

- Rename P2ID_NOTE_NUM_INPUTS to P2ID_NOTE_STORAGE_LENGTH
- Rename RPO_CLAIM_NOTE_INPUTS_COMMITMENT to RPO_CLAIM_NOTE_STORAGE_COMMITMENT
- Update comments: "note inputs" -> "note storage"
- Update error messages to use "note storage" terminology

* address PR review comments: rename get_inputs to get_storage

Changes based on Philip's review comments:
- B2AGG.masm: B2AGG_NOTE_INPUTS_COUNT → B2AGG_NOTE_STORAGE_LEN
- B2AGG.masm: ERR_B2AGG_WRONG_NUMBER_OF_INPUTS → ERR_B2AGG_UNEXPECTED_STORAGE_LENGTH
- lib.rs: claim_inputs → claim_storage_items
- prologue.masm: INPUT_COMMITMENT → STORAGE_COMMITMENT in comment
- active_note.masm: get_inputs → get_storage procedure rename
- note.masm: various comment updates (inputs → storage)
- shared_utils/note.masm: input values → storage values
- tx_args.rs: storage_commitment |-> inputs → storage_commitment |-> storage_items
- Updated all callers of get_inputs to get_storage

* fix: correct NoteError import path after merge

* fix: update generated files and fix import order

* Apply suggestions from code review

* chore: regenerate error files

* chore: revert foreign_inputs_len change

* Apply suggestions from code review

Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>

---------

Co-authored-by: Farukest <farukest@users.noreply.github.com>
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
mmagician and others added 18 commits January 26, 2026 20:06
instead of the whole METADATA word, pass only scheme and kind
* feat: working array

chore: simplify test

chore: be explicit about padding

* chore: add changelog entry for Array component (#2204)

* Initial plan

* chore: add changelog entry for PR 2203

Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>

* fix: set_map_item no longer returns old root

* chore: change Try to TryFrom for AccountComponent

* chore: correct the docs

* chore: masm doc corrections

* chore: use BeWord instead of Word

* chore: adjust masm comment about max len

* Update crates/miden-standards/asm/account_components/array.masm

Co-authored-by: Andrey Khmuro <andrey@polygon.technology>

* chore: turn array into utility

chore: remove component code

* chore: lint, simplify test & comments

* chore: remove unnecessary comments

* chore: remove duplicated changelog entry

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Andrey Khmuro <andrey@polygon.technology>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mmagician mmagician force-pushed the mmagician-network-target-helpers branch from 59052a4 to d01e1cf Compare January 27, 2026 10:26
Copilot AI changed the title [WIP] Add validation for attachment_kind and account_id in metadata helpers Validate metadata extraction helpers Jan 27, 2026
@mmagician mmagician closed this Jan 27, 2026
@mmagician mmagician deleted the copilot/validate-attachment-kind-account-id-again branch February 9, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants