From 35c84173411835620626ca7da3f8741a9299d168 Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Thu, 26 Feb 2026 22:49:18 +0300 Subject: [PATCH 1/3] refactor: normalize storage slot naming --- .../asm/agglayer/bridge/bridge_out.masm | 8 +++--- .../asm/agglayer/faucet/mod.masm | 6 ++--- crates/miden-agglayer/src/lib.rs | 27 ++++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm index 1383bf5d1f..b18ba0b626 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm @@ -30,10 +30,10 @@ type MemoryAddress = u32 # Storage slot constants for the LET (Local Exit Tree). # The frontier is stored as a double-word array in a map slot. # The root and num_leaves are stored in separate value slots. -const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::let") -const LET_ROOT_LO_SLOT=word("miden::agglayer::let::root_lo") -const LET_ROOT_HI_SLOT=word("miden::agglayer::let::root_hi") -const LET_NUM_LEAVES_SLOT=word("miden::agglayer::let::num_leaves") +const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::bridge::let") +const LET_ROOT_LO_SLOT=word("miden::agglayer::bridge::let::root_lo") +const LET_ROOT_HI_SLOT=word("miden::agglayer::bridge::let::root_hi") +const LET_NUM_LEAVES_SLOT=word("miden::agglayer::bridge::let::num_leaves") # Memory pointers const LEAF_DATA_START_PTR=44 diff --git a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm index d3b2913627..ba9204fddd 100644 --- a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm +++ b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm @@ -22,12 +22,12 @@ const ERR_INVALID_CLAIM_PROOF = "invalid claim proof" # Storage slots # The slot in this component's storage layout where the bridge account ID is stored. -const BRIDGE_ID_SLOT = word("miden::agglayer::faucet") +const BRIDGE_ID_SLOT = word("miden::agglayer::bridge::id") # Storage slots for conversion metadata. # Slot 1: [addr_felt0, addr_felt1, addr_felt2, addr_felt3] — first 4 felts of origin token address -const CONVERSION_INFO_1_SLOT = word("miden::agglayer::faucet::conversion_info_1") +const CONVERSION_INFO_1_SLOT = word("miden::agglayer::bridge::conversion_info_1") # Slot 2: [addr_felt4, origin_network, scale, 0] — remaining address felt + origin network + scale -const CONVERSION_INFO_2_SLOT = word("miden::agglayer::faucet::conversion_info_2") +const CONVERSION_INFO_2_SLOT = word("miden::agglayer::bridge::conversion_info_2") # Memory pointers for piped advice map data const PROOF_DATA_START_PTR = 0 diff --git a/crates/miden-agglayer/src/lib.rs b/crates/miden-agglayer/src/lib.rs index 21070e557b..45ce994808 100644 --- a/crates/miden-agglayer/src/lib.rs +++ b/crates/miden-agglayer/src/lib.rs @@ -110,21 +110,22 @@ fn bridge_component(storage_slots: Vec) -> AccountComponent { static GER_MAP_SLOT_NAME: LazyLock = LazyLock::new(|| { StorageSlotName::new("miden::agglayer::bridge::ger") - .expect("bridge storage slot name should be valid") + .expect("GER storage slot name should be valid") }); static LET_FRONTIER_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let").expect("LET storage slot name should be valid") + StorageSlotName::new("miden::agglayer::bridge::let") + .expect("LET storage slot name should be valid") }); static LET_ROOT_LO_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::root_lo") + StorageSlotName::new("miden::agglayer::bridge::let::root_lo") .expect("LET root_lo storage slot name should be valid") }); static LET_ROOT_HI_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::root_hi") + StorageSlotName::new("miden::agglayer::bridge::let::root_hi") .expect("LET root_hi storage slot name should be valid") }); static LET_NUM_LEAVES_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::num_leaves") + StorageSlotName::new("miden::agglayer::bridge::let::num_leaves") .expect("LET num_leaves storage slot name should be valid") }); static FAUCET_REGISTRY_SLOT_NAME: LazyLock = LazyLock::new(|| { @@ -269,9 +270,9 @@ fn agglayer_faucet_component(storage_slots: Vec) -> AccountComponen /// Builds the two storage slot values for faucet conversion metadata. /// /// The conversion metadata is stored in two value storage slots: -/// - Slot 1 (`miden::agglayer::faucet::conversion_info_1`): `[addr0, addr1, addr2, addr3]` — first +/// - Slot 1 (`miden::agglayer::bridge::conversion_info_1`): `[addr0, addr1, addr2, addr3]` — first /// 4 felts of the origin token address (5 × u32 limbs). -/// - Slot 2 (`miden::agglayer::faucet::conversion_info_2`): `[addr4, origin_network, scale, 0]` — +/// - Slot 2 (`miden::agglayer::bridge::conversion_info_2`): `[addr4, origin_network, scale, 0]` — /// remaining address felt + origin network + scale factor. /// /// # Parameters @@ -299,16 +300,16 @@ fn agglayer_faucet_conversion_slots( // AGGLAYER FAUCET STRUCT // ================================================================================================ -static AGGLAYER_FAUCET_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::faucet") +static AGGLAYER_BRIDGE_ID_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("miden::agglayer::bridge::id") .expect("agglayer faucet storage slot name should be valid") }); static CONVERSION_INFO_1_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::faucet::conversion_info_1") + StorageSlotName::new("miden::agglayer::bridge::conversion_info_1") .expect("conversion info 1 storage slot name should be valid") }); static CONVERSION_INFO_2_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::faucet::conversion_info_2") + StorageSlotName::new("miden::agglayer::bridge::conversion_info_2") .expect("conversion info 2 storage slot name should be valid") }); @@ -382,7 +383,7 @@ impl AggLayerFaucet { /// Storage slot name for the AggLayer bridge account ID. pub fn bridge_account_id_slot() -> &'static StorageSlotName { - &AGGLAYER_FAUCET_SLOT_NAME + &AGGLAYER_BRIDGE_ID_SLOT_NAME } /// Storage slot name for the first 4 felts of the origin token address. @@ -407,7 +408,7 @@ impl From for AccountComponent { faucet.bridge_account_id.prefix().as_felt(), ]); let bridge_slot = - StorageSlot::with_value(AGGLAYER_FAUCET_SLOT_NAME.clone(), bridge_account_id_word); + StorageSlot::with_value(AGGLAYER_BRIDGE_ID_SLOT_NAME.clone(), bridge_account_id_word); let (conversion_slot1_word, conversion_slot2_word) = agglayer_faucet_conversion_slots( &faucet.origin_token_address, From cc485c4b47e6cb342e9bcad5dd60833b515d87e3 Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Wed, 18 Mar 2026 16:34:08 +0300 Subject: [PATCH 2/3] chore: roll back the changes --- crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm | 8 ++++---- crates/miden-agglayer/asm/agglayer/faucet/mod.masm | 4 ++-- crates/miden-agglayer/src/bridge.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm index b18ba0b626..1383bf5d1f 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm @@ -30,10 +30,10 @@ type MemoryAddress = u32 # Storage slot constants for the LET (Local Exit Tree). # The frontier is stored as a double-word array in a map slot. # The root and num_leaves are stored in separate value slots. -const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::bridge::let") -const LET_ROOT_LO_SLOT=word("miden::agglayer::bridge::let::root_lo") -const LET_ROOT_HI_SLOT=word("miden::agglayer::bridge::let::root_hi") -const LET_NUM_LEAVES_SLOT=word("miden::agglayer::bridge::let::num_leaves") +const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::let") +const LET_ROOT_LO_SLOT=word("miden::agglayer::let::root_lo") +const LET_ROOT_HI_SLOT=word("miden::agglayer::let::root_hi") +const LET_NUM_LEAVES_SLOT=word("miden::agglayer::let::num_leaves") # Memory pointers const LEAF_DATA_START_PTR=44 diff --git a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm index 252ce31dbb..8c70386ec5 100644 --- a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm +++ b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm @@ -14,9 +14,9 @@ use miden::core::word # Storage slots for conversion metadata. # Slot 1: [addr_felt0, addr_felt1, addr_felt2, addr_felt3] — first 4 felts of origin token address -const CONVERSION_INFO_1_SLOT = word("miden::agglayer::bridge::conversion_info_1") +const CONVERSION_INFO_1_SLOT = word("miden::agglayer::faucet::conversion_info_1") # Slot 2: [addr_felt4, origin_network, scale, 0] — remaining address felt + origin network + scale -const CONVERSION_INFO_2_SLOT = word("miden::agglayer::bridge::conversion_info_2") +const CONVERSION_INFO_2_SLOT = word("miden::agglayer::faucet::conversion_info_2") # PUBLIC INTERFACE # ================================================================================================= diff --git a/crates/miden-agglayer/src/bridge.rs b/crates/miden-agglayer/src/bridge.rs index 6c3af9f94e..8fbbeff0de 100644 --- a/crates/miden-agglayer/src/bridge.rs +++ b/crates/miden-agglayer/src/bridge.rs @@ -40,7 +40,7 @@ include!(concat!(env!("OUT_DIR"), "/agglayer_constants.rs")); static GER_MAP_SLOT_NAME: LazyLock = LazyLock::new(|| { StorageSlotName::new("miden::agglayer::bridge::ger") - .expect("bridge storage slot name should be valid") + .expect("GER storage slot name should be valid") }); static LET_FRONTIER_SLOT_NAME: LazyLock = LazyLock::new(|| { StorageSlotName::new("miden::agglayer::let").expect("LET storage slot name should be valid") From 9d22786d39ef6820269c54a572cddd12ef31750b Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Wed, 18 Mar 2026 18:10:00 +0300 Subject: [PATCH 3/3] refactor: update storage slot names --- crates/miden-agglayer/SPEC.md | 37 ++- .../asm/agglayer/bridge/bridge_config.masm | 22 +- .../asm/agglayer/bridge/bridge_in.masm | 32 +-- .../asm/agglayer/bridge/bridge_out.masm | 37 ++- .../asm/agglayer/bridge/canonical_zeros.masm | 2 +- .../bridge/mmr_frontier32_keccak.masm | 6 +- .../asm/agglayer/common/asset_conversion.masm | 2 +- .../asm/agglayer/common/eth_address.masm | 2 +- .../asm/agglayer/faucet/mod.masm | 10 +- .../miden-agglayer/asm/components/bridge.masm | 8 +- .../miden-agglayer/asm/components/faucet.masm | 8 +- .../asm/note_scripts/B2AGG.masm | 2 +- .../asm/note_scripts/CLAIM.masm | 2 +- .../asm/note_scripts/CONFIG_AGG_BRIDGE.masm | 2 +- .../asm/note_scripts/UPDATE_GER.masm | 2 +- crates/miden-agglayer/build.rs | 4 +- .../test-vectors/mmr_frontier_vectors.json | 256 +++++++++--------- .../solidity-compat/test/MMRTestVectors.t.sol | 2 +- crates/miden-agglayer/src/bridge.rs | 204 +++++++------- crates/miden-agglayer/src/faucet.rs | 12 +- .../tests/agglayer/asset_conversion.rs | 8 +- .../miden-testing/tests/agglayer/bridge_in.rs | 2 +- .../tests/agglayer/config_bridge.rs | 2 +- .../tests/agglayer/global_index.rs | 2 +- .../tests/agglayer/leaf_utils.rs | 4 +- .../tests/agglayer/mmr_frontier.rs | 4 +- .../solidity_miden_address_conversion.rs | 2 +- .../tests/agglayer/update_ger.rs | 4 +- 28 files changed, 353 insertions(+), 327 deletions(-) diff --git a/crates/miden-agglayer/SPEC.md b/crates/miden-agglayer/SPEC.md index 42aa806faa..924330d031 100644 --- a/crates/miden-agglayer/SPEC.md +++ b/crates/miden-agglayer/SPEC.md @@ -86,9 +86,9 @@ Bridges an asset out of Miden into the AggLayer: | **Panics** | Note sender is not the bridge admin | Asserts the note sender matches the bridge admin stored in -`miden::agglayer::bridge::admin`, then writes +`agglayer::bridge::admin_account_id`, then writes `[0, 0, faucet_id_suffix, faucet_id_prefix] -> [1, 0, 0, 0]` into the -`faucet_registry` map slot. +`faucet_registry_map` map slot. #### `bridge_config::update_ger` @@ -101,9 +101,9 @@ Asserts the note sender matches the bridge admin stored in | **Panics** | Note sender is not the GER manager | Asserts the note sender matches the GER manager stored in -`miden::agglayer::bridge::ger_manager`, then computes +`agglayer::bridge::ger_manager_account_id`, then computes `KEY = rpo256::merge(GER_UPPER, GER_LOWER)` and stores -`KEY -> [1, 0, 0, 0]` in the `ger` map slot. This marks the GER as "known". +`KEY -> [1, 0, 0, 0]` in the `ger_map` map slot. This marks the GER as "known". #### `bridge_in::verify_leaf_bridge` TODO ([#2624](https://github.com/0xMiden/protocol/issues/2624)): document new CLAIM note flow. @@ -129,17 +129,17 @@ Verifies a bridge-in claim: | Slot name | Slot type | Key encoding | Value encoding | Purpose | |-----------|-----------|-------------|----------------|---------| -| `miden::agglayer::bridge::ger` | Map | `rpo256::merge(GER_UPPER, GER_LOWER)` | `[1, 0, 0, 0]` if known; `[0, 0, 0, 0]` if absent | Known Global Exit Root set | -| `miden::agglayer::let` | Map | `[h, 0, 0, 0]` and `[h, 1, 0, 0]` (for h = 0..31) | Per index h: two keys yield one double-word (2 words = 8 felts, a Keccak-256 digest). Absent keys return zeros. | Local Exit Tree MMR frontier | -| `miden::agglayer::let::root_lo` | Value | -- | `[root_0, root_1, root_2, root_3]` | LET root low word (Keccak-256 lower 16 bytes) | -| `miden::agglayer::let::root_hi` | Value | -- | `[root_4, root_5, root_6, root_7]` | LET root high word (Keccak-256 upper 16 bytes) | -| `miden::agglayer::let::num_leaves` | Value | -- | `[count, 0, 0, 0]` | Number of leaves appended to the LET | -| `miden::agglayer::bridge::faucet_registry` | Map | `[0, 0, faucet_id_suffix, faucet_id_prefix]` | `[1, 0, 0, 0]` if registered; `[0, 0, 0, 0]` if absent | Registered faucet lookup | -| `miden::agglayer::bridge::admin` | Value | -- | `[0, 0, admin_suffix, admin_prefix]` | Bridge admin account ID for CONFIG note authorization | -| `miden::agglayer::bridge::ger_manager` | Value | -- | `[0, 0, mgr_suffix, mgr_prefix]` | GER manager account ID for UPDATE_GER note authorization | - -Initial state: all map slots empty, all value slots `[0, 0, 0, 0]` except `admin` and -`ger_manager` which are set at account creation time. +| `agglayer::bridge::ger_map` | Map | `rpo256::merge(GER_UPPER, GER_LOWER)` | `[1, 0, 0, 0]` if known; `[0, 0, 0, 0]` if absent | Known Global Exit Root set | +| `agglayer::bridge::let_frontier` | Map | `[h, 0, 0, 0]` and `[h, 1, 0, 0]` (for h = 0..31) | Per index h: two keys yield one double-word (2 words = 8 felts, a Keccak-256 digest). Absent keys return zeros. | Local Exit Tree MMR frontier | +| `agglayer::bridge::let_root_lo` | Value | -- | `[root_0, root_1, root_2, root_3]` | LET root low word (Keccak-256 lower 16 bytes) | +| `agglayer::bridge::let_root_hi` | Value | -- | `[root_4, root_5, root_6, root_7]` | LET root high word (Keccak-256 upper 16 bytes) | +| `agglayer::bridge::let_num_leaves` | Value | -- | `[count, 0, 0, 0]` | Number of leaves appended to the LET | +| `agglayer::bridge::faucet_registry_map` | Map | `[0, 0, faucet_id_suffix, faucet_id_prefix]` | `[1, 0, 0, 0]` if registered; `[0, 0, 0, 0]` if absent | Registered faucet lookup | +| `agglayer::bridge::admin_account_id` | Value | -- | `[0, 0, admin_suffix, admin_prefix]` | Bridge admin account ID for CONFIG note authorization | +| `agglayer::bridge::ger_manager_account_id` | Value | -- | `[0, 0, mgr_suffix, mgr_prefix]` | GER manager account ID for UPDATE_GER note authorization | + +Initial state: all map slots empty, all value slots `[0, 0, 0, 0]` except +`admin_account_id` and `ger_manager_account_id` which are set at account creation time. ### 2.2 Faucet Account Component @@ -204,9 +204,8 @@ This is a re-export of `miden::standards::faucets::basic_fungible::burn`. It bur | Slot name | Slot type | Value encoding | Purpose | |-----------|-----------|----------------|---------| | Faucet metadata (standard) | Value | `[token_supply, max_supply, decimals, token_symbol]` | Standard `NetworkFungibleFaucet` metadata | -| `miden::agglayer::faucet` (TODO (Future): rename for clarity [#2356](https://github.com/0xMiden/protocol/issues/2356)) | Value | `[0, 0, bridge_suffix, bridge_prefix]` | Bridge account ID this faucet is paired with | -| `miden::agglayer::faucet::conversion_info_1` | Value | `[addr_0, addr_1, addr_2, addr_3]` | Origin token address, first 4 u32 limbs | -| `miden::agglayer::faucet::conversion_info_2` | Value | `[addr_4, origin_network, scale, 0]` | Origin token address 5th limb, origin network ID, scale exponent | +| `agglayer::faucet::conversion_info_1` | Value | `[addr_0, addr_1, addr_2, addr_3]` | Origin token address, first 4 u32 limbs | +| `agglayer::faucet::conversion_info_2` | Value | `[addr_4, origin_network, scale, 0]` | Origin token address 5th limb, origin network ID, scale exponent | --- @@ -615,7 +614,7 @@ extract the recipient's `AccountId` from the embedded Ethereum address and e.g. #### 5.4.3 Ethereum Address → `AccountId` (MASM) -`eth_address::to_account_id` — Module: `miden::agglayer::common::eth_address` +`eth_address::to_account_id` — Module: `agglayer::common::eth_address` This is the in-VM counterpart of the Rust `to_account_id`, invoked during CLAIM note consumption to decode the recipient's address from the leaf data, and eventually for building the P2ID note for the recipient. diff --git a/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm b/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm index 45a7cd694e..77a124d5be 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm @@ -17,11 +17,11 @@ const ERR_SENDER_NOT_GER_MANAGER="note sender is not the global exit root manage # ================================================================================================= # Storage slots -const BRIDGE_ADMIN_SLOT=word("miden::agglayer::bridge::admin") -const GER_MANAGER_SLOT=word("miden::agglayer::bridge::ger_manager") -const GER_STORAGE_SLOT=word("miden::agglayer::bridge::ger") -const FAUCET_REGISTRY_SLOT=word("miden::agglayer::bridge::faucet_registry") -const TOKEN_REGISTRY_SLOT=word("miden::agglayer::bridge::token_registry") +const BRIDGE_ADMIN_SLOT=word("agglayer::bridge::admin_account_id") +const GER_MANAGER_SLOT=word("agglayer::bridge::ger_manager_account_id") +const GER_MAP_STORAGE_SLOT=word("agglayer::bridge::ger_map") +const FAUCET_REGISTRY_MAP_SLOT=word("agglayer::bridge::faucet_registry_map") +const TOKEN_REGISTRY_MAP_SLOT=word("agglayer::bridge::token_registry_map") # Flags const GER_KNOWN_FLAG=1 @@ -61,7 +61,7 @@ pub proc update_ger swapw # => [GER_HASH, VALUE, pad(12)] - push.GER_STORAGE_SLOT[0..2] + push.GER_MAP_STORAGE_SLOT[0..2] # => [slot_id_prefix, slot_id_suffix, GER_HASH, VALUE, pad(12)] exec.native_account::set_map_item @@ -87,7 +87,7 @@ pub proc assert_valid_ger exec.rpo256::merge # => [GER_HASH] - push.GER_STORAGE_SLOT[0..2] + push.GER_MAP_STORAGE_SLOT[0..2] # => [slot_id_prefix, slot_id_suffix, GER_HASH] exec.active_account::get_map_item @@ -135,7 +135,7 @@ pub proc register_faucet swapw # => [[faucet_id_prefix, faucet_id_suffix, 0, 0], [0, 0, 0, 1], origin_token_addr(5), faucet_id_prefix, faucet_id_suffix, pad(9)] - push.FAUCET_REGISTRY_SLOT[0..2] + push.FAUCET_REGISTRY_MAP_SLOT[0..2] exec.native_account::set_map_item # => [OLD_VALUE, origin_token_addr(5), faucet_id_prefix, faucet_id_suffix, pad(9)] @@ -158,7 +158,7 @@ pub proc register_faucet swapw # => [TOKEN_ADDR_HASH, faucet_id_prefix, faucet_id_suffix, 0, 0, pad(10)] - push.TOKEN_REGISTRY_SLOT[0..2] + push.TOKEN_REGISTRY_MAP_SLOT[0..2] exec.native_account::set_map_item # => [OLD_VALUE, pad(12)] @@ -184,7 +184,7 @@ pub proc assert_faucet_registered movup.3 movup.3 # => [faucet_id_prefix, faucet_id_suffix, 0, 0] - push.FAUCET_REGISTRY_SLOT[0..2] + push.FAUCET_REGISTRY_MAP_SLOT[0..2] exec.active_account::get_map_item # => [VALUE(4)] @@ -211,7 +211,7 @@ pub proc lookup_faucet_by_token_address exec.hash_token_address # => [TOKEN_ADDR_HASH] - push.TOKEN_REGISTRY_SLOT[0..2] + push.TOKEN_REGISTRY_MAP_SLOT[0..2] exec.active_account::get_map_item # => [faucet_id_prefix, faucet_id_suffix, 0, 0] diff --git a/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm b/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm index 3c23856ed4..d387fb679c 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm @@ -1,9 +1,9 @@ -use miden::agglayer::bridge::bridge_config -use miden::agglayer::bridge::leaf_utils -use miden::agglayer::common::utils -use miden::agglayer::common::asset_conversion -use miden::agglayer::common::eth_address -use miden::agglayer::faucet -> agglayer_faucet +use agglayer::bridge::bridge_config +use agglayer::bridge::leaf_utils +use agglayer::common::utils +use agglayer::common::asset_conversion +use agglayer::common::eth_address +use agglayer::faucet -> agglayer_faucet use miden::core::crypto::hashes::keccak256 use miden::core::crypto::hashes::rpo256 use miden::core::mem @@ -41,23 +41,20 @@ const ERR_SOURCE_BRIDGE_NETWORK_OVERFLOW = "source bridge network overflowed u32 # CONSTANTS # ================================================================================================= -# Storage slots -# ------------------------------------------------------------------------------------------------- - -# Storage slot constants for the CGI (claimed global index) chain hash. -# It is stored in two separate value slots. -const CGI_CHAIN_HASH_LO_SLOT_NAME = word("miden::agglayer::bridge::cgi_chain_hash_lo") -const CGI_CHAIN_HASH_HI_SLOT_NAME = word("miden::agglayer::bridge::cgi_chain_hash_hi") +# Claim Nullifier Flag +const IS_CLAIMED_FLAG = [1, 0, 0, 0] -# Storage Slots +# Storage slots # ------------------------------------------------------------------------------------------------- # The slot in this component's storage layout where claim nullifiers are stored. # Map entries: RPO(leaf_index, source_bridge_network) => [1, 0, 0, 0] -const CLAIM_NULLIFIERS_SLOT = word("miden::agglayer::bridge::claim_nullifiers") +const CLAIM_NULLIFIERS_SLOT = word("agglayer::bridge::claim_nullifiers") -# Claim Nullifier Flag -const IS_CLAIMED_FLAG = [1, 0, 0, 0] +# Storage slot constants for the CGI (claimed global index) chain hash. +# It is stored in two separate value slots. +const CGI_CHAIN_HASH_LO_SLOT_NAME = word("agglayer::bridge::cgi_chain_hash_lo") +const CGI_CHAIN_HASH_HI_SLOT_NAME = word("agglayer::bridge::cgi_chain_hash_hi") # Data sizes # ------------------------------------------------------------------------------------------------- @@ -160,7 +157,6 @@ const CLAIM_DEST_ID_SUFFIX_LOCAL = 1 # PUBLIC INTERFACE # ================================================================================================= - #! Validates a claim against the AggLayer bridge and creates a MINT note for the aggfaucet. #! #! This procedure is called by the CLAIM note script. It validates the Merkle proof and then diff --git a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm index 1383bf5d1f..911fb153de 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm @@ -11,11 +11,11 @@ use miden::protocol::output_note use miden::core::crypto::hashes::keccak256 use miden::core::crypto::hashes::rpo256 use miden::core::word -use miden::agglayer::common::utils -use miden::agglayer::faucet -> agglayer_faucet -use miden::agglayer::bridge::bridge_config -use miden::agglayer::bridge::leaf_utils -use miden::agglayer::bridge::mmr_frontier32_keccak +use agglayer::common::utils +use agglayer::faucet -> agglayer_faucet +use agglayer::bridge::bridge_config +use agglayer::bridge::leaf_utils +use agglayer::bridge::mmr_frontier32_keccak # TYPE ALIASES @@ -27,21 +27,29 @@ type MemoryAddress = u32 # CONSTANTS # ================================================================================================= +# Storage slots +# ------------------------------------------------------------------------------------------------- + # Storage slot constants for the LET (Local Exit Tree). # The frontier is stored as a double-word array in a map slot. # The root and num_leaves are stored in separate value slots. -const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::let") -const LET_ROOT_LO_SLOT=word("miden::agglayer::let::root_lo") -const LET_ROOT_HI_SLOT=word("miden::agglayer::let::root_hi") -const LET_NUM_LEAVES_SLOT=word("miden::agglayer::let::num_leaves") +const LET_FRONTIER_SLOT=word("agglayer::bridge::let_frontier") +const LET_ROOT_LO_SLOT=word("agglayer::bridge::let_root_lo") +const LET_ROOT_HI_SLOT=word("agglayer::bridge::let_root_hi") +const LET_NUM_LEAVES_SLOT=word("agglayer::bridge::let_num_leaves") + +# Global memory pointers +# ------------------------------------------------------------------------------------------------- -# Memory pointers const LEAF_DATA_START_PTR=44 # Memory pointer for loading the LET (Local Exit Tree) frontier into memory. # The memory layout at this address matches what append_and_update_frontier expects: # [num_leaves, 0, 0, 0, [[FRONTIER_NODE_LO, FRONTIER_NODE_HI]; 32]] const LET_FRONTIER_MEM_PTR=100 +# Field offsets +# ------------------------------------------------------------------------------------------------- + # Leaf data field offsets (relative to LEAF_DATA_START_PTR) const LEAF_TYPE_OFFSET=0 const ORIGIN_NETWORK_OFFSET=1 @@ -52,6 +60,9 @@ const AMOUNT_OFFSET=13 const METADATA_HASH_OFFSET=21 const PADDING_OFFSET=29 +# Local memory offsets +# ------------------------------------------------------------------------------------------------- + # bridge_out memory locals const BRIDGE_OUT_BURN_ASSET_LOC=0 const DESTINATION_ADDRESS_0_LOC=4 @@ -68,6 +79,8 @@ const ATTACHMENT_SCHEME_LOC=8 const ATTACHMENT_KIND_LOC=9 # Other constants +# ------------------------------------------------------------------------------------------------- + const LEAF_TYPE_ASSET=0 const PUBLIC_NOTE=1 const BURN_NOTE_NUM_STORAGE_ITEMS=0 @@ -306,7 +319,7 @@ proc load_let_frontier_to_memory # => [h] # Read frontier[h] as a double word from the map - dup push.LOCAL_EXIT_TREE_SLOT[0..2] + dup push.LET_FRONTIER_SLOT[0..2] exec.double_word_array::get # => [VALUE_0, VALUE_1, h] @@ -375,7 +388,7 @@ proc save_let_frontier_to_storage # => [VALUE_0, VALUE_1, h] # Write it back to the map at index h - dup.8 push.LOCAL_EXIT_TREE_SLOT[0..2] + dup.8 push.LET_FRONTIER_SLOT[0..2] exec.double_word_array::set dropw dropw # => [h] diff --git a/crates/miden-agglayer/asm/agglayer/bridge/canonical_zeros.masm b/crates/miden-agglayer/asm/agglayer/bridge/canonical_zeros.masm index 1915726cee..711fe1835f 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/canonical_zeros.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/canonical_zeros.masm @@ -101,7 +101,7 @@ const ZERO_30_R = [1078065138, 2904706143, 1223587258, 1350312851] const ZERO_31_L = [2840985724, 1653344606, 4049365781, 2389186238] const ZERO_31_R = [3759582231, 2660540036, 1648733876, 2340505732] -use ::miden::agglayer::common::utils::mem_store_double_word +use ::agglayer::common::utils::mem_store_double_word #! Inputs: [zeros_ptr] #! Outputs: [] diff --git a/crates/miden-agglayer/asm/agglayer/bridge/mmr_frontier32_keccak.masm b/crates/miden-agglayer/asm/agglayer/bridge/mmr_frontier32_keccak.masm index 8ff7efb453..32eef7cec1 100644 --- a/crates/miden-agglayer/asm/agglayer/bridge/mmr_frontier32_keccak.masm +++ b/crates/miden-agglayer/asm/agglayer/bridge/mmr_frontier32_keccak.masm @@ -1,7 +1,7 @@ use miden::core::crypto::hashes::keccak256 -use ::miden::agglayer::bridge::canonical_zeros::load_zeros_to_memory -use ::miden::agglayer::common::utils::mem_store_double_word -use ::miden::agglayer::common::utils::mem_load_double_word +use ::agglayer::bridge::canonical_zeros::load_zeros_to_memory +use ::agglayer::common::utils::mem_store_double_word +use ::agglayer::common::utils::mem_load_double_word # An MMR Frontier is a data structure based on an MMR, which combines some features of an MMR and an # SMT. diff --git a/crates/miden-agglayer/asm/agglayer/common/asset_conversion.masm b/crates/miden-agglayer/asm/agglayer/common/asset_conversion.masm index 77bfa65cc6..596a45b86f 100644 --- a/crates/miden-agglayer/asm/agglayer/common/asset_conversion.masm +++ b/crates/miden-agglayer/asm/agglayer/common/asset_conversion.masm @@ -1,6 +1,6 @@ use miden::core::math::u64 use miden::core::word -use miden::agglayer::common::utils +use agglayer::common::utils use ::miden::protocol::asset::FUNGIBLE_ASSET_MAX_AMOUNT # ERRORS diff --git a/crates/miden-agglayer/asm/agglayer/common/eth_address.masm b/crates/miden-agglayer/asm/agglayer/common/eth_address.masm index 5001fd769d..1597206b6f 100644 --- a/crates/miden-agglayer/asm/agglayer/common/eth_address.masm +++ b/crates/miden-agglayer/asm/agglayer/common/eth_address.masm @@ -1,4 +1,4 @@ -use miden::agglayer::common::utils +use agglayer::common::utils use miden::core::crypto::hashes::keccak256 use miden::core::word diff --git a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm index 8c70386ec5..a1ef0b00ef 100644 --- a/crates/miden-agglayer/asm/agglayer/faucet/mod.masm +++ b/crates/miden-agglayer/asm/agglayer/faucet/mod.masm @@ -1,7 +1,7 @@ use miden::core::sys -use miden::agglayer::common::utils -use miden::agglayer::common::asset_conversion -use miden::agglayer::common::eth_address +use agglayer::common::utils +use agglayer::common::asset_conversion +use agglayer::common::eth_address use miden::protocol::active_account use miden::protocol::active_note use miden::standards::faucets @@ -14,9 +14,9 @@ use miden::core::word # Storage slots for conversion metadata. # Slot 1: [addr_felt0, addr_felt1, addr_felt2, addr_felt3] — first 4 felts of origin token address -const CONVERSION_INFO_1_SLOT = word("miden::agglayer::faucet::conversion_info_1") +const CONVERSION_INFO_1_SLOT = word("agglayer::faucet::conversion_info_1") # Slot 2: [addr_felt4, origin_network, scale, 0] — remaining address felt + origin network + scale -const CONVERSION_INFO_2_SLOT = word("miden::agglayer::faucet::conversion_info_2") +const CONVERSION_INFO_2_SLOT = word("agglayer::faucet::conversion_info_2") # PUBLIC INTERFACE # ================================================================================================= diff --git a/crates/miden-agglayer/asm/components/bridge.masm b/crates/miden-agglayer/asm/components/bridge.masm index 93789d3fc6..15f10fd4b6 100644 --- a/crates/miden-agglayer/asm/components/bridge.masm +++ b/crates/miden-agglayer/asm/components/bridge.masm @@ -3,7 +3,7 @@ # This is a thin wrapper that re-exports bridge-related procedures from the # agglayer library. -pub use ::miden::agglayer::bridge::bridge_config::register_faucet -pub use ::miden::agglayer::bridge::bridge_config::update_ger -pub use ::miden::agglayer::bridge::bridge_in::claim -pub use ::miden::agglayer::bridge::bridge_out::bridge_out +pub use ::agglayer::bridge::bridge_config::register_faucet +pub use ::agglayer::bridge::bridge_config::update_ger +pub use ::agglayer::bridge::bridge_in::claim +pub use ::agglayer::bridge::bridge_out::bridge_out diff --git a/crates/miden-agglayer/asm/components/faucet.masm b/crates/miden-agglayer/asm/components/faucet.masm index c467f558d2..f27f15edbc 100644 --- a/crates/miden-agglayer/asm/components/faucet.masm +++ b/crates/miden-agglayer/asm/components/faucet.masm @@ -7,7 +7,7 @@ # - `get_scale` for bridge-in FPI (amount verification) # - `burn` for bridge-out -pub use ::miden::agglayer::faucet::distribute -pub use ::miden::agglayer::faucet::asset_to_origin_asset -pub use ::miden::agglayer::faucet::get_scale -pub use ::miden::agglayer::faucet::burn +pub use ::agglayer::faucet::distribute +pub use ::agglayer::faucet::asset_to_origin_asset +pub use ::agglayer::faucet::get_scale +pub use ::agglayer::faucet::burn diff --git a/crates/miden-agglayer/asm/note_scripts/B2AGG.masm b/crates/miden-agglayer/asm/note_scripts/B2AGG.masm index 2fbb1b01cb..9dc2cc9718 100644 --- a/crates/miden-agglayer/asm/note_scripts/B2AGG.masm +++ b/crates/miden-agglayer/asm/note_scripts/B2AGG.masm @@ -1,4 +1,4 @@ -use miden::agglayer::bridge::bridge_out +use agglayer::bridge::bridge_out use miden::protocol::account_id use miden::protocol::active_account use miden::protocol::active_note diff --git a/crates/miden-agglayer/asm/note_scripts/CLAIM.masm b/crates/miden-agglayer/asm/note_scripts/CLAIM.masm index e8bc431d34..851a365849 100644 --- a/crates/miden-agglayer/asm/note_scripts/CLAIM.masm +++ b/crates/miden-agglayer/asm/note_scripts/CLAIM.masm @@ -1,4 +1,4 @@ -use miden::agglayer::bridge::bridge_in -> bridge +use agglayer::bridge::bridge_in -> bridge use miden::protocol::active_note use miden::protocol::note use miden::core::crypto::hashes::keccak256 diff --git a/crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm b/crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm index e9d9f1f967..03b3dcce61 100644 --- a/crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm +++ b/crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm @@ -1,4 +1,4 @@ -use miden::agglayer::bridge::bridge_config +use agglayer::bridge::bridge_config use miden::protocol::active_note use miden::protocol::active_account use miden::protocol::account_id diff --git a/crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm b/crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm index c1f5cb89d4..c11d609db0 100644 --- a/crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm +++ b/crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm @@ -1,4 +1,4 @@ -use miden::agglayer::bridge::bridge_config +use agglayer::bridge::bridge_config use miden::protocol::active_note use miden::protocol::active_account use miden::protocol::account_id diff --git a/crates/miden-agglayer/build.rs b/crates/miden-agglayer/build.rs index b085e5e9b2..62db2c33fa 100644 --- a/crates/miden-agglayer/build.rs +++ b/crates/miden-agglayer/build.rs @@ -111,7 +111,7 @@ fn compile_agglayer_lib( let standards_lib = miden_standards::StandardsLib::default(); assembler.link_static_library(standards_lib)?; - let agglayer_lib = assembler.assemble_library_from_dir(source_dir, "miden::agglayer")?; + let agglayer_lib = assembler.assemble_library_from_dir(source_dir, "agglayer")?; let output_file = target_dir.join("agglayer").with_extension(Library::LIBRARY_EXTENSION); agglayer_lib.write_to_file(output_file).into_diagnostic()?; @@ -382,7 +382,7 @@ fn generate_canonical_zeros(target_dir: &Path) -> Result<()> { // remove once CANONICAL_ZEROS advice map is available zero_constants.push_str( " -use ::miden::agglayer::common::utils::mem_store_double_word +use ::agglayer::common::utils::mem_store_double_word #! Inputs: [zeros_ptr] #! Outputs: [] diff --git a/crates/miden-agglayer/solidity-compat/test-vectors/mmr_frontier_vectors.json b/crates/miden-agglayer/solidity-compat/test-vectors/mmr_frontier_vectors.json index 79c76364dc..c1616ccc69 100644 --- a/crates/miden-agglayer/solidity-compat/test-vectors/mmr_frontier_vectors.json +++ b/crates/miden-agglayer/solidity-compat/test-vectors/mmr_frontier_vectors.json @@ -68,140 +68,140 @@ 32 ], "destination_addresses": [ - "0xB48074703337bEf6e94A9e2E1FfFe71632B42D56", - "0xBA60cd3cBD12619e6983B5D0E1CbcF2f4fed9d7b", - "0x89510362d6EdeB958F059727C9eD0F99298aAFa4", - "0xD62Cf6356E0a48e2014b71Cf942BEbBbFb00F7d7", - "0xFA5eacb9668731D74F2BB5Ad5bfB319f5A91c87D", - "0x90DD6647e5c91f9104a548876868a54795696B34", - "0x0E76F5f993A9a7f961e06397BC71d15c278A0b6c", - "0xe022226D1fFcCf12ac0e84D0aB9430F3fd56C613", - "0x1F9ecff77E28Bca8Ef18434B842A30579Bfd4EaA", - "0xe51D207B549Db157BeE9faeBd51C35aB47d180EF", - "0x9f30d6d0335E91e0593f13a567E4Fee661e1259F", - "0xE8F13Da1BDb719ba364a890a623454040A932eCf", - "0xb6EE19bf265563aA76dbe202e8dC71F8f42a58B1", - "0xf62d45e4D0DC57259B4557b5d79Ea23F67D0E381", - "0xaa94f5480aD0C906044E5E7Da8BB6BC4395aA498", - "0x060ddd9f6e6CF285004e33C30b46710ad75918Dd", - "0x8B743c166e1dA1444781AD2b5Fe2291578ABCeb1", - "0x8B08d9A773273Df976fb7448D38FeEeB15Dc34F8", - "0xbe931f6F189e6F8Da14f7B67Eb2E67b5D7f71c1d", - "0x2F891C182b23d1422D8Fddd9CC30B25BB849Bd5F", - "0x93fD7DEd75058ABA1B76C35c4Ac4e9355e596EdC", - "0x25B9eBC8D7d48a6B0e71e82Aa66832aCC9419E3A", - "0xbb086ECaC1316B81107e3CA591ef645831094E5a", - "0x08c7a5Db749DEf9280108Ec5e0354d4957CB17cF", - "0x0da76aA44116fad143F778f25907046E52F8c4d3", - "0xcFd0a3bfA35E771aad88C64EF0A310efF6730cDa", - "0xa7439b51638F31f054C93EC869C8c7E982699BAC", - "0x5C9A97f096CB18903994C44ddC07FfD921490B2c", - "0x0e52786aF0b48D764a255f6506C9C297d5BA2Dc3", - "0x5C2093921171F2c2d657eAA681D463Fe36c965d1", - "0xf8de801F1ba2a676d96Eb1F1ccB0B0CADFCbbE9e", - "0x31D230FAbAd05777Bb3E1a062e781446Bc422b80" + "0x85804AD98112Ac66C668B6e63a647102e682FdB2", + "0x4f0CE8a02Be4B36641EC934C805A897d9126259f", + "0x4d5813d295325F23B6ceD1E115415e877F276f29", + "0xa35E68E40f9b6457867AB4f9Ce57c65Ca582fb2E", + "0x7631ca2a32732b5B80473B3516ed42f9758738A2", + "0xb1415654E18EC9f52Ce0a83149D4eEC635729880", + "0x80Aa05C9D740653e768FFc29a9E805FfE155f78e", + "0xdA5d4D43Bf59b8e0B5506278DE1D6397a6130AA3", + "0xF425891FE85A6995a384C3D0f5dA342121eD9f68", + "0xcD4cddC07370652f47AD35C6e5FDe99893b27131", + "0xBe9291fFF6BedAb09F4836187D28576D7F33748E", + "0x8CBfd2A0B64A18cB5798019e77f91f69AC19C502", + "0x00f248400A7272942f3141DE879197897f6C6dAd", + "0x82E8801f1a86FEE61C3BC202CDA1502CC02f1678", + "0x872B013a0DD39a7037e1035be2999B11eBC5046D", + "0xE13F863BfbD9180e40CcB0e69B9ceb1207bfE765", + "0xf963755a92C7f039FE276a2658781A32267F1472", + "0xAA67453dF8b4B94759e7479E25Ac6De97D0C29C5", + "0x239334c09aBc4BE506E437B06C1606a5148511ce", + "0x6E117bE6582AfD5dB79F1B54D86c2ad17BBB815f", + "0x9568701DA26402b8f1B93843cCfebc5AE49A5558", + "0xb9D92B472855c0b4d2CB9829D403b5B6d525690E", + "0x41B306F7e459A9ab1753C2CE845b2A8987763FAd", + "0xfE6153675af00817fCbc3e9037504D927C13eE92", + "0xe0e6500AD102C2495feEd6196a2B82653e226dBB", + "0x9b52285052f44F598e2516ca52Bf60F1f2c710b9", + "0xA0480F62bac291B68B9d2c4aBBC20cA23127606d", + "0xb8EeC31ba8fFeD3542F7C1C97d6289F5F2F9D207", + "0x73d705D05c02B25f45A9095798cf6EC8adD21986", + "0xd758bd54A484141Ef04835E4E3a649802111F0C3", + "0xf54341E00449D00F5FB2AE2e1f6eF3C48e367D60", + "0x4edd3fa18f89B5ea0d7479c074c4766E710858Eb" ], "destination_networks": [ - 1538671592, - 1271685039, - 2812858243, - 1717044446, - 1618236512, - 1846799397, - 1114625417, - 1980472020, - 3445581035, - 1216050355, - 1334555263, - 1595653741, - 1406956437, - 2339872987, - 1591634953, - 2036330440, - 948554316, - 1629580568, - 4209912969, - 3528172732, - 4197496357, - 2020389543, - 1365501531, - 2591126838, - 273689805, - 543018504, - 3291055054, - 2685286074, - 3030491074, - 4166649488, - 1541470110, - 1181416010 + 1507074157, + 3275066435, + 1397235428, + 736774827, + 1035702945, + 2677284394, + 1247294568, + 978748429, + 717304394, + 1567186996, + 4094016686, + 290190939, + 3473766050, + 3919304923, + 2832029840, + 1004428834, + 4171274214, + 1585041715, + 152324464, + 3244001557, + 991159438, + 663129681, + 4263712733, + 299207814, + 3615323772, + 2230326463, + 435727967, + 3719615199, + 341405995, + 2388835629, + 1268627246, + 3939438541 ], "leaves": [ - "0xe460585d9b2385592b26a34d6908ea58165586cb39e5e6cb365b68246d29d7f8", - "0x5a7295b074b2ffeb07bd8bacbdd97aa97b0b269db43779112ef24b52548a9a2a", - "0xde239e1e8b54de83c9b0e3f32c269b265dd0efcda92c93a2146f44302e604080", - "0x98681050a4c0e39d25f1a44d95b343a05f7139cc882f628c569b3a1ae889f0e6", - "0xd3d70b40cc2a71e9a4996a2afaabcafe93af95ba9de147e3835ccddba2d82fdd", - "0xd46fec5943f6d40c9a68076fbc325daf7763607aaa60ca9be297cade5a1efca5", - "0x4c54e0aab6332cea9a9f867933caee83c6167aa78f663129d10e56cee35aacdd", - "0xf487aba0c467c53aa4fc9a7319817e1448efd774dedb235a1ab95a5dd2592d21", - "0xc734b7fd5abe87f4dff06da98980e19894117e92738e27e8dc0826eb4dee7202", - "0x8bcc65728c792dfaa58c6b63d192c2e37cd3db7c62774e7b40b9b3232597073a", - "0x6dbb052d9082cf78a0464cae809cd6c1be9d5657fc75a0fa1efade46f047aa01", - "0x11ea20a8fb14ed8b5ba47e83935f4dc1c032be3a3a9895a65fabed6e1adbef5c", - "0xd108801a4cfa732a19995a6f930ccdda98e91ce393f55eae7f63781568b44c74", - "0x423b7a7716ba307d27c05a6bbfde03b35c9544dffcf6702f69a205cff40a51da", - "0xed832ce8f80ed861bd13b1104490724dd38ab1c9ff18fd8e02ad13eb287af68f", - "0x6eca57794d8d55ec934427971898952017d87bd2773b64c554629f32f55fc7dc", - "0xc7abf795f5ebe46e9f86ba72d58f38ef535475cc41a11913fa1ec51cf902ee1a", - "0xbffebb2a3584cb6f96af4f8da6f5eea2e64066f0caa4bc6f44abb69b621a2b79", - "0x04de39dc7a9f11eba923271d07b5fda4f6b38012858a9a5a9d8f6557706981bd", - "0xef5e2f249fce6c67f5483b52e87384c6a6f6b5f8f102ecfede50cc9f8dfa78af", - "0x34e1511b36260dd619fcb205311055b87d31bb6440c9fb2a8b272bc1dcb1d699", - "0x0640b605ee9f8d8b38118c8dd1f51ca30f3b3f9037c29e598f39b91326825c46", - "0xfe7de1151f56cc10894b6bd63fc995a741c54d9069ee97247cb28627a4838da8", - "0xf17bb6827fe8873b839ecefe872776f757ca087dd65c2c2882523b71dcd24f05", - "0x7a11106b01c8d98348739c89007dddca673f18e9c38ef2d953315a1a49b23ce0", - "0xa7f0a37834fab9ce2cfbe364ccc4c50c88d48a061f0901889cc4fdc6b088a3ea", - "0xb386fae6a43e096a3d66147212a4fc756f7ed921febb2404f1d060111e4521e8", - "0x98484766860a98231a6834276f1ca84c8cf381e4931d635268b9b7d9db976958", - "0xd5007290e81283abd144a619da55be689e7b3eeb8a8b79f0de5e1f2793b056fe", - "0xac6812ede94056979e789ac4bd7dc5e4e682ea93aaaa1aadb22645ec44e21772", - "0xdc0662d88af437d468ed541ee9088464770bbd149a5ce5b3cdd9e836888c5b9d", - "0x6c8e78ff6214e87c5a791423385e31659921f3bb09376b302dd3933f98f346b4" + "0x9bf33ea6cfe12efaafd7e8c39f030fcf9a294338f4f85ab9bea9e0f7d50bc32f", + "0xde4bb64f2d77a738526b49da2ff115d39498461c74c295433558039877ac2d17", + "0x9dbf35bf3c0653bb6a4c25fecb15a16e1cdc2e318c534a9ca0dcb2bf396427e6", + "0x7023677d8803e2eb68a11fceb3fe06e1c9f704b340cda8b6ba829a1bf42425f8", + "0x1b28d2f9cf5a18c31dfa93c3fe0042c2652b5a1f532535b591f1f46155bd7fdf", + "0x305defaee4af6d21ee04d36c0e5e1f6b9cd05f4f3761393af704c6b2302f962f", + "0xe1976447877a353e950ff704d27e3819a3c83a252128fb8b00ad12ad2268a3ea", + "0x76b205c871cb993f134f0a71d62166fae1e17f902dbfd1874146464d30f705c5", + "0x0da6c790a7dcba50fcd3065463fd100921b5eb45bf2a115feb69a0027b0575a0", + "0xedcfd37cd7b1cb47a95574d420b8ba7fcb6f0719339919426c058c363d7a82c3", + "0xdf138331227fe9331be65754c9e78f9cd6355021c2c39830008ca99f9ad9fa51", + "0xbb324ac311b45570f071a1025598094471acd040afa997b0febdf1d270587e60", + "0xc4e2f9a028a6ab036f08d5dd9faf4adff33d9df9aeeaab1cc4a994c5980e64de", + "0x9c66b38488cd910faeb6956dbffe07364d3214df1f197307905fd6b51c704dbf", + "0x9bbe35bf31fbbe33efe56bab6f2f9983f5aeb78beb10ee72e930a53ed93cd32a", + "0xb6b8252b74d126118c5e1c5cdcf72125f93203f3d7d98573e439162365d970e5", + "0xb7519519e3090159017f6d9ada4226bde4400cd540ce3fdfe0b3050d3a50034d", + "0x0d779faf3e0814adc865884198c1affe7b475e9a2e116b9bb9e54effc8d3f89d", + "0x50a5ca3301fb7eb6071192a6593422c9be85e525438b903ee3b37d2ad7102e99", + "0x0c941e595ceca914199728e27b8c66e2b56aabb3788b17fa5a341f2963a0419d", + "0x63454e70b449128baf4cd352d30d21f2b53da6b84a9bbf4d2291547eaf400aa0", + "0x58eb7a2732fbebe3e3a50323254b92a610c82b7d83549b8ac0b9c78321c93c1f", + "0x3537b22dabb78bf1a77e2765838fe68a0bd554a659885c545f115f86fec5bde7", + "0xcfcfe2daea4047a0644aa077fbcfb44017f7f4340ac56626ae137c477f5e2f2b", + "0xd60147111840b926cb70052d953d996ddbf1bf0f911d715724e8044630f9995e", + "0xa095314f08aac6544e153549534f31eabcf676cd0a4b9633838fb16d837728f9", + "0x89a6a3d6bef7559f4837a935f9c15bcae7f3621620ffe8a1bab702275f56c1a7", + "0x9eaacd532d30b70e2e3a2de4c6b7a11fb31f3558b4959fc0035e1f8b4b252209", + "0xc8ea22cd2147f66c3b4dc8b6c442e92ae6cdb2f2f4563066a24f498e2d03581c", + "0x6f1363941f0589e43d1a8c3038a2aaf2fecd68b5a331341997ede48702a0a6be", + "0xf3329f3e0ad4e08f59040d1b5cd23d50e19b632bd330ed820152b590f21731dd", + "0xf9bc64ab44ee3a8aa8960429dd2d994cf74eac09b2610fc26d4f0f219ab7a4e0" ], "origin_token_address": "0x7a6fC3e8b57c6D1924F1A9d0E2b3c4D5e6F70891", "roots": [ - "0xacd6f8510c036081e605dd2c8749d2b7d3b289913514d10af9538cb4b32b7ded", - "0x2d7b622637d38f862a074a0160bc1e54ad7df147ff3374af82777b37021b22e1", - "0xf9bdf29ab9c4cbd2927b759b9f8ddafa90317bdb91f388b8eee08038ff5ded00", - "0x80134ca84d0d742662f3ec22543f4cf33f02dc0b628f51d1df1c521ef3018395", - "0x21d6f3b63306929d624f01ffdbe216acb822bf080bcf04b7e6021db957e7bee4", - "0x7932d55a970d094161976d0b562805779d55a81b08a501983c2b121a0c989a1e", - "0x43f09c6c8a277ee6fbc0e3f8261ba4570f32d1cbfff06bf662aa8e5feeb742bc", - "0x9ae3a76a5c7fcc2af6e3cb937b7e1a4ba397a46029987b06fec29257ba408564", - "0x007e432139766ea419be4aeda41a59e20114c0b772b61e43b3a344fa1c4e1196", - "0xdf60f37334585bc10d67b107b417a14181158ac9828f56a9337684a81e7405d9", - "0xba49ac55a723278ef6cd8f12193a405bc90cd2b6e88f8791f8d48d69fe952104", - "0x4ab8529bce44bcfb8c8e90c9adebebca9e51f44b0e8a048d99bf7717cb58eae7", - "0xf9313f060db170a5287bcc78443267e893f638731dd48a9131b120f9c5833f88", - "0x49a9e6e504f2a6938bbefba42ec2b4930eed298a04eac403af1e0a6286017960", - "0xe318ce76597523c02da0094bcfd970e88c9544c6393d9bfe17d96e2a17f4856d", - "0x00d4099acc3d2a2cdd76f693fb527b218f369bc8e92af4a39328809738497a9d", - "0xf4db3da65c8fda88ad4a1ad1aca66e9260d5230a962791b57d396948a78fe96e", - "0x6813db5a7b4ac98c11d84412df7d6552941d30c7adb95e7025b13d747cf0f3f7", - "0xf1e93cbb96e5fabaee7cbb44f87f44832c9c290a5f85631d8c86493bab6ba0d5", - "0x654a2e78a6e49c969a0fedad0e4372862950ca371406c122779cf62e16dfe7e7", - "0x1a07ce13254cfb6697256a401063d6c43e5a89b8b1945c90bce62c464da1ba27", - "0xedaf2d835d1e6fdd801555835b2cadcd04517f8668f30658019869d0376c6c36", - "0x82adda5fd38a4718f37b2d4fe9fe99b364cced5de9bdfa4c6bdcd118da42c64c", - "0x2d28e62dd13f99153b5e9eb4d68cc1f99a5bd510375f2d1ed522c0062a2d38d7", - "0xd87e80ebe2f69df6735911707780df6b882189db786b5507310249a26d3db69d", - "0x5406d2fbc12edcccd2b8c755b7063ababc760ce23da62032d500a10d49756994", - "0xce99e7d0f9d77226cae034297dfec349d866f892eb753a8c7f5bba4bec52364c", - "0x4419d0e6c47cac3e4fc917f91d878582ed4496bef8e7df219be4d483e496ff0a", - "0xafe2c2b44e58c34576299a201d4918f47d5a48b6fa7a229eaf59e226120b12ac", - "0x9d2989190f9edb660b043a55f3051412280dd7bb7d4d042e3695d3a2b23f5b8d", - "0x18b772e2e093d5f69151c3b6da00d42a2066d1f5980e5f9210ae902f5a5643ca", - "0x6717e563a6c40e1562235c4cbbc2ba0de5be6be07101715e8d3922361b77d394" + "0x348d355f3bb18e1068bff079f4db9efe55e8e04b03b16f5cd0697783223dea24", + "0xc3790c33c937baeaa9ea34cab14e9d1cd09909f7f6f03ffd5ef19f6e56fc30e5", + "0x1bca61b8118b434fdd28aa44621856b6f468da76e7c00150f653a44afa614951", + "0x14244f6a8c2321cc5d76abd645febe5671cc5d295e36e331b7d5b95f00087bc7", + "0xbb2678ed04dd46dfeefa9eedd76ef81a8fab0cb6f3fcad1cbd425c0c0f072c4c", + "0x898ed626325f2e3059a9d4d0106b2a6af28cbc6186001f68bc48cbb6d9e23a92", + "0x48b0c5f26d41952538ed475b4ce9d48ddaf3aa4a30f248ee69aa8e7a3f5fc7a9", + "0x09ee99cb08667e89ec74f23d460718e134725030c5ce8f8e32a0e14cf6d2dab3", + "0x9ba58980043e3899f438abda7a8e4ccde3be420782df74d59a7be7d21ca9cb45", + "0xb1cf5456f6db1ef3cf0ec935c7b42cb02a5367606927c963214ae4521dc2933d", + "0x29f0d5198abc10813b3d1229485540ad85ed800b42bd26b30c9b55de2bebc2fc", + "0x30a781f2b93fc104bdfb813427f1e0202011f7b9d975b1a8e425bf66488fc881", + "0x0df8398f85b8bb8120f5f866b4151adf303269494d231c43b7ac4f758d940c8b", + "0x023e54747d66e5c2246e4b08b14d079b349f16f8407b8d2e541da619a883547f", + "0xe772d97a022693935b0e6d59bb4f1b610b507d161a6d419a4a0840f36dc0b078", + "0x89f47e81978d4664522e744a261cf583cfd041ac37d06cc4e9c3ea745e854211", + "0x0382f69ca68b60ac179fde3af6c81d7d3c7aeb46afeda583853bc51ade2b3938", + "0xc77ce49f5d8602f2750266494030ff693b562193ae14b9ce2fbcbf0ebfa993b5", + "0x0cb3258f37bb2a459139ed1504164519c142e38c1d421fc48f701f48fb0b9603", + "0x7393d0f0d3bc7d56ee2e68faaaa407f93ea825af8ba5f67cbdbf61027120f9c9", + "0x617d35aae99d7dd5553b1f025181c81686aa2f9fa7a90c75eef1694a72b5616a", + "0x580c429511a69b1940fb5f4cdaafc92f7fbc6188b4251439a9244d9641c1d139", + "0x9faf9d943a47e258c2fb72d4576d0efb3f2f7752c5ff6bd7a4f2fc78d51f8e95", + "0x5dbf226e0acbef41d0ab33816425d6bf14d0b1a6b6b5a9bdc0cc6811bfb7c2e7", + "0x0b8bbed0704953abdea570105b2097f62508369c3752d502f75a5551a6f44ebe", + "0x4e19b57f603366b0cfb38e340a57f72e5531b31c3be93fe6659d422275aad5fc", + "0xd9f8952b94f1e80ebe7418ecc733565328ffd8a30ab21a06439ad2c79b9db6d0", + "0x089ada6a37011a8884decf8742411dcaac78197dca25db4dc619824f9d17a054", + "0xe66898c7fe61cf5442b455984af9f4a8e4d30a2ba4e40da714ff8943bd58c2ac", + "0x2ca6791958d5ae135e33ceccabc442f5870fb2fa02c560221a6ba16cfdce4ecd", + "0xbdfd5c17df4654c7fbe63080495133b60a9f181762f40a9986604007adbfdd82", + "0xe7890140043bca797d561323bcf42261583f659aa1087738dec3fe6b67ee42ff" ] } \ No newline at end of file diff --git a/crates/miden-agglayer/solidity-compat/test/MMRTestVectors.t.sol b/crates/miden-agglayer/solidity-compat/test/MMRTestVectors.t.sol index b3b090b471..7692d92623 100644 --- a/crates/miden-agglayer/solidity-compat/test/MMRTestVectors.t.sol +++ b/crates/miden-agglayer/solidity-compat/test/MMRTestVectors.t.sol @@ -28,7 +28,7 @@ contract MMRTestVectors is Test, DepositContractV2 { // Fixed seed for deterministic "random" destination vectors. // Keeping this constant ensures everyone regenerates the exact same JSON vectors. - uint256 constant VECTOR_SEED = uint256(keccak256("miden::agglayer::mmr_frontier_vectors::v2")); + uint256 constant VECTOR_SEED = uint256(keccak256("agglayer::mmr_frontier_vectors::v2")); /** * @notice Builds a leaf hash identical to what bridge_out.masm would produce for the diff --git a/crates/miden-agglayer/src/bridge.rs b/crates/miden-agglayer/src/bridge.rs index 8fbbeff0de..6e67cfd9d1 100644 --- a/crates/miden-agglayer/src/bridge.rs +++ b/crates/miden-agglayer/src/bridge.rs @@ -38,57 +38,69 @@ include!(concat!(env!("OUT_DIR"), "/agglayer_constants.rs")); // AGGLAYER BRIDGE STRUCT // ================================================================================================ +// bridge config +// ------------------------------------------------------------------------------------------------ + +static BRIDGE_ADMIN_ID_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::admin_account_id") + .expect("bridge admin account ID storage slot name should be valid") +}); +static GER_MANAGER_ID_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::ger_manager_account_id") + .expect("GER manager account ID storage slot name should be valid") +}); static GER_MAP_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::ger") - .expect("GER storage slot name should be valid") + StorageSlotName::new("agglayer::bridge::ger_map") + .expect("GER map storage slot name should be valid") +}); +static FAUCET_REGISTRY_MAP_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::faucet_registry_map") + .expect("faucet registry map storage slot name should be valid") +}); +static TOKEN_REGISTRY_MAP_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::token_registry_map") + .expect("token registry map storage slot name should be valid") +}); + +// bridge in +// ------------------------------------------------------------------------------------------------ + +static CLAIM_NULLIFIERS_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::claim_nullifiers") + .expect("claim nullifiers storage slot name should be valid") }); +static CGI_CHAIN_HASH_LO_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::cgi_chain_hash_lo") + .expect("CGI chain hash_lo storage slot name should be valid") +}); +static CGI_CHAIN_HASH_HI_SLOT_NAME: LazyLock = LazyLock::new(|| { + StorageSlotName::new("agglayer::bridge::cgi_chain_hash_hi") + .expect("CGI chain hash_hi storage slot name should be valid") +}); + +// bridge out +// ------------------------------------------------------------------------------------------------ + static LET_FRONTIER_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let").expect("LET storage slot name should be valid") + StorageSlotName::new("agglayer::bridge::let_frontier") + .expect("LET frontier storage slot name should be valid") }); static LET_ROOT_LO_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::root_lo") + StorageSlotName::new("agglayer::bridge::let_root_lo") .expect("LET root_lo storage slot name should be valid") }); static LET_ROOT_HI_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::root_hi") + StorageSlotName::new("agglayer::bridge::let_root_hi") .expect("LET root_hi storage slot name should be valid") }); static LET_NUM_LEAVES_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::let::num_leaves") + StorageSlotName::new("agglayer::bridge::let_num_leaves") .expect("LET num_leaves storage slot name should be valid") }); -static FAUCET_REGISTRY_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::faucet_registry") - .expect("faucet registry storage slot name should be valid") -}); -static TOKEN_REGISTRY_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::token_registry") - .expect("token registry storage slot name should be valid") -}); -static BRIDGE_ADMIN_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::admin") - .expect("bridge admin storage slot name should be valid") -}); -static GER_MANAGER_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::ger_manager") - .expect("GER manager storage slot name should be valid") -}); -static CGI_CHAIN_HASH_LO_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::cgi_chain_hash_lo") - .expect("CGI chain hash lo storage slot name should be valid") -}); -static CGI_CHAIN_HASH_HI_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::cgi_chain_hash_hi") - .expect("CGI chain hash hi storage slot name should be valid") -}); -static CLAIM_NULLIFIERS_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::bridge::claim_nullifiers") - .expect("claim nullifiers storage slot name should be valid") -}); /// An [`AccountComponent`] implementing the AggLayer Bridge. /// -/// It reexports the procedures from `miden::agglayer::bridge`. When linking against this +/// It reexports the procedures from `agglayer::bridge`. When linking against this /// component, the `agglayer` library must be available to the assembler. /// The procedures of this component are: /// - `register_faucet`, which registers a faucet in the bridge. @@ -99,19 +111,19 @@ static CLAIM_NULLIFIERS_SLOT_NAME: LazyLock = LazyLock::new(|| /// /// ## Storage Layout /// +/// - [`Self::bridge_admin_id_slot_name`]: Stores the bridge admin account ID. +/// - [`Self::ger_manager_id_slot_name`]: Stores the GER manager account ID. /// - [`Self::ger_map_slot_name`]: Stores the GERs. -/// - [`Self::let_frontier_slot_name`]: Stores the Local Exit Tree (LET) frontier. -/// - [`Self::ler_lo_slot_name`]: Stores the lower 32 bits of the LET root. -/// - [`Self::ler_hi_slot_name`]: Stores the upper 32 bits of the LET root. -/// - [`Self::let_num_leaves_slot_name`]: Stores the number of leaves in the LET frontier. -/// - [`Self::faucet_registry_slot_name`]: Stores the faucet registry map. -/// - [`Self::token_registry_slot_name`]: Stores the token address → faucet ID map. -/// - [`Self::bridge_admin_slot_name`]: Stores the bridge admin account ID. -/// - [`Self::ger_manager_slot_name`]: Stores the GER manager account ID. -/// - [`Self::cgi_lo_slot_name`]: Stores the lower 128 bits of the CGI chain hash. -/// - [`Self::cgi_hi_slot_name`]: Stores the upper 128 bits of the CGI chain hash. +/// - [`Self::faucet_registry_map_slot_name`]: Stores the faucet registry map. +/// - [`Self::token_registry_map_slot_name`]: Stores the token address → faucet ID map. /// - [`Self::claim_nullifiers_slot_name`]: Stores the CLAIM note nullifiers map (RPO(leaf_index, /// source_bridge_network) → \[1, 0, 0, 0\]). +/// - [`Self::cgi_chain_hash_lo_slot_name`]: Stores the lower 128 bits of the CGI chain hash. +/// - [`Self::cgi_chain_hash_hi_slot_name`]: Stores the upper 128 bits of the CGI chain hash. +/// - [`Self::let_frontier_slot_name`]: Stores the Local Exit Tree (LET) frontier. +/// - [`Self::let_root_lo_slot_name`]: Stores the lower 32 bits of the LET root. +/// - [`Self::let_root_hi_slot_name`]: Stores the upper 32 bits of the LET root. +/// - [`Self::let_num_leaves_slot_name`]: Stores the number of leaves in the LET frontier. /// /// The bridge starts with an empty faucet registry; faucets are registered at runtime via /// CONFIG_AGG_BRIDGE notes. @@ -138,64 +150,70 @@ impl AggLayerBridge { // PUBLIC ACCESSORS // -------------------------------------------------------------------------------------------- - /// Storage slot name for the GERs map. - pub fn ger_map_slot_name() -> &'static StorageSlotName { - &GER_MAP_SLOT_NAME - } - - /// Storage slot name for the Local Exit Tree (LET) frontier. - pub fn let_frontier_slot_name() -> &'static StorageSlotName { - &LET_FRONTIER_SLOT_NAME - } + // --- bridge config ---- - /// Storage slot name for the lower 32 bits of the LET root. - pub fn ler_lo_slot_name() -> &'static StorageSlotName { - &LET_ROOT_LO_SLOT_NAME + /// Storage slot name for the bridge admin account ID. + pub fn bridge_admin_id_slot_name() -> &'static StorageSlotName { + &BRIDGE_ADMIN_ID_SLOT_NAME } - /// Storage slot name for the upper 32 bits of the LET root. - pub fn ler_hi_slot_name() -> &'static StorageSlotName { - &LET_ROOT_HI_SLOT_NAME + /// Storage slot name for the GER manager account ID. + pub fn ger_manager_id_slot_name() -> &'static StorageSlotName { + &GER_MANAGER_ID_SLOT_NAME } - /// Storage slot name for the number of leaves in the LET frontier. - pub fn let_num_leaves_slot_name() -> &'static StorageSlotName { - &LET_NUM_LEAVES_SLOT_NAME + /// Storage slot name for the GERs map. + pub fn ger_map_slot_name() -> &'static StorageSlotName { + &GER_MAP_SLOT_NAME } /// Storage slot name for the faucet registry map. - pub fn faucet_registry_slot_name() -> &'static StorageSlotName { - &FAUCET_REGISTRY_SLOT_NAME + pub fn faucet_registry_map_slot_name() -> &'static StorageSlotName { + &FAUCET_REGISTRY_MAP_SLOT_NAME } /// Storage slot name for the token registry map. - pub fn token_registry_slot_name() -> &'static StorageSlotName { - &TOKEN_REGISTRY_SLOT_NAME + pub fn token_registry_map_slot_name() -> &'static StorageSlotName { + &TOKEN_REGISTRY_MAP_SLOT_NAME } - /// Storage slot name for the bridge admin account ID. - pub fn bridge_admin_slot_name() -> &'static StorageSlotName { - &BRIDGE_ADMIN_SLOT_NAME - } + // --- bridge in -------- - /// Storage slot name for the GER manager account ID. - pub fn ger_manager_slot_name() -> &'static StorageSlotName { - &GER_MANAGER_SLOT_NAME + /// Storage slot name for the CLAIM note nullifiers map. + pub fn claim_nullifiers_slot_name() -> &'static StorageSlotName { + &CLAIM_NULLIFIERS_SLOT_NAME } /// Storage slot name for the lower 128 bits of the CGI chain hash. - pub fn cgi_lo_slot_name() -> &'static StorageSlotName { + pub fn cgi_chain_hash_lo_slot_name() -> &'static StorageSlotName { &CGI_CHAIN_HASH_LO_SLOT_NAME } /// Storage slot name for the upper 128 bits of the CGI chain hash. - pub fn cgi_hi_slot_name() -> &'static StorageSlotName { + pub fn cgi_chain_hash_hi_slot_name() -> &'static StorageSlotName { &CGI_CHAIN_HASH_HI_SLOT_NAME } - /// Storage slot name for the CLAIM note nullifiers map. - pub fn claim_nullifiers_slot_name() -> &'static StorageSlotName { - &CLAIM_NULLIFIERS_SLOT_NAME + // --- bridge out ------- + + /// Storage slot name for the Local Exit Tree (LET) frontier. + pub fn let_frontier_slot_name() -> &'static StorageSlotName { + &LET_FRONTIER_SLOT_NAME + } + + /// Storage slot name for the lower 32 bits of the LET root. + pub fn let_root_lo_slot_name() -> &'static StorageSlotName { + &LET_ROOT_LO_SLOT_NAME + } + + /// Storage slot name for the upper 32 bits of the LET root. + pub fn let_root_hi_slot_name() -> &'static StorageSlotName { + &LET_ROOT_HI_SLOT_NAME + } + + /// Storage slot name for the number of leaves in the LET frontier. + pub fn let_num_leaves_slot_name() -> &'static StorageSlotName { + &LET_NUM_LEAVES_SLOT_NAME } /// Returns a boolean indicating whether the provided GER is present in storage of the provided @@ -242,8 +260,8 @@ impl AggLayerBridge { /// Reads the Local Exit Root (double-word) from the bridge account's storage. /// /// The Local Exit Root is stored in two dedicated value slots: - /// - [`AggLayerBridge::ler_lo_slot_name`] — low word of the root - /// - [`AggLayerBridge::ler_hi_slot_name`] — high word of the root + /// - [`AggLayerBridge::let_root_lo_slot_name`] — low word of the root + /// - [`AggLayerBridge::let_root_hi_slot_name`] — high word of the root /// /// Returns the 256-bit root as 8 `Felt`s: first the 4 elements of `root_lo` (in /// reverse of their storage order), followed by the 4 elements of `root_hi` (also in @@ -258,8 +276,8 @@ impl AggLayerBridge { // check that the provided account is a bridge account Self::assert_bridge_account(account)?; - let root_lo_slot = AggLayerBridge::ler_lo_slot_name(); - let root_hi_slot = AggLayerBridge::ler_hi_slot_name(); + let root_lo_slot = AggLayerBridge::let_root_lo_slot_name(); + let root_hi_slot = AggLayerBridge::let_root_hi_slot_name(); let root_lo = account .storage() @@ -301,11 +319,11 @@ impl AggLayerBridge { let cgi_chain_hash_lo = bridge_account .storage() - .get_item(AggLayerBridge::cgi_lo_slot_name()) + .get_item(AggLayerBridge::cgi_chain_hash_lo_slot_name()) .expect("failed to get CGI hash chain lo slot"); let cgi_chain_hash_hi = bridge_account .storage() - .get_item(AggLayerBridge::cgi_hi_slot_name()) + .get_item(AggLayerBridge::cgi_chain_hash_hi_slot_name()) .expect("failed to get CGI hash chain hi slot"); let cgi_chain_hash_bytes = cgi_chain_hash_lo @@ -393,10 +411,10 @@ impl AggLayerBridge { &*LET_ROOT_LO_SLOT_NAME, &*LET_ROOT_HI_SLOT_NAME, &*LET_NUM_LEAVES_SLOT_NAME, - &*FAUCET_REGISTRY_SLOT_NAME, - &*TOKEN_REGISTRY_SLOT_NAME, - &*BRIDGE_ADMIN_SLOT_NAME, - &*GER_MANAGER_SLOT_NAME, + &*FAUCET_REGISTRY_MAP_SLOT_NAME, + &*TOKEN_REGISTRY_MAP_SLOT_NAME, + &*BRIDGE_ADMIN_ID_SLOT_NAME, + &*GER_MANAGER_ID_SLOT_NAME, &*CGI_CHAIN_HASH_LO_SLOT_NAME, &*CGI_CHAIN_HASH_HI_SLOT_NAME, &*CLAIM_NULLIFIERS_SLOT_NAME, @@ -425,10 +443,10 @@ impl From for AccountComponent { StorageSlot::with_value(LET_ROOT_LO_SLOT_NAME.clone(), Word::empty()), StorageSlot::with_value(LET_ROOT_HI_SLOT_NAME.clone(), Word::empty()), StorageSlot::with_value(LET_NUM_LEAVES_SLOT_NAME.clone(), Word::empty()), - StorageSlot::with_empty_map(FAUCET_REGISTRY_SLOT_NAME.clone()), - StorageSlot::with_empty_map(TOKEN_REGISTRY_SLOT_NAME.clone()), - StorageSlot::with_value(BRIDGE_ADMIN_SLOT_NAME.clone(), bridge_admin_word), - StorageSlot::with_value(GER_MANAGER_SLOT_NAME.clone(), ger_manager_word), + StorageSlot::with_empty_map(FAUCET_REGISTRY_MAP_SLOT_NAME.clone()), + StorageSlot::with_empty_map(TOKEN_REGISTRY_MAP_SLOT_NAME.clone()), + StorageSlot::with_value(BRIDGE_ADMIN_ID_SLOT_NAME.clone(), bridge_admin_word), + StorageSlot::with_value(GER_MANAGER_ID_SLOT_NAME.clone(), ger_manager_word), StorageSlot::with_value(CGI_CHAIN_HASH_LO_SLOT_NAME.clone(), Word::empty()), StorageSlot::with_value(CGI_CHAIN_HASH_HI_SLOT_NAME.clone(), Word::empty()), StorageSlot::with_empty_map(CLAIM_NULLIFIERS_SLOT_NAME.clone()), diff --git a/crates/miden-agglayer/src/faucet.rs b/crates/miden-agglayer/src/faucet.rs index 7c6f7e1d58..68cd992299 100644 --- a/crates/miden-agglayer/src/faucet.rs +++ b/crates/miden-agglayer/src/faucet.rs @@ -48,11 +48,11 @@ include!(concat!(env!("OUT_DIR"), "/agglayer_constants.rs")); // ================================================================================================ static CONVERSION_INFO_1_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::faucet::conversion_info_1") + StorageSlotName::new("agglayer::faucet::conversion_info_1") .expect("conversion info 1 storage slot name should be valid") }); static CONVERSION_INFO_2_SLOT_NAME: LazyLock = LazyLock::new(|| { - StorageSlotName::new("miden::agglayer::faucet::conversion_info_2") + StorageSlotName::new("agglayer::faucet::conversion_info_2") .expect("conversion info 2 storage slot name should be valid") }); static OWNER_CONFIG_SLOT_NAME: LazyLock = LazyLock::new(|| { @@ -62,7 +62,7 @@ static OWNER_CONFIG_SLOT_NAME: LazyLock = LazyLock::new(|| { /// An [`AccountComponent`] implementing the AggLayer Faucet. /// -/// It reexports the procedures from `miden::agglayer::faucet`. When linking against this +/// It reexports the procedures from `agglayer::faucet`. When linking against this /// component, the `agglayer` library must be available to the assembler. /// The procedures of this component are: /// - `distribute`, which mints assets and creates output notes (with owner verification). @@ -393,9 +393,9 @@ pub fn faucet_registry_key(faucet_id: AccountId) -> Word { /// Builds the two storage slot values for faucet conversion metadata. /// /// The conversion metadata is stored in two value storage slots: -/// - Slot 1 (`miden::agglayer::faucet::conversion_info_1`): `[addr0, addr1, addr2, addr3]` — first -/// 4 felts of the origin token address (5 × u32 limbs). -/// - Slot 2 (`miden::agglayer::faucet::conversion_info_2`): `[addr4, origin_network, scale, 0]` — +/// - Slot 1 (`agglayer::faucet::conversion_info_1`): `[addr0, addr1, addr2, addr3]` — first 4 felts +/// of the origin token address (5 × u32 limbs). +/// - Slot 2 (`agglayer::faucet::conversion_info_2`): `[addr4, origin_network, scale, 0]` — /// remaining address felt + origin network + scale factor. /// /// # Parameters diff --git a/crates/miden-testing/tests/agglayer/asset_conversion.rs b/crates/miden-testing/tests/agglayer/asset_conversion.rs index be3cbb2b3b..284b04b2a3 100644 --- a/crates/miden-testing/tests/agglayer/asset_conversion.rs +++ b/crates/miden-testing/tests/agglayer/asset_conversion.rs @@ -31,7 +31,7 @@ async fn test_scale_up_helper( let script_code = format!( " use miden::core::sys - use miden::agglayer::common::asset_conversion + use agglayer::common::asset_conversion begin push.{}.{} @@ -103,7 +103,7 @@ async fn test_scale_up_exceeds_max_scale() { // scale_exp = 19 should fail let script_code = " use miden::core::sys - use miden::agglayer::common::asset_conversion + use agglayer::common::asset_conversion begin push.19.1 @@ -125,7 +125,7 @@ fn build_scale_down_script(x: EthAmount, scale_exp: u32, y: u64) -> String { format!( r#" use miden::core::sys - use miden::agglayer::common::asset_conversion + use agglayer::common::asset_conversion begin push.{}.{}.{}.{}.{}.{}.{}.{}.{}.{} @@ -315,7 +315,7 @@ async fn test_verify_scale_down_inline() -> anyhow::Result<()> { let script_code = format!( r#" use miden::core::sys - use miden::agglayer::common::asset_conversion + use agglayer::common::asset_conversion begin # Push expected quotient y used for verification (not returned as an output) diff --git a/crates/miden-testing/tests/agglayer/bridge_in.rs b/crates/miden-testing/tests/agglayer/bridge_in.rs index a2d9dbf0b0..0b84670a25 100644 --- a/crates/miden-testing/tests/agglayer/bridge_in.rs +++ b/crates/miden-testing/tests/agglayer/bridge_in.rs @@ -72,7 +72,7 @@ fn merkle_proof_verification_code( format!( r#" - use miden::agglayer::bridge::bridge_in + use agglayer::bridge::bridge_in use miden::core::word begin diff --git a/crates/miden-testing/tests/agglayer/config_bridge.rs b/crates/miden-testing/tests/agglayer/config_bridge.rs index 3fc9311ba5..2dffb611ba 100644 --- a/crates/miden-testing/tests/agglayer/config_bridge.rs +++ b/crates/miden-testing/tests/agglayer/config_bridge.rs @@ -51,7 +51,7 @@ async fn test_config_agg_bridge_registers_faucet() -> anyhow::Result<()> { ); // Verify the faucet is NOT in the registry before registration - let registry_slot_name = AggLayerBridge::faucet_registry_slot_name(); + let registry_slot_name = AggLayerBridge::faucet_registry_map_slot_name(); let key = faucet_registry_key(faucet_to_register); let value_before = bridge_account.storage().get_map_item(registry_slot_name, key)?; assert_eq!( diff --git a/crates/miden-testing/tests/agglayer/global_index.rs b/crates/miden-testing/tests/agglayer/global_index.rs index 4985d71b31..a79b09895f 100644 --- a/crates/miden-testing/tests/agglayer/global_index.rs +++ b/crates/miden-testing/tests/agglayer/global_index.rs @@ -24,7 +24,7 @@ fn assemble_process_global_index_program(global_index: GlobalIndex, proc_name: & let script_code = format!( r#" use miden::core::sys - use miden::agglayer::bridge::bridge_in + use agglayer::bridge::bridge_in begin push.{g7}.{g6}.{g5}.{g4}.{g3}.{g2}.{g1}.{g0} diff --git a/crates/miden-testing/tests/agglayer/leaf_utils.rs b/crates/miden-testing/tests/agglayer/leaf_utils.rs index a48e31565f..234d4a0190 100644 --- a/crates/miden-testing/tests/agglayer/leaf_utils.rs +++ b/crates/miden-testing/tests/agglayer/leaf_utils.rs @@ -103,7 +103,7 @@ async fn pack_leaf_data() -> anyhow::Result<()> { let source = format!( r#" use miden::core::mem - use miden::agglayer::bridge::leaf_utils + use agglayer::bridge::leaf_utils const LEAF_DATA_START_PTR = 0 const CLAIM_LEAF_DATA_WORD_LEN = 8 @@ -169,7 +169,7 @@ async fn get_leaf_value() -> anyhow::Result<()> { let source = format!( r#" use miden::core::sys - use miden::agglayer::bridge::bridge_in + use agglayer::bridge::bridge_in begin push.{key} diff --git a/crates/miden-testing/tests/agglayer/mmr_frontier.rs b/crates/miden-testing/tests/agglayer/mmr_frontier.rs index 083719ced2..4f3fe9f864 100644 --- a/crates/miden-testing/tests/agglayer/mmr_frontier.rs +++ b/crates/miden-testing/tests/agglayer/mmr_frontier.rs @@ -73,7 +73,7 @@ impl KeccakMmrFrontier32 { async fn test_append_and_update_frontier() -> anyhow::Result<()> { let mut mmr_frontier = KeccakMmrFrontier32::<32>::new(); - let mut source = "use miden::agglayer::bridge::mmr_frontier32_keccak \ + let mut source = "use agglayer::bridge::mmr_frontier32_keccak \ use miden::core::word begin" .to_string(); @@ -111,7 +111,7 @@ async fn test_check_empty_mmr_root() -> anyhow::Result<()> { let zero_31 = *CANONICAL_ZEROS_32.get(31).expect("zeros should have 32 values total"); let empty_mmr_root = Keccak256::merge(&[zero_31, zero_31]); - let mut source = "use miden::agglayer::bridge::mmr_frontier32_keccak \ + let mut source = "use agglayer::bridge::mmr_frontier32_keccak \ use miden::core::word begin" .to_string(); diff --git a/crates/miden-testing/tests/agglayer/solidity_miden_address_conversion.rs b/crates/miden-testing/tests/agglayer/solidity_miden_address_conversion.rs index f9290a6273..4382211389 100644 --- a/crates/miden-testing/tests/agglayer/solidity_miden_address_conversion.rs +++ b/crates/miden-testing/tests/agglayer/solidity_miden_address_conversion.rs @@ -133,7 +133,7 @@ async fn test_ethereum_address_to_account_id_in_masm() -> anyhow::Result<()> { let script_code = format!( r#" use miden::core::sys - use miden::agglayer::common::eth_address + use agglayer::common::eth_address begin push.{}.{}.{}.{}.{} diff --git a/crates/miden-testing/tests/agglayer/update_ger.rs b/crates/miden-testing/tests/agglayer/update_ger.rs index 1d2f560d51..ec791b6ffe 100644 --- a/crates/miden-testing/tests/agglayer/update_ger.rs +++ b/crates/miden-testing/tests/agglayer/update_ger.rs @@ -151,7 +151,7 @@ async fn compute_ger() -> anyhow::Result<()> { let source = format!( r#" use miden::core::sys - use miden::agglayer::bridge::bridge_in + use agglayer::bridge::bridge_in begin # Initialize memory with exit roots @@ -234,7 +234,7 @@ async fn test_compute_ger_basic() -> anyhow::Result<()> { let source = format!( r#" use miden::core::sys - use miden::agglayer::bridge::bridge_in + use agglayer::bridge::bridge_in begin # Initialize memory with exit roots