diff --git a/Cargo.lock b/Cargo.lock index 28a6e5e525..a4cfe1fdeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1470,9 +1470,8 @@ dependencies = [ [[package]] name = "miden-lib" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea3fdad9ad0e50f71f4be0e27479d2de800a9b9262810d0cbedaea30e3f450b" +version = "0.9.0" +source = "git+https://github.com/0xPolygonMiden/miden-base?branch=next#0b0a2d8d955772583767ba656dd85a36694fa1f1" dependencies = [ "miden-assembly", "miden-objects", @@ -1526,9 +1525,8 @@ dependencies = [ [[package]] name = "miden-node-proto-build" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cb1d9b312ec25b732b4d3f6f75d37dd6ff1b69dd483e89ec8001be482dcc5fb" +version = "0.9.0" +source = "git+https://github.com/0xPolygonMiden/miden-node?branch=next#a8649333b2dd8fe182607f80998e5b4abe6f1502" dependencies = [ "anyhow", "prost", @@ -1538,9 +1536,8 @@ dependencies = [ [[package]] name = "miden-objects" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea350fdd6d025d2e4791ac0769bfbc04afca404fbb20f918354dcc758debd4c" +version = "0.9.0" +source = "git+https://github.com/0xPolygonMiden/miden-base?branch=next#0b0a2d8d955772583767ba656dd85a36694fa1f1" dependencies = [ "bech32", "getrandom 0.3.2", @@ -1586,9 +1583,8 @@ dependencies = [ [[package]] name = "miden-proving-service-client" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba272e6749ad8a146ff62dc621f396021d347257d948eac26e4493c0b9d3d341" +version = "0.9.0" +source = "git+https://github.com/0xPolygonMiden/miden-base?branch=next#0b0a2d8d955772583767ba656dd85a36694fa1f1" dependencies = [ "async-trait", "getrandom 0.3.2", @@ -1617,9 +1613,8 @@ dependencies = [ [[package]] name = "miden-tx" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f253174345a55a08229cc7eb0094f290d515c0a39f46eb807881da4ce40c9e" +version = "0.9.0" +source = "git+https://github.com/0xPolygonMiden/miden-base?branch=next#0b0a2d8d955772583767ba656dd85a36694fa1f1" dependencies = [ "async-trait", "miden-lib", diff --git a/Cargo.toml b/Cargo.toml index 766387121c..2de38e5e7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,10 @@ repository = "https://github.com/0xPolygonMiden/miden-client" [workspace.dependencies] async-trait = "0.1" -miden-lib = { version = "0.8", default-features = false } -miden-objects = { version = "0.8", default-features = false } -miden-tx = { version = "0.8", default-features = false, features = ["async"] } -miden-proving-service-client = { version = "0.8", default-features = false, features = ["tx-prover"] } +miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false } +miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false } +miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false, features = ["async"] } +miden-proving-service-client = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false, features = ["tx-prover"] } miette = { version = "7.2", features = ["fancy"] } rand = { version = "0.9" } serde = { version = "1.0", features = ["derive"] } diff --git a/Makefile b/Makefile index 77dade20c5..c5ca683094 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,11 @@ WARNINGS=RUSTDOCFLAGS="-D warnings" NODE_DIR="miden-node" NODE_REPO="https://github.com/0xPolygonMiden/miden-node.git" -NODE_BRANCH="main" +NODE_BRANCH="next" PROVER_DIR="miden-base" PROVER_REPO="https://github.com/0xPolygonMiden/miden-base.git" -PROVER_BRANCH="main" +PROVER_BRANCH="next" PROVER_FEATURES_TESTING=--features "testing" PROVER_PORT=50051 diff --git a/bin/miden-cli/src/tests.rs b/bin/miden-cli/src/tests.rs index 3f94559d6b..600bd425fc 100644 --- a/bin/miden-cli/src/tests.rs +++ b/bin/miden-cli/src/tests.rs @@ -112,7 +112,7 @@ async fn test_mint_with_untracked_account() { // ================================================================================================ // Only one faucet is being created on the genesis block -const GENESIS_ACCOUNTS_FILENAMES: [&str; 1] = ["account_0.mac"]; +const GENESIS_ACCOUNTS_FILENAMES: [&str; 1] = ["account.mac"]; // This tests that it's possible to import the genesis accounts and interact with them. To do so it: // diff --git a/crates/rust-client/Cargo.toml b/crates/rust-client/Cargo.toml index 8400b5193a..2d14a1ee3a 100644 --- a/crates/rust-client/Cargo.toml +++ b/crates/rust-client/Cargo.toml @@ -66,7 +66,7 @@ uuid = { version = "1.10", features = ["serde", "v4"] } web-sys = { version = "0.3", features = ["console"]} [build-dependencies] -miden-node-proto-build = { version = "0.8.0", default-features = false } +miden-node-proto-build = { git = "https://github.com/0xPolygonMiden/miden-node", branch = "next", default-features = false } miden-lib = { workspace = true } miden-objects = { workspace = true } miette = { workspace = true } diff --git a/crates/rust-client/src/rpc/domain/account.rs b/crates/rust-client/src/rpc/domain/account.rs index 05a4cdae20..6e7277b689 100644 --- a/crates/rust-client/src/rpc/domain/account.rs +++ b/crates/rust-client/src/rpc/domain/account.rs @@ -8,7 +8,7 @@ use core::fmt::{self, Debug, Display, Formatter}; use miden_objects::{ Digest, Felt, account::{Account, AccountCode, AccountHeader, AccountId, AccountStorageHeader}, - block::BlockNumber, + block::{AccountWitness, BlockNumber}, crypto::merkle::{MerklePath, SmtProof}, }; use miden_tx::utils::{Deserializable, Serializable, ToHex}; @@ -20,7 +20,10 @@ use crate::rpc::{ generated::{ account::{AccountHeader as ProtoAccountHeader, AccountId as ProtoAccountId}, requests::get_account_proofs_request, - responses::{AccountStateHeader as ProtoAccountStateHeader, StorageSlotMapProof}, + responses::{ + AccountStateHeader as ProtoAccountStateHeader, AccountWitness as ProtoAccountWitness, + StorageSlotMapProof, + }, }, }; @@ -96,7 +99,7 @@ impl Debug for ProtoAccountId { } // INTO PROTO ACCOUNT ID -// ------------------------------------------------------------------------------------------------ +// ================================================================================================ impl From for ProtoAccountId { fn from(account_id: AccountId) -> Self { @@ -105,7 +108,7 @@ impl From for ProtoAccountId { } // FROM PROTO ACCOUNT ID -// ------------------------------------------------------------------------------------------------ +// ================================================================================================ impl TryFrom for AccountId { type Error = RpcConversionError; @@ -148,7 +151,7 @@ impl ProtoAccountHeader { } // FROM PROTO ACCOUNT HEADERS -// ------------------------------------------------------------------------------------------------ +// ================================================================================================ impl ProtoAccountStateHeader { /// Converts the RPC response into `StateHeaders`. @@ -229,7 +232,9 @@ impl ProtoAccountStateHeader { pub type AccountProofs = (BlockNumber, Vec); /// Account state headers. +#[derive(Clone, Debug)] pub struct StateHeaders { + // TODO: should this be renamed? or storage_slots moved to AccountProof pub account_header: AccountHeader, pub storage_header: AccountStorageHeader, pub code: AccountCode, @@ -237,32 +242,27 @@ pub struct StateHeaders { } /// Represents a proof of existence of an account's state at a specific block number. +#[derive(Clone, Debug)] pub struct AccountProof { - /// Account ID. - account_id: AccountId, - /// Authentication path from the `account_root` of the block header to the account. - merkle_proof: MerklePath, - /// Account commitment for the current state. - account_commitment: Digest, + /// Account witness. + account_witness: AccountWitness, /// State headers of public accounts. state_headers: Option, } impl AccountProof { pub fn new( - account_id: AccountId, - merkle_proof: MerklePath, - account_commitment: Digest, + account_witness: AccountWitness, state_headers: Option, ) -> Result { if let Some(StateHeaders { account_header, storage_header: _, code, .. }) = &state_headers { - if account_header.commitment() != account_commitment { + if account_header.commitment() != account_witness.state_commitment() { return Err(AccountProofError::InconsistentAccountCommitment); } - if account_id != account_header.id() { + if account_header.id() != account_witness.id() { return Err(AccountProofError::InconsistentAccountId); } if code.commitment() != account_header.code_commitment() { @@ -270,16 +270,11 @@ impl AccountProof { } } - Ok(Self { - account_id, - merkle_proof, - account_commitment, - state_headers, - }) + Ok(Self { account_witness, state_headers }) } pub fn account_id(&self) -> AccountId { - self.account_id + self.account_witness.id() } pub fn account_header(&self) -> Option<&AccountHeader> { @@ -303,16 +298,45 @@ impl AccountProof { } pub fn account_commitment(&self) -> Digest { - self.account_commitment + self.account_witness.state_commitment() + } + + pub fn account_witness(&self) -> &AccountWitness { + &self.account_witness } pub fn merkle_proof(&self) -> &MerklePath { - &self.merkle_proof + self.account_witness.path() } /// Deconstructs `AccountProof` into its individual parts. - pub fn into_parts(self) -> (AccountId, MerklePath, Digest, Option) { - (self.account_id, self.merkle_proof, self.account_commitment, self.state_headers) + pub fn into_parts(self) -> (AccountWitness, Option) { + (self.account_witness, self.state_headers) + } +} + +// ACCOUNT WITNESS +// ================================================================================================ + +impl TryFrom for AccountWitness { + type Error = RpcError; + + fn try_from(account_witness: ProtoAccountWitness) -> Result { + let state_commitment = account_witness + .commitment + .ok_or(RpcError::ExpectedDataMissing(String::from("AccountWitness.StateCommitment")))? + .try_into()?; + let merkle_path = account_witness + .path + .ok_or(RpcError::ExpectedDataMissing(String::from("AccountWitness.MerklePath")))? + .try_into()?; + let account_id = account_witness + .witness_id + .ok_or(RpcError::ExpectedDataMissing(String::from("AccountWitness.WitnessId")))? + .try_into()?; + + let witness = AccountWitness::new(account_id, state_commitment, merkle_path).unwrap(); + Ok(witness) } } diff --git a/crates/rust-client/src/rpc/generated/nostd/requests.rs b/crates/rust-client/src/rpc/generated/nostd/requests.rs index 33b0cf1aed..df7904d3bb 100644 --- a/crates/rust-client/src/rpc/generated/nostd/requests.rs +++ b/crates/rust-client/src/rpc/generated/nostd/requests.rs @@ -214,3 +214,49 @@ pub mod get_account_proofs_request { pub map_keys: ::prost::alloc::vec::Vec, } } +/// Returns a list of unconsumed network notes using pagination. +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetUnconsumedNetworkNotesRequest { + /// An opaque token used to paginate through the notes. + /// + /// This should be null on the first call, and set to the response + /// token until the response token is null, at which point all data + /// has been fetched. + #[prost(uint64, optional, tag = "1")] + pub page_token: ::core::option::Option, + /// Number of notes to retrieve per page. + #[prost(uint64, tag = "2")] + pub page_size: u64, +} +/// Submit a list of network notes to the network transaction builder. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubmitNetworkNotesRequest { + /// Id of the transaction that created the notes. + #[prost(message, optional, tag = "1")] + pub transaction_id: ::core::option::Option, + /// The network notes to submit. + #[prost(message, repeated, tag = "2")] + pub note: ::prost::alloc::vec::Vec, +} +/// Update network transaction builder with transaction status changes. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateTransactionStatusRequest { + /// The list of updates for each transaction. + #[prost(message, repeated, tag = "1")] + pub updates: ::prost::alloc::vec::Vec< + update_transaction_status_request::TransactionUpdate, + >, +} +/// Nested message and enum types in `UpdateTransactionStatusRequest`. +pub mod update_transaction_status_request { + /// Represents the update for a single transaction. + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct TransactionUpdate { + /// Id of the transaction to update. + #[prost(message, optional, tag = "1")] + pub transaction_id: ::core::option::Option, + /// New status of the transaction. + #[prost(enumeration = "super::super::transaction::TransactionStatus", tag = "2")] + pub status: i32, + } +} diff --git a/crates/rust-client/src/rpc/generated/nostd/responses.rs b/crates/rust-client/src/rpc/generated/nostd/responses.rs index 9c13f0958f..bfd3baf09f 100644 --- a/crates/rust-client/src/rpc/generated/nostd/responses.rs +++ b/crates/rust-client/src/rpc/generated/nostd/responses.rs @@ -81,19 +81,23 @@ pub struct SyncNoteResponse { #[prost(message, repeated, tag = "4")] pub notes: ::prost::alloc::vec::Vec, } -/// An account returned as a response to the `GetBlockInputs`. +/// An account witness returned as a response to the `GetBlockInputs`. #[derive(Clone, PartialEq, ::prost::Message)] pub struct AccountWitness { - /// The account ID. + /// Account ID for which this proof is requested. #[prost(message, optional, tag = "1")] pub account_id: ::core::option::Option, - /// The latest account state commitment used as the initial state of the requested block. - /// This will be the zero digest if the account doesn't exist. + /// The account ID within the proof, which may be different from the above account ID. + /// This can happen when the requested account ID's prefix matches the prefix of an existing + /// account ID in the tree. Then the witness will prove inclusion of this witness ID in the tree. #[prost(message, optional, tag = "2")] - pub initial_state_commitment: ::core::option::Option, - /// Merkle path to verify the account's inclusion in the account tree. + pub witness_id: ::core::option::Option, + /// The state commitment whose inclusion the witness proves. #[prost(message, optional, tag = "3")] - pub proof: ::core::option::Option, + pub commitment: ::core::option::Option, + /// The merkle path of the state commitment in the account tree. + #[prost(message, optional, tag = "4")] + pub path: ::core::option::Option, } /// A nullifier returned as a response to the `GetBlockInputs`. #[derive(Clone, PartialEq, ::prost::Message)] @@ -220,27 +224,21 @@ pub struct GetAccountStateDeltaResponse { /// Represents the result of getting account proofs. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetAccountProofsResponse { - /// Block number at which the state of the account was returned. + /// Block number at which the state of the accounts is returned. #[prost(fixed32, tag = "1")] pub block_num: u32, /// List of account state infos for the requested account keys. #[prost(message, repeated, tag = "2")] pub account_proofs: ::prost::alloc::vec::Vec, } -/// A single account proof returned as a response to the `GetAccountProofs`. +/// A single account proof returned as a response to `GetAccountProofs`. #[derive(Clone, PartialEq, ::prost::Message)] pub struct AccountProofsResponse { - /// Account ID. + /// The account witness for the current state commitment of one account ID. #[prost(message, optional, tag = "1")] - pub account_id: ::core::option::Option, - /// Account commitment. - #[prost(message, optional, tag = "2")] - pub account_commitment: ::core::option::Option, - /// Authentication path from the `account_root` of the block header to the account. - #[prost(message, optional, tag = "3")] - pub account_proof: ::core::option::Option, + pub witness: ::core::option::Option, /// State header for public accounts. Filled only if `include_headers` flag is set to `true`. - #[prost(message, optional, tag = "4")] + #[prost(message, optional, tag = "2")] pub state_header: ::core::option::Option, } /// State header for public accounts. @@ -270,3 +268,18 @@ pub struct StorageSlotMapProof { #[prost(bytes = "vec", tag = "2")] pub smt_proof: ::prost::alloc::vec::Vec, } +/// Represents the result of getting the unconsumed network notes. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetUnconsumedNetworkNotesResponse { + /// An opaque pagination token. + /// + /// Use this in your next request to get the next + /// set of data. + /// + /// Will be null once there is no more data remaining. + #[prost(uint64, optional, tag = "1")] + pub next_token: ::core::option::Option, + /// The list of unconsumed network notes. + #[prost(message, repeated, tag = "2")] + pub notes: ::prost::alloc::vec::Vec, +} diff --git a/crates/rust-client/src/rpc/generated/nostd/transaction.rs b/crates/rust-client/src/rpc/generated/nostd/transaction.rs index 3439e78eae..b60bc53e4b 100644 --- a/crates/rust-client/src/rpc/generated/nostd/transaction.rs +++ b/crates/rust-client/src/rpc/generated/nostd/transaction.rs @@ -19,3 +19,29 @@ pub struct TransactionSummary { #[prost(message, optional, tag = "3")] pub account_id: ::core::option::Option, } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum TransactionStatus { + Commited = 0, + Failed = 1, +} +impl TransactionStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(self) -> &'static str { + match self { + Self::Commited => "COMMITED", + Self::Failed => "FAILED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "COMMITED" => Some(Self::Commited), + "FAILED" => Some(Self::Failed), + _ => None, + } + } +} diff --git a/crates/rust-client/src/rpc/generated/std/requests.rs b/crates/rust-client/src/rpc/generated/std/requests.rs index 33b0cf1aed..df7904d3bb 100644 --- a/crates/rust-client/src/rpc/generated/std/requests.rs +++ b/crates/rust-client/src/rpc/generated/std/requests.rs @@ -214,3 +214,49 @@ pub mod get_account_proofs_request { pub map_keys: ::prost::alloc::vec::Vec, } } +/// Returns a list of unconsumed network notes using pagination. +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetUnconsumedNetworkNotesRequest { + /// An opaque token used to paginate through the notes. + /// + /// This should be null on the first call, and set to the response + /// token until the response token is null, at which point all data + /// has been fetched. + #[prost(uint64, optional, tag = "1")] + pub page_token: ::core::option::Option, + /// Number of notes to retrieve per page. + #[prost(uint64, tag = "2")] + pub page_size: u64, +} +/// Submit a list of network notes to the network transaction builder. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubmitNetworkNotesRequest { + /// Id of the transaction that created the notes. + #[prost(message, optional, tag = "1")] + pub transaction_id: ::core::option::Option, + /// The network notes to submit. + #[prost(message, repeated, tag = "2")] + pub note: ::prost::alloc::vec::Vec, +} +/// Update network transaction builder with transaction status changes. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateTransactionStatusRequest { + /// The list of updates for each transaction. + #[prost(message, repeated, tag = "1")] + pub updates: ::prost::alloc::vec::Vec< + update_transaction_status_request::TransactionUpdate, + >, +} +/// Nested message and enum types in `UpdateTransactionStatusRequest`. +pub mod update_transaction_status_request { + /// Represents the update for a single transaction. + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct TransactionUpdate { + /// Id of the transaction to update. + #[prost(message, optional, tag = "1")] + pub transaction_id: ::core::option::Option, + /// New status of the transaction. + #[prost(enumeration = "super::super::transaction::TransactionStatus", tag = "2")] + pub status: i32, + } +} diff --git a/crates/rust-client/src/rpc/generated/std/responses.rs b/crates/rust-client/src/rpc/generated/std/responses.rs index 9c13f0958f..bfd3baf09f 100644 --- a/crates/rust-client/src/rpc/generated/std/responses.rs +++ b/crates/rust-client/src/rpc/generated/std/responses.rs @@ -81,19 +81,23 @@ pub struct SyncNoteResponse { #[prost(message, repeated, tag = "4")] pub notes: ::prost::alloc::vec::Vec, } -/// An account returned as a response to the `GetBlockInputs`. +/// An account witness returned as a response to the `GetBlockInputs`. #[derive(Clone, PartialEq, ::prost::Message)] pub struct AccountWitness { - /// The account ID. + /// Account ID for which this proof is requested. #[prost(message, optional, tag = "1")] pub account_id: ::core::option::Option, - /// The latest account state commitment used as the initial state of the requested block. - /// This will be the zero digest if the account doesn't exist. + /// The account ID within the proof, which may be different from the above account ID. + /// This can happen when the requested account ID's prefix matches the prefix of an existing + /// account ID in the tree. Then the witness will prove inclusion of this witness ID in the tree. #[prost(message, optional, tag = "2")] - pub initial_state_commitment: ::core::option::Option, - /// Merkle path to verify the account's inclusion in the account tree. + pub witness_id: ::core::option::Option, + /// The state commitment whose inclusion the witness proves. #[prost(message, optional, tag = "3")] - pub proof: ::core::option::Option, + pub commitment: ::core::option::Option, + /// The merkle path of the state commitment in the account tree. + #[prost(message, optional, tag = "4")] + pub path: ::core::option::Option, } /// A nullifier returned as a response to the `GetBlockInputs`. #[derive(Clone, PartialEq, ::prost::Message)] @@ -220,27 +224,21 @@ pub struct GetAccountStateDeltaResponse { /// Represents the result of getting account proofs. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetAccountProofsResponse { - /// Block number at which the state of the account was returned. + /// Block number at which the state of the accounts is returned. #[prost(fixed32, tag = "1")] pub block_num: u32, /// List of account state infos for the requested account keys. #[prost(message, repeated, tag = "2")] pub account_proofs: ::prost::alloc::vec::Vec, } -/// A single account proof returned as a response to the `GetAccountProofs`. +/// A single account proof returned as a response to `GetAccountProofs`. #[derive(Clone, PartialEq, ::prost::Message)] pub struct AccountProofsResponse { - /// Account ID. + /// The account witness for the current state commitment of one account ID. #[prost(message, optional, tag = "1")] - pub account_id: ::core::option::Option, - /// Account commitment. - #[prost(message, optional, tag = "2")] - pub account_commitment: ::core::option::Option, - /// Authentication path from the `account_root` of the block header to the account. - #[prost(message, optional, tag = "3")] - pub account_proof: ::core::option::Option, + pub witness: ::core::option::Option, /// State header for public accounts. Filled only if `include_headers` flag is set to `true`. - #[prost(message, optional, tag = "4")] + #[prost(message, optional, tag = "2")] pub state_header: ::core::option::Option, } /// State header for public accounts. @@ -270,3 +268,18 @@ pub struct StorageSlotMapProof { #[prost(bytes = "vec", tag = "2")] pub smt_proof: ::prost::alloc::vec::Vec, } +/// Represents the result of getting the unconsumed network notes. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetUnconsumedNetworkNotesResponse { + /// An opaque pagination token. + /// + /// Use this in your next request to get the next + /// set of data. + /// + /// Will be null once there is no more data remaining. + #[prost(uint64, optional, tag = "1")] + pub next_token: ::core::option::Option, + /// The list of unconsumed network notes. + #[prost(message, repeated, tag = "2")] + pub notes: ::prost::alloc::vec::Vec, +} diff --git a/crates/rust-client/src/rpc/generated/std/transaction.rs b/crates/rust-client/src/rpc/generated/std/transaction.rs index 3439e78eae..b60bc53e4b 100644 --- a/crates/rust-client/src/rpc/generated/std/transaction.rs +++ b/crates/rust-client/src/rpc/generated/std/transaction.rs @@ -19,3 +19,29 @@ pub struct TransactionSummary { #[prost(message, optional, tag = "3")] pub account_id: ::core::option::Option, } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum TransactionStatus { + Commited = 0, + Failed = 1, +} +impl TransactionStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(self) -> &'static str { + match self { + Self::Commited => "COMMITED", + Self::Failed => "FAILED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "COMMITED" => Some(Self::Commited), + "FAILED" => Some(Self::Failed), + _ => None, + } + } +} diff --git a/crates/rust-client/src/rpc/tonic_client/mod.rs b/crates/rust-client/src/rpc/tonic_client/mod.rs index a333c663a9..07c6b04a67 100644 --- a/crates/rust-client/src/rpc/tonic_client/mod.rs +++ b/crates/rust-client/src/rpc/tonic_client/mod.rs @@ -10,7 +10,7 @@ use async_trait::async_trait; use miden_objects::{ Digest, account::{Account, AccountCode, AccountDelta, AccountId}, - block::{BlockHeader, BlockNumber, ProvenBlock}, + block::{AccountWitness, BlockHeader, BlockNumber, ProvenBlock}, crypto::merkle::{MerklePath, MmrProof, SmtProof}, note::{Note, NoteId, NoteInclusionProof, NoteTag, Nullifier}, transaction::ProvenTransaction, @@ -341,35 +341,25 @@ impl NodeRpcClient for TonicRpcClient { } for account in response.account_proofs { - let merkle_proof = account - .account_proof - .ok_or(RpcError::ExpectedDataMissing("AccountProof".to_string()))? + let account_witness: AccountWitness = account + .witness + .ok_or(RpcError::ExpectedDataMissing("AccountWitness".to_string()))? .try_into()?; - let account_commitment = account - .account_commitment - .ok_or(RpcError::ExpectedDataMissing("AccountCommitment".to_string()))? - .try_into()?; - - let account_id: AccountId = account - .account_id - .ok_or(RpcError::ExpectedDataMissing("AccountId".to_string()))? - .try_into()?; - - // Because we set `include_headers` to true, for any public account we requeted we + // Because we set `include_headers` to true, for any public account we requested we // should have the corresponding `state_header` field - let headers = if account_id.is_public() { + let headers = if account_witness.id().is_public() { Some( account .state_header .ok_or(RpcError::ExpectedDataMissing("Account.StateHeader".to_string()))? - .into_domain(account_id, &known_account_codes)?, + .into_domain(account_witness.id(), &known_account_codes)?, ) } else { None }; - let proof = AccountProof::new(account_id, merkle_proof, account_commitment, headers) + let proof = AccountProof::new(account_witness, headers) .map_err(|err| RpcError::InvalidResponse(err.to_string()))?; account_proofs.push(proof); } diff --git a/crates/rust-client/src/transaction/mod.rs b/crates/rust-client/src/transaction/mod.rs index 87be3b2e18..96df14dc7c 100644 --- a/crates/rust-client/src/transaction/mod.rs +++ b/crates/rust-client/src/transaction/mod.rs @@ -79,8 +79,7 @@ use miden_objects::{ AssetError, Digest, Felt, Word, ZERO, account::{Account, AccountCode, AccountDelta, AccountId}, asset::{Asset, NonFungibleAsset}, - block::BlockNumber, - crypto::merkle::MerklePath, + block::{AccountWitness, BlockNumber}, note::{Note, NoteDetails, NoteId, NoteTag}, transaction::{InputNotes, TransactionArgs}, vm::AdviceInputs, @@ -910,7 +909,7 @@ impl Client { .remove(account_id) .expect("Proof was requested and received"); - let (foreign_account_inputs, merkle_path) = account_proof.try_into()?; + let (foreign_account_inputs, account_witness) = account_proof.try_into()?; // Update our foreign account code cache self.store @@ -920,16 +919,15 @@ impl Client { ) .await?; - (foreign_account_inputs, merkle_path) + (foreign_account_inputs, account_witness) }, ForeignAccount::Private(foreign_account_inputs) => { let account_id = foreign_account_inputs.account_header().id(); let proof = account_proofs .remove(&account_id) .expect("Proof was requested and received"); - let merkle_path = proof.merkle_proof(); - (foreign_account_inputs.clone(), merkle_path.clone()) + (foreign_account_inputs.clone(), proof.account_witness().clone()) }, }; @@ -1020,7 +1018,7 @@ fn extend_advice_inputs_for_foreign_account( tx_args: &mut TransactionArgs, tx_executor: &mut TransactionExecutor, foreign_account_inputs: ForeignAccountInputs, - merkle_path: &MerklePath, + account_witness: &AccountWitness, ) -> Result<(), ClientError> { let (account_header, storage_header, account_code, proofs) = foreign_account_inputs.into_parts(); @@ -1050,10 +1048,17 @@ fn extend_advice_inputs_for_foreign_account( .extend_advice_map(core::iter::once((proof.leaf().hash(), proof.leaf().to_elements()))); } + let account_leaf = account_witness.leaf(); + let account_leaf_hash = account_leaf.hash(); + // Extend the advice inputs with Merkle store data tx_args.extend_merkle_store( - merkle_path.inner_nodes(account_id.prefix().as_u64(), account_header.commitment())?, + account_witness + .path() + .inner_nodes(account_id.prefix().as_u64(), account_leaf_hash)?, ); + // populate advice map with the account's leaf + tx_args.extend_advice_map([(account_leaf_hash, account_leaf.to_elements())]); tx_executor.load_account_code(&account_code); diff --git a/crates/rust-client/src/transaction/request/foreign.rs b/crates/rust-client/src/transaction/request/foreign.rs index ef407a1eae..c7e931b1d1 100644 --- a/crates/rust-client/src/transaction/request/foreign.rs +++ b/crates/rust-client/src/transaction/request/foreign.rs @@ -4,7 +4,8 @@ use core::cmp::Ordering; use miden_objects::{ account::{Account, AccountCode, AccountHeader, AccountId, AccountStorageHeader, StorageSlot}, - crypto::merkle::{MerklePath, SmtProof}, + block::AccountWitness, + crypto::merkle::SmtProof, }; use miden_tx::utils::{Deserializable, DeserializationError, Serializable}; @@ -272,11 +273,12 @@ impl Deserializable for ForeignAccountInputs { } } -impl TryFrom for (ForeignAccountInputs, MerklePath) { +impl TryFrom for (ForeignAccountInputs, AccountWitness) { type Error = TransactionRequestError; fn try_from(value: AccountProof) -> Result { - let (_, merkle_proof, _, state_headers) = value.into_parts(); + let (account_witness, state_headers) = value.into_parts(); + if let Some(StateHeaders { account_header, storage_header, @@ -287,7 +289,7 @@ impl TryFrom for (ForeignAccountInputs, MerklePath) { // discard slot indices - not needed for execution let slots = storage_slots.into_iter().flat_map(|(_, slots)| slots).collect(); let inputs = ForeignAccountInputs::new(account_header, storage_header, code, slots); - return Ok((inputs, merkle_proof)); + return Ok((inputs, account_witness)); } Err(TransactionRequestError::ForeignAccountDataMissing) } diff --git a/crates/web-client/package-lock.json b/crates/web-client/package-lock.json index 76101a0b2a..46d7ce3b6d 100644 --- a/crates/web-client/package-lock.json +++ b/crates/web-client/package-lock.json @@ -1,12 +1,12 @@ { "name": "@demox-labs/miden-sdk", - "version": "0.8.1-next.0", + "version": "0.8.1-next.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@demox-labs/miden-sdk", - "version": "0.8.1-next.0", + "version": "0.8.1-next.1", "dependencies": { "chai-as-promised": "^8.0.0", "dexie": "^4.0.1", diff --git a/crates/web-client/yarn.lock b/crates/web-client/yarn.lock index 3ac001b057..67cc394af3 100644 --- a/crates/web-client/yarn.lock +++ b/crates/web-client/yarn.lock @@ -93,7 +93,7 @@ "@nodelib/fs.stat" "2.0.5" run-parallel "^1.1.9" -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": +"@nodelib/fs.stat@^2.0.2", "@nodelib/fs.stat@2.0.5": version "2.0.5" resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== @@ -180,7 +180,7 @@ dependencies: "@shikijs/types" "3.2.1" -"@shikijs/types@3.2.1", "@shikijs/types@^3.2.1": +"@shikijs/types@^3.2.1", "@shikijs/types@3.2.1": version "3.2.1" resolved "https://registry.npmjs.org/@shikijs/types/-/types-3.2.1.tgz" integrity sha512-/NTWAk4KE2M8uac0RhOsIhYQf4pdU0OywQuYDGIGAJ6Mjunxl2cGiuLkvu4HLCMn+OTTLRWkjZITp+aYJv60yA== @@ -465,6 +465,11 @@ binary-extensions@^2.0.0: resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz" integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== +binaryen@^121.0.0: + version "121.0.0" + resolved "https://registry.npmjs.org/binaryen/-/binaryen-121.0.0.tgz" + integrity sha512-St5LX+CmVdDQMf+DDHWdne7eDK+8tH9TE4Kc+Xk3s5+CzVYIKeJbWuXgsKVbkdLJXGUc2eflFqjThQy555mBag== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" @@ -538,7 +543,7 @@ chai-as-promised@^8.0.0: dependencies: check-error "^2.0.0" -chai@^5.1.1: +chai@^5.1.1, "chai@>= 2.1.2 < 6": version "5.1.1" resolved "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz" integrity sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA== @@ -637,16 +642,16 @@ color-convert@^2.0.1: dependencies: color-name "~1.1.4" -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" - integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== - color-name@~1.1.4: version "1.1.4" resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + colorette@^1.1.0: version "1.4.0" resolved "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz" @@ -718,13 +723,6 @@ data-uri-to-buffer@^6.0.2: resolved "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz" integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== -debug@4, debug@^4.1.1, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6: - version "4.3.6" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz" - integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== - dependencies: - ms "2.1.2" - debug@^3.2.7: version "3.2.7" resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz" @@ -732,6 +730,13 @@ debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.1.1, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@4: + version "4.3.6" + resolved "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz" + integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== + dependencies: + ms "2.1.2" + decamelize@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz" @@ -765,7 +770,7 @@ degenerator@^5.0.0: escodegen "^2.1.0" esprima "^4.0.1" -devtools-protocol@0.0.1330662: +devtools-protocol@*, devtools-protocol@0.0.1330662: version "0.0.1330662" resolved "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1330662.tgz" integrity sha512-pzh6YQ8zZfz3iKlCvgzVCu22NdpZ8hNmwU6WnQjNVquh0A9iVosPtNLWDwaWVGyrntQlltPFztTMK5Cg6lfCuw== @@ -1102,7 +1107,18 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.3, glob@^8.1.0: +glob@^8.0.3: + version "8.1.0" + resolved "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + +glob@^8.1.0: version "8.1.0" resolved "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz" integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== @@ -1538,7 +1554,14 @@ minimatch@^5.0.1, minimatch@^5.1.6: dependencies: brace-expansion "^2.0.1" -minimatch@^9.0.4, minimatch@^9.0.5: +minimatch@^9.0.4: + version "9.0.5" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^9.0.5: version "9.0.5" resolved "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz" integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== @@ -1606,16 +1629,16 @@ mocha@^10.7.3: yargs-parser "^20.2.9" yargs-unparser "^2.0.0" -ms@2.1.2: - version "2.1.2" - resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +ms@2.1.2: + version "2.1.2" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + netmask@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz" @@ -1944,7 +1967,7 @@ rollup-plugin-copy@^3.5.0: globby "10.0.1" is-plain-object "^3.0.0" -rollup@^3.27.2: +rollup@^1.20.0||^2.0.0||^3.0.0||^4.0.0, rollup@^2.68.0||^3.0.0||^4.0.0, rollup@^2.78.0||^3.0.0||^4.0.0, rollup@^3.27.2: version "3.29.4" resolved "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz" integrity sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw== @@ -1958,7 +1981,7 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -safe-buffer@5.1.2, safe-buffer@^5.1.0: +safe-buffer@^5.1.0, safe-buffer@5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== @@ -2236,7 +2259,7 @@ typedoc-plugin-markdown@^4.6.0: resolved "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.6.1.tgz" integrity sha512-SrJv9zkpCWdG1cvtWniFU6M7MkCZuheN2R3fuqDPF+O+PeZ8bzmfj1ju/BJwoPWIKyFJVPhK8Sg6tBrM1y+VoA== -typedoc@^0.28.1: +typedoc@^0.28.1, typedoc@0.28.x: version "0.28.1" resolved "https://registry.npmjs.org/typedoc/-/typedoc-0.28.1.tgz" integrity sha512-Mn2VPNMaxoe/hlBiLriG4U55oyAa3Xo+8HbtEwV7F5WEOPXqtxzGuMZhJYHaqFJpajeQ6ZDUC2c990NAtTbdgw== @@ -2247,7 +2270,7 @@ typedoc@^0.28.1: minimatch "^9.0.5" yaml "^2.7.0 " -typescript@^5.5.4: +typescript@^5.5.4, typescript@>=2.7, typescript@>=4.9.5, "typescript@5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x": version "5.5.4" resolved "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz" integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==