From dbaeb2c7408bdc71799c11a34be5efd54e407c49 Mon Sep 17 00:00:00 2001 From: qima Date: Tue, 17 Sep 2024 20:53:48 +0800 Subject: [PATCH] feat(client): carry out quote self validation --- sn_networking/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sn_networking/src/lib.rs b/sn_networking/src/lib.rs index 05e9b162fc..f08f361bf7 100644 --- a/sn_networking/src/lib.rs +++ b/sn_networking/src/lib.rs @@ -366,7 +366,7 @@ impl Network { let mut all_costs = vec![]; let mut all_quotes = vec![]; for response in responses.into_values().flatten() { - debug!( + info!( "StoreCostReq for {record_address:?} received response: {:?}", response ); @@ -376,6 +376,14 @@ impl Network { payment_address, peer_address, }) => { + // Check the quote itself is valid. + if quote.cost.as_nano() + != calculate_cost_for_records(quote.quoting_metrics.close_records_stored) + { + warn!("Received invalid quote from {peer_address:?}, {quote:?}"); + continue; + } + all_costs.push((peer_address.clone(), payment_address, quote.clone())); all_quotes.push((peer_address, quote)); }