Skip to content
Draft
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
9 changes: 3 additions & 6 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ path = "src/bin/ant-devnet/main.rs"
# Until then, the git pin tracks the matching saorsa-core lineage
# (the rc-2026.4.2 branch) so Cargo can unify the wire types here
# with ant-protocol's re-exports.
ant-protocol = "2.0.1"
ant-protocol = { git = "https://github.com/WithAutonomi/ant-protocol.git", branch = "mick/remove-bootstrap-cache" }

# Core (provides EVERYTHING: networking, DHT, security, trust, storage)
saorsa-core = "0.24.0"
saorsa-core = { git = "https://github.com/saorsa-labs/saorsa-core.git", branch = "mick/remove-bootstrap-cache" }
saorsa-pqc = "0.5"

# Payment verification - autonomi network lookup + EVM payment
Expand Down
24 changes: 2 additions & 22 deletions src/bin/ant-node/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Command-line interface definition.

use ant_node::config::{
BootstrapCacheConfig, BootstrapPeersConfig, BootstrapSource, EvmNetworkConfig, NetworkMode,
NodeConfig, PaymentConfig, UpgradeChannel,
BootstrapPeersConfig, BootstrapSource, EvmNetworkConfig, NetworkMode, NodeConfig,
PaymentConfig, UpgradeChannel,
};
use clap::{Parser, ValueEnum};
use std::net::SocketAddr;
Expand Down Expand Up @@ -133,18 +133,6 @@ pub struct Cli {
/// that will restart the process automatically.
#[arg(long)]
pub stop_on_upgrade: bool,

/// Disable persistent bootstrap cache.
#[arg(long)]
pub disable_bootstrap_cache: bool,

/// Directory for bootstrap cache files.
#[arg(long, env = "ANT_BOOTSTRAP_CACHE_DIR")]
pub bootstrap_cache_dir: Option<PathBuf>,

/// Maximum peers to cache in the bootstrap cache.
#[arg(long, default_value = "10000", env = "ANT_BOOTSTRAP_CACHE_CAPACITY")]
pub bootstrap_cache_capacity: usize,
}

/// Upgrade channel CLI enum.
Expand Down Expand Up @@ -282,14 +270,6 @@ impl Cli {
metrics_port: self.metrics_port,
};

// Bootstrap cache config
config.bootstrap_cache = BootstrapCacheConfig {
enabled: !self.disable_bootstrap_cache,
cache_dir: self.bootstrap_cache_dir,
max_contacts: self.bootstrap_cache_capacity,
..config.bootstrap_cache
};

// Determine bootstrap source and apply auto-discovery if needed.
let bootstrap_source = if cli_bootstrap_provided {
BootstrapSource::Cli
Expand Down
60 changes: 0 additions & 60 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ pub struct NodeConfig {
#[serde(default)]
pub payment: PaymentConfig,

/// Bootstrap cache configuration for persistent peer storage.
#[serde(default)]
pub bootstrap_cache: BootstrapCacheConfig,

/// Storage configuration for chunk persistence.
#[serde(default)]
pub storage: StorageConfig,
Expand Down Expand Up @@ -282,7 +278,6 @@ impl Default for NodeConfig {
testnet: TestnetConfig::default(),
upgrade: UpgradeConfig::default(),
payment: PaymentConfig::default(),
bootstrap_cache: BootstrapCacheConfig::default(),
storage: StorageConfig::default(),
close_group_cache_dir: None,
max_message_size: default_max_message_size(),
Expand Down Expand Up @@ -407,61 +402,6 @@ const fn default_staged_rollout_hours() -> u64 {

// ============================================================================
// Bootstrap Cache Configuration
// ============================================================================

/// Bootstrap cache configuration for persistent peer storage.
///
/// The bootstrap cache stores discovered peers across node restarts,
/// ranking them by quality metrics (success rate, latency, recency).
/// This reduces dependency on hardcoded bootstrap nodes and enables
/// faster network reconnection after restarts.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BootstrapCacheConfig {
/// Enable persistent bootstrap cache.
/// Default: true
#[serde(default = "default_bootstrap_cache_enabled")]
pub enabled: bool,

/// Directory for cache files.
/// Default: `{root_dir}/bootstrap_cache/`
#[serde(default)]
pub cache_dir: Option<PathBuf>,

/// Maximum contacts to store in the cache.
/// Default: 10,000
#[serde(default = "default_bootstrap_max_contacts")]
pub max_contacts: usize,

/// Stale contact threshold in days.
/// Contacts older than this are removed during cleanup.
/// Default: 7 days
#[serde(default = "default_bootstrap_stale_days")]
pub stale_threshold_days: u64,
}

impl Default for BootstrapCacheConfig {
fn default() -> Self {
Self {
enabled: default_bootstrap_cache_enabled(),
cache_dir: None,
max_contacts: default_bootstrap_max_contacts(),
stale_threshold_days: default_bootstrap_stale_days(),
}
}
}

const fn default_bootstrap_cache_enabled() -> bool {
true
}

const fn default_bootstrap_max_contacts() -> usize {
10_000
}

const fn default_bootstrap_stale_days() -> u64 {
7
}

// ============================================================================
// Storage Configuration
// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub use client::{
compute_address, hex_node_id_to_encoded_peer_id, peer_id_to_xor_name, xor_distance, DataChunk,
XorName,
};
pub use config::{BootstrapCacheConfig, NodeConfig, StorageConfig};
pub use config::{NodeConfig, StorageConfig};
pub use devnet::{Devnet, DevnetConfig, DevnetEvmInfo, DevnetManifest};
pub use error::{Error, Result};
pub use event::{NodeEvent, NodeEventsChannel};
Expand Down
56 changes: 0 additions & 56 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::upgrade::{
use rand::Rng;
use saorsa_core::identity::NodeIdentity;
use saorsa_core::{
BootstrapConfig as CoreBootstrapConfig, BootstrapManager,
IPDiversityConfig as CoreDiversityConfig, MultiAddr, NodeConfig as CoreNodeConfig, P2PEvent,
P2PNode,
};
Expand Down Expand Up @@ -108,14 +107,6 @@ impl NodeBuilder {
Some(Self::build_upgrade_monitor(&self.config, node_id_seed))
};

// Initialize bootstrap cache manager if enabled
let bootstrap_manager = if self.config.bootstrap_cache.enabled {
Self::build_bootstrap_manager(&self.config).await
} else {
info!("Bootstrap cache disabled");
None
};

// Initialize ANT protocol handler for chunk storage and
// wire the fresh-write channel so PUTs trigger replication.
let (ant_protocol, fresh_write_rx) = if self.config.storage.enabled {
Expand Down Expand Up @@ -173,7 +164,6 @@ impl NodeBuilder {
events_tx,
events_rx: Some(events_rx),
upgrade_monitor,
bootstrap_manager,
ant_protocol,
replication_engine,
protocol_task: None,
Expand Down Expand Up @@ -410,41 +400,6 @@ impl NodeBuilder {

Ok(protocol)
}

/// Build the bootstrap cache manager from config.
async fn build_bootstrap_manager(config: &NodeConfig) -> Option<BootstrapManager> {
let cache_dir = config
.bootstrap_cache
.cache_dir
.clone()
.unwrap_or_else(|| config.root_dir.join("bootstrap_cache"));

// Create cache directory
if let Err(e) = std::fs::create_dir_all(&cache_dir) {
warn!("Failed to create bootstrap cache directory: {e}");
return None;
}

let bootstrap_config = CoreBootstrapConfig {
cache_dir,
max_peers: config.bootstrap_cache.max_contacts,
..CoreBootstrapConfig::default()
};

match BootstrapManager::with_config(bootstrap_config).await {
Ok(manager) => {
info!(
"Bootstrap cache initialized with {} max contacts",
config.bootstrap_cache.max_contacts
);
Some(manager)
}
Err(e) => {
warn!("Failed to initialize bootstrap cache: {e}");
None
}
}
}
}

/// A running Ant node.
Expand All @@ -455,8 +410,6 @@ pub struct RunningNode {
events_tx: NodeEventsSender,
events_rx: Option<NodeEventsChannel>,
upgrade_monitor: Option<UpgradeMonitor>,
/// Bootstrap cache manager for persistent peer storage.
bootstrap_manager: Option<BootstrapManager>,
/// ANT protocol handler for chunk storage.
ant_protocol: Option<Arc<AntProtocol>>,
/// Replication engine (manages neighbor sync, verification, audits).
Expand Down Expand Up @@ -691,15 +644,6 @@ impl RunningNode {
// Run the main event loop with signal handling
self.run_event_loop().await?;

// Log bootstrap cache stats before shutdown
if let Some(ref manager) = self.bootstrap_manager {
let stats = manager.stats().await;
info!(
"Bootstrap cache shutdown: {} peers, avg quality {:.2}",
stats.total_peers, stats.average_quality
);
}

// Shutdown replication engine before P2P so background tasks don't
// use a dead P2P layer, and Arc<LmdbStorage> references are released.
if let Some(ref mut engine) = self.replication_engine {
Expand Down
Loading