Skip to content

feat: replace ant-evm and libp2p with evmlib#53

Merged
jacderida merged 4 commits intomainfrom
merge-evmlib
Mar 31, 2026
Merged

feat: replace ant-evm and libp2p with evmlib#53
jacderida merged 4 commits intomainfrom
merge-evmlib

Conversation

@grumbach
Copy link
Copy Markdown
Collaborator

Summary

  • Remove ant-evm, libp2p, and multihash dependencies entirely
  • All payment types now come from evmlib (which absorbed the needed ant-evm types)
  • EncodedPeerId is now [u8; 32] (native saorsa PeerId, no libp2p multihash encoding)
  • hex_node_id_to_encoded_peer_id() simplified to direct hex decode
  • validate_peer_bindings() compares raw 32-byte PeerIds directly
  • ~530 transitive dependencies removed from lock file

Context

Depends on WithAutonomi/evmlib#3 — evmlib must absorb the ant-evm types first.

The saorsa network uses native 32-byte PeerIds (BLAKE3 hash of ML-DSA-65 public keys), not libp2p PeerIds. The old code wrapped these in a libp2p identity-multihash (34 bytes), passed through libp2p::PeerId, then unwrapped by stripping the 2-byte header. This PR removes that overhead entirely.

Test plan

  • cargo check passes
  • cargo fmt + clippy clean (strict deny on unwrap/expect/panic)
  • cargo test --lib — 300 tests pass
  • E2E tests with local devnet

Remove ant-evm, libp2p, and multihash dependencies entirely. All
payment types now come from evmlib which absorbed the needed ant-evm
types with libp2p stripped out.

Key changes:
- EncodedPeerId is now [u8; 32] (native saorsa PeerId bytes)
- hex_node_id_to_encoded_peer_id simplified to hex decode + wrap
- validate_peer_bindings compares raw 32-byte PeerIds directly
  instead of decoding through libp2p multihash
- All test helpers rewritten to use EncodedPeerId::new(rand::random())
  instead of libp2p Keypair/PeerId construction

This removes ~530 transitive dependencies from the lock file.
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 migrates the node’s EVM/payment integration off ant-evm/libp2p/multihash and onto evmlib, aligning peer identity handling with saorsa’s native 32-byte PeerId format and significantly reducing transitive dependencies.

Changes:

  • Replaced ant-evm payment types/usages across core and E2E tests with evmlib equivalents.
  • Simplified peer-id encoding/validation to operate on raw 32-byte peer IDs (no multihash/libp2p wrapping).
  • Updated Anvil/Testnet helpers to propagate Result errors instead of assuming infallible calls.

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/e2e/testnet.rs Swaps RewardsAddress import to evmlib.
tests/e2e/security_attacks.rs Uses evmlib::ProofOfPayment; propagates Testnet::new() errors.
tests/e2e/payment_flow.rs Propagates default_wallet_private_key() / Testnet::new() errors.
tests/e2e/merkle_payment.rs Moves merkle payment types + RewardsAddress to evmlib; propagates Testnet::new() errors.
tests/e2e/integration_tests.rs Adapts to default_wallet_key() returning Result.
tests/e2e/data_types/chunk.rs Updates payment proof/types to evmlib; improves testnet startup error context.
tests/e2e/anvil.rs Makes wallet key retrieval fallible; maps evmlib errors into AnvilError.
src/storage/handler.rs Switches test imports from ant_evm to evmlib types.
src/payment/wallet.rs Replaces ant_evm::RewardsAddress with evmlib::RewardsAddress.
src/payment/verifier.rs Replaces ant_evm types; validates peer bindings against raw 32-byte IDs; improves error formatting.
src/payment/single_node.rs Moves common/payment types to evmlib modules; improves error propagation in tests.
src/payment/quote.rs Updates quote/candidate/metrics types to evmlib.
src/payment/proof.rs Updates proof + merkle proof types to evmlib; adjusts tests to avoid libp2p.
src/payment/pricing.rs Uses evmlib Amount + QuotingMetrics modules.
src/payment/metrics.rs Updates quoting metrics import to evmlib.
src/devnet.rs Swaps RewardsAddress import to evmlib.
src/client/mod.rs Simplifies hex peer-id conversion to direct 32-byte decode + EncodedPeerId::new.
src/bin/ant-devnet/main.rs Propagates Anvil testnet startup + wallet key retrieval errors.
Cargo.toml Removes ant-evm, libp2p, multihash; switches evmlib dependency specification.
Cargo.lock Reflects dependency graph reduction and the updated evmlib resolution.

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

))
let bytes: [u8; 32] = raw_bytes.try_into().map_err(|v: Vec<u8>| {
let len = v.len();
Error::Payment(format!("Peer ID must be 32 bytes, got {len}"))
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The length error path drops the offending input value, making it harder to diagnose which peer ID was malformed. Consider including hex_id (and/or expected hex length of 64 chars) in the "Peer ID must be 32 bytes" error message for easier debugging.

Suggested change
Error::Payment(format!("Peer ID must be 32 bytes, got {len}"))
Error::Payment(format!(
"Peer ID must be 32 bytes (64 hex chars), got {len} bytes from '{hex_id}'"
))

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 31, 2026 09:04
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 18 out of 20 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 on lines +88 to 92
pub fn default_wallet_key(&self) -> Result<String> {
self.testnet
.default_wallet_private_key()
.map_err(|e| AnvilError::Startup(format!("Failed to get wallet key: {e}")))
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

default_wallet_key() maps failures to AnvilError::Startup, which results in error messages like "Failed to start Anvil: Failed to get wallet key..." even though startup already succeeded. Consider using a more appropriate error variant (or renaming Startup to a more general variant) so callers get accurate context.

Copilot uses AI. Check for mistakes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jacderida jacderida merged commit c012bb1 into main Mar 31, 2026
10 checks passed
@jacderida jacderida deleted the merge-evmlib branch March 31, 2026 13:07
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.

4 participants