Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions ant-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ path = "tests/merkle_unit.rs"
[[test]]
name = "e2e_merkle"
path = "tests/e2e_merkle.rs"

[[test]]
name = "e2e_huge_file"
path = "tests/e2e_huge_file.rs"
29 changes: 16 additions & 13 deletions ant-core/src/data/client/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use ant_node::core::{MultiAddr, PeerId};
use ant_node::payment::{serialize_single_node_proof, PaymentProof, SingleNodePayment};
use bytes::Bytes;
use evmlib::common::TxHash;
use evmlib::contract::payment_vault::get_market_price;
use evmlib::wallet::PayForQuotesError;
use futures::stream::{self, StreamExt};
use std::collections::{HashMap, HashSet};
use tracing::{debug, info};
Expand Down Expand Up @@ -180,12 +182,11 @@ impl Client {
.map(|(_, _, quote, _)| quote.quoting_metrics.clone())
.collect();

let contract_prices =
evmlib::contract::payment_vault::get_market_price(evm_network, metrics_batch)
.await
.map_err(|e| {
Error::Payment(format!("Failed to get market prices from contract: {e}"))
})?;
let contract_prices = get_market_price(evm_network, metrics_batch)
.await
.map_err(|e| {
Error::Payment(format!("Failed to get market prices from contract: {e}"))
})?;

if contract_prices.len() != quotes_with_peers.len() {
return Err(Error::Payment(format!(
Expand Down Expand Up @@ -237,8 +238,8 @@ impl Client {
let wallet = self.require_wallet()?;

// Flatten all quote payments from all chunks into a single batch.
let mut all_payments =
Vec::with_capacity(prepared.len() * prepared[0].payment.quotes.len());
let total_quotes: usize = prepared.iter().map(|c| c.payment.quotes.len()).sum();
let mut all_payments = Vec::with_capacity(total_quotes);
for chunk in &prepared {
for info in &chunk.payment.quotes {
all_payments.push((info.quote_hash, info.rewards_address, info.amount));
Expand All @@ -251,11 +252,13 @@ impl Client {
all_payments.len()
);

let (tx_hash_map, _gas_info) = wallet.pay_for_quotes(all_payments).await.map_err(
|evmlib::wallet::PayForQuotesError(err, _)| {
Error::Payment(format!("Batch payment failed: {err}"))
},
)?;
let (tx_hash_map, _gas_info) =
wallet
.pay_for_quotes(all_payments)
.await
.map_err(|PayForQuotesError(err, _)| {
Error::Payment(format!("Batch payment failed: {err}"))
})?;

info!(
"Batch payment succeeded: {} transactions",
Expand Down
Loading
Loading