Skip to content

Conversation

@partylikeits1983
Copy link
Contributor

@partylikeits1983 partylikeits1983 commented Oct 27, 2025

B2AGG Note and AggLayerBridgeOut Component

This PR adds the B2AGG note script and the AggLayerBridgeOut component with stubbed-out MMR functionality. This PR includes tests covering both bridge-out and reclaim scenarios for B2AGG notes.

Note Structure

The NoteInputs to the B2AGG note consist of a destination chain ID (u32) and 5 u32 values representing a 160-bit EVM address (20 bytes).

The B2AGG note has a total of 6 inputs with the following layout:

0: destination_network (u32 chain ID)
1: destination_address_0 (bytes 0-3)
2: destination_address_1 (bytes 4-7)
3: destination_address_2 (bytes 8-11)
4: destination_address_3 (bytes 12-15)
5: destination_address_4 (bytes 16-19)

Test Scenarios

The test in crates/miden-testing/tests/agglayer/bridge_out.rs validates two scenarios:

Bridge-Out Scenario

  • User creates a B2AGG note to transfer assets from Miden to an EVM chain.
  • The B2AGG note is consumed by a bridge account using the AggLayerBridgeOut component.
  • During consumption, the Keccak MMR frontier is updated (stubbed implementation).
  • A public BURN note is created and consumed by the network faucet.

Reclaim Scenario

  • User creates and consumes their own B2AGG note (same account as sender).
  • Assets are added back to the account without creating a BURN note.
  • No bridge operations are performed in this scenario.

Additional Changes

Note: This PR also adds helper functions to convert Ethereum addresses represented as strings to a vector of Felt values.


This PR resolves #2007

Builds on #1995 & #1925

@partylikeits1983 partylikeits1983 force-pushed the ajl-b2agg-bridge-out-burn branch from f7a0204 to 9c18c62 Compare October 27, 2025 14:43
@partylikeits1983 partylikeits1983 self-assigned this Oct 27, 2025
@partylikeits1983 partylikeits1983 force-pushed the ajl-b2agg-bridge-out-burn branch from 9c18c62 to 10e3470 Compare November 5, 2025 10:18
@partylikeits1983 partylikeits1983 added no changelog This PR does not require an entry in the `CHANGELOG.md` file agglayer labels Nov 5, 2025
@partylikeits1983 partylikeits1983 marked this pull request as ready for review November 10, 2025 19:15
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

This PR implements a stubbed-out bridging-out flow for the AggLayer integration, establishing the infrastructure for transferring assets from Miden to the AggLayer. The implementation creates a B2AGG note type that can be consumed by accounts with the bridge_out component, which then generates a BURN note to destroy the bridged assets.

Key changes:

  • Adds B2AGG note script that validates bridge-out requests and calls the bridge_out account component
  • Implements bridge_out account component with stubbed MMR frontier functions and burn note creation
  • Introduces utility functions for Ethereum address conversion to/from Felt values
  • Includes comprehensive integration test covering the full bridge-out flow

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/miden-testing/tests/lib.rs Adds agglayer module to test suite
crates/miden-testing/tests/agglayer/mod.rs Declares bridge_out test module
crates/miden-testing/tests/agglayer/bridge_out.rs Comprehensive integration test for B2AGG note → bridge_out component → BURN note flow
crates/miden-lib/src/lib.rs Exposes new agglayer module
crates/miden-lib/src/errors/note_script_errors.rs Adds error constants for B2AGG note validation
crates/miden-lib/src/agglayer/utils.rs Provides Ethereum address conversion utilities
crates/miden-lib/src/agglayer/mod.rs Main module exposing B2AGG script and bridge_out component
crates/miden-lib/build.rs Adds build support for agglayer library, note scripts, and account components
crates/miden-lib/asm/agglayer/note_scripts/B2AGG.masm Assembly implementation of B2AGG note script with validation and reclaim logic
crates/miden-lib/asm/agglayer/account_components/bridge_out.masm Assembly implementation of bridge_out component with stubbed MMR functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@partylikeits1983 partylikeits1983 force-pushed the ajl-b2agg-bridge-out-burn branch from d496d57 to c758274 Compare November 24, 2025 17:04
Copy link
Contributor

@mmagician mmagician left a comment

Choose a reason for hiding this comment

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

I added minor comments regarding the docs, but leaving another approval, great work ✅

Copy link
Contributor

@bobbinth bobbinth 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! Thank you! I left just a couple of small comments inline.

@mmagician mmagician merged commit bfb28d4 into agglayer Dec 12, 2025
15 checks passed
@mmagician mmagician deleted the ajl-b2agg-bridge-out-burn branch December 12, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants