Skip to content

refactor(Agglayer): restructure tracking PR#2477

Merged
mmagician merged 11 commits intoagglayerfrom
miden-base-agglayer-restructure
Feb 24, 2026
Merged

refactor(Agglayer): restructure tracking PR#2477
mmagician merged 11 commits intoagglayerfrom
miden-base-agglayer-restructure

Conversation

@mmagician
Copy link
Collaborator

@mmagician mmagician commented Feb 20, 2026

To be done here:

But as they're separate changes, will be built on top of one another, and then merged into ajl-claim-note-quotient-notestorage (or directly into agglayer, depending on which is ready first).

I added an empty commit because otherwise GitHub won't let me change the PR base (no new commits)

@mmagician mmagician changed the base branch from agglayer to ajl-claim-note-quotient-notestorage February 20, 2026 11:07
@mmagician mmagician added no changelog This PR does not require an entry in the `CHANGELOG.md` file agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Feb 20, 2026
…y, components, notes (#2471)

* refactor: restructure miden-agglayer asm directory with per-component libraries

Restructure the agglayer asm directory to follow the miden-standards
pattern, addressing the security vulnerability where all component
library functions returned the same unified library, causing bridge
accounts to expose faucet procedures and vice versa.

Changes:
- Move asm/bridge/ files to asm/agglayer/bridge/ subdirectory
- Rename agglayer_faucet.masm to asm/agglayer/faucet/mod.masm
- Create thin component wrappers in asm/components/ (bridge.masm,
  faucet.masm) that pub use only relevant procedures
- Update build.rs to compile main library from asm/agglayer/, then
  compile per-component libraries from asm/components/
- Update lib.rs with per-component LazyLock libraries so bridge_*_library()
  returns the bridge component library and faucet_library() returns the
  faucet component library
- Update all MASM namespace references (miden::agglayer::X to
  miden::agglayer::bridge::X, agglayer_faucet to faucet)
- Update Rust test files with new namespace paths

Closes #2294

Co-authored-by: marti <marti@hungrycats.studio>

* fix: address CI failures (rustfmt and changelog)

- Fix rustfmt line length issue in mmr_frontier.rs test strings
- Add CHANGELOG.md entry for the asm directory restructuring

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: consolidate component library API

- Remove bridge_out_library, bridge_in_library, local_exit_tree_library
  aliases; keep a single agglayer_bridge_library()
- Remove faucet_library alias; keep a single agglayer_faucet_library()
- Replace separate bridge_out_component/bridge_in_component/
  local_exit_tree_component with a single bridge_component()
- Remove bridge_out_with_local_exit_tree_component convenience function
- Consolidate create_bridge_account_builder to use one bridge_component
  with all storage slots combined

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: move update_ger to bridge_config and shared modules to common/

- Move update_ger procedure from bridge_in.masm to bridge_config.masm,
  since it is a bridge configuration operation alongside register_faucet
- Move utils.masm, asset_conversion.masm, eth_address.masm from
  agglayer/bridge/ to agglayer/common/ since they are shared between
  bridge and faucet modules
- Update all MASM use statements and Rust test strings to reflect
  the new module paths (bridge::utils -> common::utils, etc.)
- Update component wrapper and note script references accordingly

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: move bridge_in-specific procs out of crypto_utils

Move procedures that are only called from bridge_in.masm out of the
shared crypto_utils.masm module:
- get_leaf_value: loads leaf data from advice map, delegates to
  compute_leaf_value
- compute_ger: computes GER from mainnet/rollup exit roots
- verify_merkle_proof: verifies a Keccak-based Merkle proof
- calculate_root: private helper for verify_merkle_proof

crypto_utils.masm now only contains compute_leaf_value and pack_leaf_data,
which are genuinely shared between bridge_in and bridge_out.

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: deduplicate storage slot constants into bridge_config

Move GER and faucet registry storage management into bridge_config.masm
to eliminate duplicate constant definitions:

- Move assert_valid_ger from bridge_in to bridge_config as a pub proc,
  so GER_STORAGE_SLOT and GER_KNOWN_FLAG are defined only in bridge_config
- Add assert_faucet_registered to bridge_config as a pub proc, so
  FAUCET_REGISTRY_SLOT is defined only in bridge_config
- bridge_in now calls bridge_config::assert_valid_ger
- bridge_out now calls bridge_config::assert_faucet_registered instead
  of inlining the registry lookup

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: rename crypto_utils to leaf_utils

The module now only contains compute_leaf_value and pack_leaf_data,
so leaf_utils better describes its purpose.

Co-authored-by: marti <marti@hungrycats.studio>

* chore: remove unused local exit tree mod

* chore: remove getters from interface

* refactor: move verify_merkle_proof test to bridge_in module

Move solidity_verify_merkle_proof_compatibility test and its helper
from leaf_utils.rs to bridge_in.rs, since verify_merkle_proof now
lives in bridge_in. Drop the 'test_' prefix from the name.

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: standardize file organization across all agglayer MASM files

Apply consistent section ordering to all MASM files:
1. Imports (use statements, alphabetized)
2. Type aliases
3. Errors
4. Constants (grouped: storage slots, memory pointers, data offsets,
   local memory offsets, data sizes, flags/other)
5. Public interface (pub proc)
6. Helper procedures (private proc)

Files reorganized:
- bridge_config.masm: separate storage slots from flags, errors first
- bridge_in.masm: group memory pointers, local offsets, data sizes
- bridge_out.masm: group LET storage slots, memory pointers, leaf
  data offsets, local memory offsets, and other constants into
  labeled blocks
- common/eth_address.masm: errors before constants, public interface
  before helper procs
- common/asset_conversion.masm: errors before constants
- faucet/mod.masm: group storage slots, memory pointers, local memory
  offsets, data sizes, and note constants; public interface before
  helpers

Co-authored-by: marti <marti@hungrycats.studio>

* Apply suggestions from code review

dont need such verbosity

* chore: remove dead code; make functions private

* chore: use ZERO instead of Felt::new(0)

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Base automatically changed from ajl-claim-note-quotient-notestorage to agglayer February 23, 2026 15:57
mmagician and others added 3 commits February 24, 2026 14:36
* refactor: restructure miden-agglayer asm directory with per-component libraries

Restructure the agglayer asm directory to follow the miden-standards
pattern, addressing the security vulnerability where all component
library functions returned the same unified library, causing bridge
accounts to expose faucet procedures and vice versa.

Changes:
- Move asm/bridge/ files to asm/agglayer/bridge/ subdirectory
- Rename agglayer_faucet.masm to asm/agglayer/faucet/mod.masm
- Create thin component wrappers in asm/components/ (bridge.masm,
  faucet.masm) that pub use only relevant procedures
- Update build.rs to compile main library from asm/agglayer/, then
  compile per-component libraries from asm/components/
- Update lib.rs with per-component LazyLock libraries so bridge_*_library()
  returns the bridge component library and faucet_library() returns the
  faucet component library
- Update all MASM namespace references (miden::agglayer::X to
  miden::agglayer::bridge::X, agglayer_faucet to faucet)
- Update Rust test files with new namespace paths

Closes #2294

Co-authored-by: marti <marti@hungrycats.studio>

* fix: address CI failures (rustfmt and changelog)

- Fix rustfmt line length issue in mmr_frontier.rs test strings
- Add CHANGELOG.md entry for the asm directory restructuring

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: consolidate component library API

- Remove bridge_out_library, bridge_in_library, local_exit_tree_library
  aliases; keep a single agglayer_bridge_library()
- Remove faucet_library alias; keep a single agglayer_faucet_library()
- Replace separate bridge_out_component/bridge_in_component/
  local_exit_tree_component with a single bridge_component()
- Remove bridge_out_with_local_exit_tree_component convenience function
- Consolidate create_bridge_account_builder to use one bridge_component
  with all storage slots combined

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: move update_ger to bridge_config and shared modules to common/

- Move update_ger procedure from bridge_in.masm to bridge_config.masm,
  since it is a bridge configuration operation alongside register_faucet
- Move utils.masm, asset_conversion.masm, eth_address.masm from
  agglayer/bridge/ to agglayer/common/ since they are shared between
  bridge and faucet modules
- Update all MASM use statements and Rust test strings to reflect
  the new module paths (bridge::utils -> common::utils, etc.)
- Update component wrapper and note script references accordingly

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: move bridge_in-specific procs out of crypto_utils

Move procedures that are only called from bridge_in.masm out of the
shared crypto_utils.masm module:
- get_leaf_value: loads leaf data from advice map, delegates to
  compute_leaf_value
- compute_ger: computes GER from mainnet/rollup exit roots
- verify_merkle_proof: verifies a Keccak-based Merkle proof
- calculate_root: private helper for verify_merkle_proof

crypto_utils.masm now only contains compute_leaf_value and pack_leaf_data,
which are genuinely shared between bridge_in and bridge_out.

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: deduplicate storage slot constants into bridge_config

Move GER and faucet registry storage management into bridge_config.masm
to eliminate duplicate constant definitions:

- Move assert_valid_ger from bridge_in to bridge_config as a pub proc,
  so GER_STORAGE_SLOT and GER_KNOWN_FLAG are defined only in bridge_config
- Add assert_faucet_registered to bridge_config as a pub proc, so
  FAUCET_REGISTRY_SLOT is defined only in bridge_config
- bridge_in now calls bridge_config::assert_valid_ger
- bridge_out now calls bridge_config::assert_faucet_registered instead
  of inlining the registry lookup

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: rename crypto_utils to leaf_utils

The module now only contains compute_leaf_value and pack_leaf_data,
so leaf_utils better describes its purpose.

Co-authored-by: marti <marti@hungrycats.studio>

* chore: remove unused local exit tree mod

* chore: remove getters from interface

* refactor: move verify_merkle_proof test to bridge_in module

Move solidity_verify_merkle_proof_compatibility test and its helper
from leaf_utils.rs to bridge_in.rs, since verify_merkle_proof now
lives in bridge_in. Drop the 'test_' prefix from the name.

Co-authored-by: marti <marti@hungrycats.studio>

* refactor: standardize file organization across all agglayer MASM files

Apply consistent section ordering to all MASM files:
1. Imports (use statements, alphabetized)
2. Type aliases
3. Errors
4. Constants (grouped: storage slots, memory pointers, data offsets,
   local memory offsets, data sizes, flags/other)
5. Public interface (pub proc)
6. Helper procedures (private proc)

Files reorganized:
- bridge_config.masm: separate storage slots from flags, errors first
- bridge_in.masm: group memory pointers, local offsets, data sizes
- bridge_out.masm: group LET storage slots, memory pointers, leaf
  data offsets, local memory offsets, and other constants into
  labeled blocks
- common/eth_address.masm: errors before constants, public interface
  before helper procs
- common/asset_conversion.masm: errors before constants
- faucet/mod.masm: group storage slots, memory pointers, local memory
  offsets, data sizes, and note constants; public interface before
  helpers

Co-authored-by: marti <marti@hungrycats.studio>

* Apply suggestions from code review

dont need such verbosity

* chore: remove dead code; make functions private

* chore: use ZERO instead of Felt::new(0)

* refactor(agglayer): encapsulate faucet and bridge in structs, make helpers private

- Add AggLayerBridge and AggLayerFaucet structs with new() and From for AccountComponent
- Use TokenMetadata for faucet metadata slot instead of hardcoded layout
- Make internal helpers private: agglayer_bridge_library, agglayer_faucet_library,
  create_agglayer_faucet_component, create_bridge_account_builder,
  create_agglayer_faucet_builder

Closes #2371

Co-authored-by: marti <marti@hungrycats.studio>

* lint

* chore: slot name getters; improve struct docs

* chore: use slot getters in tests

* Update crates/miden-agglayer/src/lib.rs

Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Alexander John Lee <77119221+partylikeits1983@users.noreply.github.com>
@mmagician mmagician marked this pull request as ready for review February 24, 2026 15:48
@mmagician
Copy link
Collaborator Author

similarly to #2490, merging w/o explicit approvals since this is a tracking PR which had the individual components approved already.

@mmagician mmagician merged commit 4ee2778 into agglayer Feb 24, 2026
17 checks passed
@mmagician mmagician deleted the miden-base-agglayer-restructure branch February 24, 2026 15:57
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.

2 participants