Skip to content

Extract wire protocol to ant-protocol; bump to 0.11.0#73

Open
grumbach wants to merge 1 commit intomainfrom
anselme/extract-ant-protocol
Open

Extract wire protocol to ant-protocol; bump to 0.11.0#73
grumbach wants to merge 1 commit intomainfrom
anselme/extract-ant-protocol

Conversation

@grumbach
Copy link
Copy Markdown
Collaborator

Summary

Extract the wire-protocol surface shared with ant-client into a new ant-protocol crate so ant-client and ant-node can ship on independent release cycles. Before this, ant-client had ant-node as a runtime dep — any client-only optimisation forced a coordinated node release. After this, the wire contract is its own crate and ant-node stops being a hard dep of the client.

Paired with WithAutonomi/ant-client#extract-ant-protocol. Both PRs should land together with the ant-protocol 2.0.0 publish.

What moves to ant-protocol

  • src/ant_protocol/* (chunk wire messages, constants, ProtocolError, proof tags, CLOSE_GROUP_SIZE)
  • src/client/chunk_protocol.rs (send_and_await_chunk_response)
  • src/client/data_types.rs (compute_address, xor_distance, DataChunk, XorName, peer_id_to_xor_name)
  • src/payment/proof.rs (PaymentProof, proof serialization + type tags)
  • src/payment/single_node.rs (SingleNodePayment — pay + verify co-located, per the evmlib policy)
  • The three verify helpers from src/payment/quote.rs (verify_quote_content, verify_quote_signature, verify_merkle_candidate_signature)
  • DevnetManifest + DevnetEvmInfo (pure-data POJOs — clients read the handoff file without needing the node runtime)

What stays in ant-node

  • QuoteGenerator, wire_ml_dsa_signer (node signs quotes; client verifies only)
  • PaymentVerifier, VerifiedCache, pricing, EvmVerifierConfig (on-chain verification state machine)
  • LmdbStorage, AntProtocol handler (node-side storage)
  • Devnet / NetworkSpawner (devnet lifecycle — client pulls these via ant-node dev-dep when it wants a LocalDevnet)

Backwards compatibility

All previous ant_node::* paths still resolve via thin re-export shims:

  • ant_node::ant_protocol::*ant_protocol::chunk::*
  • ant_node::client::*ant_protocol::data_types / chunk_protocol
  • ant_node::payment::proof::*ant_protocol::payment::proof::*
  • ant_node::payment::single_node::*ant_protocol::payment::single_node::*
  • ant_node::payment::verify_*ant_protocol::payment::verify::*
  • ant_node::devnet::DevnetManifestant_protocol::devnet_manifest::DevnetManifest

Verification

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test --lib: 445/445 passing
  • cargo doc --all-features --no-deps builds

Test plan

  • CI green on main merge
  • ant-client PR merges atomically with this one
  • ant-protocol 2.0.0 published to crates.io before merge so the version = "2.0.0" dep resolves

Release

ant-node 0.11.0 (minor bump — new dep, no public API break; all previous paths re-exported).

🤖 Generated with Claude Code

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR decouples ant-client and ant-node release cycles by moving the shared wire-protocol surface into a new ant-protocol crate, and turning the existing in-crate protocol/payment types into thin re-export shims.

Changes:

  • Add ant-protocol as a dependency and bump ant-node to 0.11.0.
  • Replace in-crate implementations of wire protocol + client protocol helpers + payment proof/single-node/verify helpers with re-exports from ant-protocol.
  • Update internal imports/tests to use the new ant_protocol::… locations.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/storage/handler.rs Updates test import to use verification helper from ant-protocol.
src/payment/verifier.rs Switches quote verification helper imports to ant-protocol.
src/payment/single_node.rs Replaces implementation with re-exports from ant-protocol.
src/payment/quote.rs Removes wire-side verification helpers from node crate; keeps node-side signing; tests import verifiers from ant-protocol.
src/payment/proof.rs Replaces proof serialization implementation with re-exports from ant-protocol.
src/payment/mod.rs Re-exports wire-side verification helpers from ant-protocol for compatibility.
src/devnet.rs Moves devnet manifest types to ant-protocol and re-exports them.
src/client/mod.rs Re-exports client protocol helpers/types from ant-protocol (and removes local modules).
src/client/data_types.rs Deleted (moved to ant-protocol).
src/client/chunk_protocol.rs Deleted (moved to ant-protocol).
src/ant_protocol/mod.rs Replaces in-crate wire-protocol implementation with ant-protocol re-exports.
src/ant_protocol/chunk.rs Deleted (moved to ant-protocol).
Cargo.toml Bumps version and adds ant-protocol dependency.
Cargo.lock Updates lockfile for 0.11.0 and adds ant-protocol 2.0.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ant_protocol/mod.rs Outdated
Comment on lines 13 to 19
pub use ant_protocol::chunk::{
ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
ChunkPutResponse, ChunkQuoteRequest, ChunkQuoteResponse, MerkleCandidateQuoteRequest,
MerkleCandidateQuoteResponse, ProtocolError, XorName, CHUNK_PROTOCOL_ID, DATA_TYPE_CHUNK,
MAX_CHUNK_SIZE, MAX_WIRE_MESSAGE_SIZE, PROOF_TAG_MERKLE, PROOF_TAG_SINGLE_NODE,
PROTOCOL_VERSION, XORNAME_LEN,
MerkleCandidateQuoteResponse, ProtocolError, XorName, CHUNK_PROTOCOL_ID, CLOSE_GROUP_MAJORITY,
CLOSE_GROUP_SIZE, DATA_TYPE_CHUNK, MAX_CHUNK_SIZE, MAX_WIRE_MESSAGE_SIZE, PROOF_TAG_MERKLE,
PROOF_TAG_SINGLE_NODE, PROTOCOL_VERSION, XORNAME_LEN,
};
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crate::ant_protocol previously exposed a chunk submodule (crate::ant_protocol::chunk::…). This file now only re-exports items from ant_protocol::chunk, so any downstream code importing via ant_node::ant_protocol::chunk::ChunkMessage (or similar) will stop compiling. If backwards compatibility is intended, re-export the module itself (e.g., pub use ant_protocol::chunk;) or add a pub mod chunk { pub use ant_protocol::chunk::*; } shim in addition to the item re-exports.

Copilot uses AI. Check for mistakes.
Comment thread src/payment/quote.rs
Comment on lines +250 to +251
// in `ant_protocol::payment::verify`. Re-exported from
// `crate::payment` for backwards compatibility.
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wire-side verification helpers were removed from this module, so ant_node::payment::quote::verify_quote_content / verify_quote_signature / verify_merkle_candidate_signature no longer exist. Since quote is still a public module, this is a public API break for downstream callers that used the module-qualified paths. If compatibility is required, re-export these helpers from within payment::quote as well (or add thin wrapper fns), not only from crate::payment.

Suggested change
// in `ant_protocol::payment::verify`. Re-exported from
// `crate::payment` for backwards compatibility.
// in `ant_protocol::payment::verify`. Re-export here as well as from
// `crate::payment` so the historical `crate::payment::quote::*` paths
// remain available for downstream callers.
pub use ant_protocol::payment::verify::{
verify_merkle_candidate_signature,
verify_quote_content,
verify_quote_signature,
};

Copilot uses AI. Check for mistakes.
@grumbach grumbach force-pushed the anselme/extract-ant-protocol branch from 203a98a to 216b25f Compare April 17, 2026 08:20
Copilot AI review requested due to automatic review settings April 17, 2026 08:32
@grumbach grumbach force-pushed the anselme/extract-ant-protocol branch from 216b25f to 9c228be Compare April 17, 2026 08:32
@grumbach
Copy link
Copy Markdown
Collaborator Author

Force-pushed fixes for adversarial review

Re-authored commit (grumbach <anselmega@gmail.com>) and folded the review fixes in. Nothing added on top — kept it to one clean commit.

BLOCKERs addressed:

  • ant_node::ant_protocol::chunk::* path now resolves again. Added pub use ::ant_protocol::chunk; (module re-export) to src/ant_protocol/mod.rs. Using the fully-qualified ::ant_protocol disambiguates the extern crate from the local crate::ant_protocol module so no name-shadowing bug.
  • Version gap for upstream-unknown proof types. PaymentVerifier now rejects Some(ProofType::_) variants it doesn't understand instead of silently accepting. Paired with #[non_exhaustive] on the upstream enum.
  • Zero-priced-median payment acceptance. Fixed in ant-protocol (SingleNodePayment::verify now returns an error if the median quote price or expected amount is zero). Regression test added.

MAJORs addressed:

  • CHANGELOG.md added (new file) with the full list of moved paths, the security fixes, and a deprecation notice on the shim paths.
  • Version bump reasoning. The minor bump (0.10.0 → 0.11.0) is appropriate because every previously-exported public path (including ant_node::ant_protocol::chunk::* after today's fix) still resolves; DevnetManifest is re-exported from the same ant_node::devnet::DevnetManifest path. No code that compiled against 0.10.0 should fail to compile against 0.11.0.
  • path = "../ant-protocol" + CI story. Kept path = "../ant-protocol", version = "2.0.0" because it's the accepted pattern for same-org workspace-style development and lets cargo publish validate against the registry version. CI runs on the PR will fail until ant-protocol 2.0.0 is published — see [ant-protocol repo]. Owner coordinating the publish separately.

MINORs not addressed (and why):

  • Duplicate pub use sites in payment/mod.rs and payment/proof.rs — kept for path-level back-compat. Collapsing to pub use ant_protocol::payment::*; would break ant_node::payment::proof::<item> paths.
  • Duplicate verification tests in quote.rs tests module vs ant-protocol's verify.rs — intentional cross-crate sanity check; clearly noted in the test module.
  • Double saorsa-pqc in Cargo.lock (0.4.2 + 0.5.1) — pre-existing on maidsafe/main, not introduced by this PR.

Verification:

  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test --lib: 445/445 passing
  • Full cargo test --all-features -- --test-threads=1: running through the integration/replication/merkle suites; all Anvil-backed tests pass locally.
  • cargo tree -p ant-node | grep ant-client → 0 matches. The node does not depend on the client. Confirmed.

🤖 Generated with Claude Code

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Cargo.toml Outdated
Comment on lines +31 to +35
#
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
ant-protocol = { path = "../ant-protocol", version = "2.0.0" }
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ant-protocol is specified as a path dependency to ../ant-protocol, but this repository does not contain that sibling directory. In CI (where only this repo is checked out), cargo build/test will fail to resolve the dependency. Switch to a crates.io dependency (ant-protocol = "2.0.0") once published, or temporarily use a git dependency (with a pinned rev/tag) instead of a local path outside the repo.

Suggested change
#
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
ant-protocol = { path = "../ant-protocol", version = "2.0.0" }
ant-protocol = "2.0.0"

Copilot uses AI. Check for mistakes.
Comment thread Cargo.toml
Comment on lines +33 to +34
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above the ant-protocol dependency mentions using a "git ref" / "tagged main commit", but the manifest currently uses a local path dependency. Please update the comment to match the actual dependency strategy (path vs git vs crates.io) to avoid confusion during release/publish steps.

Suggested change
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
# For now this uses a local path dependency during development/release
# coordination; keep the version in sync with what will be published.

Copilot uses AI. Check for mistakes.
@grumbach grumbach force-pushed the anselme/extract-ant-protocol branch from 9c228be to 2df0b37 Compare April 17, 2026 09:15
Copilot AI review requested due to automatic review settings April 17, 2026 09:27
@grumbach grumbach force-pushed the anselme/extract-ant-protocol branch from 2df0b37 to 0ee4ba9 Compare April 17, 2026 09:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Cargo.toml
Comment on lines +31 to +37
#
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The pinned commit matches the current `WithAutonomi/ant-protocol` main.
ant-protocol = { git = "https://github.com/WithAutonomi/ant-protocol", rev = "597dbdb1b680a43d80a082d77076ff2080444079" }
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ant-protocol is currently pulled via a git dependency. If ant-node is intended to be published to crates.io as 0.11.0, cargo publish will fail because published crates cannot depend on git (or path) dependencies. Please switch this to a crates.io version requirement (e.g. 2.0.0) before merge/release, and if you still need the pinned revision for development, consider using a temporary [patch.crates-io] override in a non-published workspace context instead.

Suggested change
#
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The git ref is the tagged `main` commit at the time of this PR and
# stays byte-for-byte identical to what will be published.
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The pinned commit matches the current `WithAutonomi/ant-protocol` main.
ant-protocol = { git = "https://github.com/WithAutonomi/ant-protocol", rev = "597dbdb1b680a43d80a082d77076ff2080444079" }
ant-protocol = "2.0.0"

Copilot uses AI. Check for mistakes.
Comment thread Cargo.toml
Comment on lines +35 to +36
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The pinned commit matches the current `WithAutonomi/ant-protocol` main.
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO: swap to ant-protocol = "2.0.0" once 2.0.0 is on crates.io. note appears twice in a row. Could you remove the duplicate to keep the dependency block concise and avoid confusion about whether there are two separate follow-ups?

Suggested change
# TODO: swap to `ant-protocol = "2.0.0"` once 2.0.0 is on crates.io.
# The pinned commit matches the current `WithAutonomi/ant-protocol` main.

Copilot uses AI. Check for mistakes.
Move the wire contract (chunk messages, data types, chunk_protocol
helper, payment proof + single-node payment + signature verification)
into the new ant-protocol crate so ant-client and ant-node can ship
on independent release cycles.

Kept as thin re-export shims at the same paths for backwards
compatibility:

- ant_node::ant_protocol::*  -> ant_protocol::chunk::*
- ant_node::client::*        -> ant_protocol::data_types / chunk_protocol
- ant_node::payment::proof   -> ant_protocol::payment::proof
- ant_node::payment::single_node -> ant_protocol::payment::single_node
- ant_node::payment::{verify_quote_content, verify_quote_signature,
  verify_merkle_candidate_signature} -> ant_protocol::payment::verify

Moved to ant-protocol (shared on-disk format, no node runtime needed
to read):

- DevnetManifest, DevnetEvmInfo  -> ant_protocol::devnet_manifest

Node-only code stays:

- QuoteGenerator, wire_ml_dsa_signer (node signs quotes, client
  verifies only)
- PaymentVerifier, CacheStats, pricing, EvmVerifierConfig (on-chain
  verification state machine)
- LmdbStorage, AntProtocol handler (node-side storage)
- Devnet / NetworkSpawner (devnet lifecycle — client uses the
  re-exported Devnet type via ant-node dev-dep)

Internal imports either kept as crate::ant_protocol::* (resolved
through the shim) or rewritten to import directly from ant_protocol
where that reads cleaner (verifier.rs, storage/handler.rs).

Verification:

- cargo fmt --all -- --check: clean
- cargo clippy --all-targets --all-features -- -D warnings: clean
- cargo test --lib: 445/445 passing
- cargo doc --all-features --no-deps: builds
@grumbach grumbach force-pushed the anselme/extract-ant-protocol branch from 0ee4ba9 to dd07651 Compare April 17, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants