Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

### Changes

- [BREAKING] Renamed `MMR Frontier` to `Merkle Tree Frontier (MTF)`, module was renamed from `mmr_frontier32_keccak` to `merkle_tree_frontier` ([#2642](https://github.com/0xMiden/protocol/pull/2642)).
- [BREAKING] Separated `EthAddress` (plain 20-byte Ethereum address) and `EthEmbeddedAccountId` (Miden AccountId encoded as Ethereum address) into distinct types, replacing the single `EthAddressFormat` struct. ([#2622](https://github.com/0xMiden/protocol/pull/2622)).
- Migrated to miden-vm v0.22 and miden-crypto v0.23 ([#2644](https://github.com/0xMiden/protocol/pull/2644)).
- [BREAKING] Renamed `AccountComponent::get_procedures()` to `procedures()`, returning `impl Iterator<Item = (AccountProcedureRoot, bool)>` ([#2597](https://github.com/0xMiden/protocol/pull/2597)).
- [BREAKING] Removed `NoteAssets::add_asset`; `OutputNoteBuilder` now accumulates assets in a `Vec` and computes the commitment only when `build()` is called, avoiding rehashing on every asset addition. ([#2577](https://github.com/0xMiden/protocol/pull/2577))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ build-no-std-testing: ## Build without the standard library. Includes the `testi
# --- test vectors --------------------------------------------------------------------------------

.PHONY: generate-solidity-test-vectors
generate-solidity-test-vectors: ## Regenerate Solidity MMR test vectors using Foundry
generate-solidity-test-vectors: ## Regenerate Solidity test vectors using Foundry
cd crates/miden-agglayer/solidity-compat && forge test -vv --match-test test_generateVectors
cd crates/miden-agglayer/solidity-compat && forge test -vv --match-test test_generateCanonicalZeros
cd crates/miden-agglayer/solidity-compat && forge test -vv --match-test test_generateVerificationProofData
Expand Down
347 changes: 280 additions & 67 deletions crates/miden-agglayer/SPEC.md

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ pub proc claim
exec.claim_batch_pipe_double_words
# => [pad(16)]

exec.get_destination_account_id_data
exec.load_destination_address
exec.eth_address::to_account_id
loc_store.CLAIM_DEST_ID_SUFFIX_LOCAL loc_store.CLAIM_DEST_ID_PREFIX_LOCAL
# => [pad(16)]

Expand All @@ -215,7 +216,7 @@ pub proc claim
# => [pad(16)]

# Look up the faucet account ID from the origin token address
exec.get_origin_token_address
exec.load_origin_token_address
# => [origin_token_addr(5), pad(16)]

exec.bridge_config::lookup_faucet_by_token_address
Expand Down Expand Up @@ -458,7 +459,7 @@ proc verify_claim_amount
# => [scale]

# Step 3: Load the raw U256 amount from leaf data memory
exec.get_raw_claim_amount
exec.load_raw_claim_amount
# => [x7, x6, x5, x4, x3, x2, x1, x0, scale]

# Step 4: Load faucet_mint_amount (y) and position it for verification
Expand Down Expand Up @@ -728,28 +729,24 @@ end

#! Extracts the destination account ID as address[5] from memory.
#!
#! This procedure reads the destination address from the leaf data and converts it from
#! Ethereum address format to AccountId format (suffix, prefix).
#! Reads the destination address (5 felts) from the leaf data in memory.
#!
#! Inputs: []
#! Outputs: [suffix, prefix]
#! Outputs: [address[5]]
#!
#! Invocation: exec
proc get_destination_account_id_data
proc load_destination_address
mem_load.DESTINATION_ADDRESS_4
mem_load.DESTINATION_ADDRESS_3
mem_load.DESTINATION_ADDRESS_2
mem_load.DESTINATION_ADDRESS_1
mem_load.DESTINATION_ADDRESS_0
# => [address[5]]

exec.eth_address::to_account_id
# => [suffix, prefix]
end

# Inputs: []
# Outputs: [U256[0], U256[1]]
proc get_raw_claim_amount
proc load_raw_claim_amount
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_7
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_6
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_5
Expand All @@ -766,7 +763,7 @@ end
#! Outputs: [origin_token_addr(5)]
#!
#! Invocation: exec
proc get_origin_token_address
proc load_origin_token_address
mem_load.ORIGIN_TOKEN_ADDRESS_4
mem_load.ORIGIN_TOKEN_ADDRESS_3
mem_load.ORIGIN_TOKEN_ADDRESS_2
Expand Down
10 changes: 5 additions & 5 deletions crates/miden-agglayer/asm/agglayer/bridge/bridge_out.masm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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
use agglayer::bridge::merkle_tree_frontier
use agglayer::common::utils::EthereumAddressFormat

# CONSTANTS
Expand Down Expand Up @@ -90,7 +90,7 @@ const BURN_NOTE_NUM_STORAGE_ITEMS=0
#! 1. Validates the asset's faucet is registered in the bridge's faucet registry
#! 2. Queries the faucet for origin asset conversion data via FPI
#! 3. Builds the leaf data (origin token, destination, amount, metadata)
#! 4. Computes Keccak hash and adds it to the MMR frontier
#! 4. Computes Keccak hash of the leaf data and appends it to the Local Exit Tree
#! 5. Creates a BURN note with the bridged out asset
#!
#! Inputs: [ASSET_KEY, ASSET_VALUE, dest_network_id, dest_address(5), pad(2)]
Expand Down Expand Up @@ -206,7 +206,7 @@ pub proc bridge_out
mem_store
# => [pad(16)]

# --- 4. Compute leaf value and add to MMR frontier ---
# --- 4. Compute leaf value and append it to the Local Exit Tree ---
push.LEAF_DATA_START_PTR
exec.add_leaf_bridge
# => [pad(16)]
Expand Down Expand Up @@ -279,7 +279,7 @@ proc convert_asset
# => [AMOUNT_U256[0](4), AMOUNT_U256[1](4), origin_addr(5), origin_network]
end

#! Computes the leaf value from the leaf data in memory and adds it to the MMR frontier.
#! Computes the leaf value from the leaf data in memory and appends it to the Local Exit Tree.
#!
#! Inputs: [leaf_data_start_ptr]
#! Outputs: []
Expand Down Expand Up @@ -310,7 +310,7 @@ proc add_leaf_bridge(leaf_data_start_ptr: MemoryAddress)
# => [LEAF_VALUE_LO, LEAF_VALUE_HI, let_frontier_ptr]

# Append the leaf to the frontier and compute the new root
exec.mmr_frontier32_keccak::append_and_update_frontier
exec.merkle_tree_frontier::append_and_update_frontier
# => [NEW_ROOT_LO, NEW_ROOT_HI, new_leaf_count]

# Save the root and num_leaves to their value slots
Expand Down
Loading
Loading