feat(AggLayer bridge-out e2e #2): store Local Exit Tree in AggLayerBridge contract and update it upon B2AGG consumption#2424
Conversation
|
Cursor Agent can help with this pull request. Just |
AggLayerBridge contract and append leaves to it upon B2AGG note processing
4e0c724 to
ba44bbb
Compare
1266876 to
8303a1a
Compare
ba44bbb to
c72720b
Compare
There was a problem hiding this comment.
Pull request overview
Implements Local Exit Tree (LET) persistence for AggLayer bridge-out by storing the LET frontier and associated metadata in the AggLayerBridge account storage, and validating the resulting Local Exit Root against Solidity-generated vectors.
Changes:
- Add dedicated bridge account storage slots for LET root (lo/hi) and leaf count, alongside the existing LET map slot.
- Update
bridge_out.masmto load the LET frontier from storage, append a leaf viaappend_and_update_frontier, and persist the updated frontier/root/leaf-count back to storage. - Extend Solidity/Rust compatibility vectors and tests to include destination parameters and amounts, and assert the computed Local Exit Root matches Solidity.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/miden-testing/tests/agglayer/mod.rs | Exposes mmr_frontier module for cross-test reuse. |
| crates/miden-testing/tests/agglayer/mmr_frontier.rs | Makes Solidity vector JSON/static data public and extends vector schema (amounts + destination fields). |
| crates/miden-testing/tests/agglayer/bridge_out.rs | Adds a test asserting Local Exit Root after B2AGG processing matches Solidity vector root. |
| crates/miden-agglayer/src/lib.rs | Extends bridge account builder with LET root/leaf-count value slots in addition to the LET map slot. |
| crates/miden-agglayer/solidity-compat/test/MMRTestVectors.t.sol | Updates vector generation to DepositContractV2, includes destination params and amounts, and generates leaf values via getLeafValue. |
| crates/miden-agglayer/solidity-compat/test-vectors/mmr_frontier_vectors.json | Updates embedded vectors to new leaf/root set and includes amounts + destination fields. |
| crates/miden-agglayer/solidity-compat/foundry.lock | Adds OZ upgradeable dependency required by updated Solidity contracts. |
| crates/miden-agglayer/asm/bridge/bridge_out.masm | Implements LET frontier load/append/store, plus root and leaf-count persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
8303a1a to
c011f8d
Compare
…sor-bridge-out-component-implementation-details-5737
| use miden::protocol::active_note | ||
| use miden::protocol::active_account | ||
| use miden::protocol::native_account | ||
| use miden::protocol::note | ||
| use miden::standards::note_tag | ||
| use miden::standards::data_structures::double_word_array | ||
| use miden::protocol::output_note | ||
| use miden::core::crypto::hashes::keccak256 | ||
| use miden::core::crypto::hashes::rpo256 | ||
| use miden::core::word | ||
| use miden::agglayer::utils | ||
| use miden::agglayer::asset_conversion | ||
| use miden::agglayer::crypto_utils | ||
| use miden::agglayer::mmr_frontier32_keccak |
There was a problem hiding this comment.
I wish these imports were autoformatted to be in alphabetical order since there are so many imports. My old masm formatter would do this, but its out of date with the latest masm syntax.
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks good! Just want to figure out what is going on here: https://github.com/0xMiden/miden-base/pull/2424/changes#r2816492107
before I leave an approval, but otherwise this is great!
75a75db to
05d206e
Compare
Signed-off-by: Marti <marti@miden.team>
Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Co-authored-by: marti <marti@hungrycats.studio> Signed-off-by: Marti <marti@miden.team>
Signed-off-by: Marti <marti@miden.team>
2698ce5 to
3bfb9d3
Compare
…sor-bridge-out-component-implementation-details-5737
…t-implementation-details-5737
…t-implementation-details-5737
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks good! Thanks for addressing https://github.com/0xMiden/miden-base/pull/2424/changes#r2816492107
AggLayerBridge contract and update it upon B2AGG consumptionAggLayerBridge contract and update it upon B2AGG consumption
Implements Local Exit Tree (LET) frontier management in the
bridge_outcomponent.Changes:
LeafDatato memory #2425, process the leaf:append_and_update_frontierto update the frontier in-memory and obtain the root