Conversation
* chore: unit test for compute_ger * fix: use LE byte<>felt conversion * chore: inline bytes32_to_felts into callers * fixup! fix: use LE byte<>felt conversion * Update crates/miden-testing/tests/agglayer/update_ger.rs * chore: unify underlying repr, use type aliases * changelog * Update crates/miden-agglayer/asm/bridge/crypto_utils.masm Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> --------- Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
…note (#2405) * feat: move padding to the end of LEAF_DATA * chore: uncomment temp unsued code * changelog
…Packed` (#2401) * generate test vectors for getLeafValue * feat: introduce MetadataHash wrapper * feat: refactor amount * feat: introduce LeafValueVector * feat: pack leaf data + test chore: remove u32_words_to_solidity_bytes32_hex * chore: move helper func before tests * feat: EthAddressFormat byte ordering feat: change Address ordering to BE limbs * fix: adjust mainnet exit root to match * feat: test get_leaf_value against vec * feat(test): compare all packed elements from memory * feat: change within-felt byte ordering to LE * feat: make EthAmount internal repr bytes * chore: use bytes_to_packed_u32_felts helper * chore: replace felts_to_u256_bytes with felts_to_bytes * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com> * chore: refactor into get_and compute_ leaf_value * chore: document mem layout for pack_leaf_data --------- Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
* feat: GlobalIndex wrapper around 32 bytes * feat: reverse byte ordering checks for global index * Update crates/miden-agglayer/src/claim_note.rs
* feat: infra for reading full real claim data chore: add claim test gen to makefile * chore: move deser structs to test_utils.rs * feat: use real claim data in bridge in test * fix: reverse keccak hash elements in ProofData serialization for MASM compatibility The keccak256::merge MASM function applies word::reverse to its input words before hashing. mem_stream (used to load SMT proof nodes) does NOT apply per-word reversal, while loc_loadw_be (used to load the current hash) DOES. To produce consistent per-word reversed format on the stack for both the current hash (via loc_storew_be/loc_loadw_be) and the path nodes (via mem_stream), SMT proof nodes must be stored in fully reversed element order in memory. Exit roots are per-word reversed because they are loaded via mem_load_double_word (which uses mem_loadw_be), and the per-word reversal by mem_loadw_be undoes the storage reversal to produce natural order on the stack. Also adds diagnostic and integration tests for Merkle proof verification using claim_asset_vectors data. Co-authored-by: marti <marti@hungrycats.studio> fix: simplify bridge_in test assertions for stubbed scale function The test now correctly verifies that the bridge-in flow validates the Merkle proof and creates an output note, without asserting specific note content that depends on the stubbed scale_u256_to_native_amount function. Removes diagnostic test test_claim_asset_verify_leaf_via_advice_map which has a stack management issue unrelated to the core fix. Co-authored-by: marti <marti@hungrycats.studio> chore: fix warnings and remove diagnostic test - Remove unused imports (Asset, NoteRecipient, NoteStorage) - Remove unused leaf_elements variable - Remove test_claim_asset_verify_leaf_via_advice_map diagnostic test (covered by test_bridge_in_claim_to_p2id) Co-authored-by: marti <marti@hungrycats.studio> refactor: use data-level fix without MASM changes The keccak256::merge function (from external miden-core-lib) applies word::reverse internally and expects per-word reversed input. Since loc_loadw_be naturally produces per-word reversal, changing to loc_loadw_le would break merge's byte ordering. Instead, fix at the data level: - SMT proof nodes: fully reversed (to_memory_elements) so mem_stream's half-swap produces per-word reversed format matching loc_loadw_be output - Exit roots: per-word reversed (to_word_reversed_elements) so mem_load_double_word's mem_loadw_be reversal produces natural order - No MASM code changes needed Co-authored-by: marti <marti@hungrycats.studio> chore: remove diagnostic tests Remove 7 diagnostic/exploratory tests that were added during debugging. The pre-existing tests (pack_leaf_data, get_leaf_value, test_solidity_verify_merkle_proof_compatibility) plus the fixed test_bridge_in_claim_to_p2id provide sufficient coverage. Co-authored-by: marti <marti@hungrycats.studio> * refactor: replace mem_stream with mem_loadw_be in calculate_root Replace mem_stream (which requires RPO hasher state padding) with two explicit mem_loadw_be calls for loading Merkle path nodes. This uses the same instruction as loc_loadw_be for the current hash, ensuring both undergo identical element ordering. The change eliminates 12 elements of RPO padding from the stack, simplifies pointer management, and makes the memory access pattern more explicit. Co-authored-by: marti <marti@hungrycats.studio> * chore: mem_loadw_le for merkle paths * chore: use LE for local word storage * chore: mem_loadw_le for expected root * test: prepare leaf in LE-felt order * chore: use LE for word storage in MMR frontier and canonical zeros - Replace loc_storew_be/loc_loadw_be with loc_storew_le/loc_loadw_le - Replace mem_load_double_word with inline mem_loadw_le - Replace mem_store_double_word with inline mem_storew_le - Update canonical_zeros.masm and build.rs to use mem_storew_le Co-authored-by: marti <marti@hungrycats.studio> chore: update mem_load/store_double_word to LE and resolve TODO - Update utils.masm: mem_storew_be -> mem_storew_le, mem_loadw_be -> mem_loadw_le - Replace inline mem_loadw_le in crypto_utils.masm with exec.utils::mem_load_double_word - Restore mem_load/store_double_word usage in mmr_frontier32_keccak.masm and canonical_zeros.masm - Update stale comment in claim_note.rs Co-authored-by: marti <marti@hungrycats.studio> * chore: simplify inline comments * lints * chore: re-enable bridge-in tests * chore: remove dead code * remove keccak_digest_to_word_strings; use SmtRoot/ExitRoot * chore: avoid loc mem, keep is_odd on stack * lints * remove unused import --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* chore: rename NOTE_INPUTS -> NOTE_STORAGE PTR * chore: explicit stack comment * chore: use constants for mem storage * chore: use mem locals for prefix/suffix * chore: use mem locals for amount * feat: serialize amounts as strings * feat: deserialize amount from json string * chore: amount conversion tests * chore: use UINT256 internally * chore: cleanup
* wip: u256 to felt scaling procedure * refactor: pass quotient via stack * refactor: procedure comments * refactor: modify tests & use assertz * refactor: cleanup test helper inputs * refactor: cleanup tests * feat: add inline sanity check test * refactor: cleanup test * refator: simplify and rename to verify_u256_to_native_amount_conversion * refactor: import FUNGIBLE_ASSET_MAX_AMOUNT & use word::eqz * revert: rename to try_to_u64 * refactor: use Felt::MODULUS * refactor: simplify EthAmount * refactor: rename EthAmountError variants * refactor: renamed functions and refactored errors & conversion * fix: taplo fmt * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * chore: clean up EthAmountError enum and improve docs * refactor: cleanup doc comments and test case * refactor: use existing error messages * fix: update global_index to use little-endian format * fix: clean up test_utils and crypto_utils files with agglayer-new changes * fix: rm unused function * chore: merge agglayer-new * feat: encorporate endianness reveral procedure * feat: clean up tests & add fuzzing test * refactor: add byte ordering comment & add testing attribute for from_u256 * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * Update crates/miden-testing/tests/agglayer/asset_conversion.rs Co-authored-by: Marti <marti@miden.team> * refactor: cleanup fuzzing test & address comments * chore: use EthAmount directly in tests (#2455) --------- Co-authored-by: Marti <marti@miden.team>
…ry (#2425) * chore: unify b2agg note storage layout with claim note * chore: clarify destinationAddress in CLAIM note * feat: mem_store_double_word_unaligned * feat: compute leaf value for bridging out * chore: update comment about origin network ID * fix: write_address_to_memory had incorrect address arithmetic The add.N values should all be add.1 (incrementing the running pointer by 1 each time), not add.1, add.2, add.3, add.4 which caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of P, P+1, P+2, P+3, P+4). Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes for originNetwork and leafType) and test infrastructure for verifying the root against Solidity vectors. Status: the MMR root computation via call is verified correct (test_mmr_append_via_call passes). The write_address_to_memory fix changed the bridge_out root. Still investigating a remaining mismatch related to u256_le_to_abi + mem_store_double_word_unaligned interaction. Co-authored-by: marti <marti@hungrycats.studio> * fix: handling of dest address and ID in B2AGG * feat: reverse_limbs_and_change_byte_endianness * chore: integrate byte and limb swapping to bridging * fix: swap origin net ID endianness; rearrange mem writes Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: pad mem with zeros after metadata --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… `assert_valid_ger` (#2388) * chore: unit test for compute_ger * fix: use LE byte<>felt conversion * chore: inline bytes32_to_felts into callers * fixup! fix: use LE byte<>felt conversion * Update crates/miden-testing/tests/agglayer/update_ger.rs * chore: unify underlying repr, use type aliases * feat: store GER hash in a map * feat: check GER in storage * chore: rename to GER_KNOWN_FLAG * Apply suggestions from code review * chore: reduce inline comments * changelog * chore: use constants on Felt * fix: reverse felt order within word after hashing * chore: generate GER test vectors * chore: integrate GER vectors to compute_ger test * chore: add expected GER in bridge-in test * Revert "fix: reverse felt order within word after hashing" This reverts commit 61852a9. * fix: reverse felt order before Hasher::merge * Update crates/miden-agglayer/solidity-compat/test/ExitRoots.t.sol * chore: add comments re: rpo256:merge stack ordering
…d update it upon `B2AGG` consumption (#2424) * chore: unify b2agg note storage layout with claim note * chore: clarify destinationAddress in CLAIM note * feat: mem_store_double_word_unaligned * feat: compute leaf value for bridging out * chore: update comment about origin network ID * fix: write_address_to_memory had incorrect address arithmetic The add.N values should all be add.1 (incrementing the running pointer by 1 each time), not add.1, add.2, add.3, add.4 which caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of P, P+1, P+2, P+3, P+4). Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes for originNetwork and leafType) and test infrastructure for verifying the root against Solidity vectors. Status: the MMR root computation via call is verified correct (test_mmr_append_via_call passes). The write_address_to_memory fix changed the bridge_out root. Still investigating a remaining mismatch related to u256_le_to_abi + mem_store_double_word_unaligned interaction. Co-authored-by: marti <marti@hungrycats.studio> * fix: handling of dest address and ID in B2AGG * feat: reverse_limbs_and_change_byte_endianness * chore: integrate byte and limb swapping to bridging * fix: swap origin net ID endianness; rearrange mem writes Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: pad mem with zeros after metadata * feat: store LET frontier in double-word array * feat: frontier test generation from param"d leaves * feat: verify computed LER against expected root * write leaf"s amounts to JSON * fix: compare LET by elements, rev elements per word * chore: Replace `unwrap()` with `expect()` for StorageSlotName parsing (#2451) * Initial plan * chore: replace unwrap() with expect() for storage slot names 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> * Update crates/miden-testing/tests/agglayer/bridge_out.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: move (de)ser logic to test_utils * chore: organize test_utils better Signed-off-by: Marti <marti@miden.team> * chore: serialize amounts as strings in mmr test vecs Signed-off-by: Marti <marti@miden.team> * test bridge_out frontier persistence across two consumes Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * fix bridge_out frontier reload num_leaves endianness Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * test bridge_out with shared multi-note helper and 32-leaf case Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * refactor bridge_out coverage to direct 32-leaf burn flow Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * refactor MMR vectors to seeded per-leaf destinations Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * chore: cleanup tests Signed-off-by: Marti <marti@miden.team> --------- Signed-off-by: Marti <marti@miden.team> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
* chore: unify b2agg note storage layout with claim note * chore: clarify destinationAddress in CLAIM note * feat: mem_store_double_word_unaligned * feat: compute leaf value for bridging out * chore: update comment about origin network ID * fix: write_address_to_memory had incorrect address arithmetic The add.N values should all be add.1 (incrementing the running pointer by 1 each time), not add.1, add.2, add.3, add.4 which caused addresses to skip (P, P+1, P+3, P+6, P+10 instead of P, P+1, P+2, P+3, P+4). Also includes byte-order fixes (u256_le_to_abi, swap_u32_bytes for originNetwork and leafType) and test infrastructure for verifying the root against Solidity vectors. Status: the MMR root computation via call is verified correct (test_mmr_append_via_call passes). The write_address_to_memory fix changed the bridge_out root. Still investigating a remaining mismatch related to u256_le_to_abi + mem_store_double_word_unaligned interaction. Co-authored-by: marti <marti@hungrycats.studio> * fix: handling of dest address and ID in B2AGG * feat: reverse_limbs_and_change_byte_endianness * chore: integrate byte and limb swapping to bridging * fix: swap origin net ID endianness; rearrange mem writes Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: pad mem with zeros after metadata * feat: store LET frontier in double-word array * feat: frontier test generation from param"d leaves * feat: verify computed LER against expected root * write leaf"s amounts to JSON * fix: compare LET by elements, rev elements per word * feat: add faucet registry * chore: CONFIG note docs * chore: simplify creation of existing agg faucet w/supply * lint * chore: TODO on bridge admin validation * chore: simplify stack operations Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com> * chore: Replace `unwrap()` with `expect()` for StorageSlotName parsing (#2451) * Initial plan * chore: replace unwrap() with expect() for storage slot names 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> * Update crates/miden-testing/tests/agglayer/bridge_out.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: only truncate at the end * chore: move (de)ser logic to test_utils * chore: organize test_utils better Signed-off-by: Marti <marti@miden.team> * chore: serialize amounts as strings in mmr test vecs Signed-off-by: Marti <marti@miden.team> * test bridge_out frontier persistence across two consumes Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * fix bridge_out frontier reload num_leaves endianness Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * test bridge_out with shared multi-note helper and 32-leaf case Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * refactor bridge_out coverage to direct 32-leaf burn flow Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * refactor MMR vectors to seeded per-leaf destinations Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team> * chore: cleanup tests Signed-off-by: Marti <marti@miden.team> * fix: rustfmt line wrapping + clippy needless_range_loop Co-authored-by: marti <marti@hungrycats.studio> * fix: read addr conversion slot in reverse * chore: use non-zero address * chore: rename loc const to distinguish * chore: use loc const in create_burn_note * chore: bring back doc and inline comments --------- Signed-off-by: Marti <marti@miden.team> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Closed
…m 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 - 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>
…LAIM` 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>
…DGE` & `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>
…r 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>
Co-authored-by: Marti <marti@miden.team>
…tachment, not `NoteStorage` (#2480) * refactor: enforce CLAIM note consumer via NetworkAccountTarget attachment Replace the storage-based assert_aggfaucet_is_consumer check with the standard network_account_target::active_account_matches_target_account attachment check, unifying how all agglayer note scripts enforce their target consumer. The CLAIM note already carries the target faucet ID in its NetworkAccountTarget attachment (set during note creation in Rust). This change makes the note script use that attachment for the consumer check instead of reading target_faucet_account_id from note storage. Closes #2468 Co-authored-by: marti <marti@hungrycats.studio> * refactor: remove target_faucet_account_id from CLAIM NoteStorage Now that the consumer check uses the NetworkAccountTarget attachment, the target_faucet_account_id no longer needs to be serialized into NoteStorage. The field is kept in OutputNoteData (used to build the attachment in Rust) but excluded from to_elements(). The OutputNoteData memory layout changes from: [serial_num(4), faucet_id(2), tag(1), amount(1)] to: [serial_num(4), tag(1), amount(1), padding(2)] Updated MASM constants: - OUTPUT_NOTE_TAG_MEM_ADDR: 574 -> 572 - OUTPUT_NOTE_FAUCET_AMOUNT: 575 -> 573 Co-authored-by: marti <marti@hungrycats.studio> * refactor: move target_faucet_id out of OutputNoteData into create_claim_note param The target faucet account ID is only needed to build the NetworkAccountTarget attachment, not as part of the note storage data. Move it from OutputNoteData to a direct parameter of create_claim_note. Co-authored-by: marti <marti@hungrycats.studio> * lint --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
…2511) * refactor: move sender authorization from note scripts into account procedures Sender authorization for UPDATE_GER and CONFIG_AGG_BRIDGE notes was previously enforced in the note scripts via separate calls to assert_sender_is_ger_manager / assert_sender_is_bridge_admin. This was unsafe because any note script consumed by the bridge account could call update_ger or register_faucet directly, bypassing the sender check. Move the authorization into the account procedures themselves (update_ger and register_faucet) so that sender verification is enforced regardless of which note script invokes them. The assertion procedures have a net-zero stack effect, so they can be called first thing without disturbing the procedure's inputs. https://claude.ai/code/session_01JeSHNeBxs1aTUe3Lm8NjVi * refactor: remove superfluous stack-effect comments https://claude.ai/code/session_01JeSHNeBxs1aTUe3Lm8NjVi * Apply suggestions from code review * Update crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm * Update crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm * refactor: remove assert_sender_is_* from bridge component interface These procedures are now internal implementation details called via exec from within update_ger and register_faucet. They no longer need to be part of the bridge account's public interface. https://claude.ai/code/session_01JeSHNeBxs1aTUe3Lm8NjVi --------- Co-authored-by: Claude <noreply@anthropic.com>
…nents (#2510) * docs: fix doc comments and inline comments for bridge components - Update AggLayerBridge doc comments to list current procedures (assert_sender_is_bridge_admin, assert_sender_is_ger_manager) - Add bridge_admin and ger_manager storage slots to doc comments - Fix faucet_registry_key doc comment to match actual element order - Fix inline comments in tests ("bridge_out" -> "bridge") * Apply suggestions from code review --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
…2509) * feat: rm serial_num & output_note_tag from OutputNoteData * feat: rm OutputNoteData from AdviceMap * refactor: cleanup masm & fix pad amounts in stack comments * refactor: update number of NoteStorage values in comment * refactor: update claim_storage size and update comments * refactor: use prefix from proc input & cleanup pad stack comments * revert stack pad comment changes * fix: rm old comment * fix: correct CLAIM stack comments and flatten OutputNoteData into ClaimNoteStorage * fix: rustfmt * fix: fix stack comment pad(x) * chore: dropw -> drop is sufficient --------- Co-authored-by: Marti <marti@miden.team> Co-authored-by: mmagician <marcin.gorny.94@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.