Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): carry out quote self validation #2118

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion sn_networking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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));
}
Expand Down
Loading