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
176 changes: 126 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ant-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ utoipa = { version = "5", features = ["axum_extras"] }
zip = "2"
tower-http = { version = "0.6.8", features = ["cors"] }

# Data operations (from saorsa-client)
# Data operations
ant-evm = "0.1.19"
evmlib = "0.4.7"
xor_name = "5"
Expand All @@ -37,7 +37,7 @@ tracing = "0.1"
bytes = "1"
lru = "0.16"
rand = "0.8"
saorsa-node = { git = "https://github.com/saorsa-labs/saorsa-node", branch = "merkle_payments" }
ant-node = "0.6"
saorsa-pqc = "0.5"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

Expand Down
6 changes: 3 additions & 3 deletions ant-core/examples/start-local-devnet.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Start a local devnet with EVM payments.
//!
//! Launches a minimal Saorsa network (5 nodes) with an embedded Anvil
//! blockchain, writes a manifest to `/tmp/saorsa-devnet-manifest.json`,
//! Launches a minimal Autonomi network (5 nodes) with an embedded Anvil
//! blockchain, writes a manifest to `/tmp/ant-devnet-manifest.json`,
//! and waits for Ctrl+C.
//!
//! # Usage
Expand All @@ -27,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let devnet = LocalDevnet::start_minimal().await?;

// Write manifest so the CLI example can use it
let manifest_path = PathBuf::from("/tmp/saorsa-devnet-manifest.json");
let manifest_path = PathBuf::from("/tmp/ant-devnet-manifest.json");
devnet.write_manifest(&manifest_path).await?;

println!();
Expand Down
2 changes: 1 addition & 1 deletion ant-core/src/data/client/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! Caches recently fetched chunks in memory to avoid re-fetching
//! the same content-addressed data from the network.

use ant_node::client::XorName;
use bytes::Bytes;
use lru::LruCache;
use saorsa_node::client::XorName;
use std::num::NonZeroUsize;
use std::sync::{Mutex, PoisonError};

Expand Down
26 changes: 15 additions & 11 deletions ant-core/src/data/client/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

use crate::data::client::Client;
use crate::data::error::{Error, Result};
use bytes::Bytes;
use saorsa_node::ant_protocol::{
use ant_node::ant_protocol::{
ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
ChunkPutResponse,
};
use saorsa_node::client::{compute_address, send_and_await_chunk_response, DataChunk, XorName};
use saorsa_node::core::PeerId;
use ant_node::client::{compute_address, send_and_await_chunk_response, DataChunk, XorName};
use ant_node::core::{MultiAddr, PeerId};
use bytes::Bytes;
use std::time::Duration;
use tracing::{debug, info};

/// Data type identifier for chunks (used in quote requests).
const CHUNK_DATA_TYPE: u32 = 0;

impl Client {
/// Store a chunk on the saorsa network with payment.
/// Store a chunk on the Autonomi network with payment.
///
/// Checks if the chunk already exists before paying. If it does,
/// returns the address immediately without incurring on-chain costs.
Expand All @@ -37,8 +37,8 @@ impl Client {
.pay_for_storage(&address, data_size, CHUNK_DATA_TYPE)
.await
{
Ok((proof, target_peer)) => {
self.chunk_put_with_proof(content, proof, &target_peer)
Ok((proof, target_peer, peer_addrs)) => {
self.chunk_put_with_proof(content, proof, &target_peer, &peer_addrs)
.await
}
Err(Error::AlreadyStored) => {
Expand All @@ -52,7 +52,7 @@ impl Client {
}
}

/// Store a chunk on the saorsa network with a pre-built payment proof.
/// Store a chunk on the Autonomi network with a pre-built payment proof.
///
/// `target_peer` must be one of the peers that was quoted during payment —
/// sending the proof to a different peer will cause rejection because the
Expand All @@ -66,6 +66,7 @@ impl Client {
content: Bytes,
proof: Vec<u8>,
target_peer: &PeerId,
peer_addrs: &[MultiAddr],
) -> Result<XorName> {
let address = compute_address(&content);
let node = self.network().node();
Expand All @@ -90,6 +91,7 @@ impl Client {
message_bytes,
request_id,
timeout,
peer_addrs,
|body| match body {
ChunkMessageBody::PutResponse(ChunkPutResponse::Success { address: addr }) => {
info!("Chunk stored at {}", hex::encode(addr));
Expand Down Expand Up @@ -119,7 +121,7 @@ impl Client {
.await
}

/// Retrieve a chunk from the saorsa network.
/// Retrieve a chunk from the Autonomi network.
///
/// Queries all peers in the close group for the chunk address,
/// returning the first successful response. This handles the case
Expand Down Expand Up @@ -148,8 +150,8 @@ impl Client {
let peers = self.close_group_peers(address).await?;
let addr_hex = hex::encode(address);

for peer in &peers {
match self.chunk_get_from_peer(address, peer).await {
for (peer, addrs) in &peers {
match self.chunk_get_from_peer(address, peer, addrs).await {
Ok(Some(chunk)) => {
self.chunk_cache().put(chunk.address, chunk.content.clone());
return Ok(Some(chunk));
Expand All @@ -173,6 +175,7 @@ impl Client {
&self,
address: &XorName,
peer: &PeerId,
peer_addrs: &[MultiAddr],
) -> Result<Option<DataChunk>> {
let node = self.network().node();
let request_id = self.next_request_id();
Expand All @@ -195,6 +198,7 @@ impl Client {
message_bytes,
request_id,
timeout,
peer_addrs,
|body| match body {
ChunkMessageBody::GetResponse(ChunkGetResponse::Success {
address: addr,
Expand Down
Loading
Loading