Skip to content

feat(AggLayer bridge-out e2e #1): process bridging-out data and load LeafData to memory#2425

Merged
mmagician merged 13 commits intoagglayer-newfrom
mmagician-bridge-out-store-frontier
Feb 18, 2026
Merged

feat(AggLayer bridge-out e2e #1): process bridging-out data and load LeafData to memory#2425
mmagician merged 13 commits intoagglayer-newfrom
mmagician-bridge-out-store-frontier

Conversation

@mmagician
Copy link
Copy Markdown
Collaborator

@mmagician mmagician commented Feb 10, 2026

Builds on top of #2413 in the following way:

  • split out the logic of get_leaf_value to first load the data from advice provider to memory, and then call another exposed procedure compute_leaf_value which operates on data in memory
  • the latter compute_leaf_value is then re-used for bridging-out, which also needs to hash data in the same leaf format and obtain the leaf value
  • packing bytes takes a start pointer parameter, instead of hardcoding the pointer location

Other than that, this PR carries the following changes and be reviewed independently of #2413:

  • bridge_out prepares the data and stores it to appropriate memory locations
    • scale miden amount to u256 (scale stubbed out, see below)
    • push LEAF_TYPE_ASSET
    • the rest of the preparation is still stubbed out and we just use zeros for now. Parts that are still stubbed out:
      1. mapping of Miden token addresses to Ethereum addresses;
      2. getting the scaling parameter for amount conversion
      3. computing the metadata (and its hash)
  • after the leaf data is prepared, delegate the rest to add_leaf_bridge to mimic AggLayer Solidity contracts
  • add_leaf_bridge does two things:

@mmagician mmagician 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 added the agglayer PRs or issues related to AggLayer bridging integration label Feb 10, 2026
@mmagician mmagician marked this pull request as ready for review February 11, 2026 08:31
@mmagician mmagician changed the title feat(AggLayer): process bridging-out data and load to memory feat(AggLayer): process bridging-out data and load LET to memory Feb 12, 2026
@mmagician mmagician changed the title feat(AggLayer): process bridging-out data and load LET to memory feat(AggLayer): process bridging-out data and load LeafData to memory Feb 12, 2026
@mmagician mmagician requested a review from Copilot February 12, 2026 09:25

This comment was marked as resolved.

@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-real-bridge-data branch from 4bf984c to e8c4306 Compare February 14, 2026 18:25
Base automatically changed from mmagician-real-bridge-data to agglayer-new February 15, 2026 10:46
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
@mmagician mmagician changed the title feat(AggLayer): process bridging-out data and load LeafData to memory feat(AggLayer bridge-out #1): process bridging-out data and load LeafData to memory Feb 15, 2026
Comment on lines +110 to +124
pub proc reverse_limbs_and_change_byte_endianness
# reverse the felts within each word
# [a, b, c, d, e, f, g, h] -> [h, g, f, e, d, c, b, a]
exec.word::reverse
swapw
exec.word::reverse

# change the byte endianness of each felt
repeat.8
exec.utils::swap_u32_bytes
movdn.7
end

# => [RESULT_U256[0], RESULT_U256[1]]
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very important procedure to convert from big endian limbs, little endian byte order, to little endian limbs big endian byte order.

I wonder if this procedure should be in the VM standard library?

Comment on lines +96 to +97
# TODO construct metadata hash
padw padw
Copy link
Copy Markdown
Member

@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.

This is part of B2AGG NoteStorage right?. Is it difficult to load these values here? Or is this for a follow up PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Metadata can be constructed directly inside this procedure. I opened a tracking issue: #2453

#!
#! Inputs: [WORD_1, WORD_2, ptr]
#! Outputs: []
pub proc mem_store_double_word_unaligned(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also make me wonder, shouldn't this be a VM std procedure? But lets do this later once everything is working end to end.

Copy link
Copy Markdown
Member

@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 great! Super useful procedures here! reverse_limbs_and_change_byte_endianness is super valuable.

@mmagician mmagician added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Feb 17, 2026
@mmagician mmagician merged commit 3b4bd70 into agglayer-new Feb 18, 2026
15 checks passed
@mmagician mmagician deleted the mmagician-bridge-out-store-frontier branch February 18, 2026 10:23
@mmagician mmagician changed the title feat(AggLayer bridge-out #1): process bridging-out data and load LeafData to memory feat(AggLayer bridge-out e2e #1): process bridging-out data and load LeafData to memory Feb 24, 2026
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
…ry (0xMiden#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>
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.

4 participants