diff --git a/ant-networking/src/lib.rs b/ant-networking/src/lib.rs index 7449b731da..1ef8f78f9b 100644 --- a/ant-networking/src/lib.rs +++ b/ant-networking/src/lib.rs @@ -411,8 +411,7 @@ impl Network { let mut all_quotes = vec![]; let mut quotes_to_pay = vec![]; for (peer, response) in responses { - info!( - "StoreCostReq for {record_address:?} received response: {response:?}"); + info!("StoreCostReq for {record_address:?} received response: {response:?}"); match response { Ok(Response::Query(QueryResponse::GetStoreQuote { quote: Ok(quote), diff --git a/ant-networking/src/log_markers.rs b/ant-networking/src/log_markers.rs index c8ce2ce744..71787c0a65 100644 --- a/ant-networking/src/log_markers.rs +++ b/ant-networking/src/log_markers.rs @@ -20,9 +20,7 @@ pub enum Marker<'a> { /// Close records held (Used in VDash) CloseRecordsLen(usize), /// Quoting metrics - QuotingMetrics { - quoting_metrics: &'a QuotingMetrics, - }, + QuotingMetrics { quoting_metrics: &'a QuotingMetrics }, /// The peer has been considered as bad PeerConsideredAsBad { bad_peer: &'a PeerId }, /// We have been flagged as a bad node by a peer. diff --git a/ant-networking/src/metrics/mod.rs b/ant-networking/src/metrics/mod.rs index d48dfe6930..89e63202de 100644 --- a/ant-networking/src/metrics/mod.rs +++ b/ant-networking/src/metrics/mod.rs @@ -284,9 +284,7 @@ impl NetworkMetricsRecorder { } }); } - Marker::QuotingMetrics { - quoting_metrics, - } => { + Marker::QuotingMetrics { quoting_metrics } => { let _ = self.relevant_records.set( quoting_metrics .close_records_stored diff --git a/ant-node/src/node.rs b/ant-node/src/node.rs index ef5c33bc8f..36a7c3e765 100644 --- a/ant-node/src/node.rs +++ b/ant-node/src/node.rs @@ -561,7 +561,8 @@ impl Node { let record_key = key.to_record_key(); let self_id = network.peer_id(); - let maybe_quoting_metrics = network.get_local_quoting_metrics(record_key.clone()).await; + let maybe_quoting_metrics = + network.get_local_quoting_metrics(record_key.clone()).await; let storage_proofs = if let Some(nonce) = nonce { Self::respond_x_closest_record_proof( @@ -588,7 +589,7 @@ impl Node { } } else { QueryResponse::GetStoreQuote { - quote: Self::create_quote_for_storecost( + quote: Self::create_quote_for_storecost( network, &key, "ing_metrics, diff --git a/ant-node/src/put_validation.rs b/ant-node/src/put_validation.rs index 436980323c..3709ca3bc7 100644 --- a/ant-node/src/put_validation.rs +++ b/ant-node/src/put_validation.rs @@ -619,12 +619,21 @@ impl Node { ))); } + // verify the claimed payees are all known to us within the certain range. + let closest_k_peers = self.network().get_closest_k_value_local_peers().await?; + let mut payees = payment.payees(); + payees.retain(|peer_id| !closest_k_peers.contains(peer_id)); + if !payees.is_empty() { + return Err(Error::InvalidRequest(format!( + "Payment quote has out-of-range payees {payees:?}" + ))); + } + let owned_payment_quotes = payment .quotes_by_peer(&self_peer_id) .iter() .map(|quote| quote.hash()) .collect(); - // check if payment is valid on chain let payments_to_verify = payment.digest(); debug!("Verifying payment for record {pretty_key}"); diff --git a/ant-node/src/quote.rs b/ant-node/src/quote.rs index 4a11fd2ef7..f7c61b2af8 100644 --- a/ant-node/src/quote.rs +++ b/ant-node/src/quote.rs @@ -22,12 +22,8 @@ impl Node { ) -> Result { let content = address.as_xorname().unwrap_or_default(); let timestamp = std::time::SystemTime::now(); - let bytes = PaymentQuote::bytes_for_signing( - content, - timestamp, - quoting_metrics, - payment_address, - ); + let bytes = + PaymentQuote::bytes_for_signing(content, timestamp, quoting_metrics, payment_address); let Ok(signature) = network.sign(&bytes) else { return Err(ProtocolError::QuoteGenerationFailed); diff --git a/autonomi/src/client/external_signer.rs b/autonomi/src/client/external_signer.rs index 1c501ec68b..aee672f29b 100644 --- a/autonomi/src/client/external_signer.rs +++ b/autonomi/src/client/external_signer.rs @@ -28,7 +28,9 @@ impl Client { > { let quote = self.get_store_quotes(content_addrs.clone()).await?; let payments = quote.payments(); - let free_chunks = content_addrs.filter(|addr| !quote.0.contains_key(addr)).collect(); + let free_chunks = content_addrs + .filter(|addr| !quote.0.contains_key(addr)) + .collect(); let quotes_per_addr = quote.0.into_iter().collect(); Ok((quotes_per_addr, payments, free_chunks)) diff --git a/evmlib/src/external_signer.rs b/evmlib/src/external_signer.rs index 30186f031d..b7f7ce9b6d 100644 --- a/evmlib/src/external_signer.rs +++ b/evmlib/src/external_signer.rs @@ -7,7 +7,7 @@ // permissions and limitations relating to use of the SAFE Network Software. use crate::common::{Address, Amount, Calldata, QuoteHash, QuotePayment, U256}; -use crate::contract::network_token::{NetworkToken, self}; +use crate::contract::network_token::{self, NetworkToken}; use crate::contract::payment_vault::MAX_TRANSFERS_PER_TRANSACTION; use crate::utils::http_provider; use crate::Network; diff --git a/evmlib/src/wallet.rs b/evmlib/src/wallet.rs index 327c0faf40..0f6ba3acea 100644 --- a/evmlib/src/wallet.rs +++ b/evmlib/src/wallet.rs @@ -6,7 +6,7 @@ // KIND, either express or implied. Please review the Licences for the specific language governing // permissions and limitations relating to use of the SAFE Network Software. -use crate::common::{Address, Amount, QuotePayment, QuoteHash, TxHash, U256}; +use crate::common::{Address, Amount, QuoteHash, QuotePayment, TxHash, U256}; use crate::contract::network_token::NetworkToken; use crate::contract::payment_vault::handler::PaymentVaultHandler; use crate::contract::payment_vault::MAX_TRANSFERS_PER_TRANSACTION; diff --git a/evmlib/tests/wallet.rs b/evmlib/tests/wallet.rs index f6ac01e3a4..e9e5f0a077 100644 --- a/evmlib/tests/wallet.rs +++ b/evmlib/tests/wallet.rs @@ -90,11 +90,7 @@ async fn test_pay_for_quotes_and_data_payment_verification() { let result = verify_data_payment( &network, vec![*quote_hash], - vec![( - *quote_hash, - QuotingMetrics::default(), - *reward_addr, - )], + vec![(*quote_hash, QuotingMetrics::default(), *reward_addr)], ) .await;