Skip to content
Draft
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,101 changes: 921 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ miden-tx = { default-features = false, version = "=0.14.0-alpha.1" }
miden-node-block-producer = { version = "=0.14.0-alpha.4" }
miden-node-ntx-builder = { version = "=0.14.0-alpha.4" }
miden-node-proto = { version = "=0.14.0-alpha.4" }
miden-node-proto-build = { default-features = false, version = "=0.14.0-alpha.4" }
miden-node-proto-build = { default-features = false, path = "../node/proto", version = "=0.14.0-alpha.1" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This also needs to be fixed.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, sure. I should have marked this as a draft.

miden-node-rpc = { version = "=0.14.0-alpha.4" }
miden-node-store = { version = "=0.14.0-alpha.4" }
miden-node-utils = { version = "=0.14.0-alpha.4" }
miden-node-validator = { version = "=0.14.0-alpha.4" }
miden-note-transport-proto-build = { default-features = false, version = "0.2" }
miden-remote-prover-client = { default-features = false, features = ["tx-prover"], version = "=0.14.0-alpha.4" }
miden-remote-prover-client = { default-features = false, features = ["tx-prover"], path = "../node/crates/remote-prover-client" }

# Miden debug dependency
miden-debug = { default-features = false, features = ["dap", "std"], path = "../miden-debug" }

# External dependencies
anyhow = { default-features = false, version = "1.0" }
Expand All @@ -76,3 +79,9 @@ module_name_repetitions = "allow" # Many triggers, and is a stylistic choice
must_use_candidate = "allow" # This marks many fn's which isn't helpful.
should_panic_without_expect = "allow" # We don't care about the specific panic message.
# End of pedantic lints.

[patch.crates-io]
miden-protocol = { path = "../protocol/crates/miden-protocol" }
miden-standards = { path = "../protocol/crates/miden-standards" }
miden-testing = { path = "../protocol/crates/miden-testing" }
miden-tx = { path = "../protocol/crates/miden-tx" }
Comment on lines +83 to +87
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be removed

4 changes: 4 additions & 0 deletions bin/miden-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ version.workspace = true
name = "miden-client"
path = "src/main.rs"

[features]
dap = ["miden-client/dap", "dep:miden-debug"]
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 gate behind a feature? Or have connection depend on an Optional argument?


[dependencies]
# Workspace dependencies
miden-client = { features = ["tonic"], workspace = true }
miden-client-sqlite-store = { workspace = true }
miden-debug = { optional = true, workspace = true }

# External dependencies
clap = { features = ["derive"], version = "4.5" }
Expand Down
13 changes: 6 additions & 7 deletions bin/miden-cli/src/commands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async fn list_accounts<AUTH>(client: Client<AUTH>) -> Result<(), CliError> {
acc.id().to_hex(),
account_type_display_name(&acc.id())?,
acc.id().storage_mode().to_string(),
acc.nonce().as_int().to_string(),
acc.nonce().as_canonical_u64().to_string(),
status,
]);
}
Expand Down Expand Up @@ -172,11 +172,7 @@ pub async fn show_account<AUTH>(
},
Asset::NonFungible(non_fungible_asset) => {
// TODO: Display non-fungible assets more clearly.
(
"Non Fungible Asset",
non_fungible_asset.faucet_id_prefix().to_hex(),
1.0.to_string(),
)
("Non Fungible Asset", non_fungible_asset.faucet_id().to_hex(), 1.0.to_string())
},
};
table.add_row(vec![asset_type, &faucet, &amount.clone()]);
Expand Down Expand Up @@ -263,7 +259,10 @@ async fn print_summary_table<AUTH>(
Cell::new("Storage Root"),
Cell::new(account.storage().to_commitment().to_string()),
]);
table.add_row(vec![Cell::new("Nonce"), Cell::new(account.nonce().as_int().to_string())]);
table.add_row(vec![
Cell::new("Nonce"),
Cell::new(account.nonce().as_canonical_u64().to_string()),
]);

println!("{table}\n");
Ok(())
Expand Down
21 changes: 21 additions & 0 deletions bin/miden-cli/src/commands/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ pub struct ExecCmd {
/// Print the output stack grouped into words
#[arg(long, default_value_t = false)]
hex_words: bool,

/// Start a DAP debug adapter server on the given address (e.g. "127.0.0.1:4711")
/// and wait for a DAP client to connect before executing.
#[cfg(feature = "dap")]
#[arg(long = "start-debug-adapter")]
start_debug_adapter: Option<String>,
}

impl ExecCmd {
Expand Down Expand Up @@ -87,6 +93,21 @@ impl ExecCmd {

let tx_script = client.code_builder().compile_tx_script(&program)?;

#[cfg(feature = "dap")]
let result = if let Some(ref addr) = self.start_debug_adapter {
miden_debug::DapConfig::set_global(miden_debug::DapConfig {
listen_addr: addr.clone(),
});
client
.execute_program_with_dap(account_id, tx_script, advice_inputs, BTreeSet::new())
.await
} else {
client
.execute_program(account_id, tx_script, advice_inputs, BTreeSet::new())
.await
};

#[cfg(not(feature = "dap"))]
let result = client
.execute_program(account_id, tx_script, advice_inputs, BTreeSet::new())
.await;
Comment on lines +105 to 113
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is duplicated code. Maybe the best approach is not to split between feature = "dap" or not.

Expand Down
24 changes: 22 additions & 2 deletions bin/miden-cli/src/commands/new_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ pub struct NewWalletCmd {
/// authentication transaction.
#[arg(long, default_value_t = false)]
pub deploy: bool,
/// Seed local-only state so the wallet can be created and used for execution without a node.
#[arg(long, default_value_t = false)]
pub offline: bool,
}

impl NewWalletCmd {
Expand Down Expand Up @@ -124,6 +127,7 @@ impl NewWalletCmd {
&package_paths,
self.init_storage_data_path.clone(),
self.deploy,
self.offline,
)
.await?;

Expand Down Expand Up @@ -191,6 +195,9 @@ pub struct NewAccountCmd {
/// authentication transaction.
#[arg(long, default_value_t = false)]
pub deploy: bool,
/// Seed local-only state so the account can be created and used for execution without a node.
#[arg(long, default_value_t = false)]
pub offline: bool,
}

impl NewAccountCmd {
Expand All @@ -207,6 +214,7 @@ impl NewAccountCmd {
&self.packages,
self.init_storage_data_path.clone(),
self.deploy,
self.offline,
)
.await?;

Expand Down Expand Up @@ -354,6 +362,7 @@ async fn create_client_account<AUTH: Keystore + Sync + 'static>(
package_paths: &[PathBuf],
init_storage_data_path: Option<PathBuf>,
deploy: bool,
offline: bool,
) -> Result<Account, CliError> {
if package_paths.is_empty() {
return Err(CliError::InvalidArgument(format!(
Expand All @@ -362,6 +371,12 @@ async fn create_client_account<AUTH: Keystore + Sync + 'static>(
", client_binary_name().display())));
}

if deploy && offline {
return Err(CliError::InvalidArgument(
"`--offline` cannot be combined with `--deploy`".to_string(),
));
}

// Load the component templates and initialization storage data.

let cli_config = CliConfig::load()?;
Expand Down Expand Up @@ -390,10 +405,10 @@ async fn create_client_account<AUTH: Keystore + Sync + 'static>(
None
} else {
debug!("Adding default Falcon auth component");
let kp = AuthSecretKey::new_falcon512_rpo_with_rng(client.rng());
let kp = AuthSecretKey::new_falcon512_poseidon2_with_rng(client.rng());
builder = builder.with_auth_component(AuthSingleSig::new(
kp.public_key().to_commitment(),
AuthSchemeId::Falcon512Rpo,
AuthSchemeId::Falcon512Poseidon2,
));
Some(kp)
};
Expand All @@ -416,6 +431,11 @@ async fn create_client_account<AUTH: Keystore + Sync + 'static>(
println!("Using custom authentication component from package (no key generated).");
}

if offline {
client.prepare_offline_bootstrap().await?;
println!("Offline mode seeded default RPC limits and a synthetic genesis header.");
}

client.add_account(&account, false).await?;

if deploy {
Expand Down
15 changes: 3 additions & 12 deletions bin/miden-cli/src/commands/new_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use miden_client::store::NoteRecordError;
use miden_client::transaction::{
ExecutedTransaction,
InputNote,
OutputNote,
PaymentNoteDescription,
SwapTransactionData,
TransactionRequest,
Expand Down Expand Up @@ -401,7 +400,7 @@ async fn execute_transaction<AUTH: Keystore + Sync + 'static>(
let output_notes = executed_transaction
.output_notes()
.iter()
.map(OutputNote::id)
.map(miden_client::transaction::RawOutputNote::id)
.collect::<Vec<_>>();

println!("Proving transaction...");
Expand Down Expand Up @@ -514,18 +513,10 @@ fn print_transaction_details(executed_tx: &ExecutedTransaction) -> Result<(), Cl
for (asset, action) in account_delta.vault().non_fungible().iter() {
match action {
NonFungibleDeltaAction::Add => {
table.add_row(vec![
"Non Fungible Asset",
&asset.faucet_id_prefix().to_hex(),
"1",
]);
table.add_row(vec!["Non Fungible Asset", &asset.faucet_id().to_hex(), "1"]);
},
NonFungibleDeltaAction::Remove => {
table.add_row(vec![
"Non Fungible Asset",
&asset.faucet_id_prefix().to_hex(),
"-1",
]);
table.add_row(vec!["Non Fungible Asset", &asset.faucet_id().to_hex(), "-1"]);
},
}
}
Expand Down
8 changes: 3 additions & 5 deletions bin/miden-cli/src/commands/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,9 @@ async fn show_note<AUTH: Keystore + Sync>(
let (faucet, amount) = faucet_details_map.format_fungible_asset(fungible_asset)?;
("Fungible Asset", faucet, amount)
},
Asset::NonFungible(non_fungible_asset) => (
"Non Fungible Asset",
non_fungible_asset.faucet_id_prefix().to_hex(),
1.0.to_string(),
),
Asset::NonFungible(non_fungible_asset) => {
("Non Fungible Asset", non_fungible_asset.faucet_id().to_hex(), 1.0.to_string())
},
};
table.add_row(vec![asset_type, &faucet, &amount.clone()]);
}
Expand Down
8 changes: 4 additions & 4 deletions bin/miden-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use miden_client::testing::common::{
execute_tx_and_sync,
insert_new_wallet,
};
use miden_client::transaction::{OutputNote, TransactionRequestBuilder};
use miden_client::transaction::{RawOutputNote, TransactionRequestBuilder};
use miden_client::utils::Serializable;
use miden_client::{self, Client, DebugMode, Felt};
use miden_client_cli::MIDEN_DIR;
Expand Down Expand Up @@ -714,7 +714,7 @@ async fn debug_mode_outputs_logs() -> Result<()> {
// Send transaction and wait for it to be committed
client.sync_state().await?;
let transaction_request = TransactionRequestBuilder::new()
.own_output_notes(vec![OutputNote::Full(note.clone())])
.own_output_notes(vec![RawOutputNote::Full(note.clone())])
.build()?;
execute_tx_and_sync(&mut client, account.id(), transaction_request).await?;

Expand Down Expand Up @@ -906,7 +906,7 @@ async fn new_wallet_with_deploy_flag() -> Result<()> {
// Verify that the nonce is non-zero (account was deployed)
// By convention, a nonce of 0 indicates an undeployed account
assert!(
nonce.as_int() > 0,
nonce.as_canonical_u64() > 0,
"Account nonce should be non-zero after deployment, but got: {nonce}"
);

Expand Down Expand Up @@ -1320,7 +1320,7 @@ fn create_account_with_acl_auth() {
// Create init storage data file for acl-auth with a test public key
let init_storage_data_toml = r#"
"miden::standards::auth::singlesig_acl::pub_key" = "0x0000000000000000000000000000000000000000000000000000000000000001"
"miden::standards::auth::singlesig_acl::scheme" = "Falcon512Rpo"
"miden::standards::auth::singlesig_acl::scheme" = "Falcon512Poseidon2"
"miden::standards::auth::singlesig_acl::config.num_tracked_procs" = "1"
"miden::standards::auth::singlesig_acl::config.allow_unauthorized_output_notes" = "0"
"miden::standards::auth::singlesig_acl::config.allow_unauthorized_input_notes" = "0"
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ std = [
"tonic/transport",
]
testing = ["dep:miden-testing", "dep:uuid", "miden-protocol/testing", "miden-standards/testing", "miden-tx/testing"]
dap = ["dep:miden-debug"]
tonic = []

[dependencies]
# Miden dependencies
miden-mast-package = { default-features = false, version = "0.20" }
miden-debug = { optional = true, workspace = true }
miden-protocol = { workspace = true }
miden-remote-prover-client = { default-features = false, features = ["tx-prover"], workspace = true }
miden-standards = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-client/src/account/account_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl AccountReader {
/// To load the entire vault, use
/// [`Client::get_account_vault`](crate::Client::get_account_vault).
pub async fn get_balance(&self, faucet_id: AccountId) -> Result<u64, ClientError> {
if let Some(vault_key) = AssetVaultKey::from_account_id(faucet_id)
if let Some(vault_key) = AssetVaultKey::new_fungible(faucet_id)
&& let Some((Asset::Fungible(fungible_asset), _)) =
self.store.get_account_asset(self.account_id, vault_key).await?
{
Expand Down
7 changes: 4 additions & 3 deletions crates/rust-client/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<AUTH> Client<AUTH> {
return Err(ClientError::AccountAlreadyTracked(account.id()));
}

if tracked_account.nonce().as_int() > account.nonce().as_int() {
if tracked_account.nonce().as_canonical_u64() > account.nonce().as_canonical_u64() {
// If the new account is older than the one being tracked, return an error
return Err(ClientError::AccountNonceTooLow);
}
Expand Down Expand Up @@ -422,9 +422,10 @@ pub fn build_wallet_id(

let auth_scheme = public_key.auth_scheme();
let auth_component = match auth_scheme {
AuthSchemeId::Falcon512Rpo => {
AuthSchemeId::Falcon512Poseidon2 => {
let auth_component: AccountComponent =
AuthSingleSig::new(public_key.to_commitment(), AuthSchemeId::Falcon512Rpo).into();
AuthSingleSig::new(public_key.to_commitment(), AuthSchemeId::Falcon512Poseidon2)
.into();
auth_component
},
AuthSchemeId::EcdsaK256Keccak => {
Expand Down
1 change: 1 addition & 0 deletions crates/rust-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ where
exec_options: ExecutionOptions::new(
Some(MAX_TX_EXECUTION_CYCLES),
MIN_TX_EXECUTION_CYCLES,
ExecutionOptions::DEFAULT_CORE_TRACE_FRAGMENT_SIZE,
false,
self.in_debug_mode.into(),
)
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use miden_standards::account::interface::AccountInterfaceError;
// ================================================================================================
pub use miden_standards::errors::CodeBuilderError;
pub use miden_tx::AuthenticationError;
use miden_tx::utils::{DeserializationError, HexParseError};
use miden_tx::utils::HexParseError;
use miden_tx::utils::serde::DeserializationError;
use miden_tx::{NoteCheckerError, TransactionExecutorError, TransactionProverError};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion crates/rust-client/src/keystore/fs_keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use miden_protocol::account::AccountId;
use miden_protocol::account::auth::{AuthSecretKey, PublicKey, PublicKeyCommitment, Signature};
use miden_tx::AuthenticationError;
use miden_tx::auth::{SigningInputs, TransactionAuthenticator};
use miden_tx::utils::serde::{Deserializable, Serializable};
use miden_tx::utils::sync::RwLock;
use miden_tx::utils::{Deserializable, Serializable};
use serde::{Deserialize, Serialize};

use super::{KeyStoreError, Keystore};
Expand Down
Loading