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
14 changes: 7 additions & 7 deletions crates/miden-agglayer/asm/bridge/agglayer_faucet.masm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_0 = 548
const OUTPUT_NOTE_ASSET_AMOUNT_MEM_ADDR_1 = 552

# P2ID output note constants
const P2ID_SCRIPT_ROOT = [7588674509004260508, 4058706621878288170, 5607159951796201570, 5541281552524512743]
const P2ID_SCRIPT_ROOT = [13362761878458161062, 15090726097241769395, 444910447169617901, 3558201871398422326]
const P2ID_NOTE_NUM_INPUTS = 2
const OUTPUT_NOTE_TYPE_PUBLIC = 1
const EXECUTION_HINT_ALWAYS = 1
Expand Down Expand Up @@ -160,19 +160,19 @@ proc build_p2id_output_note

exec.note::build_recipient
# => [RECIPIENT]
push.EXECUTION_HINT_ALWAYS push.OUTPUT_NOTE_TYPE_PUBLIC push.OUTPUT_NOTE_AUX
# => [aux, note_type, execution_hint, RECIPIENT]

push.OUTPUT_NOTE_TYPE_PUBLIC
# => [note_type, RECIPIENT]

mem_load.OUTPUT_NOTE_TAG_MEM_ADDR
# => [tag, aux, execution_hint, RECIPIENT]
# => [tag, RECIPIENT]

exec.get_raw_claim_amount
# => [AMOUNT[1], AMOUNT[0], tag, aux, note_type, execution_hint, RECIPIENT]
# => [AMOUNT[1], AMOUNT[0], tag, note_type, RECIPIENT]

# TODO: implement scale down logic; stubbed out for now
exec.asset_conversion::scale_u256_to_native_amount
# => [amount, tag, aux, note_type, execution_hint, RECIPIENT]
# => [amount, tag, note_type, RECIPIENT]

exec.faucets::distribute
# => [pad(16)]
Expand Down
7 changes: 2 additions & 5 deletions crates/miden-agglayer/asm/bridge/bridge_out.masm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use miden::agglayer::local_exit_tree
const MMR_PTR=42
const LOCAL_EXIT_TREE_SLOT=word("miden::agglayer::let")

const BURN_NOTE_ROOT = [6407337173854817345, 5626358912819151014, 703918618794810515, 17401169215223723177]
const EXECUTION_HINT_ALWAYS=1
const BURN_NOTE_ROOT = [15615638671708113717, 1774623749760042586, 2028263167268363492, 12931944505143778072]
const PUBLIC_NOTE=1
const AUX=0
const NUM_BURN_NOTE_INPUTS=0
Expand Down Expand Up @@ -75,11 +74,9 @@ proc create_burn_note
exec.note::build_recipient
# => [RECIPIENT]

push.EXECUTION_HINT_ALWAYS
push.PUBLIC_NOTE
push.AUX
loc_load.5
# => [tag, aux, note_type, execution_hint, RECIPIENT]
# => [tag, note_type, RECIPIENT]

call.output_note::create
# => [note_idx]
Expand Down
13 changes: 2 additions & 11 deletions crates/miden-agglayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use miden_protocol::crypto::rand::FeltRng;
use miden_protocol::note::{
Note,
NoteAssets,
NoteExecutionHint,
NoteInputs,
NoteMetadata,
NoteRecipient,
Expand Down Expand Up @@ -465,23 +464,15 @@ pub fn create_claim_note<R: FeltRng>(params: ClaimNoteParams<'_, R>) -> Result<N

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

// Use a default tag since we don't have agg_faucet_id anymore
let tag = NoteTag::for_local_use_case(0, 0)?;
let tag = NoteTag::with_account_target(params.agglayer_faucet_account_id);

let claim_script = claim_script();
let serial_num = params.rng.draw_word();

let note_type = NoteType::Public;
let execution_hint = NoteExecutionHint::always();

// Use a default sender since we don't have sender anymore - create from destination address
let metadata = NoteMetadata::new(
params.claim_note_creator_account_id,
note_type,
tag,
execution_hint,
Felt::ZERO,
)?;
let metadata = NoteMetadata::new(params.claim_note_creator_account_id, note_type, tag);
let assets = NoteAssets::new(vec![])?;
let recipient = NoteRecipient::new(serial_num, claim_script, inputs);

Expand Down
15 changes: 3 additions & 12 deletions crates/miden-testing/tests/agglayer/bridge_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use miden_protocol::crypto::rand::FeltRng;
use miden_protocol::note::{
Note,
NoteAssets,
NoteExecutionHint,
NoteInputs,
NoteMetadata,
NoteRecipient,
Expand Down Expand Up @@ -87,8 +86,6 @@ async fn test_bridge_in_claim_to_p2id() -> anyhow::Result<()> {
metadata,
) = claim_note_test_inputs(amount_felt, user_account.id());

let aux = Felt::new(0);

// Generate a serial number for the P2ID note
let serial_num = builder.rng_mut().draw_word();

Expand All @@ -106,7 +103,7 @@ async fn test_bridge_in_claim_to_p2id() -> anyhow::Result<()> {
metadata,
claim_note_creator_account_id: user_account.id(),
agglayer_faucet_account_id: agglayer_faucet.id(),
output_note_tag: NoteTag::from_account_id(user_account.id()),
output_note_tag: NoteTag::with_account_target(user_account.id()),
p2id_serial_number: serial_num,
destination_account_id: user_account.id(),
rng: builder.rng_mut(),
Expand All @@ -131,16 +128,10 @@ async fn test_bridge_in_claim_to_p2id() -> anyhow::Result<()> {
// CREATE EXPECTED P2ID NOTE FOR VERIFICATION
// --------------------------------------------------------------------------------------------
let mint_asset: Asset = FungibleAsset::new(agglayer_faucet.id(), amount_felt.into())?.into();
let output_note_tag = NoteTag::from_account_id(user_account.id());
let output_note_tag = NoteTag::with_account_target(user_account.id());
let expected_p2id_note = Note::new(
NoteAssets::new(vec![mint_asset])?,
NoteMetadata::new(
agglayer_faucet.id(),
NoteType::Public,
output_note_tag,
NoteExecutionHint::always(),
aux,
)?,
NoteMetadata::new(agglayer_faucet.id(), NoteType::Public, output_note_tag),
p2id_recipient,
);

Expand Down
17 changes: 5 additions & 12 deletions crates/miden-testing/tests/agglayer/bridge_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use miden_protocol::asset::{Asset, FungibleAsset};
use miden_protocol::note::{
Note,
NoteAssets,
NoteExecutionHint,
NoteInputs,
NoteMetadata,
NoteRecipient,
Expand Down Expand Up @@ -70,9 +69,7 @@ async fn test_bridge_out_consumes_b2agg_note() -> anyhow::Result<()> {

let amount = Felt::new(100);
let bridge_asset: Asset = FungibleAsset::new(faucet.id(), amount.into()).unwrap().into();
let tag = NoteTag::for_local_use_case(0, 0).unwrap();
let aux = Felt::new(0);
let note_execution_hint = NoteExecutionHint::always();
let tag = NoteTag::new(0);
let note_type = NoteType::Public; // Use Public note type for network transaction

// Get the B2AGG note script
Expand All @@ -93,8 +90,7 @@ async fn test_bridge_out_consumes_b2agg_note() -> anyhow::Result<()> {
let inputs = NoteInputs::new(input_felts.clone())?;

// Create the B2AGG note with assets from the faucet
let b2agg_note_metadata =
NoteMetadata::new(faucet.id(), note_type, tag, note_execution_hint, aux)?;
let b2agg_note_metadata = NoteMetadata::new(faucet.id(), note_type, tag);
let b2agg_note_assets = NoteAssets::new(vec![bridge_asset])?;
let serial_num = Word::from([1, 2, 3, 4u32]);
let b2agg_note_script = NoteScript::new(b2agg_script);
Expand Down Expand Up @@ -146,7 +142,7 @@ async fn test_bridge_out_consumes_b2agg_note() -> anyhow::Result<()> {

assert_eq!(
burn_note.metadata().tag(),
NoteTag::from_account_id(faucet.id()),
NoteTag::with_account_target(faucet.id()),
"BURN note should have the correct tag"
);

Expand Down Expand Up @@ -230,9 +226,7 @@ async fn test_b2agg_note_reclaim_scenario() -> anyhow::Result<()> {

let amount = Felt::new(50);
let bridge_asset: Asset = FungibleAsset::new(faucet.id(), amount.into()).unwrap().into();
let tag = NoteTag::for_local_use_case(0, 0).unwrap();
let aux = Felt::new(0);
let note_execution_hint = NoteExecutionHint::always();
let tag = NoteTag::new(0);
let note_type = NoteType::Public;

// Get the B2AGG note script
Expand All @@ -252,8 +246,7 @@ async fn test_b2agg_note_reclaim_scenario() -> anyhow::Result<()> {

// Create the B2AGG note with the USER ACCOUNT as the sender
// This is the key difference - the note sender will be the same as the consuming account
let b2agg_note_metadata =
NoteMetadata::new(user_account.id(), note_type, tag, note_execution_hint, aux)?;
let b2agg_note_metadata = NoteMetadata::new(user_account.id(), note_type, tag);
let b2agg_note_assets = NoteAssets::new(vec![bridge_asset])?;
let serial_num = Word::from([1, 2, 3, 4u32]);
let b2agg_note_script = NoteScript::new(b2agg_script);
Expand Down
Loading