Skip to content

feat(AggLayer bridge-out e2e #2): store Local Exit Tree in AggLayerBridge contract and update it upon B2AGG consumption#2424

Merged
mmagician merged 33 commits intoagglayer-newfrom
mmagician-cursor-bridge-out-component-implementation-details-5737
Feb 18, 2026
Merged

feat(AggLayer bridge-out e2e #2): store Local Exit Tree in AggLayerBridge contract and update it upon B2AGG consumption#2424
mmagician merged 33 commits intoagglayer-newfrom
mmagician-cursor-bridge-out-component-implementation-details-5737

Conversation

@mmagician
Copy link
Collaborator

@mmagician mmagician commented Feb 10, 2026

Implements Local Exit Tree (LET) frontier management in the bridge_out component.

Changes:

  • store the frontier (32 nodes) of the Local Exit Tree in the bridge contract
    • uses a double-array data structure for convenience, with the map as the underlying storage slot
  • store the root as two value slots (low, high)
  • store the number of leaves in a single value slot
  • after computing the leaf value in feat(AggLayer bridge-out e2e #1): process bridging-out data and load LeafData to memory #2425, process the leaf:
    1. load the existing LET frontier to memory
    2. call append_and_update_frontier to update the frontier in-memory and obtain the root
    3. write back the frontier from memory to storage
    4. save the obtained root and number of leaves to storage

Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Feb 10, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@igamigo igamigo added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label Feb 10, 2026
@mmagician mmagician changed the title Bridge_out component implementation details feat(AggLayer): store Local Exit Tree in AggLayerBridge contract and append leaves to it upon B2AGG note processing Feb 10, 2026
@mmagician mmagician added the agglayer PRs or issues related to AggLayer bridging integration label Feb 10, 2026
@mmagician mmagician force-pushed the mmagician-cursor-bridge-out-component-implementation-details-5737 branch 4 times, most recently from 4e0c724 to ba44bbb Compare February 12, 2026 09:23
@mmagician mmagician marked this pull request as ready for review February 12, 2026 09:25
@mmagician mmagician force-pushed the mmagician-bridge-out-store-frontier branch from 1266876 to 8303a1a Compare February 12, 2026 10:46
@mmagician mmagician force-pushed the mmagician-cursor-bridge-out-component-implementation-details-5737 branch from ba44bbb to c72720b Compare February 12, 2026 10:48
@mmagician mmagician requested a review from Copilot February 12, 2026 11:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.masm to load the LET frontier from storage, append a leaf via append_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.

mmagician and others added 11 commits February 15, 2026 15:04
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>
@mmagician mmagician force-pushed the mmagician-bridge-out-store-frontier branch from 8303a1a to c011f8d Compare February 15, 2026 15:06
Comment on lines 1 to +14
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
Copy link
Contributor

@partylikeits1983 partylikeits1983 Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@mmagician mmagician force-pushed the mmagician-cursor-bridge-out-component-implementation-details-5737 branch from 75a75db to 05d206e Compare February 17, 2026 18:41
mmagician and others added 8 commits February 17, 2026 19:43
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>
@mmagician mmagician force-pushed the mmagician-cursor-bridge-out-component-implementation-details-5737 branch from 2698ce5 to 3bfb9d3 Compare February 17, 2026 19:43
Base automatically changed from mmagician-bridge-out-store-frontier to agglayer-new February 18, 2026 10:23
@mmagician mmagician added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Feb 18, 2026
Copy link
Contributor

@partylikeits1983 partylikeits1983 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmagician mmagician merged commit b1c483b into agglayer-new Feb 18, 2026
15 checks passed
@mmagician mmagician deleted the mmagician-cursor-bridge-out-component-implementation-details-5737 branch February 18, 2026 13:06
@mmagician mmagician changed the title feat(AggLayer bridge-out #2): store Local Exit Tree in AggLayerBridge contract and update it upon B2AGG consumption feat(AggLayer bridge-out e2e #2): store Local Exit Tree in AggLayerBridge contract and update it upon B2AGG consumption Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration no changelog This PR does not require an entry in the `CHANGELOG.md` file pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AggLayer: maintain proper tracking of LER in the bridge via MMR frontier

6 participants