Skip to content
Open
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
107 changes: 25 additions & 82 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[workspace]
members = ["ant-core", "ant-cli"]
resolver = "2"

# While ant-protocol 2.0.0 and ant-node 0.11.0 are unpublished, resolve
# both through git pins against their open PR branches. Remove this
# block when both crates are on crates.io.
[patch.crates-io]
ant-protocol = { git = "https://github.com/WithAutonomi/ant-protocol", rev = "597dbdb1b680a43d80a082d77076ff2080444079" }
ant-node = { git = "https://github.com/WithAutonomi/ant-node", branch = "anselme/extract-ant-protocol" }
57 changes: 57 additions & 0 deletions ant-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Changelog

All notable changes to the `ant-core` library will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0] — Unreleased

This release decouples `ant-core` from `ant-node` at runtime. The wire
protocol was extracted into the new [`ant-protocol`] crate; `ant-core`
now depends on `ant-protocol` and keeps `ant-node` only as an optional
dependency (for `LocalDevnet`) and a dev-dependency (for the test
harness that spins up real nodes).

[`ant-protocol`]: https://crates.io/crates/ant-protocol

### Breaking

- **`ant-node` is no longer a default runtime dependency.** The
`LocalDevnet` wrapper and its types (`DevnetManifest` re-export) now
require `features = ["devnet"]`. Downstream `Cargo.toml`:
```toml
ant-core = { version = "0.2", features = ["devnet"] }
```
- `Client::with_evm_network` now takes `ant_protocol::evm::Network`
instead of `evmlib::Network`. Both paths resolve to the same
underlying type (`ant_protocol::evm` is a re-export of `evmlib`), so
the fix for downstream callers is a one-line path change.
- `impl From<ant_node::Error> for Error` has been removed. Call sites
that used `?` to propagate an `ant_node::Error` into an `ant-core`
`Error` must now map explicitly:
```rust
foo().await.map_err(|e| Error::Network(e.to_string()))?;
```
- `ant_core::data::LocalDevnet` is now behind the `devnet` feature.
Code that previously imported it unconditionally must either enable
the feature or use the `DevnetManifest` type alone (available
unconditionally via `ant_core::data::DevnetManifest`).

### Changed

- `ant-core` no longer declares direct dependencies on `evmlib`,
`saorsa-core`, or `saorsa-pqc`. Those transitive dependencies are
consumed through `ant_protocol::{evm, transport, pqc}` so Cargo
enforces a single version pin shared with `ant-node`.
- `DevnetManifest` and `DevnetEvmInfo` moved to
`ant_protocol::devnet_manifest`. The `ant_core::data::DevnetManifest`
path is unchanged; only the origin crate differs. The on-disk JSON
format is byte-for-byte compatible.
- All internal `ant_node::{ant_protocol, client, payment}::*` imports
rewritten to `ant_protocol::*` paths.

### Added

- `devnet` feature flag (off by default) that pulls in `ant-node` as an
optional runtime dependency to enable `LocalDevnet`.
32 changes: 28 additions & 4 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"
xor_name = "5"
self_encryption = "0.35.0"
futures = "0.3"
Expand All @@ -38,8 +43,10 @@ tracing = "0.1"
bytes = "1"
lru = "0.16"
rand = "0.8"
ant-node = "0.10.1"
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", optional = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[target.'cfg(unix)'.dependencies]
Expand All @@ -52,7 +59,20 @@ 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"
serial_test = "3"
anyhow = "1"
alloy = { version = "1.6", features = ["node-bindings"] }
Expand All @@ -61,6 +81,10 @@ tokio-test = "0.4"
[[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
19 changes: 10 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,16 @@ 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::transport::{MultiAddr, PeerId};
use ant_protocol::{
compute_address, serialize_single_node_proof, PaymentProof, SingleNodePayment, 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 +630,7 @@ 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::{QuotePaymentInfo, CLOSE_GROUP_SIZE};

/// Median index in the quotes array.
const MEDIAN_INDEX: usize = CLOSE_GROUP_SIZE / 2;
Expand Down
Loading
Loading