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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- [BREAKING] Moved standard note code into individual note modules ([#2363](https://github.com/0xMiden/miden-base/pull/2363)).
- [BREAKING] Added `miden::standards::note_tag` module for account target note tags ([#2366](https://github.com/0xMiden/miden-base/pull/2366)).
- Unified the underlying representation of `ExitRoot` and `SmtNode` and use type aliases ([#2387](https://github.com/0xMiden/miden-base/pull/2387)).
- [BREAKING] Moved padding to the end of `CLAIM` `NoteStorage` layout ([#2405](https://github.com/0xMiden/miden-base/pull/2405)).

### Fixes
- Fixed byte-to-felt conversion for `ExitRoot` and `SmtNode`'s `to_elements()` method ([#2387](https://github.com/0xMiden/miden-base/pull/2387)).
Expand Down
33 changes: 23 additions & 10 deletions crates/miden-agglayer/asm/bridge/agglayer_faucet.masm
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ const CLAIM_NOTE_DATA_MEM_ADDR = 712
const OUTPUT_NOTE_INPUTS_MEM_ADDR = 0
const OUTPUT_NOTE_TAG_MEM_ADDR = 574
const OUTPUT_NOTE_SERIAL_NUM_MEM_ADDR = 568
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0 = 552
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 556

const DESTINATION_ADDRESS_0 = 547
const DESTINATION_ADDRESS_1 = 548
const DESTINATION_ADDRESS_2 = 549
const DESTINATION_ADDRESS_3 = 550
const DESTINATION_ADDRESS_4 = 551
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0 = 549
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 550
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_2 = 551
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_3 = 552
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_4 = 553
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_5 = 554
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_6 = 555
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_7 = 556

const DESTINATION_ADDRESS_0 = 544
const DESTINATION_ADDRESS_1 = 545
const DESTINATION_ADDRESS_2 = 546
const DESTINATION_ADDRESS_3 = 547
const DESTINATION_ADDRESS_4 = 548

# P2ID output note constants
const P2ID_NOTE_NUM_STORAGE_ITEMS = 2
Expand Down Expand Up @@ -86,8 +92,14 @@ end
# Inputs: []
# Outputs: [U256[0], U256[1]]
proc get_raw_claim_amount
padw mem_loadw_be.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0
padw mem_loadw_be.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_2
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_3
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_4
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_5
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_6
mem_load.OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_7
end

# Inputs: [U256[0], U256[1]]
Expand Down Expand Up @@ -220,6 +232,7 @@ end
#! rollupExitRoot[8], // Rollup exit root hash (8 felts, bytes32 as 8 u32 felts)
#! ],
#! LEAF_DATA_KEY => [
#! leafType[1], // Leaf type (1 felt, uint8)
#! originNetwork[1], // Origin network identifier (1 felt, uint32)
#! originTokenAddress[5], // Origin token address (5 felts, address as 5 u32 felts)
#! destinationNetwork[1], // Destination network identifier (1 felt, uint32)
Expand Down
2 changes: 1 addition & 1 deletion crates/miden-agglayer/asm/bridge/bridge_in.masm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end
#! destinationAddress[5], // Destination address (5 felts, address as 5 u32 felts)
#! amount[8], // Amount of tokens (8 felts, uint256 as 8 u32 felts)
#! metadata[8], // ABI encoded metadata (8 felts, fixed size)
#! EMPTY_WORD // padding
#! padding[3], // padding (3 felts) - not used in the hash
#! ],
#! }
#!
Expand Down
2 changes: 2 additions & 0 deletions crates/miden-agglayer/asm/bridge/crypto_utils.masm
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ const CUR_HASH_HI_LOCAL = 4
#! Operand stack: [LEAF_DATA_KEY]
#! Advice map: {
#! LEAF_DATA_KEY => [
#! leafType[1], // Leaf type (1 felt, uint8)
#! originNetwork[1], // Origin network identifier (1 felt, uint32)
#! originTokenAddress[5], // Origin token address (5 felts, address as 5 u32 felts)
#! destinationNetwork[1], // Destination network identifier (1 felt, uint32)
#! destinationAddress[5], // Destination address (5 felts, address as 5 u32 felts)
#! amount[8], // Amount of tokens (8 felts, uint256 as 8 u32 felts)
#! metadata[8], // ABI encoded metadata (8 felts, fixed size)
#! padding[3], // padding (3 felts) - not used in the hash
#! ],
#! }
#! Outputs: [LEAF_VALUE[8]]
Expand Down
16 changes: 8 additions & 8 deletions crates/miden-agglayer/asm/note_scripts/CLAIM.masm
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ end
#!
#! LEAF_DATA_KEY => [
#! leafType[1], // Leaf type (1 felt, uint32)
#! padding[3], // padding (3 felts)
#! originNetwork[1], // Origin network identifier (1 felt, uint32)
#! originTokenAddress[5], // Origin token address (5 felts, address as 5 u32 felts)
#! destinationNetwork[1], // Destination network identifier (1 felt, uint32)
#! destinationAddress[5], // Destination address (5 felts, address as 5 u32 felts)
#! amount[8], // Amount of tokens (8 felts, uint256 as 8 u32 felts)
#! metadata[8], // ABI encoded metadata (8 felts, fixed size)
#! padding[3], // padding (3 felts)
#! ]
#!
#! TODO: Will be removed in future PR
Expand Down Expand Up @@ -154,13 +154,13 @@ end
#! - mainnetExitRoot [520..527]: 8 felts
#! - rollupExitRoot [528..535]: 8 felts
#! - leafType [536] : 1 felt
#! - padding [537..539]: 3 felts
#! - originNetwork [540] : 1 felt
#! - originTokenAddress [541..545]: 5 felts
#! - destinationNetwork [546] : 1 felt
#! - destinationAddress [547..551]: 5 felts
#! - amount [552..559]: 8 felts
#! - metadata [560..567]: 8 felts
#! - originNetwork [537] : 1 felt
#! - originTokenAddress [538..542]: 5 felts
#! - destinationNetwork [543] : 1 felt
#! - destinationAddress [544..548]: 5 felts
#! - amount [549..556]: 8 felts
#! - metadata [557..564]: 8 felts
#! - padding [565..567]: 3 felts
#! - output_p2id_serial_num [568..571]: 4 felts
#! - target_faucet_account_id [572..573]: 2 felts
#! - output_note_tag [574] : 1 felt
Expand Down
8 changes: 4 additions & 4 deletions crates/miden-agglayer/src/claim_note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,14 @@ impl SequentialCommit for LeafData {
type Commitment = Word;

fn to_elements(&self) -> Vec<Felt> {
const LEAF_DATA_ELEMENT_COUNT: usize = 32; // 1 + 3 + 1 + 5 + 1 + 5 + 8 + 8 (leafType + padding + networks + addresses + amount + metadata)
const LEAF_DATA_ELEMENT_COUNT: usize = 32; // 1 + 1 + 5 + 1 + 5 + 8 + 8 + 3 (leafType + networks + addresses + amount + metadata + padding)
let mut elements = Vec::with_capacity(LEAF_DATA_ELEMENT_COUNT);

// LeafType (uint32 as Felt): 0u32 for transfer Ether / ERC20 tokens, 1u32 for message
// passing.
// for a `CLAIM` note, leafType is always 0 (transfer Ether / ERC20 tokens)
elements.push(Felt::ZERO);

// Padding
elements.extend(vec![Felt::ZERO; 3]);

// Origin network
elements.push(Felt::new(self.origin_network as u64));

Expand All @@ -158,6 +155,9 @@ impl SequentialCommit for LeafData {
// Metadata (8 u32 felts)
elements.extend(self.metadata.iter().map(|&v| Felt::new(v as u64)));

// Padding
elements.extend(vec![Felt::ZERO; 3]);

elements
}
}
Expand Down
6 changes: 5 additions & 1 deletion crates/miden-testing/tests/agglayer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
pub mod asset_conversion;
mod bridge_in;
// TODO: Uncomment this when https://github.com/0xMiden/miden-base/issues/2397 is ready.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is re-enabled in the last PR of the series in chore: re-enable bridge-in tests

// The mainnet exit root is hardcoded to pass the current test (i.e. we set the expected mainnet
// root to whatever the current implementation computes), and changing any impl. details will break
// the test, forcing us to artificially change the expected root every time.
// mod bridge_in;
mod bridge_out;
mod crypto_utils;
mod global_index;
Expand Down
6 changes: 6 additions & 0 deletions crates/miden-testing/tests/agglayer/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ pub async fn execute_program_with_default_host(
processor.execute(&program, &mut host).await
}

/*
// TODO: Uncomment this when https://github.com/0xMiden/miden-base/issues/2397 is ready.
// The mainnet exit root is hardcoded to pass the current test (i.e. we set the expected mainnet
// root to whatever the current implementation computes), and changing any impl. details will break
// the test, forcing us to artificially change the expected root every time.
Comment on lines +52 to +56
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this test data is eventually removed in 034d539

// TESTING HELPERS
// ================================================================================================

Expand Down Expand Up @@ -125,3 +130,4 @@ pub fn claim_note_test_inputs() -> ClaimNoteTestInputs {
metadata,
)
}
*/