feat: add native asset claim amount as element in NoteStorage of CLAIM note#2460
Conversation
08b7bd8 to
ae80508
Compare
| # TODO: why do we need to reverse and swap here? | ||
| exec.word::reverse swapw | ||
| # => [] |
There was a problem hiding this comment.
@mmagician I think we might need to reverse the limb order & swap these two Word values in NoteStorage
Will do if the current NoteStorage layout is incorrect for AMOUNT(8)
There was a problem hiding this comment.
this looks strange: why are we reversing only one of the words?
could it be that the other limb is zeros (because of the input we test with)?
if so, it would be important to test a case where we know the second limb is non-zero. I suspect this will show that we need to reverse both
mmagician
left a comment
There was a problem hiding this comment.
The PR looks good, but now that scaling is ready, we should also verify that the P2ID note created as a result of CLAIM note processing outputs the right amount - this is not done ATM
| #! target_faucet_account_id[2], // Target faucet account ID (2 felts, prefix and suffix) | ||
| #! output_note_tag[1], // P2ID output note tag | ||
| #! padding[1], // padding (1 felt) | ||
| #! miden_claim_amount[1], // Miden claim amount (1 felt) |
There was a problem hiding this comment.
Not a fan on this naming, maybe it should be native_claim_amount?
Not sure how much of a catch it was, it wouldn't work without this change :) |
| # TODO: why do we need to reverse and swap here? | ||
| exec.word::reverse swapw | ||
| # => [] |
There was a problem hiding this comment.
this looks strange: why are we reversing only one of the words?
could it be that the other limb is zeros (because of the input we test with)?
if so, it would be important to test a case where we know the second limb is non-zero. I suspect this will show that we need to reverse both
Co-authored-by: Marti <marti@miden.team>
Update the AggLayer bridge spec to reflect changes from the agglayer branch merge: - Bridge is now a single unified component (#2294 closed) - CONFIG_AGG_BRIDGE sender validation enforced via bridge admin (#2450 closed) - UPDATE_GER sender validation enforced via GER manager (#2467 closed) - BURN note now uses NetworkAccountTarget attachment (#2470 closed) - Claim amount scaling implemented with miden_claim_amount field (#2460 merged) - Add bridge_admin and ger_manager storage slots to spec - Fix element-index notation consistency throughout storage tables - Fix faucet_registry_key() doc comment to match element-index convention - Update AggLayerBridge struct docs with new procedures and slots - Fix stale test comments referencing old two-component structure https://claude.ai/code/session_01UDgsAS2j2CFrTLsDoLiSUN
* feat: add p2id::new MASM constructor for creating P2ID notes (#2381) * feat: add p2id::new MASM constructor for creating P2ID notes This adds a new `p2id::new` procedure to the P2ID note MASM code that makes it easy to create P2ID notes from MASM transaction scripts. The procedure: - Takes target_id_prefix, target_id_suffix, tag, note_type, SERIAL_NUM - Handles writing note storage to memory in the expected layout - Uses procref.main to obtain the note script root - Builds the recipient and creates the note - Returns the note index This allows MASM code to create P2ID notes without manually handling the note storage layout or hardcoding script roots. Closes #2280 * refactor: move inline comments to doc comment in p2id::new * refactor: simplify local store instructions in p2id::new --------- Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> * fix: u64 limb ordering in `note_tag::create_custom_account_target` (#2441) * Execute FPI with one `syscall` (#2408) * refactor: rework kernel proc invocations during FPI * test: update FPI tests to check the new memory * chore: tiny comment fix * refactor: compress bookkeeping section, move upcoming pointers before stack * refactor: organize the prefix/suffix ordering * refactor: move api helpers to tx, move zero ID check to exec_foreign_proc, import constants * refactor: make tx_exec_foreign_proc to be invoked with dynexec * refactor: store 16th element instead of 1st * refactor: add ID validation, update doc comments, rename tx_prepare_fpi_call * refactor: update doc comments, update constant name * test: create test to check all 16 FP input values, fix bug * test: assert the forieign procedure outputs * refactor: reset foreign data after FPI, move foregin account validation --------- Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com> * chore: reorder account ID and nonce memory and advice layout (#2442) * chore: reorder account ID limbs in advice inputs * chore: rename native account ID -> global account ID * chore: reorder fee parameter word * chore: implement SequentialCommit for `AccountHeader` * chore: add changelog * fix: docs * chore: store global account ID individually instead of in word * chore: introduce `account_id::create_key` * chore: move `account_id::create_key` to `account::create_id_key` * chore: add missing import * feat: add `make test-release` command running without debug mode (#2448) * feat: add test make command without debug mode * chore: switch CI test to use `make testf` * chore: test bench building in debug mode * fix: unnecessary rebuilds * chore: revert fix in protocol and standards * chore: rename `make testf` to `make test-release` * Revert "chore: revert fix in protocol and standards" This reverts commit 3471c7b. * feat: increase `TokenSymbol` max length from 6 to 12 uppercase characters (#2420) The previous limit of 6 characters (48 bits) was unnecessarily restrictive compared to other blockchains (Solana: 10, Algorand: 8, Ethereum: unlimited). Since uppercase-only encoding (base-26) fits up to 12 characters within a single field element, the limit is increased to 12. Closes #2406 Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> * chore: Remove BlockSigner trait (#2447) * feat: account builder helper for schema commitment (#2419) * Add `P2idNoteStorage` and `P2ideNoteStorage` (#2389) * feat: implement P2ID and P2IDE note storage structures with validation * feat: enhance P2ID note storage with improved account ID handling and validation * feat: refine P2IDE note storage structure and improve field naming for clarity * feat: add P2idNoteStorage and P2ideNoteStorage to changelog * fix: update changelog to include P2idNoteStorage and P2ideNoteStorage pull request reference * feat: add tests for P2idNoteStorage and P2ideNoteStorage validation and decoding * refactor: simplify test code by consolidating vector initialization for P2idNoteStorage and P2ideNoteStorage * feat: add P2ideNoteStorage for improved note handling and update related tests * feat: enhance NoteError handling with detailed messages for invalid note storage * feat: enhance NoteError handling with detailed messages for invalid note storage * feat: improve error handling in P2idNoteStorage and P2ideNoteStorage for invalid note storage * feat: enhance documentation for P2ideNote and P2ideNoteStorage structures * fix: reorder imports for consistency in test file * feat: implement P2ID and P2IDE note storage handling with improved error management * feat: refactor P2ID and P2IDE note recipient creation to use storage directly * refactor: simplify consumable height calculation and improve error message for P2IDE note storage validation * test: enhance error message assertions for note consumability static analysis * refactor: update error handling for P2ID and P2IDE note storage to use more descriptive messages * feat: update P2ID and P2IDE note storage to use dynamic item counts * feat: integrate P2idNoteStorage for recipient creation in P2ID tests * Apply suggestions from code review * Update crates/miden-testing/src/kernel_tests/tx/test_account_interface.rs --------- Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> * feat: add `DEFAULT_TAG` constant to `note_tag` MASM module (#2482) * feat: add DEFAULT_TAG constant to note_tag MASM module Add a public DEFAULT_TAG = 0 constant to the note_tag standards module. This is the default note tag value for notes that rely on attachments rather than tags for targeting. Co-authored-by: marti <marti@hungrycats.studio> * docs: add changelog entry for DEFAULT_TAG constant (#2482) Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * fix: batch test assumes wrong input note order (#2485) Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com> * feat: add solidity-compat test for generating local claimAsset() param data (#2474) * feat: add solidity-compat test for generating local claimAsset() param data * refactor: rename solidity compat test files & claimAsset vector JSON files * refactor: rename testing methods & update test comments * Update crates/miden-testing/tests/agglayer/bridge_in.rs * Update crates/miden-testing/tests/agglayer/bridge_in.rs * refactor: address review nits from PR #2474 (#2489) * refactor: address review nits from PR #2474 - Add `ClaimDataSource::get_data()` method so the match is encapsulated in the enum rather than inlined in the test body - Extract `claim_data_from_vector()` helper to deduplicate the shared logic between `real_claim_data()` and `local_claim_data()` - Fix `.json.json` double-extension typo in `ClaimDataSource::Real` doc - Extract `_computeCanonicalZeros()` and `_generateLocalProof()` helpers in `SMTMerkleProofVectors.t.sol`, mirroring `ClaimAssetTestVectorsLocalTx`, and replace the inline loop with calls to these helpers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: address follow-up review comments on PR #2489 - Move `ClaimDataSource` into `test_utils.rs` so its `get_data()` method can select the right lazy static directly, removing the now-unnecessary `real_claim_data()` and `local_claim_data()` public helpers - Extract `_computeCanonicalZeros` and `_generateLocalProof` into a new `DepositContractTestHelpers` abstract contract; both `SMTMerkleProofVectors` and `ClaimAssetTestVectorsLocalTx` now inherit from it instead of each defining their own copies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: avoid collisions in random numbers in batch test (#2492) * feat: add native asset claim amount as element in `NoteStorage` of `CLAIM` note (#2460) * feat: add native asset claim amount as element in NoteStorage of CLAIM note * feat: add output note assertion checks * refactor: rm debug statement * Update crates/miden-testing/tests/agglayer/bridge_in.rs Co-authored-by: Marti <marti@miden.team> * refactor: cleanup test & rm leftover comments * wip: consume P2ID by destination AccountId * feat: add solidity-compat test for generating local claimAsset() param data * feat: add solidity-compat test for generating local claimAsset() param data * feat: consume output P2ID note from CLAIM note * fix: taplo fmt * refactor: rename solidity compat test files & claimAsset vector JSON files * refactor: rename testing methods & update test comments * Update crates/miden-testing/tests/agglayer/bridge_in.rs * Update crates/miden-testing/tests/agglayer/bridge_in.rs * refactor: add warnings in comments & update TODO regarding u256 scaling * refactor: assert mock destination account ID matches claim data * fix: load amount BE-felt from mem --------- Co-authored-by: Marti <marti@miden.team> * feat: consolidate authentication components (#2390) * single sig * change AuthScheme, AuthSingleSig, AuthSingleSigAcl, AuthMultisig * fix cleanup_pubkey & update_signers_and_thresholds for multisig * add ERR_INVALID_SCHEME_ID message to standard errors * fmt * changelog * clippy fmt * fix documentation * change scheme_id for Falcon * add hybrid multisig tests * fmt * fix documentation * add threshold validations for key rotation * fix error standards * add helper procedures for multisig * fix tests * fix conflict * fix documentation * fmt * fix standards error format * fmt * rename miden_standars::AuthScheme -> miden_standards::AuthMethod * fix new p2id test * change u8 to AuthScheme in SingleSig and SingleSigAcl * refactor Multisig u8 -> AuthScheme * Execute FPI with one `syscall` (#2408) * refactor: rework kernel proc invocations during FPI * test: update FPI tests to check the new memory * chore: tiny comment fix * refactor: compress bookkeeping section, move upcoming pointers before stack * refactor: organize the prefix/suffix ordering * refactor: move api helpers to tx, move zero ID check to exec_foreign_proc, import constants * refactor: make tx_exec_foreign_proc to be invoked with dynexec * refactor: store 16th element instead of 1st * refactor: add ID validation, update doc comments, rename tx_prepare_fpi_call * refactor: update doc comments, update constant name * test: create test to check all 16 FP input values, fix bug * test: assert the forieign procedure outputs * refactor: reset foreign data after FPI, move foregin account validation --------- Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com> * chore: reorder account ID and nonce memory and advice layout (#2442) * chore: reorder account ID limbs in advice inputs * chore: rename native account ID -> global account ID * chore: reorder fee parameter word * chore: implement SequentialCommit for `AccountHeader` * chore: add changelog * fix: docs * chore: store global account ID individually instead of in word * chore: introduce `account_id::create_key` * chore: move `account_id::create_key` to `account::create_id_key` * chore: add missing import * merge conflicts * rename auth_tx * add constants to masm & fix locals * fix scheme_id constants to auth_scheme * fix masm comments & add error messages * fix storage slots comments * refactor APPROVER_SCHEME_ID_SLOT to [key_index, 0, 0, 0] => [scheme_id, 0, 0, 0] * fmt * clippy and std errors * fix documentation * fmt * fix documentation * apply masm suggestions * refactor type registry * fix scheme -> method naming * fix comments * add rstest and consolidate multisig tests * refactor and consolidate acl and multisig tests * refactor is_signer * simplify is_signer loop * fmt * feat: add `make test-release` command running without debug mode (#2448) * feat: add test make command without debug mode * chore: switch CI test to use `make testf` * chore: test bench building in debug mode * fix: unnecessary rebuilds * chore: revert fix in protocol and standards * chore: rename `make testf` to `make test-release` * Revert "chore: revert fix in protocol and standards" This reverts commit 3471c7b. * feat: increase `TokenSymbol` max length from 6 to 12 uppercase characters (#2420) The previous limit of 6 characters (48 bits) was unnecessarily restrictive compared to other blockchains (Solana: 10, Algorand: 8, Ethereum: unlimited). Since uppercase-only encoding (base-26) fits up to 12 characters within a single field element, the limit is increased to 12. Closes #2406 Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> * chore: Remove BlockSigner trait (#2447) * feat: account builder helper for schema commitment (#2419) * Add `P2idNoteStorage` and `P2ideNoteStorage` (#2389) * feat: implement P2ID and P2IDE note storage structures with validation * feat: enhance P2ID note storage with improved account ID handling and validation * feat: refine P2IDE note storage structure and improve field naming for clarity * feat: add P2idNoteStorage and P2ideNoteStorage to changelog * fix: update changelog to include P2idNoteStorage and P2ideNoteStorage pull request reference * feat: add tests for P2idNoteStorage and P2ideNoteStorage validation and decoding * refactor: simplify test code by consolidating vector initialization for P2idNoteStorage and P2ideNoteStorage * feat: add P2ideNoteStorage for improved note handling and update related tests * feat: enhance NoteError handling with detailed messages for invalid note storage * feat: enhance NoteError handling with detailed messages for invalid note storage * feat: improve error handling in P2idNoteStorage and P2ideNoteStorage for invalid note storage * feat: enhance documentation for P2ideNote and P2ideNoteStorage structures * fix: reorder imports for consistency in test file * feat: implement P2ID and P2IDE note storage handling with improved error management * feat: refactor P2ID and P2IDE note recipient creation to use storage directly * refactor: simplify consumable height calculation and improve error message for P2IDE note storage validation * test: enhance error message assertions for note consumability static analysis * refactor: update error handling for P2ID and P2IDE note storage to use more descriptive messages * feat: update P2ID and P2IDE note storage to use dynamic item counts * feat: integrate P2idNoteStorage for recipient creation in P2ID tests * Apply suggestions from code review * Update crates/miden-testing/src/kernel_tests/tx/test_account_interface.rs --------- Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> * merge next * fmt * fix schema commitment storage error * fix comments * fix comments * fix naming * fmt * add approvers: Vec<(PublicKeyCommitment, AuthScheme)> --------- Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com> Co-authored-by: Andrey Khmuro <andrey@polygon.technology> Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> Co-authored-by: Farukest <abdullahfarukozden@gmail.com> Co-authored-by: Serge Radinovich <47865535+sergerad@users.noreply.github.com> Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com> Co-authored-by: Nikhil Patil <nikhil876706@gmail.com> * feat(AggLayer): Sender (resp. consumer) validation on `CONFIG_AGG_BRIDGE` & `UPDATE_GER` (resp. `BURN`) notes * chore: tracking empty commit * feat(AggLayer): validate `CONFIG_AGG_BRIDGE` and `UPDATE_GER` note senders are authorized entities (#2479) * feat: validate CONFIG_AGG_BRIDGE and UPDATE_GER note senders Add sender validation to ensure only authorized entities can update bridge configuration or the global exit root. Two distinct roles are enforced: - **Bridge admin** (BRIDGE_ADMIN_SLOT): authorized to register faucets via CONFIG_AGG_BRIDGE notes - **Global exit root manager** (GER_MANAGER_SLOT): authorized to update the GER via UPDATE_GER notes Changes: - Add BRIDGE_ADMIN_SLOT and GER_MANAGER_SLOT storage slots to bridge account - Add assert_sender_is_bridge_admin account procedure in bridge_config - Add assert_sender_is_ger_manager account procedure in bridge_config - Export both procedures from the bridge component - CONFIG_AGG_BRIDGE calls assert_sender_is_bridge_admin - UPDATE_GER calls assert_sender_is_ger_manager - Update create_bridge_account to accept bridge_admin_id and ger_manager_id - Update all tests accordingly Closes #2450 Closes #2467 Co-authored-by: marti <marti@hungrycats.studio> * test: use distinct bridge_admin and ger_manager accounts in all tests Create separate wallet accounts for bridge admin and GER manager roles in every test, even when only one role is exercised. This makes the role distinction explicit and avoids accidentally relying on both roles sharing the same identity. Co-authored-by: marti <marti@hungrycats.studio> * lints * fix: order of stack comments; simplify ops --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> * feat: create BURN note with NetworkAccountTarget attachment (#2481) * feat: create BURN note with NetworkAccountTarget attachment Replace NoteTag-based targeting with NetworkAccountTarget attachment for BURN notes created by bridge_out. The BURN note now uses: - A NetworkAccountTarget attachment to specify the faucet as target - A simple tag (0) instead of note_tag::create_account_target - set_attachment is called right after note creation, using a dup'd note_idx so no local is needed to save it Changes: - bridge_out.masm: use network_account_target::new + output_note::set_attachment instead of note_tag::create_account_target - bridge_out test: verify attachment target instead of NoteTag Closes #2470 Co-authored-by: marti <marti@hungrycats.studio> * refactor: use DEFAULT_TAG constant and set_attachment in create_burn_note Replace the local BURN_NOTE_TAG constant with the DEFAULT_TAG constant from the note_tag standards module (re-declared locally since MASM does not support cross-module constant references in push). Save attachment_scheme and attachment_kind to locals and use set_attachment instead of set_word_attachment. Co-authored-by: marti <marti@hungrycats.studio> * Apply suggestions from code review Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> * Apply suggestion from @partylikeits1983 Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> * feat(standards): add NoteExecutionHint constants to MASM standards Add `note/execution_hint.masm` under the standards library exposing the four NoteExecutionHint variants as public constants: - NONE = 0 - ALWAYS = 1 - AFTER_BLOCK = 2 (tag bits only; payload must be composed at runtime) - ON_BLOCK_SLOT = 3 (tag bits only; payload must be composed at runtime) These mirror the `NONE_TAG` / `ALWAYS_TAG` / `AFTER_BLOCK_TAG` / `ON_BLOCK_SLOT_TAG` internal constants from the Rust `NoteExecutionHint` implementation and allow MASM callers to reference them via `use miden::standards::note::execution_hint::ALWAYS` (etc.) rather than duplicating magic numbers locally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(agglayer): import ALWAYS execution hint from standards library Replace the locally-defined `EXECUTION_HINT_ALWAYS = 1` constants with the canonical `ALWAYS` constant from `miden::standards::note::execution_hint`. - `bridge_out.masm`: add `use miden::standards::note::execution_hint::ALWAYS`, drop local const, update `push.EXECUTION_HINT_ALWAYS` → `push.ALWAYS` - `agglayer_faucet.masm`: drop dead `EXECUTION_HINT_ALWAYS = 1` (was defined but never referenced in the file) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: lowercase `.expect()` messages in agglayer code (#2491) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(Agglayer): restructure `asm` directory and split out agglayer lib from bridge & faucet components libs * feat: add native asset claim amount as element in NoteStorage of CLAIM note * feat: add output note assertion checks * refactor: rm debug statement * Update crates/miden-testing/tests/agglayer/bridge_in.rs Co-authored-by: Marti <marti@miden.team> * refactor: cleanup test & rm leftover comments * empty commit * Agglayer: restructure the `asm` directory: clear split between library, components, notes (#2471) * refactor: restructure miden-agglayer asm directory with per-component libraries Restructure the agglayer asm directory to follow the miden-standards pattern, addressing the security vulnerability where all component library functions returned the same unified library, causing bridge accounts to expose faucet procedures and vice versa. Changes: - Move asm/bridge/ files to asm/agglayer/bridge/ subdirectory - Rename agglayer_faucet.masm to asm/agglayer/faucet/mod.masm - Create thin component wrappers in asm/components/ (bridge.masm, faucet.masm) that pub use only relevant procedures - Update build.rs to compile main library from asm/agglayer/, then compile per-component libraries from asm/components/ - Update lib.rs with per-component LazyLock libraries so bridge_*_library() returns the bridge component library and faucet_library() returns the faucet component library - Update all MASM namespace references (miden::agglayer::X to miden::agglayer::bridge::X, agglayer_faucet to faucet) - Update Rust test files with new namespace paths Closes #2294 Co-authored-by: marti <marti@hungrycats.studio> * fix: address CI failures (rustfmt and changelog) - Fix rustfmt line length issue in mmr_frontier.rs test strings - Add CHANGELOG.md entry for the asm directory restructuring Co-authored-by: marti <marti@hungrycats.studio> * refactor: consolidate component library API - Remove bridge_out_library, bridge_in_library, local_exit_tree_library aliases; keep a single agglayer_bridge_library() - Remove faucet_library alias; keep a single agglayer_faucet_library() - Replace separate bridge_out_component/bridge_in_component/ local_exit_tree_component with a single bridge_component() - Remove bridge_out_with_local_exit_tree_component convenience function - Consolidate create_bridge_account_builder to use one bridge_component with all storage slots combined Co-authored-by: marti <marti@hungrycats.studio> * refactor: move update_ger to bridge_config and shared modules to common/ - Move update_ger procedure from bridge_in.masm to bridge_config.masm, since it is a bridge configuration operation alongside register_faucet - Move utils.masm, asset_conversion.masm, eth_address.masm from agglayer/bridge/ to agglayer/common/ since they are shared between bridge and faucet modules - Update all MASM use statements and Rust test strings to reflect the new module paths (bridge::utils -> common::utils, etc.) - Update component wrapper and note script references accordingly Co-authored-by: marti <marti@hungrycats.studio> * refactor: move bridge_in-specific procs out of crypto_utils Move procedures that are only called from bridge_in.masm out of the shared crypto_utils.masm module: - get_leaf_value: loads leaf data from advice map, delegates to compute_leaf_value - compute_ger: computes GER from mainnet/rollup exit roots - verify_merkle_proof: verifies a Keccak-based Merkle proof - calculate_root: private helper for verify_merkle_proof crypto_utils.masm now only contains compute_leaf_value and pack_leaf_data, which are genuinely shared between bridge_in and bridge_out. Co-authored-by: marti <marti@hungrycats.studio> * refactor: deduplicate storage slot constants into bridge_config Move GER and faucet registry storage management into bridge_config.masm to eliminate duplicate constant definitions: - Move assert_valid_ger from bridge_in to bridge_config as a pub proc, so GER_STORAGE_SLOT and GER_KNOWN_FLAG are defined only in bridge_config - Add assert_faucet_registered to bridge_config as a pub proc, so FAUCET_REGISTRY_SLOT is defined only in bridge_config - bridge_in now calls bridge_config::assert_valid_ger - bridge_out now calls bridge_config::assert_faucet_registered instead of inlining the registry lookup Co-authored-by: marti <marti@hungrycats.studio> * refactor: rename crypto_utils to leaf_utils The module now only contains compute_leaf_value and pack_leaf_data, so leaf_utils better describes its purpose. Co-authored-by: marti <marti@hungrycats.studio> * chore: remove unused local exit tree mod * chore: remove getters from interface * refactor: move verify_merkle_proof test to bridge_in module Move solidity_verify_merkle_proof_compatibility test and its helper from leaf_utils.rs to bridge_in.rs, since verify_merkle_proof now lives in bridge_in. Drop the 'test_' prefix from the name. Co-authored-by: marti <marti@hungrycats.studio> * refactor: standardize file organization across all agglayer MASM files Apply consistent section ordering to all MASM files: 1. Imports (use statements, alphabetized) 2. Type aliases 3. Errors 4. Constants (grouped: storage slots, memory pointers, data offsets, local memory offsets, data sizes, flags/other) 5. Public interface (pub proc) 6. Helper procedures (private proc) Files reorganized: - bridge_config.masm: separate storage slots from flags, errors first - bridge_in.masm: group memory pointers, local offsets, data sizes - bridge_out.masm: group LET storage slots, memory pointers, leaf data offsets, local memory offsets, and other constants into labeled blocks - common/eth_address.masm: errors before constants, public interface before helper procs - common/asset_conversion.masm: errors before constants - faucet/mod.masm: group storage slots, memory pointers, local memory offsets, data sizes, and note constants; public interface before helpers Co-authored-by: marti <marti@hungrycats.studio> * Apply suggestions from code review dont need such verbosity * chore: remove dead code; make functions private * chore: use ZERO instead of Felt::new(0) --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> * refactor(agglayer): encapsulate faucet and bridge in structs (#2478) * refactor: restructure miden-agglayer asm directory with per-component libraries Restructure the agglayer asm directory to follow the miden-standards pattern, addressing the security vulnerability where all component library functions returned the same unified library, causing bridge accounts to expose faucet procedures and vice versa. Changes: - Move asm/bridge/ files to asm/agglayer/bridge/ subdirectory - Rename agglayer_faucet.masm to asm/agglayer/faucet/mod.masm - Create thin component wrappers in asm/components/ (bridge.masm, faucet.masm) that pub use only relevant procedures - Update build.rs to compile main library from asm/agglayer/, then compile per-component libraries from asm/components/ - Update lib.rs with per-component LazyLock libraries so bridge_*_library() returns the bridge component library and faucet_library() returns the faucet component library - Update all MASM namespace references (miden::agglayer::X to miden::agglayer::bridge::X, agglayer_faucet to faucet) - Update Rust test files with new namespace paths Closes #2294 Co-authored-by: marti <marti@hungrycats.studio> * fix: address CI failures (rustfmt and changelog) - Fix rustfmt line length issue in mmr_frontier.rs test strings - Add CHANGELOG.md entry for the asm directory restructuring Co-authored-by: marti <marti@hungrycats.studio> * refactor: consolidate component library API - Remove bridge_out_library, bridge_in_library, local_exit_tree_library aliases; keep a single agglayer_bridge_library() - Remove faucet_library alias; keep a single agglayer_faucet_library() - Replace separate bridge_out_component/bridge_in_component/ local_exit_tree_component with a single bridge_component() - Remove bridge_out_with_local_exit_tree_component convenience function - Consolidate create_bridge_account_builder to use one bridge_component with all storage slots combined Co-authored-by: marti <marti@hungrycats.studio> * refactor: move update_ger to bridge_config and shared modules to common/ - Move update_ger procedure from bridge_in.masm to bridge_config.masm, since it is a bridge configuration operation alongside register_faucet - Move utils.masm, asset_conversion.masm, eth_address.masm from agglayer/bridge/ to agglayer/common/ since they are shared between bridge and faucet modules - Update all MASM use statements and Rust test strings to reflect the new module paths (bridge::utils -> common::utils, etc.) - Update component wrapper and note script references accordingly Co-authored-by: marti <marti@hungrycats.studio> * refactor: move bridge_in-specific procs out of crypto_utils Move procedures that are only called from bridge_in.masm out of the shared crypto_utils.masm module: - get_leaf_value: loads leaf data from advice map, delegates to compute_leaf_value - compute_ger: computes GER from mainnet/rollup exit roots - verify_merkle_proof: verifies a Keccak-based Merkle proof - calculate_root: private helper for verify_merkle_proof crypto_utils.masm now only contains compute_leaf_value and pack_leaf_data, which are genuinely shared between bridge_in and bridge_out. Co-authored-by: marti <marti@hungrycats.studio> * refactor: deduplicate storage slot constants into bridge_config Move GER and faucet registry storage management into bridge_config.masm to eliminate duplicate constant definitions: - Move assert_valid_ger from bridge_in to bridge_config as a pub proc, so GER_STORAGE_SLOT and GER_KNOWN_FLAG are defined only in bridge_config - Add assert_faucet_registered to bridge_config as a pub proc, so FAUCET_REGISTRY_SLOT is defined only in bridge_config - bridge_in now calls bridge_config::assert_valid_ger - bridge_out now calls bridge_config::assert_faucet_registered instead of inlining the registry lookup Co-authored-by: marti <marti@hungrycats.studio> * refactor: rename crypto_utils to leaf_utils The module now only contains compute_leaf_value and pack_leaf_data, so leaf_utils better describes its purpose. Co-authored-by: marti <marti@hungrycats.studio> * chore: remove unused local exit tree mod * chore: remove getters from interface * refactor: move verify_merkle_proof test to bridge_in module Move solidity_verify_merkle_proof_compatibility test and its helper from leaf_utils.rs to bridge_in.rs, since verify_merkle_proof now lives in bridge_in. Drop the 'test_' prefix from the name. Co-authored-by: marti <marti@hungrycats.studio> * refactor: standardize file organization across all agglayer MASM files Apply consistent section ordering to all MASM files: 1. Imports (use statements, alphabetized) 2. Type aliases 3. Errors 4. Constants (grouped: storage slots, memory pointers, data offsets, local memory offsets, data sizes, flags/other) 5. Public interface (pub proc) 6. Helper procedures (private proc) Files reorganized: - bridge_config.masm: separate storage slots from flags, errors first - bridge_in.masm: group memory pointers, local offsets, data sizes - bridge_out.masm: group LET storage slots, memory pointers, leaf data offsets, local memory offsets, and other constants into labeled blocks - common/eth_address.masm: errors before constants, public interface before helper procs - common/asset_conversion.masm: errors before constants - faucet/mod.masm: group storage slots, memory pointers, local memory offsets, data sizes, and note constants; public interface before helpers Co-authored-by: marti <marti@hungrycats.studio> * Apply suggestions from code review dont need such verbosity * chore: remove dead code; make functions private * chore: use ZERO instead of Felt::new(0) * refactor(agglayer): encapsulate faucet and bridge in structs, make helpers private - Add AggLayerBridge and AggLayerFaucet structs with new() and From for AccountComponent - Use TokenMetadata for faucet metadata slot instead of hardcoded layout - Make internal helpers private: agglayer_bridge_library, agglayer_faucet_library, create_agglayer_faucet_component, create_bridge_account_builder, create_agglayer_faucet_builder Closes #2371 Co-authored-by: marti <marti@hungrycats.studio> * lint * chore: slot name getters; improve struct docs * chore: use slot getters in tests * Update crates/miden-agglayer/src/lib.rs Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> --------- Co-authored-by: riemann <aleqvids@gmail.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> * refactor: wrap `verify_u128_*` in `verify_u256_*` procedure (#2504) Co-authored-by: Marti <marti@miden.team> * docs: update SPEC.md for resolved issues and current bridge design * docs: address review comments on SPEC.md - Update baseline to "to-be-tagged v0.14-alpha" - Add explanation for why native claim amount is verified (avoids expensive U256 division inside the VM) - Simplify addr output notation to addr(5) https://claude.ai/code/session_01UDgsAS2j2CFrTLsDoLiSUN --------- Co-authored-by: Farukest <abdullahfarukozden@gmail.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com> Co-authored-by: Andrey Khmuro <andrey@polygon.technology> Co-authored-by: Bobbin Threadbare <43513081+bobbinth@users.noreply.github.com> Co-authored-by: Serge Radinovich <47865535+sergerad@users.noreply.github.com> Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com> Co-authored-by: Nikhil Patil <nikhil876706@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: onurinanc <e191322@metu.edu.tr> Co-authored-by: riemann <aleqvids@gmail.com>
This PR modifies the agglayer faucet and
CLAIMnote to use theverify_u256_to_native_amount_conversionprocedure.The claim note now carries one additional
Feltvalue, themiden_claim_amount. The number of values inNoteStorageremains the same due to the fact we can storemiden_claim_amountin aFeltslot which was previously used as padding.This is one of the final PRs for fully non stubbed out e2e bridge in flows via agglayer!
Completely resolves: #2011 (comment)