Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,432 changes: 884 additions & 1,548 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ miden-tx = { branch = "next", default-features = false, git = "https://gi
# Miden node dependencies
miden-node-block-producer = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-ntx-builder = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-proto = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-proto-build = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-node" }
miden-node-rpc = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-store = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-utils = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-validator = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-note-transport-proto-build = { default-features = false, version = "0.2" }
miden-remote-prover = { branch = "next", features = ["concurrent"], git = "https://github.com/0xMiden/miden-node" }
miden-remote-prover-client = { branch = "next", default-features = false, features = [
"tx-prover",
], git = "https://github.com/0xMiden/miden-node" }
Expand Down
39 changes: 29 additions & 10 deletions bin/integration-tests/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ pub async fn test_multiple_tx_on_same_block(client_config: ClientConfig) -> Resu
// wait for 1 block
wait_for_blocks(&mut client, 1).await;

// wait for 1 block
// wait for both transactions to be committed
wait_for_tx(&mut client, transaction_id_1).await?;
wait_for_tx(&mut client, transaction_id_2).await?;

let transactions = client
.get_transactions(TransactionFilter::All)
Expand Down Expand Up @@ -710,20 +711,38 @@ pub async fn test_consume_multiple_expected_notes(client_config: ClientConfig) -
let faucet_account_id = faucet_account_header.id();
let to_account_ids = [target_basic_account_1.id(), target_basic_account_2.id()];

// Mint tokens to the accounts
let fungible_asset = FungibleAsset::new(faucet_account_id, TRANSFER_AMOUNT).unwrap();
let mint_tx_request = mint_multiple_fungible_asset(
fungible_asset,
&[to_account_ids[0], to_account_ids[0], to_account_ids[1], to_account_ids[1]],
NoteType::Private,
client.rng(),
);

execute_tx_and_sync(&mut client, faucet_account_id, mint_tx_request.clone()).await?;
// TODO: mint tokens in a single transaction once multiple note minting is fixed on protocol
// https://github.com/0xMiden/protocol/issues/2519
// Mint tokens to the accounts
// let mint_tx_request = mint_multiple_fungible_asset(
// fungible_asset,
// &[to_account_ids[0], to_account_ids[0], to_account_ids[1], to_account_ids[1]],
// NoteType::Private,
// client.rng(),
// );
// execute_tx_and_sync(&mut client, faucet_account_id, mint_tx_request.clone()).await?;

// Mint tokens individually to work around a protocol bug where minting
// multiple notes in a single transaction fails (0xMiden/protocol#2519).
let targets = [to_account_ids[0], to_account_ids[0], to_account_ids[1], to_account_ids[1]];
let mut all_expected_notes = Vec::new();

for &target_id in &targets {
let tx_request = TransactionRequestBuilder::new()
.build_mint_fungible_asset(fungible_asset, target_id, NoteType::Private, client.rng())
.unwrap();

all_expected_notes.extend(tx_request.expected_output_own_notes());
execute_tx_and_sync(&mut client, faucet_account_id, tx_request).await?;
}

unauth_client.sync_state().await.unwrap();

// Filter notes by ownership
let expected_notes = mint_tx_request.expected_output_own_notes().into_iter();
// let expected_notes = mint_tx_request.expected_output_own_notes().into_iter();
let expected_notes = all_expected_notes.into_iter();
let client_notes: Vec<_> = client.get_input_notes(NoteFilter::All).await.unwrap();
let client_notes_ids: Vec<_> = client_notes.iter().map(|note| note.id()).collect();

Expand Down
147 changes: 94 additions & 53 deletions bin/integration-tests/src/tests/fpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,48 @@ pub async fn test_fpi_execute_program(client_config: ClientConfig) -> Result<()>
&mut client,
&keystore,
AccountStorageMode::Public,
format!(
r#"
const MAP_STORAGE_SLOT = word("{MAP_SLOT_NAME}")
"
use miden::protocol::active_account
pub proc get_fpi_map_item
# map key
push.{map_key}

# item slot
push.MAP_STORAGE_SLOT[0..2]

exec.::miden::protocol::active_account::get_map_item
swapw dropw
end"#,
map_key = Word::from(MAP_KEY)
),
# inputs are passed as foreign_procedure_inputs:
# [slot_id_prefix, slot_id_suffix, KEY, pad(10)]
exec.active_account::get_map_item
Comment on lines +51 to +53
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we still push the storage slot here? Why was this changed to assumed inputs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think both approaches test effectively the same, so no need to change it necessarily, but yeah not sure why this was generalized (now you can query any slot)

end"
.to_string(),
RPO_FALCON_SCHEME_ID,
)
.await?;
let foreign_account_id = foreign_account.id();
let code = format!(
"
use miden::protocol::tx
use miden::core::sys
const MAP_STORAGE_SLOT = word(\"{MAP_SLOT_NAME}\")
begin
# push the root of the `get_fpi_item` account procedure
# pad the stack for the foreign procedure inputs
padw padw push.0.0

# push the key of the desired storage item
push.{map_key}

# push the slot name of the desired storage item
push.MAP_STORAGE_SLOT[0..2]

# push the root of the `get_fpi_map_item` account procedure
push.{proc_root}

# push the foreign account id
push.{account_id_suffix} push.{account_id_prefix}
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT, storage_item_index]
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT,
# slot_id_prefix, slot_id_suffix, KEY, pad(10)]

exec.tx::execute_foreign_procedure
# => [VALUE, pad(12)]

exec.sys::truncate_stack
end
",
map_key = Word::from(MAP_KEY),
account_id_prefix = foreign_account_id.prefix().as_u64(),
account_id_suffix = foreign_account_id.suffix(),
);
Expand Down Expand Up @@ -144,22 +153,14 @@ pub async fn test_nested_fpi_calls(client_config: ClientConfig) -> Result<()> {
&mut client,
&keystore,
AccountStorageMode::Public,
format!(
r#"
const STORAGE_MAP_SLOT = word("{MAP_SLOT_NAME}")
"
use miden::protocol::active_account
pub proc get_fpi_map_item
# map key
push.{map_key}

# push item slot
push.STORAGE_MAP_SLOT[0..2]

# get item
exec.::miden::protocol::active_account::get_map_item
swapw dropw
end"#,
map_key = Word::from(MAP_KEY)
),
# inputs are passed as foreign_procedure_inputs:
# [slot_id_prefix, slot_id_suffix, KEY, pad(10)]
exec.active_account::get_map_item
end"
.to_string(),
RPO_FALCON_SCHEME_ID,
)
.await?;
Expand All @@ -172,20 +173,40 @@ pub async fn test_nested_fpi_calls(client_config: ClientConfig) -> Result<()> {
format!(
"
use miden::protocol::tx
use miden::core::sys
const STORAGE_MAP_SLOT = word(\"{MAP_SLOT_NAME}\")
pub proc get_fpi_map_item
# push the hash of the `get_fpi_item` account procedure
# The outer foreign procedure receives foreign_procedure_inputs(16) on the stack.
# We need to set up the inner FPI call with map key and slot as inputs.

# pad the stack for the inner foreign procedure inputs
padw padw push.0.0

# push the key of the desired storage item
push.{map_key}

# push the slot name of the desired storage item
push.STORAGE_MAP_SLOT[0..2]

# push the hash of the inner account procedure
push.{inner_proc_root}

# push the foreign account id
push.{account_id_suffix} push.{account_id_prefix}
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT, storage_item_index]
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT,
# slot_id_prefix, slot_id_suffix, KEY, pad(10)]

exec.tx::execute_foreign_procedure
# => [VALUE, pad(12)]

# add one to the result of the foreign procedure call
# add one to the first element of the result
add.1

# truncate any remaining stack items to ensure stack depth is 16
exec.sys::truncate_stack
end
",
map_key = Word::from(MAP_KEY),
account_id_prefix = inner_foreign_account_id.prefix().as_u64(),
account_id_suffix = inner_foreign_account_id.suffix(),
),
Expand All @@ -199,17 +220,26 @@ pub async fn test_nested_fpi_calls(client_config: ClientConfig) -> Result<()> {
let tx_script = format!(
"
use miden::protocol::tx
use miden::protocol::native_account
use miden::core::sys
begin
# push the hash of the `get_fpi_item` account procedure
# pad the stack for the outer foreign procedure inputs (it doesn't use inputs directly)
padw padw padw push.0.0.0.0

# push the root of the outer account procedure
push.{outer_proc_root}

# push the foreign account id
push.{account_id_suffix} push.{account_id_prefix}
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT, storage_item_index]
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT, pad(16)]

exec.tx::execute_foreign_procedure
# => [result(16)]

# assert the top word equals FPI_STORAGE_VALUE + 1
push.{fpi_value} add.1 assert_eqw

# truncate any remaining stack items
exec.sys::truncate_stack
end
",
fpi_value = Word::from(FPI_STORAGE_VALUE),
Expand Down Expand Up @@ -279,21 +309,14 @@ async fn standard_fpi(
&mut client,
&keystore,
storage_mode,
format!(
r#"
const STORAGE_MAP_SLOT = word("{MAP_SLOT_NAME}")
"
use miden::protocol::active_account
pub proc get_fpi_map_item
# map key
push.{map_key}

# push item slot name
push.STORAGE_MAP_SLOT[0..2]

exec.::miden::protocol::active_account::get_map_item
swapw dropw
end"#,
map_key = Word::from(MAP_KEY)
),
# inputs are passed as foreign_procedure_inputs:
# [slot_id_prefix, slot_id_suffix, KEY, pad(10)]
exec.active_account::get_map_item
end"
.to_string(),
auth_scheme,
)
.await?;
Expand All @@ -305,18 +328,36 @@ async fn standard_fpi(
let tx_script = format!(
"
use miden::protocol::tx
use miden::core::sys
const STORAGE_MAP_SLOT = word(\"{MAP_SLOT_NAME}\")
begin
# push the hash of the `get_fpi_item` account procedure
# pad the stack for the foreign procedure inputs
padw padw push.0.0

# push the key of the desired storage item
push.{map_key}

# push the slot name of the desired storage item
push.STORAGE_MAP_SLOT[0..2]

# push the hash of the `get_fpi_map_item` account procedure
push.{proc_root}

# push the foreign account id
push.{account_id_suffix} push.{account_id_prefix}
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT, storage_item_index]
# => [foreign_id_prefix, foreign_id_suffix, FOREIGN_PROC_ROOT,
# slot_id_prefix, slot_id_suffix, KEY, pad(10)]

exec.tx::execute_foreign_procedure
# => [VALUE, pad(12)]

push.{fpi_value} assert_eqw

# truncate any remaining stack items
exec.sys::truncate_stack
end
",
map_key = Word::from(MAP_KEY),
fpi_value = Word::from(FPI_STORAGE_VALUE),
account_id_prefix = foreign_account_id.prefix().as_u64(),
account_id_suffix = foreign_account_id.suffix(),
Expand Down
2 changes: 1 addition & 1 deletion bin/miden-cli/templates/basic-fungible-faucet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ supported-types = ["FungibleFaucet"]
name = "miden::standards::fungible_faucets::metadata"
description = "Contains metadata about the token associated to the faucet account"
type = [
{ type = "void" },
{ name = "max_supply", description = "Maximum supply of the token in base units" },
{ name = "decimals", type = "u8", description = "Number of decimal places" },
{ name = "ticker", type = "miden::standards::fungible_faucets::metadata::token_symbol", description = "Token symbol of the faucet's asset, limited to 4 characters." },
{ type = "void" },
]
Loading
Loading