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 @@ -8,6 +8,7 @@

- Skip requests to the `DataStore` for asset vault witnesses which are already in transaction inputs ([#2298](https://github.com/0xMiden/miden-base/pull/2298)).
- [BREAKING] refactored `TransactionAuthenticator::get_public_key()` method to return `Arc<PublicKey> `instead of `&PublicKey` ([#2304](https://github.com/0xMiden/miden-base/pull/2304)).
- [BREAKING] Renamed `NoteInputs` to `NoteStorage` to better reflect that values are stored data associated with a note rather than inputs ([#1662](https://github.com/0xMiden/miden-base/issues/1662)).

## 0.13.0 (2026-01-16)

Expand Down
12 changes: 6 additions & 6 deletions crates/miden-agglayer/asm/bridge/agglayer_faucet.masm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 552

# P2ID output note constants
const P2ID_SCRIPT_ROOT = [13362761878458161062, 15090726097241769395, 444910447169617901, 3558201871398422326]
const P2ID_NOTE_NUM_INPUTS = 2
const P2ID_NOTE_STORAGE_LENGTH = 2
const OUTPUT_NOTE_TYPE_PUBLIC = 1
const EXECUTION_HINT_ALWAYS = 1
const OUTPUT_NOTE_AUX = 0
Expand Down Expand Up @@ -146,17 +146,17 @@ proc build_p2id_output_note
swapw mem_loadw_be.OUTPUT_NOTE_SERIAL_NUM_MEM_ADDR
# => [SERIAL_NUM, SCRIPT_ROOT]

push.P2ID_NOTE_NUM_INPUTS
# => [num_output_note_inputs, SERIAL_NUM, SCRIPT_ROOT]
push.P2ID_NOTE_STORAGE_LENGTH
# => [note_storage_length, SERIAL_NUM, SCRIPT_ROOT]

exec.get_destination_account_id
# => [account_id_prefix, account_id_suffix, num_output_note_inputs, SERIAL_NUM, SCRIPT_ROOT]
# => [account_id_prefix, account_id_suffix, note_storage_length, SERIAL_NUM, SCRIPT_ROOT]

mem_store.0 mem_store.1
# => [num_output_note_inputs, SERIAL_NUM, SCRIPT_ROOT]
# => [note_storage_length, SERIAL_NUM, SCRIPT_ROOT]

push.OUTPUT_NOTE_INPUTS_MEM_ADDR
# => [inputs_ptr = 0, num_output_note_inputs, SERIAL_NUM, SCRIPT_ROOT]
# => [storage_ptr = 0, note_storage_length, SERIAL_NUM, SCRIPT_ROOT]

exec.note::build_recipient
# => [RECIPIENT]
Expand Down
2 changes: 1 addition & 1 deletion crates/miden-agglayer/asm/bridge/crypto_utils.masm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ end
#! Operand stack: [is_valid]
#!
#! Where:
#! - RPO_CLAIM_NOTE_INPUTS_COMMITMENT is the RPO hash commitment of all claim note inputs
#! - RPO_CLAIM_NOTE_STORAGE_COMMITMENT is the RPO hash commitment of all claim note storage
#! - leafType is the leaf type: [0] transfer Ether / ERC20 tokens, [1] message
#! - originNetwork is the origin network identifier (u32 as Felt)
#! - originAddress is the origin address (5 felts representing address)
Expand Down
14 changes: 7 additions & 7 deletions crates/miden-agglayer/asm/note_scripts/B2AGG.masm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use miden::standards::wallets::basic->basic_wallet
# CONSTANTS
# =================================================================================================

const B2AGG_NOTE_INPUTS_COUNT=6
const B2AGG_NOTE_STORAGE_LEN=6

# ERRORS
# =================================================================================================
const ERR_B2AGG_WRONG_NUMBER_OF_ASSETS="B2AGG script requires exactly 1 note asset"

const ERR_B2AGG_WRONG_NUMBER_OF_INPUTS="B2AGG script expects exactly 6 note inputs"
const ERR_B2AGG_UNEXPECTED_STORAGE_LENGTH="B2AGG script expects exactly 6 note storage items"

#! Bridge-to-AggLayer (B2AGG) note script: bridges assets from Miden to an AggLayer-connected chain.
#!
Expand All @@ -26,7 +26,7 @@ const ERR_B2AGG_WRONG_NUMBER_OF_INPUTS="B2AGG script expects exactly 6 note inpu
#! Inputs: []
#! Outputs: []
#!
#! Note inputs are assumed to be as follows:
#! Note storage is assumed to be as follows:
#! - destination_network: u32 value representing the target chain ID
#! - destination_address: split into 5 u32 values representing a 20-byte Ethereum address:
#! - destination_address_0: bytes 0-3
Expand Down Expand Up @@ -58,11 +58,11 @@ begin
exec.basic_wallet::add_assets_to_account
# => [pad(16)]
else
# Store note inputs -> mem[8..14]
push.8 exec.active_note::get_inputs
# => [num_inputs, dest_ptr, pad(16)]
# Store note storage -> mem[8..14]
push.8 exec.active_note::get_storage
# => [storage_length, dest_ptr, pad(16)]

push.B2AGG_NOTE_INPUTS_COUNT assert_eq.err=ERR_B2AGG_WRONG_NUMBER_OF_INPUTS drop
push.B2AGG_NOTE_STORAGE_LEN assert_eq.err=ERR_B2AGG_UNEXPECTED_STORAGE_LENGTH drop
# => [pad(16)]

# Store note assets -> mem[0..4]
Expand Down
14 changes: 7 additions & 7 deletions crates/miden-agglayer/asm/note_scripts/CLAIM.masm
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ const ERR_CLAIM_TARGET_ACCT_MISMATCH = "CLAIM's target account address and trans
#! Asserts that the consuming account matches the target agglayer faucet account.
#!
#! This procedure ensures that only the specified agglayer faucet account can consume
#! this CLAIM note. It assumes that the note inputs have already been loaded into memory
#! via active_note::get_inputs.
#! this CLAIM note. It assumes that the note storage has already been loaded into memory
#! via active_note::get_storage.
#!
#! Inputs: []
#! Output: []
#!
#! Panics if:
#! - The consuming account ID does not match the target faucet account ID stored in memory
proc assert_aggfaucet_is_consumer
# Load target faucet ID (assumes active_note::get_inputs has been called)
# Load target faucet ID (assumes active_note::get_storage has been called)
mem_load.TARGET_FAUCET_SUFFIX_MEM_ADDR mem_load.TARGET_FAUCET_PREFIX_MEM_ADDR
# => [target_faucet_prefix, target_faucet_suffix]

Expand Down Expand Up @@ -137,15 +137,15 @@ end
#! Agglayer Faucet CLAIM script: claims assets by calling the agglayer faucet's claim function.
#!
#! This note can only be consumed by the specific agglayer faucet account whose ID is provided
#! in the note inputs (target_faucet_account_id). Upon consumption, it will create a P2ID note.
#! in the note storage (target_faucet_account_id). Upon consumption, it will create a P2ID note.
#!
#! Requires that the account exposes:
#! - agglayer::agglayer_faucet::claim procedure.
#!
#! Inputs: [ARGS, pad(12)]
#! Outputs: [pad(16)]
#!
#! NoteInputs layout (575 felts total):
#! NoteStorage layout (575 felts total):
#! - smtProofLocalExitRoot [0..255] : 256 felts
#! - smtProofRollupExitRoot [256..511]: 256 felts
#! - globalIndex [512..519]: 8 felts
Expand Down Expand Up @@ -191,8 +191,8 @@ begin
dropw
# => [pad(16)]

# Load CLAIM note inputs into memory, starting at address 0
push.0 exec.active_note::get_inputs drop drop
# Load CLAIM note storage into memory, starting at address 0
push.0 exec.active_note::get_storage drop drop
# => [pad(16)]

# Check consuming account == aggfaucet
Expand Down
4 changes: 2 additions & 2 deletions crates/miden-agglayer/src/errors/agglayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use miden_protocol::errors::MasmError;
/// Error Message: "most-significant 4 bytes (addr4) must be zero"
pub const ERR_ADDR4_NONZERO: MasmError = MasmError::from_static_str("most-significant 4 bytes (addr4) must be zero");

/// Error Message: "B2AGG script expects exactly 6 note storage items"
pub const ERR_B2AGG_UNEXPECTED_STORAGE_LENGTH: MasmError = MasmError::from_static_str("B2AGG script expects exactly 6 note storage items");
/// Error Message: "B2AGG script requires exactly 1 note asset"
pub const ERR_B2AGG_WRONG_NUMBER_OF_ASSETS: MasmError = MasmError::from_static_str("B2AGG script requires exactly 1 note asset");
/// Error Message: "B2AGG script expects exactly 6 note inputs"
pub const ERR_B2AGG_WRONG_NUMBER_OF_INPUTS: MasmError = MasmError::from_static_str("B2AGG script expects exactly 6 note inputs");

/// Error Message: "CLAIM's target account address and transaction address do not match"
pub const ERR_CLAIM_TARGET_ACCT_MISMATCH: MasmError = MasmError::from_static_str("CLAIM's target account address and transaction address do not match");
Expand Down
38 changes: 19 additions & 19 deletions crates/miden-agglayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use miden_protocol::errors::NoteError;
use miden_protocol::note::{
Note,
NoteAssets,
NoteInputs,
NoteMetadata,
NoteRecipient,
NoteScript,
NoteStorage,
NoteTag,
NoteType,
};
Expand Down Expand Up @@ -400,36 +400,36 @@ pub fn create_claim_note<R: FeltRng>(params: ClaimNoteParams<'_, R>) -> Result<N
)));
}
// Create claim inputs matching exactly the agglayer claimAsset function parameters
let mut claim_inputs = vec![];
let mut claim_storage_items = vec![];

// 1) PROOF DATA
// smtProofLocalExitRoot (256 felts) - first SMT proof parameter
claim_inputs.extend(params.smt_proof_local_exit_root);
claim_storage_items.extend(params.smt_proof_local_exit_root);
// smtProofRollupExitRoot (256 felts) - second SMT proof parameter
claim_inputs.extend(params.smt_proof_rollup_exit_root);
claim_storage_items.extend(params.smt_proof_rollup_exit_root);

// globalIndex (uint256 as 8 u32 felts)
claim_inputs.extend(params.global_index);
claim_storage_items.extend(params.global_index);

// mainnetExitRoot (bytes32 as 8 u32 felts)
let mainnet_exit_root_felts = bytes32_to_felts(params.mainnet_exit_root);
claim_inputs.extend(mainnet_exit_root_felts);
claim_storage_items.extend(mainnet_exit_root_felts);

// rollupExitRoot (bytes32 as 8 u32 felts)
let rollup_exit_root_felts = bytes32_to_felts(params.rollup_exit_root);
claim_inputs.extend(rollup_exit_root_felts);
claim_storage_items.extend(rollup_exit_root_felts);

// 2) LEAF DATA
// originNetwork (uint32 as Felt)
claim_inputs.push(params.origin_network);
claim_storage_items.push(params.origin_network);

// originTokenAddress (address as 5 u32 felts)
let origin_token_address_felts =
EthAddressFormat::new(*params.origin_token_address).to_elements().to_vec();
claim_inputs.extend(origin_token_address_felts);
claim_storage_items.extend(origin_token_address_felts);

// destinationNetwork (uint32 as Felt)
claim_inputs.push(params.destination_network);
claim_storage_items.push(params.destination_network);

// destinationAddress (address as 5 u32 felts)
// Use AccountId prefix and suffix directly to get [suffix, prefix, 0, 0, 0]
Expand All @@ -442,30 +442,30 @@ pub fn create_claim_note<R: FeltRng>(params: ClaimNoteParams<'_, R>) -> Result<N
Felt::new(0),
Felt::new(0),
];
claim_inputs.extend(destination_address_felts);
claim_storage_items.extend(destination_address_felts);

// amount (uint256 as 8 u32 felts)
claim_inputs.extend(params.amount);
claim_storage_items.extend(params.amount);

// metadata (fixed size of 8 felts)
claim_inputs.extend(params.metadata);
claim_storage_items.extend(params.metadata);

let padding = vec![Felt::ZERO; 4];
claim_inputs.extend(padding);
claim_storage_items.extend(padding);

// 3) CLAIM NOTE DATA
// TODO: deterministically compute serial number of p2id hash(GER, leaf index)
// output_p2id_serial_num (4 felts as Word)
claim_inputs.extend(params.p2id_serial_number);
claim_storage_items.extend(params.p2id_serial_number);

// agglayer_faucet_account_id (2 felts: prefix and suffix)
claim_inputs.push(params.agglayer_faucet_account_id.prefix().as_felt());
claim_inputs.push(params.agglayer_faucet_account_id.suffix());
claim_storage_items.push(params.agglayer_faucet_account_id.prefix().as_felt());
claim_storage_items.push(params.agglayer_faucet_account_id.suffix());

// output note tag
claim_inputs.push(params.output_note_tag.as_u32().into());
claim_storage_items.push(params.output_note_tag.as_u32().into());

let inputs = NoteInputs::new(claim_inputs)?;
let inputs = NoteStorage::new(claim_storage_items)?;

let tag = NoteTag::with_account_target(params.agglayer_faucet_account_id);

Expand Down
44 changes: 22 additions & 22 deletions crates/miden-protocol/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_RECIPIENT_WHILE_NO_NOTE_BEING_PROCESSED="f

const ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_METADATA_WHILE_NO_NOTE_BEING_PROCESSED="failed to access note metadata of active note because no note is currently being processed"

const ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_INPUTS_WHILE_NO_NOTE_BEING_PROCESSED="failed to access note inputs of active note because no note is currently being processed"
const ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_STORAGE_WHILE_NO_NOTE_BEING_PROCESSED="failed to access note storage of active note because no note is currently being processed"

const ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_SCRIPT_ROOT_WHILE_NO_NOTE_BEING_PROCESSED="failed to access note script root of active note because no note is currently being processed"

Expand Down Expand Up @@ -907,7 +907,7 @@ end
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
Expand Down Expand Up @@ -945,7 +945,7 @@ end
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
Expand Down Expand Up @@ -984,7 +984,7 @@ end
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
Expand Down Expand Up @@ -1030,7 +1030,7 @@ end
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
Expand All @@ -1056,49 +1056,49 @@ pub proc input_note_get_serial_number
# => [SERIAL_NUMBER, pad(12)]
end

#! Returns the inputs commitment and length of the specified input note.
#! Returns the storage commitment and length of the specified input note.
#!
#! Inputs: [is_active_note, note_index, pad(14)]
#! Outputs: [NOTE_INPUTS_COMMITMENT, num_inputs, pad(11)]
#! Outputs: [NOTE_STORAGE_COMMITMENT, storage_len, pad(11)]
#!
#! Where:
#! - is_active_note is the boolean flag indicating whether we should return the inputs commitment
#! - is_active_note is the boolean flag indicating whether we should return the storage commitment
#! and length from the active note or from the note with the specified index.
#! - note_index is the index of the input note whose data should be returned. Notice that if
#! is_active_note is 1, note_index is ignored.
#! - NOTE_INPUTS_COMMITMENT is the inputs commitment of the specified input note.
#! - num_inputs is the number of inputs of the specified input note.
#! - NOTE_STORAGE_COMMITMENT is the storage commitment of the specified input note.
#! - storage_len is the number of storage items of the specified input note.
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
pub proc input_note_get_inputs_info
pub proc input_note_get_storage_info
# get the input note pointer depending on whether the requested note is current or it was
# requested by index.
exec.get_requested_note_ptr
# => [input_note_ptr, pad(15)]

# assert the pointer is not zero - this would suggest the procedure has been called from an
# incorrect context
dup neq.0 assert.err=ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_INPUTS_WHILE_NO_NOTE_BEING_PROCESSED
dup neq.0 assert.err=ERR_NOTE_ATTEMPT_TO_ACCESS_NOTE_STORAGE_WHILE_NO_NOTE_BEING_PROCESSED
# => [input_note_ptr, pad(15)]

# get the note inputs length
dup exec.memory::get_input_note_num_inputs swap
# => [input_note_ptr, num_inputs, pad(16)]
# get the note storage length
dup exec.memory::get_input_note_storage_len swap
# => [input_note_ptr, storage_len, pad(16)]

# get the inputs commitment
exec.memory::get_input_note_inputs_commitment
# => [NOTE_INPUTS_COMMITMENT, num_inputs, pad(16)]
# get the storage commitment
exec.memory::get_input_note_storage_commitment
# => [NOTE_STORAGE_COMMITMENT, storage_len, pad(16)]

# truncate the stack
repeat.5
movup.5 drop
end
# => [NOTE_INPUTS_COMMITMENT, num_inputs, pad(11)]
# => [NOTE_STORAGE_COMMITMENT, storage_len, pad(11)]
end

#! Returns the script root of the specified input note.
Expand All @@ -1107,15 +1107,15 @@ end
#! Outputs: [SCRIPT_ROOT, pad(12)]
#!
#! Where:
#! - is_active_note is the boolean flag indicating whether we should return the inputs commitment
#! - is_active_note is the boolean flag indicating whether we should return the storage commitment
#! and length from the active note or from the note with the specified index.
#! - note_index is the index of the input note whose data should be returned. Notice that if
#! is_active_note is 1, note_index is ignored.
#! - SCRIPT_ROOT is the script root of the specified input note.
#!
#! Panics if:
#! - the note index is greater or equal to the total number of input notes.
#! - is_active_note is 1 and no input note is not being processed (attempted to access note inputs
#! - is_active_note is 1 and no input note is not being processed (attempted to access note storage
#! from incorrect context).
#!
#! Invocation: dynexec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub const WORD_SIZE = 4

# The maximum number of input values associated with a single note.
pub const MAX_INPUTS_PER_NOTE = 1024
pub const MAX_NOTE_STORAGE_ITEMS = 1024

# The maximum number of assets that can be stored in a single note.
pub const MAX_ASSETS_PER_NOTE = 256
Expand Down
Loading