Closed
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>
Collaborator
Author
|
closing in favor of #2461, now that the branch |
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.