Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/miden-agglayer/asm/agglayer/faucet/mod.masm
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

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

as per the docs, we should follow:

project_name::component_name::slot_name

Here, I would make two modifications:

  • drop miden altogether (from all agglayer storage slots)
  • use bridge or faucet depending on which component this belongs to (e.g. particular one belongs to the faucet, but describes the bridge account ID. So overall I'd keep it as agglayer::faucet::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
Expand Down
27 changes: 14 additions & 13 deletions crates/miden-agglayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,22 @@ fn bridge_component(storage_slots: Vec<StorageSlot>) -> AccountComponent {

static GER_MAP_SLOT_NAME: LazyLock<StorageSlotName> = 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<StorageSlotName> = 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<StorageSlotName> = 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<StorageSlotName> = 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<StorageSlotName> = 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<StorageSlotName> = LazyLock::new(|| {
Expand Down Expand Up @@ -269,9 +270,9 @@ fn agglayer_faucet_component(storage_slots: Vec<StorageSlot>) -> 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
Expand Down Expand Up @@ -299,16 +300,16 @@ fn agglayer_faucet_conversion_slots(
// AGGLAYER FAUCET STRUCT
// ================================================================================================

static AGGLAYER_FAUCET_SLOT_NAME: LazyLock<StorageSlotName> = LazyLock::new(|| {
StorageSlotName::new("miden::agglayer::faucet")
static AGGLAYER_BRIDGE_ID_SLOT_NAME: LazyLock<StorageSlotName> = LazyLock::new(|| {
StorageSlotName::new("miden::agglayer::bridge::id")
.expect("agglayer faucet storage slot name should be valid")
});
static CONVERSION_INFO_1_SLOT_NAME: LazyLock<StorageSlotName> = 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<StorageSlotName> = 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")
});

Expand Down Expand Up @@ -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.
Expand All @@ -407,7 +408,7 @@ impl From<AggLayerFaucet> 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,
Expand Down
Loading