From 4bef43bf44db5ee10ae2cf421cb3cabba3980701 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 20:00:35 -0300 Subject: [PATCH 01/17] feat: Use expected notes from TransactionResult --- src/cli/notes.rs | 24 +++--- src/client/note_screener.rs | 10 +-- src/client/notes.rs | 2 +- src/client/sync.rs | 2 +- src/client/transactions/mod.rs | 107 ++++++++++++------------- src/errors.rs | 8 -- src/store/sqlite_store/transactions.rs | 17 ++-- 7 files changed, 79 insertions(+), 91 deletions(-) diff --git a/src/cli/notes.rs b/src/cli/notes.rs index 88d5c6be7..23dbed9b7 100644 --- a/src/cli/notes.rs +++ b/src/cli/notes.rs @@ -481,12 +481,11 @@ fn note_record_type(note_record_metadata: Option<&NoteMetadata>) -> String { #[cfg(test)] mod tests { - use std::env::temp_dir; + use std::{env::temp_dir, rc::Rc}; use miden_client::{ client::{ - authenticator::{self, StoreAuthenticator}, - get_random_coin, + authenticator::StoreAuthenticator, get_random_coin, transactions::transaction_request::TransactionTemplate, }, config::{ClientConfig, Endpoint, RpcConfig}, @@ -495,15 +494,16 @@ mod tests { mock_full_chain_mmr_and_notes, mock_fungible_faucet_account, mock_notes, MockClient, MockRpcApi, }, - store::{sqlite_store::SqliteStore, AuthInfo, InputNoteRecord, NoteFilter, Store}, + store::{sqlite_store::SqliteStore, InputNoteRecord, NoteFilter}, }; use miden_lib::transaction::TransactionKernel; use miden_objects::{ - accounts::{AccountId, ACCOUNT_ID_FUNGIBLE_FAUCET_OFF_CHAIN}, + accounts::{account_id::testing::ACCOUNT_ID_FUNGIBLE_FAUCET_OFF_CHAIN, AccountId}, assets::FungibleAsset, crypto::dsa::rpo_falcon512::SecretKey, notes::Note, }; + use miden_tx::AuthSecretKey; use uuid::Uuid; use crate::cli::{ @@ -522,8 +522,12 @@ mod tests { ); let rng = get_random_coin(); - let store = SqliteStore::new((&client_config).into()).unwrap(); - let authenticator = StoreAuthenticator::new_with_rng(Rc::new(store), rng); + let store = { + let sqlite_store = SqliteStore::new((&client_config).into()).unwrap(); + Rc::new(sqlite_store) + }; + + let authenticator = StoreAuthenticator::new_with_rng(store.clone(), rng); let mut client = MockClient::new( MockRpcApi::new(&Endpoint::default().to_string()), rng, @@ -590,7 +594,9 @@ mod tests { ); client.sync_state().await.unwrap(); - client.insert_account(&faucet, None, &AuthInfo::RpoFalcon512(key_pair)).unwrap(); + client + .insert_account(&faucet, None, &AuthSecretKey::RpoFalcon512(key_pair)) + .unwrap(); // Ensure client has no notes assert!(client.get_input_notes(NoteFilter::All).unwrap().is_empty()); @@ -659,7 +665,7 @@ mod tests { let rng = get_random_coin(); let store = { let sqlite_store = SqliteStore::new((&client_config).into()).unwrap(); - Rc::new(store) + Rc::new(sqlite_store) }; let authenticator = StoreAuthenticator::new_with_rng(store.clone(), rng); let mut client = MockClient::new( diff --git a/src/client/note_screener.rs b/src/client/note_screener.rs index a10475dab..d5a992c84 100644 --- a/src/client/note_screener.rs +++ b/src/client/note_screener.rs @@ -1,4 +1,4 @@ -use alloc::collections::BTreeSet; +use alloc::{collections::BTreeSet, rc::Rc}; use core::fmt; use miden_objects::{accounts::AccountId, assets::Asset, notes::Note, Word}; @@ -34,12 +34,12 @@ impl fmt::Display for NoteRelevance { } } -pub struct NoteScreener<'a, S: Store> { - store: &'a S, +pub struct NoteScreener { + store: Rc, } -impl<'a, S: Store> NoteScreener<'a, S> { - pub fn new(store: &'a S) -> Self { +impl NoteScreener { + pub fn new(store: Rc) -> Self { Self { store } } diff --git a/src/client/notes.rs b/src/client/notes.rs index b1d4df958..9fab2b5d2 100644 --- a/src/client/notes.rs +++ b/src/client/notes.rs @@ -45,7 +45,7 @@ impl Client ) -> Result, ClientError> { let commited_notes = self.store.get_input_notes(NoteFilter::Committed)?; - let note_screener = NoteScreener::new(self.store.as_ref()); + let note_screener = NoteScreener::new(self.store.clone()); let mut relevant_notes = Vec::new(); for input_note in commited_notes { diff --git a/src/client/sync.rs b/src/client/sync.rs index 0cfe1b082..62e74e903 100644 --- a/src/client/sync.rs +++ b/src/client/sync.rs @@ -437,7 +437,7 @@ impl Client // We'll only do the check for either incoming public notes or pending input notes as // output notes are not really candidates to be consumed here. - let note_screener = NoteScreener::new(self.store.as_ref()); + let note_screener = NoteScreener::new(self.store.clone()); // Find all relevant Input Notes using the note checker for input_note in committed_notes.updated_input_notes() { diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index f43e1ea54..2f973393e 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -1,4 +1,4 @@ -use alloc::collections::{BTreeMap, BTreeSet}; +use alloc::collections::BTreeMap; use miden_lib::notes::{create_p2id_note, create_p2idr_note}; use miden_objects::{ @@ -6,10 +6,10 @@ use miden_objects::{ assembly::ProgramAst, assets::FungibleAsset, crypto::rand::RpoRandomCoin, - notes::{Note, NoteId, NoteType}, + notes::{Note, NoteType}, transaction::{ - ExecutedTransaction, OutputNotes, ProvenTransaction, TransactionArgs, TransactionId, - TransactionScript, + ExecutedTransaction, OutputNote, OutputNotes, ProvenTransaction, TransactionArgs, + TransactionId, TransactionScript, }, Digest, Felt, Word, }; @@ -20,11 +20,11 @@ use rand::Rng; use tracing::info; use self::transaction_request::{PaymentTransactionData, TransactionRequest, TransactionTemplate}; -use super::{note_screener::NoteRelevance, rpc::NodeRpcClient, Client, FeltRng}; +use super::{rpc::NodeRpcClient, Client, FeltRng}; use crate::{ client::NoteScreener, errors::ClientError, - store::{Store, TransactionFilter}, + store::{InputNoteRecord, Store, TransactionFilter}, }; pub mod transaction_request; @@ -35,47 +35,56 @@ pub mod transaction_request; /// Represents the result of executing a transaction by the client /// /// It contains an [ExecutedTransaction], a list of [Note] that describe the details of the notes -/// created by the transaction execution, and a list of `usize` `relevant_notes` that contain the -/// indices of `output_notes` that are relevant to the client +/// created by the transaction execution, and a list of `relevant_notes` that contains the +/// `output_notes` that the client has to store as input notes, based on the NoteScreener output pub struct TransactionResult { executed_transaction: ExecutedTransaction, - output_notes: Vec, - relevant_notes: Option>>, + relevant_notes: Vec, } impl TransactionResult { - pub fn new(executed_transaction: ExecutedTransaction, created_notes: Vec) -> Self { - Self { - executed_transaction, - output_notes: created_notes, - relevant_notes: None, + /// Screens the output notes to store and track the relevant ones, and instantiates a [TransactionResult] + pub fn new( + executed_transaction: ExecutedTransaction, + note_screener: NoteScreener, + ) -> Result { + let mut relevant_notes = vec![]; + let output_notes = executed_transaction.output_notes().iter().map(|n| match n { + OutputNote::Full(n) => n, + OutputNote::Header(_) => panic!("ExecutedTransaction should have all note details"), + }); + for note in output_notes { + let account_relevance = note_screener.check_relevance(note)?; + + if !account_relevance.is_empty() { + relevant_notes.push(note.clone().into()); + } } + + let tx_result = Self { executed_transaction, relevant_notes }; + + Ok(tx_result) } pub fn executed_transaction(&self) -> &ExecutedTransaction { &self.executed_transaction } - pub fn created_notes(&self) -> &Vec { - &self.output_notes - } - - pub fn relevant_notes(&self) -> Vec<&Note> { - if let Some(relevant_notes) = &self.relevant_notes { - relevant_notes - .keys() - .map(|note_index| &self.output_notes[*note_index]) - .collect() - } else { - self.created_notes().iter().collect() - } + pub fn created_notes(&self) -> Vec { + // All output notes should be OutputNote::Full because they are shrinked + // only at the moment of proving (the ExecutedTransaction keeps all details) + self.executed_transaction + .output_notes() + .iter() + .map(|n| match n { + OutputNote::Full(n) => n.clone(), + OutputNote::Header(_) => panic!("ExecutedTransaction should have all note details"), + }) + .collect() } - pub fn set_relevant_notes( - &mut self, - relevant_notes: BTreeMap>, - ) { - self.relevant_notes = Some(relevant_notes); + pub fn relevant_notes(&self) -> &[InputNoteRecord] { + &self.relevant_notes } pub fn block_num(&self) -> u32 { @@ -228,8 +237,6 @@ impl Client let note_ids = transaction_request.get_input_note_ids(); - let output_notes = transaction_request.expected_output_notes().to_vec(); - // Execute the transaction and get the witness let executed_transaction = self.tx_executor.execute_transaction( account_id, @@ -238,20 +245,9 @@ impl Client transaction_request.into(), )?; - // Check that the expected output notes is a subset of the transaction's output notes - let tx_note_ids: BTreeSet = - executed_transaction.output_notes().iter().map(|n| n.id()).collect(); - - let missing_note_ids: Vec = output_notes - .iter() - .filter_map(|n| (!tx_note_ids.contains(&n.id())).then_some(n.id())) - .collect(); - - if !missing_note_ids.is_empty() { - return Err(ClientError::MissingOutputNotes(missing_note_ids)); - } + let screener = NoteScreener::new(self.store.clone()); - Ok(TransactionResult::new(executed_transaction, output_notes)) + TransactionResult::new(executed_transaction, screener) } /// Proves the specified transaction witness, submits it to the node, and stores the transaction in @@ -269,19 +265,18 @@ impl Client self.submit_proven_transaction_request(proven_transaction.clone()).await?; - let note_screener = NoteScreener::new(self.store.as_ref()); + let note_screener = NoteScreener::new(self.store.clone()); let mut relevant_notes = BTreeMap::new(); - for (idx, note) in tx_result.created_notes().iter().enumerate() { - let account_relevance = note_screener.check_relevance(note)?; - if !account_relevance.is_empty() { - relevant_notes.insert(idx, account_relevance); + for (idx, note) in tx_result.executed_transaction.output_notes().iter().enumerate() { + if let OutputNote::Full(output_note) = note { + let account_relevance = note_screener.check_relevance(output_note)?; + if !account_relevance.is_empty() { + relevant_notes.insert(idx, account_relevance); + } } } - let mut tx_result = tx_result; - tx_result.set_relevant_notes(relevant_notes); - // Transaction was proven and submitted to the node correctly, persist note details and update account self.store.apply_transaction(tx_result)?; diff --git a/src/errors.rs b/src/errors.rs index c65e8e567..996391a66 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -20,7 +20,6 @@ pub enum ClientError { DataDeserializationError(DeserializationError), HexParseError(HexParseError), ImportNewAccountWithoutSeed, - MissingOutputNotes(Vec), NoteError(NoteError), NoteRecordError(String), NoConsumableNoteForAccount(AccountId), @@ -45,13 +44,6 @@ impl fmt::Display for ClientError { f, "import account error: can't import a new account without its initial seed" ), - ClientError::MissingOutputNotes(note_ids) => { - write!( - f, - "transaction error: The transaction did not produce expected Note IDs: {}", - note_ids.iter().map(|&id| id.to_hex()).collect::>().join(", ") - ) - }, ClientError::NoConsumableNoteForAccount(account_id) => { write!(f, "No consumable note for account ID {}", account_id) }, diff --git a/src/store/sqlite_store/transactions.rs b/src/store/sqlite_store/transactions.rs index 437122db1..b489b4507 100644 --- a/src/store/sqlite_store/transactions.rs +++ b/src/store/sqlite_store/transactions.rs @@ -18,7 +18,7 @@ use super::{ use crate::{ client::transactions::{TransactionRecord, TransactionResult, TransactionStatus}, errors::StoreError, - store::{InputNoteRecord, OutputNoteRecord, TransactionFilter}, + store::{OutputNoteRecord, TransactionFilter}, }; pub(crate) const INSERT_TRANSACTION_QUERY: &str = @@ -86,12 +86,10 @@ impl SqliteStore { account.apply_delta(account_delta).map_err(StoreError::AccountError)?; - let created_input_notes = tx_result - .relevant_notes() - .into_iter() - .map(|note| InputNoteRecord::from(note.clone())) - .collect::>(); + // Save only input notes that we care for (based on the note screener assessment) + let created_input_notes = tx_result.relevant_notes().to_vec(); + // Save all output notes let created_output_notes = tx_result .created_notes() .iter() @@ -108,11 +106,8 @@ impl SqliteStore { update_account(&tx, &account)?; // Updates for notes - - // TODO: see if we should filter the input notes we store to keep notes we can consume with - // existing accounts - for note in &created_input_notes { - insert_input_note_tx(&tx, note)?; + for note in created_input_notes { + insert_input_note_tx(&tx, ¬e)?; } for note in &created_output_notes { From 04e6d3331b3b35325f1ec7ec492d188a26cf225c Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 20:13:03 -0300 Subject: [PATCH 02/17] fix: Re-add output note check --- README.md | 4 ++-- src/client/transactions/mod.rs | 32 +++++++++++++++++++++++++++++--- src/errors.rs | 8 ++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0f9fa53b9..728635c57 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The Miden client is still under heavy development and the project can be conside The Miden client currently consists of two components: - `miden-client` library, which can be used by other project to programmatically interact with the Miden rollup. -- `miden-client` binary which is a wrapper around the library exposing its functionality via a simple command-line interface (CLI). +- `miden` binary which is a wrapper around the library exposing its functionality via a simple command-line interface (CLI). The client's main responsibility is to maintain a partial view of the blockchain which allows for locally executing and proving transactions. It keeps a local store of various entities that periodically get updated by syncing with the node. @@ -54,7 +54,7 @@ You can either build from source with: cargo build --release ``` -Once the binary is built, you can find it on `./target/release/miden-client`. +Once the binary is built, you can find it on `./target/release/miden`. Or you can install the CLI from crates-io with: diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 2f973393e..4ff357811 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -1,12 +1,14 @@ -use alloc::collections::BTreeMap; +use alloc::collections::{BTreeMap, BTreeSet}; -use miden_lib::notes::{create_p2id_note, create_p2idr_note}; +use miden_lib::{ + notes::{create_p2id_note, create_p2idr_note}, +}; use miden_objects::{ accounts::{AccountDelta, AccountId}, assembly::ProgramAst, assets::FungibleAsset, crypto::rand::RpoRandomCoin, - notes::{Note, NoteType}, + notes::{Note, NoteId, NoteType}, transaction::{ ExecutedTransaction, OutputNote, OutputNotes, ProvenTransaction, TransactionArgs, TransactionId, TransactionScript, @@ -236,6 +238,7 @@ impl Client let block_num = self.store.get_sync_height()?; let note_ids = transaction_request.get_input_note_ids(); + let output_notes = transaction_request.expected_output_notes().to_vec(); // Execute the transaction and get the witness let executed_transaction = self.tx_executor.execute_transaction( @@ -245,6 +248,29 @@ impl Client transaction_request.into(), )?; + // Check that the expected output notes matches the transaction outcome. + let tx_note_auth_hashes: BTreeSet = executed_transaction + .output_notes() + .iter() + .map(|n| match n { + OutputNote::Full(n) => n.authentication_hash(), + OutputNote::Header(_) => { + panic!("ExecutedTransaction should always have every note's details") + }, + }) + .collect(); + + let missing_note_ids: Vec = output_notes + .iter() + .filter_map(|n| { + (!tx_note_auth_hashes.contains(&n.authentication_hash())).then_some(n.id()) + }) + .collect(); + + if !missing_note_ids.is_empty() { + return Err(ClientError::MissingOutputNotes(missing_note_ids)); + } + let screener = NoteScreener::new(self.store.clone()); TransactionResult::new(executed_transaction, screener) diff --git a/src/errors.rs b/src/errors.rs index 996391a66..c474c6c40 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -20,6 +20,7 @@ pub enum ClientError { DataDeserializationError(DeserializationError), HexParseError(HexParseError), ImportNewAccountWithoutSeed, + MissingOutputNotes(Vec), NoteError(NoteError), NoteRecordError(String), NoConsumableNoteForAccount(AccountId), @@ -44,6 +45,13 @@ impl fmt::Display for ClientError { f, "import account error: can't import a new account without its initial seed" ), + ClientError::MissingOutputNotes(note_ids) => { + write!( + f, + "transaction error: The transaction did not produce the expected notes corresponding to Note IDs: {}", + note_ids.iter().map(|&id| id.to_hex()).collect::>().join(", ") + ) + }, ClientError::NoConsumableNoteForAccount(account_id) => { write!(f, "No consumable note for account ID {}", account_id) }, From 86403c065db711b8352f8156be11cb655ad0127d Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 20:16:10 -0300 Subject: [PATCH 03/17] Remove unused code --- src/client/transactions/mod.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 4ff357811..d79344f12 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -291,18 +291,6 @@ impl Client self.submit_proven_transaction_request(proven_transaction.clone()).await?; - let note_screener = NoteScreener::new(self.store.clone()); - let mut relevant_notes = BTreeMap::new(); - - for (idx, note) in tx_result.executed_transaction.output_notes().iter().enumerate() { - if let OutputNote::Full(output_note) = note { - let account_relevance = note_screener.check_relevance(output_note)?; - if !account_relevance.is_empty() { - relevant_notes.insert(idx, account_relevance); - } - } - } - // Transaction was proven and submitted to the node correctly, persist note details and update account self.store.apply_transaction(tx_result)?; From 2dbb6811b1cdf44e6d462c70a8b16da23f60eccb Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 20:22:54 -0300 Subject: [PATCH 04/17] Lints --- README.md | 4 ++-- src/client/transactions/mod.rs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 728635c57..0f9fa53b9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The Miden client is still under heavy development and the project can be conside The Miden client currently consists of two components: - `miden-client` library, which can be used by other project to programmatically interact with the Miden rollup. -- `miden` binary which is a wrapper around the library exposing its functionality via a simple command-line interface (CLI). +- `miden-client` binary which is a wrapper around the library exposing its functionality via a simple command-line interface (CLI). The client's main responsibility is to maintain a partial view of the blockchain which allows for locally executing and proving transactions. It keeps a local store of various entities that periodically get updated by syncing with the node. @@ -54,7 +54,7 @@ You can either build from source with: cargo build --release ``` -Once the binary is built, you can find it on `./target/release/miden`. +Once the binary is built, you can find it on `./target/release/miden-client`. Or you can install the CLI from crates-io with: diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index d79344f12..d33ef2ef3 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -1,8 +1,6 @@ use alloc::collections::{BTreeMap, BTreeSet}; -use miden_lib::{ - notes::{create_p2id_note, create_p2idr_note}, -}; +use miden_lib::notes::{create_p2id_note, create_p2idr_note}; use miden_objects::{ accounts::{AccountDelta, AccountId}, assembly::ProgramAst, From 261e4201971f02e9f1ff45bdb48a21710e21fdca Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 20:35:37 -0300 Subject: [PATCH 05/17] Fix tests --- tests/integration/common.rs | 8 +++++--- tests/integration/custom_transactions_tests.rs | 11 ++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/integration/common.rs b/tests/integration/common.rs index 01a29fef7..0bff7dced 100644 --- a/tests/integration/common.rs +++ b/tests/integration/common.rs @@ -1,4 +1,4 @@ -use std::{env::temp_dir, time::Duration}; +use std::{env::temp_dir, rc::Rc, time::Duration}; use figment::{ providers::{Format, Toml}, @@ -7,6 +7,7 @@ use figment::{ use miden_client::{ client::{ accounts::{AccountStorageMode, AccountTemplate}, + authenticator::StoreAuthenticator, get_random_coin, rpc::TonicRpcClient, transactions::transaction_request::{TransactionRequest, TransactionTemplate}, @@ -31,7 +32,8 @@ use uuid::Uuid; pub const ACCOUNT_ID_REGULAR: u64 = ACCOUNT_ID_REGULAR_ACCOUNT_UPDATABLE_CODE_OFF_CHAIN; -pub type TestClient = Client; +pub type TestClient = + Client>; pub const TEST_CLIENT_CONFIG_FILE_PATH: &str = "./tests/config/miden-client.toml"; /// Creates a `TestClient` @@ -56,7 +58,7 @@ pub fn create_test_client() -> TestClient { let store = { let sqlite_store = SqliteStore::new((&client_config).into()).unwrap(); - Rc::new(store); + Rc::new(sqlite_store) }; let rng = get_random_coin(); diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index 5d599282d..c65d47ee5 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -1,11 +1,8 @@ use std::collections::BTreeMap; -use miden_client::{ - client::{ - accounts::{AccountStorageMode, AccountTemplate}, - transactions::transaction_request::TransactionRequest, - }, - store::AuthSecretKey, +use miden_client::client::{ + accounts::{AccountStorageMode, AccountTemplate}, + transactions::transaction_request::TransactionRequest, }; use miden_objects::{ accounts::AccountId, @@ -18,7 +15,7 @@ use miden_objects::{ }, Felt, Word, }; -use miden_tx::utils::Serializable; +use miden_tx::{utils::Serializable, AuthSecretKey}; use super::common::*; From add0a1386ec25b7d025180afd70fe82f11382026 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Wed, 8 May 2024 23:11:15 -0300 Subject: [PATCH 06/17] fix: Tetss --- src/client/transactions/mod.rs | 2 +- tests/integration/asm/custom_p2id.masm | 4 ++-- tests/integration/custom_transactions_tests.rs | 16 +++------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index d33ef2ef3..4c2a8c712 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -408,7 +408,7 @@ impl Client note_type, random_coin, )?; - + println!("note tag {}", created_note.metadata().tag()); let recipient = created_note .recipient() .digest() diff --git a/tests/integration/asm/custom_p2id.masm b/tests/integration/asm/custom_p2id.masm index 3d9b07be5..1a3a54a33 100644 --- a/tests/integration/asm/custom_p2id.masm +++ b/tests/integration/asm/custom_p2id.masm @@ -47,10 +47,10 @@ proc.add_note_assets_to_account end begin - # drop the note script root - dropw # => [NOTE_ARG] push.{expected_note_arg} assert_eqw + # drop the note script root + dropw # store the note inputs to memory starting at address 0 push.0 exec.note::get_inputs diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index c65d47ee5..e4edbfcdf 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -54,10 +54,11 @@ async fn test_transaction_request() { storage_mode: AccountStorageMode::Local, }; let (fungible_faucet, _seed) = client.new_account(account_template).unwrap(); + println!("sda1"); // Execute mint transaction in order to create custom note let note = mint_custom_note(&mut client, fungible_faucet.id(), regular_account.id()).await; - + println!("sda"); client.sync_state().await.unwrap(); // Prepare transaction @@ -177,18 +178,7 @@ async fn mint_custom_note( let program = ProgramAst::parse(&code).unwrap(); - let tx_script = { - let account_auth = client.get_account_auth(faucet_account_id).unwrap(); - let (pubkey_input, advice_map): (Word, Vec) = match account_auth { - AuthSecretKey::RpoFalcon512(key) => ( - key.public_key().into(), - key.to_bytes().iter().map(|a| Felt::new(*a as u64)).collect::>(), - ), - }; - - let script_inputs = vec![(pubkey_input, advice_map)]; - client.compile_tx_script(program, script_inputs, vec![]).unwrap() - }; + let tx_script = client.compile_tx_script(program, vec![], vec![]).unwrap(); let transaction_request = TransactionRequest::new( faucet_account_id, From 0c85c915d2df6aac283587e3c6db80c4855a8d76 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Thu, 9 May 2024 12:52:00 -0300 Subject: [PATCH 07/17] Stash --- src/client/transactions/mod.rs | 33 ++++++++------------- src/store/note_record/output_note_record.rs | 32 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 4c2a8c712..e4b82f070 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -6,7 +6,7 @@ use miden_objects::{ assembly::ProgramAst, assets::FungibleAsset, crypto::rand::RpoRandomCoin, - notes::{Note, NoteId, NoteType}, + notes::{NoteId, NoteType}, transaction::{ ExecutedTransaction, OutputNote, OutputNotes, ProvenTransaction, TransactionArgs, TransactionId, TransactionScript, @@ -38,7 +38,7 @@ pub mod transaction_request; /// created by the transaction execution, and a list of `relevant_notes` that contains the /// `output_notes` that the client has to store as input notes, based on the NoteScreener output pub struct TransactionResult { - executed_transaction: ExecutedTransaction, + transaction: ExecutedTransaction, relevant_notes: Vec, } @@ -49,9 +49,9 @@ impl TransactionResult { note_screener: NoteScreener, ) -> Result { let mut relevant_notes = vec![]; - let output_notes = executed_transaction.output_notes().iter().map(|n| match n { - OutputNote::Full(n) => n, - OutputNote::Header(_) => panic!("ExecutedTransaction should have all note details"), + let output_notes = executed_transaction.output_notes().iter().filter_map(|n| match n { + OutputNote::Full(n) => Some(n), + OutputNote::Header(_) => None, }); for note in output_notes { let account_relevance = note_screener.check_relevance(note)?; @@ -61,26 +61,17 @@ impl TransactionResult { } } - let tx_result = Self { executed_transaction, relevant_notes }; + let tx_result = Self { transaction: executed_transaction, relevant_notes }; Ok(tx_result) } pub fn executed_transaction(&self) -> &ExecutedTransaction { - &self.executed_transaction + &self.transaction } - pub fn created_notes(&self) -> Vec { - // All output notes should be OutputNote::Full because they are shrinked - // only at the moment of proving (the ExecutedTransaction keeps all details) - self.executed_transaction - .output_notes() - .iter() - .map(|n| match n { - OutputNote::Full(n) => n.clone(), - OutputNote::Header(_) => panic!("ExecutedTransaction should have all note details"), - }) - .collect() + pub fn created_notes(&self) -> &OutputNotes { + &self.transaction.output_notes() } pub fn relevant_notes(&self) -> &[InputNoteRecord] { @@ -88,15 +79,15 @@ impl TransactionResult { } pub fn block_num(&self) -> u32 { - self.executed_transaction.block_header().block_num() + self.transaction.block_header().block_num() } pub fn transaction_arguments(&self) -> &TransactionArgs { - self.executed_transaction.tx_args() + self.transaction.tx_args() } pub fn account_delta(&self) -> &AccountDelta { - self.executed_transaction.account_delta() + self.transaction.account_delta() } } diff --git a/src/store/note_record/output_note_record.rs b/src/store/note_record/output_note_record.rs index 871d36f29..09dc11782 100644 --- a/src/store/note_record/output_note_record.rs +++ b/src/store/note_record/output_note_record.rs @@ -1,6 +1,5 @@ use miden_objects::{ - notes::{Note, NoteAssets, NoteId, NoteInclusionProof, NoteMetadata}, - Digest, + notes::{Note, NoteAssets, NoteHeader, NoteId, NoteInclusionProof, NoteMetadata}, transaction::OutputNote, Digest }; use super::{InputNoteRecord, NoteRecordDetails, NoteStatus}; @@ -79,6 +78,35 @@ impl OutputNoteRecord { } } +// CONVERSIONS +// ================================================================================================ + +impl From for OutputNoteRecord { + fn from(value: OutputNote) -> Self { + match value { + OutputNote::Full(note) => note.into(), + OutputNote::Header(header) => + header.into(), + } + } +} + + +impl From for OutputNoteRecord { + fn from(value: NoteHeader) -> Self { + OutputNoteRecord { + id: value.id(), + recipient: value.recipient().digest(), + assets: value.metadata, + status: NoteStatus::Pending, + metadata: *value.metadata(), + inclusion_proof: None, + details: None, + } + } +} + + impl From for OutputNoteRecord { fn from(note: Note) -> Self { OutputNoteRecord { From b36d05a1403d67770d2533f21fc593eb64de3e36 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Thu, 9 May 2024 17:23:18 -0300 Subject: [PATCH 08/17] fix: Address reviews --- src/cli/notes.rs | 2 +- src/client/transactions/mod.rs | 44 ++++++++++++--------- src/store/note_record/output_note_record.rs | 30 ++------------ src/store/sqlite_store/transactions.rs | 11 +++--- 4 files changed, 35 insertions(+), 52 deletions(-) diff --git a/src/cli/notes.rs b/src/cli/notes.rs index 23dbed9b7..af0bc84f2 100644 --- a/src/cli/notes.rs +++ b/src/cli/notes.rs @@ -613,7 +613,7 @@ mod tests { let transaction_request = client.build_transaction_request(transaction_template).unwrap(); let transaction = client.new_transaction(transaction_request).unwrap(); - let created_note = transaction.created_notes()[0].clone(); + let created_note = transaction.created_notes().get_note(0).clone(); client.submit_transaction(transaction).await.unwrap(); // Ensure client has no input notes and one output note diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index e4b82f070..b36913d09 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -6,7 +6,7 @@ use miden_objects::{ assembly::ProgramAst, assets::FungibleAsset, crypto::rand::RpoRandomCoin, - notes::{NoteId, NoteType}, + notes::{Note, NoteId, NoteType}, transaction::{ ExecutedTransaction, OutputNote, OutputNotes, ProvenTransaction, TransactionArgs, TransactionId, TransactionScript, @@ -45,15 +45,12 @@ pub struct TransactionResult { impl TransactionResult { /// Screens the output notes to store and track the relevant ones, and instantiates a [TransactionResult] pub fn new( - executed_transaction: ExecutedTransaction, + transaction: ExecutedTransaction, note_screener: NoteScreener, ) -> Result { let mut relevant_notes = vec![]; - let output_notes = executed_transaction.output_notes().iter().filter_map(|n| match n { - OutputNote::Full(n) => Some(n), - OutputNote::Header(_) => None, - }); - for note in output_notes { + + for note in notes_from_output(transaction.output_notes()) { let account_relevance = note_screener.check_relevance(note)?; if !account_relevance.is_empty() { @@ -61,7 +58,7 @@ impl TransactionResult { } } - let tx_result = Self { transaction: executed_transaction, relevant_notes }; + let tx_result = Self { transaction, relevant_notes }; Ok(tx_result) } @@ -71,7 +68,7 @@ impl TransactionResult { } pub fn created_notes(&self) -> &OutputNotes { - &self.transaction.output_notes() + self.transaction.output_notes() } pub fn relevant_notes(&self) -> &[InputNoteRecord] { @@ -238,16 +235,12 @@ impl Client )?; // Check that the expected output notes matches the transaction outcome. - let tx_note_auth_hashes: BTreeSet = executed_transaction - .output_notes() - .iter() - .map(|n| match n { - OutputNote::Full(n) => n.authentication_hash(), - OutputNote::Header(_) => { - panic!("ExecutedTransaction should always have every note's details") - }, - }) - .collect(); + // We comprae authentication hashes where possible since that involves note IDs + metadata + // (as opposed to just note ID which remains the same regardless of metadata) + let tx_note_auth_hashes: BTreeSet = + notes_from_output(executed_transaction.output_notes()) + .map(Note::authentication_hash) + .collect(); let missing_note_ids: Vec = output_notes .iter() @@ -436,3 +429,16 @@ impl Client pub(crate) fn prepare_word(word: &Word) -> String { word.iter().map(|x| x.as_int().to_string()).collect::>().join(".") } + +/// Extracts notes from [OutputNotes] +/// Used for: +/// - checking the relevance of notes to save them as input notes +/// - validate hashes versus expected output notes after a transaction is executed +pub(crate) fn notes_from_output(output_notes: &OutputNotes) -> impl Iterator { + output_notes.iter().map(|n| match n { + OutputNote::Full(n) => n, + // The following todo!() applies until we have a way to support flows where we have + // partial details of the note + OutputNote::Header(_) => todo!("For now, all details should be held in OutputNote::Fulls"), + }) +} diff --git a/src/store/note_record/output_note_record.rs b/src/store/note_record/output_note_record.rs index 09dc11782..9d8b6f09e 100644 --- a/src/store/note_record/output_note_record.rs +++ b/src/store/note_record/output_note_record.rs @@ -1,5 +1,6 @@ use miden_objects::{ - notes::{Note, NoteAssets, NoteHeader, NoteId, NoteInclusionProof, NoteMetadata}, transaction::OutputNote, Digest + notes::{Note, NoteAssets, NoteId, NoteInclusionProof, NoteMetadata}, + Digest, }; use super::{InputNoteRecord, NoteRecordDetails, NoteStatus}; @@ -81,32 +82,7 @@ impl OutputNoteRecord { // CONVERSIONS // ================================================================================================ -impl From for OutputNoteRecord { - fn from(value: OutputNote) -> Self { - match value { - OutputNote::Full(note) => note.into(), - OutputNote::Header(header) => - header.into(), - } - } -} - - -impl From for OutputNoteRecord { - fn from(value: NoteHeader) -> Self { - OutputNoteRecord { - id: value.id(), - recipient: value.recipient().digest(), - assets: value.metadata, - status: NoteStatus::Pending, - metadata: *value.metadata(), - inclusion_proof: None, - details: None, - } - } -} - - +// TODO: Improve conversions by implementing into_parts() impl From for OutputNoteRecord { fn from(note: Note) -> Self { OutputNoteRecord { diff --git a/src/store/sqlite_store/transactions.rs b/src/store/sqlite_store/transactions.rs index b489b4507..fef09adae 100644 --- a/src/store/sqlite_store/transactions.rs +++ b/src/store/sqlite_store/transactions.rs @@ -16,7 +16,9 @@ use super::{ SqliteStore, }; use crate::{ - client::transactions::{TransactionRecord, TransactionResult, TransactionStatus}, + client::transactions::{ + notes_from_output, TransactionRecord, TransactionResult, TransactionStatus, + }, errors::StoreError, store::{OutputNoteRecord, TransactionFilter}, }; @@ -90,10 +92,9 @@ impl SqliteStore { let created_input_notes = tx_result.relevant_notes().to_vec(); // Save all output notes - let created_output_notes = tx_result - .created_notes() - .iter() - .map(|note| OutputNoteRecord::from(note.clone())) + let created_output_notes = notes_from_output(tx_result.created_notes()) + .cloned() + .map(OutputNoteRecord::from) .collect::>(); let mut db = self.db(); From b0103b0a7517db672b06171eea5e3dee84131032 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Fri, 10 May 2024 10:37:23 -0300 Subject: [PATCH 09/17] fix: Tests --- Makefile.toml | 2 +- src/client/note_screener.rs | 2 +- src/client/transactions/mod.rs | 2 +- tests/integration/asm/custom_p2id.masm | 5 +++-- tests/integration/custom_transactions_tests.rs | 7 ++----- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 4c88b8fed..697e30ffe 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -74,7 +74,7 @@ args = ["-rf", "miden-node"] description = "Clone or update miden-node repository and clean up files" script_runner = "bash" script = [ - 'if [ -d miden-node ]; then cd miden-node && git checkout main; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node && git checkout main; fi', + 'if [ -d miden-node ]; then cd miden-node && git checkout next; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node && git checkout next; fi', 'rm -rf miden-store.sqlite3 miden-store.sqlite3-wal miden-store.sqlite3-shm', 'cd bin/node', 'cargo run --features $NODE_FEATURES_TESTING -- make-genesis --force' diff --git a/src/client/note_screener.rs b/src/client/note_screener.rs index d5a992c84..ef969ff24 100644 --- a/src/client/note_screener.rs +++ b/src/client/note_screener.rs @@ -15,7 +15,7 @@ pub(crate) const P2ID_NOTE_SCRIPT_ROOT: &str = pub(crate) const P2IDR_NOTE_SCRIPT_ROOT: &str = "0x418ae31e80b53ddc99179d3cacbc4140c7b36ab04ddb26908b3a6ed2e40061d5"; pub(crate) const SWAP_NOTE_SCRIPT_ROOT: &str = - "0xf08db4112793a0ccb12d43c552408a64d51a0a12600e7670d8df97f223276f74"; + "0x755c5dd2fd8d2aa8c2896e0e366a45bdc59c6d5ab543909db32ccfaf949c5826"; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum NoteRelevance { diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index b36913d09..15ac29dd7 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -392,7 +392,7 @@ impl Client note_type, random_coin, )?; - println!("note tag {}", created_note.metadata().tag()); + let recipient = created_note .recipient() .digest() diff --git a/tests/integration/asm/custom_p2id.masm b/tests/integration/asm/custom_p2id.masm index 1a3a54a33..04111c857 100644 --- a/tests/integration/asm/custom_p2id.masm +++ b/tests/integration/asm/custom_p2id.masm @@ -47,10 +47,11 @@ proc.add_note_assets_to_account end begin - # => [NOTE_ARG] - push.{expected_note_arg} assert_eqw # drop the note script root dropw + + # => [NOTE_ARG] + push.{expected_note_arg} assert_eqw # store the note inputs to memory starting at address 0 push.0 exec.note::get_inputs diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index e4edbfcdf..7fe489368 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -10,8 +10,7 @@ use miden_objects::{ assets::{FungibleAsset, TokenSymbol}, crypto::rand::{FeltRng, RpoRandomCoin}, notes::{ - Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteTag, - NoteType, + Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteScript, NoteTag, NoteType }, Felt, Word, }; @@ -54,11 +53,9 @@ async fn test_transaction_request() { storage_mode: AccountStorageMode::Local, }; let (fungible_faucet, _seed) = client.new_account(account_template).unwrap(); - println!("sda1"); // Execute mint transaction in order to create custom note let note = mint_custom_note(&mut client, fungible_faucet.id(), regular_account.id()).await; - println!("sda"); client.sync_state().await.unwrap(); // Prepare transaction @@ -199,7 +196,7 @@ fn create_custom_note( ) -> Note { let expected_note_arg = [Felt::new(9), Felt::new(12), Felt::new(18), Felt::new(3)] .iter() - .map(|x| x.to_string()) + .map(|x| x.as_int().to_string()) .collect::>() .join("."); From a90dda98c617ae5bddabcc1bc8d1de4d1f5c3932 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Fri, 10 May 2024 10:44:02 -0300 Subject: [PATCH 10/17] fix: Lints --- src/client/transactions/mod.rs | 2 +- tests/integration/custom_transactions_tests.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 15ac29dd7..4d4b568e6 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -392,7 +392,7 @@ impl Client note_type, random_coin, )?; - + let recipient = created_note .recipient() .digest() diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index ae27ca8d1..965b9fa3d 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -10,7 +10,8 @@ use miden_objects::{ assets::{FungibleAsset, TokenSymbol}, crypto::rand::{FeltRng, RpoRandomCoin}, notes::{ - Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteScript, NoteTag, NoteType + Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteScript, + NoteTag, NoteType, }, Felt, Word, }; From a2cdb3064de8b23ead09cc134cec200460f89d6d Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Fri, 10 May 2024 10:48:29 -0300 Subject: [PATCH 11/17] fix: Lints --- tests/integration/custom_transactions_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index 965b9fa3d..aded4b76e 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -10,7 +10,7 @@ use miden_objects::{ assets::{FungibleAsset, TokenSymbol}, crypto::rand::{FeltRng, RpoRandomCoin}, notes::{ - Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteScript, + Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteTag, NoteType, }, Felt, Word, From e2c0385ebc778c25c08e42972ace23252f0cdcd4 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Fri, 10 May 2024 11:38:16 -0300 Subject: [PATCH 12/17] Try fix test --- Makefile.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index 697e30ffe..5e87e546c 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -74,7 +74,8 @@ args = ["-rf", "miden-node"] description = "Clone or update miden-node repository and clean up files" script_runner = "bash" script = [ - 'if [ -d miden-node ]; then cd miden-node && git checkout next; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node && git checkout next; fi', + 'if [ -d miden-node ]; then cd miden-node ; else git clone https://github.com/0xPolygonMiden/miden-node.git && cd miden-node; fi', + 'git checkout next && git pull origin next && cargo update', 'rm -rf miden-store.sqlite3 miden-store.sqlite3-wal miden-store.sqlite3-shm', 'cd bin/node', 'cargo run --features $NODE_FEATURES_TESTING -- make-genesis --force' From b9e9b3901e7de87c06868ff01252c03a337d3fd5 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Fri, 10 May 2024 15:30:24 -0300 Subject: [PATCH 13/17] fix: Merge conflicts --- src/cli/import.rs | 2 +- src/client/transactions/mod.rs | 6 +++--- tests/integration/custom_transactions_tests.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/import.rs b/src/cli/import.rs index 5621a1259..e4d286bc2 100644 --- a/src/cli/import.rs +++ b/src/cli/import.rs @@ -224,7 +224,7 @@ mod tests { let transaction_request = client.build_transaction_request(transaction_template).unwrap(); let transaction = client.new_transaction(transaction_request).unwrap(); - let created_note = transaction.created_notes()[0].clone(); + let created_note = transaction.created_notes().get_note(0).clone(); client.submit_transaction(transaction).await.unwrap(); // Ensure client has no input notes and one output note diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index a1e793b65..1c8a225dc 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -8,8 +8,8 @@ use miden_objects::{ crypto::rand::RpoRandomCoin, notes::{Note, NoteId, NoteType}, transaction::{ - ExecutedTransaction, OutputNote, OutputNotes, ProvenTransaction, TransactionArgs, - TransactionId, TransactionScript, + ExecutedTransaction, InputNotes, OutputNote, OutputNotes, ProvenTransaction, + TransactionArgs, TransactionId, TransactionScript, }, Digest, Felt, Word, }; @@ -88,7 +88,7 @@ impl TransactionResult { } pub fn consumed_notes(&self) -> &InputNotes { - self.executed_transaction.tx_inputs().input_notes() + self.transaction.tx_inputs().input_notes() } } diff --git a/tests/integration/custom_transactions_tests.rs b/tests/integration/custom_transactions_tests.rs index aded4b76e..0a539685b 100644 --- a/tests/integration/custom_transactions_tests.rs +++ b/tests/integration/custom_transactions_tests.rs @@ -10,8 +10,8 @@ use miden_objects::{ assets::{FungibleAsset, TokenSymbol}, crypto::rand::{FeltRng, RpoRandomCoin}, notes::{ - Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, - NoteTag, NoteType, + Note, NoteAssets, NoteExecutionHint, NoteInputs, NoteMetadata, NoteRecipient, NoteTag, + NoteType, }, Felt, Word, }; From f2933fd114d978257ed1030fdb2531f3c750e029 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Mon, 13 May 2024 00:39:10 -0300 Subject: [PATCH 14/17] Fix tests --- src/client/transactions/transaction_request.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/transactions/transaction_request.rs b/src/client/transactions/transaction_request.rs index cdcb00d4c..117f32729 100644 --- a/src/client/transactions/transaction_request.rs +++ b/src/client/transactions/transaction_request.rs @@ -173,9 +173,9 @@ impl PaymentTransactionData { // -------------------------------------------------------------------------------------------- pub mod known_script_roots { - pub const P2ID: &str = "0xcdfd70344b952980272119bc02b837d14c07bbfc54f86a254422f39391b77b35"; - pub const P2IDR: &str = "0x41e5727b99a12b36066c09854d39d64dd09d9265c442a9be3626897572bf1745"; - pub const SWAP: &str = "0x5852920f88985b651cf7ef5e48623f898b6c292f4a2c25dd788ff8b46dd90417"; + pub const P2ID: &str = "0x0007b2229f7c8e3205a485a9879f1906798a2e27abd1706eaf58536e7cc3868b"; + pub const P2IDR: &str = "0x418ae31e80b53ddc99179d3cacbc4140c7b36ab04ddb26908b3a6ed2e40061d5"; + pub const SWAP: &str = "0x755c5dd2fd8d2aa8c2896e0e366a45bdc59c6d5ab543909db32ccfaf949c5826"; } #[cfg(test)] From 9b0c0b7657c36b884d0c9ab50b9e9003c50d3b39 Mon Sep 17 00:00:00 2001 From: igamigo Date: Mon, 13 May 2024 14:09:26 -0300 Subject: [PATCH 15/17] docs: Address reviews --- src/client/transactions/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 1c8a225dc..9a36d55a3 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -32,11 +32,11 @@ pub mod transaction_request; // TRANSACTION RESULT // -------------------------------------------------------------------------------------------- -/// Represents the result of executing a transaction by the client +/// Represents the result of executing a transaction by the client. /// -/// It contains an [ExecutedTransaction], a list of [Note] that describe the details of the notes -/// created by the transaction execution, and a list of `relevant_notes` that contains the -/// `output_notes` that the client has to store as input notes, based on the NoteScreener output +/// It contains an [ExecutedTransaction], and a list of `relevant_notes` that contains the +/// `output_notes` that the client has to store as input notes, based on the NoteScreener +/// output from filtering the transaction's output notes. pub struct TransactionResult { transaction: ExecutedTransaction, relevant_notes: Vec, From bd5919224170000db201a9f9423694967d7b3021 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Mon, 13 May 2024 14:31:10 -0300 Subject: [PATCH 16/17] Lints --- src/client/transactions/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/transactions/mod.rs b/src/client/transactions/mod.rs index 9a36d55a3..7cc3fb136 100644 --- a/src/client/transactions/mod.rs +++ b/src/client/transactions/mod.rs @@ -35,7 +35,7 @@ pub mod transaction_request; /// Represents the result of executing a transaction by the client. /// /// It contains an [ExecutedTransaction], and a list of `relevant_notes` that contains the -/// `output_notes` that the client has to store as input notes, based on the NoteScreener +/// `output_notes` that the client has to store as input notes, based on the NoteScreener /// output from filtering the transaction's output notes. pub struct TransactionResult { transaction: ExecutedTransaction, From 1e39716bfcbf079f6704649a75c84f540d9ecdb5 Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Mon, 13 May 2024 15:44:09 -0300 Subject: [PATCH 17/17] fix: New script root --- src/client/transactions/transaction_request.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/transactions/transaction_request.rs b/src/client/transactions/transaction_request.rs index 117f32729..5957029af 100644 --- a/src/client/transactions/transaction_request.rs +++ b/src/client/transactions/transaction_request.rs @@ -175,7 +175,7 @@ impl PaymentTransactionData { pub mod known_script_roots { pub const P2ID: &str = "0x0007b2229f7c8e3205a485a9879f1906798a2e27abd1706eaf58536e7cc3868b"; pub const P2IDR: &str = "0x418ae31e80b53ddc99179d3cacbc4140c7b36ab04ddb26908b3a6ed2e40061d5"; - pub const SWAP: &str = "0x755c5dd2fd8d2aa8c2896e0e366a45bdc59c6d5ab543909db32ccfaf949c5826"; + pub const SWAP: &str = "0xebbc82ad1688925175599bee2fb56bde649ebb9986fbce957ebee3eb4be5f140"; } #[cfg(test)]