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
121 changes: 24 additions & 97 deletions Cargo.lock

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

38 changes: 31 additions & 7 deletions ant-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ant-core"
version = "0.1.1"
version = "0.2.0"
edition = "2021"

[dependencies]
Expand All @@ -27,7 +27,12 @@ zip = "2"
tower-http = { version = "0.6.8", features = ["cors"] }

# Data operations
evmlib = "0.8"
# Wire protocol crate: gives us `ant_protocol::{chunk, payment, …}` plus
# re-exports of `evmlib`, `saorsa-core` (transport), and `saorsa-pqc`
# under `ant_protocol::{evm, transport, pqc}`. This is the ONE pin for
# those three deps — do not add direct evmlib/saorsa-core/saorsa-pqc
# deps here or the version can skew between ant-client and ant-node.
ant-protocol = "2.0.1"
xor_name = "5"
self_encryption = "0.35.0"
futures = "0.3"
Expand All @@ -44,8 +49,10 @@ rand = "0.8"
# sysinfo, so the crate is loaded lazily and the cost is bounded to first-time
# upgrade scenarios.
sysinfo = { version = "0.32", default-features = false, features = ["system"] }
ant-node = "0.11.0"
saorsa-pqc = "0.5"
# ant-node is optional. It is only linked for the `LocalDevnet` wrapper
# that spawns a local in-process network for development and testing.
# Enable with `--features devnet`.
ant-node = { version = "0.11.0", optional = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[target.'cfg(unix)'.dependencies]
Expand All @@ -58,21 +65,38 @@ openssl = { version = "0.10", features = ["vendored"] }
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Console", "Win32_System_Threading"] }

[features]
# No features enabled by default — consumers that want to spawn a local
# devnet opt in with `features = ["devnet"]`.
default = []
# Enable `LocalDevnet` (ant-core/src/node/devnet.rs) which wraps
# `ant_node::devnet::Devnet` and an Anvil EVM testnet.
devnet = ["dep:ant-node"]

[dev-dependencies]
# Test infrastructure in tests/support/mod.rs spawns real ant-nodes
# in-process to exercise the wire protocol end-to-end. ant-node is a
# dev-dep here (separate from the optional runtime dep above) so tests
# always compile even without the `devnet` feature.
ant-node = "0.11.0"
serial_test = "3"
anyhow = "1"
alloy = { version = "1.6", features = ["node-bindings"] }
tokio-test = "0.4"
rmp-serde = "1"
# Direct access to BootstrapManager used by the cold-start-from-disk test,
# which populates a cache via `add_peer_trusted` (bypasses Sybil rate limits)
# and then verifies reload after save. Version tracks ant-node's transitive
# saorsa-core dep.
saorsa-core = "0.23"
# and then verifies reload after save. Test-only — no runtime version-pin
# concern. Tracks ant-node's transitive saorsa-core dep.
saorsa-core = "0.24"

[[example]]
name = "start-local-devnet"
path = "examples/start-local-devnet.rs"
# `LocalDevnet` (and therefore this example) is gated behind `devnet`.
# Running under default features would produce a confusing "LocalDevnet
# not found" error, so require the feature explicitly.
required-features = ["devnet"]

[[test]]
name = "e2e_chunk"
Expand Down
18 changes: 9 additions & 9 deletions ant-core/src/data/client/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use crate::data::client::file::UploadEvent;
use crate::data::client::payment::peer_id_to_encoded;
use crate::data::client::Client;
use crate::data::error::{Error, Result};
use ant_node::ant_protocol::DATA_TYPE_CHUNK;
use ant_node::client::{compute_address, XorName};
use ant_node::core::{MultiAddr, PeerId};
use ant_node::payment::{serialize_single_node_proof, PaymentProof, SingleNodePayment};
use ant_protocol::evm::{
Amount, EncodedPeerId, PayForQuotesError, PaymentQuote, ProofOfPayment, QuoteHash,
RewardsAddress, TxHash,
};
use ant_protocol::payment::{serialize_single_node_proof, PaymentProof, SingleNodePayment};
use ant_protocol::transport::{MultiAddr, PeerId};
use ant_protocol::{compute_address, XorName, DATA_TYPE_CHUNK};
use bytes::Bytes;
use evmlib::common::{Amount, QuoteHash, TxHash};
use evmlib::wallet::PayForQuotesError;
use evmlib::{EncodedPeerId, PaymentQuote, ProofOfPayment, RewardsAddress};
use futures::stream::{self, StreamExt};
use std::collections::{HashMap, HashSet};
use std::time::Duration;
Expand Down Expand Up @@ -628,8 +628,8 @@ mod send_assertions {
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
use ant_node::payment::single_node::QuotePaymentInfo;
use ant_node::CLOSE_GROUP_SIZE;
use ant_protocol::payment::QuotePaymentInfo;
use ant_protocol::CLOSE_GROUP_SIZE;

/// Median index in the quotes array.
const MEDIAN_INDEX: usize = CLOSE_GROUP_SIZE / 2;
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,7 +3,7 @@
//! Caches recently fetched chunks in memory to avoid re-fetching
//! the same content-addressed data from the network.

use ant_node::client::XorName;
use ant_protocol::XorName;
use bytes::Bytes;
use lru::LruCache;
use std::num::NonZeroUsize;
Expand Down
11 changes: 5 additions & 6 deletions ant-core/src/data/client/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
use crate::data::client::peer_cache::record_peer_outcome;
use crate::data::client::Client;
use crate::data::error::{Error, Result};
use ant_node::ant_protocol::{
ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
ChunkPutResponse,
use ant_protocol::transport::{MultiAddr, PeerId};
use ant_protocol::{
compute_address, send_and_await_chunk_response, ChunkGetRequest, ChunkGetResponse,
ChunkMessage, ChunkMessageBody, ChunkPutRequest, ChunkPutResponse, DataChunk, XorName,
CLOSE_GROUP_MAJORITY,
};
use ant_node::client::{compute_address, send_and_await_chunk_response, DataChunk, XorName};
use ant_node::core::{MultiAddr, PeerId};
use ant_node::CLOSE_GROUP_MAJORITY;
use bytes::Bytes;
use futures::stream::{FuturesUnordered, StreamExt};
use std::future::Future;
Expand Down
3 changes: 1 addition & 2 deletions ant-core/src/data/client/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use crate::data::client::file::{ExternalPaymentInfo, PreparedUpload};
use crate::data::client::merkle::PaymentMode;
use crate::data::client::Client;
use crate::data::error::{Error, Result};
use ant_node::ant_protocol::DATA_TYPE_CHUNK;
use ant_node::client::compute_address;
use ant_protocol::{compute_address, DATA_TYPE_CHUNK};
use bytes::Bytes;
use futures::stream::{self, StreamExt, TryStreamExt};
use self_encryption::{decrypt, encrypt, DataMap, EncryptedChunk};
Expand Down
13 changes: 5 additions & 8 deletions ant-core/src/data/client/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ use crate::data::client::merkle::{
};
use crate::data::client::Client;
use crate::data::error::{Error, Result};
use ant_node::ant_protocol::DATA_TYPE_CHUNK;
use ant_node::client::compute_address;
use ant_node::core::{MultiAddr, PeerId};
use ant_protocol::evm::{Amount, PaymentQuote, QuoteHash, TxHash, MAX_LEAVES};
use ant_protocol::transport::{MultiAddr, PeerId};
use ant_protocol::{compute_address, DATA_TYPE_CHUNK};
use bytes::Bytes;
use evmlib::common::{Amount, QuoteHash, TxHash};
use evmlib::merkle_payments::MAX_LEAVES;
use evmlib::PaymentQuote;
use fs2::FileExt;
use futures::stream::{self, StreamExt};
use self_encryption::{get_root_data_map_parallel, stream_encrypt, streaming_decrypt, DataMap};
Expand Down Expand Up @@ -1246,7 +1243,7 @@ impl Client {
progress: Option<&mpsc::Sender<UploadEvent>>,
) -> Result<(usize, String, u128)> {
let mut total_stored = 0usize;
let mut total_storage = evmlib::common::Amount::ZERO;
let mut total_storage = Amount::ZERO;
let mut total_gas: u128 = 0;
let total_chunks = spill.len();
let waves: Vec<&[[u8; 32]]> = spill.waves().collect();
Expand Down Expand Up @@ -1276,7 +1273,7 @@ impl Client {
.batch_upload_chunks_with_events(wave_data, progress, total_stored, total_chunks)
.await?;
total_stored += addresses.len();
if let Ok(cost) = wave_storage.parse::<evmlib::common::Amount>() {
if let Ok(cost) = wave_storage.parse::<Amount>() {
total_storage += cost;
}
total_gas = total_gas.saturating_add(wave_gas);
Expand Down
Loading
Loading