feat: bootstrap peers auto-discovery and release cleanup#47
feat: bootstrap peers auto-discovery and release cleanup#47jacderida wants to merge 2 commits intoWithAutonomi:mainfrom
Conversation
…flow The installers-linux (deb/rpm) and installers-windows (msi) jobs are no longer needed. This removes the workflow jobs, their WiX/systemd support files, Cargo.toml packaging metadata, and all installer references from the sign, checksum, and release-notes steps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds production bootstrap peer auto-discovery (via a shipped bootstrap_peers.toml) and simplifies the release pipeline by dropping deb/rpm/msi installer artifacts.
Changes:
- Introduces
BootstrapPeersConfig+ discovery logic and logs the bootstrap source on startup. - Adds a shipped
config/bootstrap_peers.tomlwith production bootstrap peer addresses and documents discovery/precedence in the README. - Removes packaging/installer assets (WiX/systemd metadata) and updates the release workflow to only build/sign tar/zip archives.
Reviewed changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/config.rs |
Adds bootstrap peers config/discovery + unit tests. |
src/bin/ant-node/cli.rs |
Implements precedence logic (CLI/config/auto-discover) and returns bootstrap source. |
src/bin/ant-node/main.rs |
Logs which bootstrap source was selected at startup. |
config/bootstrap_peers.toml |
Adds the production bootstrap peers list to ship with releases. |
README.md |
Documents bootstrap peers file format, discovery paths, and precedence. |
.github/workflows/release.yml |
Bundles bootstrap_peers.toml into release archives and removes installer build/signing steps. |
Cargo.toml |
Removes deb/rpm packaging metadata. |
Cargo.lock |
Updates lockfile for the new crate version. |
CLAUDE.md |
Updates internal dev notes to reference the new bootstrap peers configuration approach. |
wix/main.wxs |
Removed (dropping MSI packaging). |
wix/license.rtf |
Removed (WiX installer asset). |
systemd/ant-node.service |
Removed (dropping packaged systemd unit file). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/release.yml
Outdated
| shell: pwsh | ||
| run: | | ||
| Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.binary }}", "target/${{ matrix.target }}/release/ant-keygen.exe" -DestinationPath "ant-node-cli-${{ matrix.friendly_name }}.zip" | ||
| Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.binary }}", "target/${{ matrix.target }}/release/ant-keygen.exe", "config/bootstrap_peers.toml" -DestinationPath "ant-node-cli-${{ matrix.friendly_name }}.zip" |
There was a problem hiding this comment.
Windows release archive currently includes config/bootstrap_peers.toml from the repository root, which will be stored under a config/ subdirectory inside the zip. The node’s auto-discovery only checks for bootstrap_peers.toml next to the executable (and other well-known config dirs), so the shipped file won’t be found on Windows after extraction. Copy the file into target/${{ matrix.target }}/release/ (or otherwise place it at the zip root next to the binaries) and archive that path instead.
| Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.binary }}", "target/${{ matrix.target }}/release/ant-keygen.exe", "config/bootstrap_peers.toml" -DestinationPath "ant-node-cli-${{ matrix.friendly_name }}.zip" | |
| Copy-Item "config/bootstrap_peers.toml" "target/${{ matrix.target }}/release/bootstrap_peers.toml" | |
| Push-Location "target/${{ matrix.target }}/release" | |
| Compress-Archive -Path "${{ matrix.binary }}", "ant-keygen.exe", "bootstrap_peers.toml" -DestinationPath "../../../ant-node-cli-${{ matrix.friendly_name }}.zip" | |
| Pop-Location |
There was a problem hiding this comment.
Fixed. The Windows archive step now copies the file into the release directory first, matching the Unix approach. All three archive formats now place bootstrap_peers.toml next to the binary at the archive root.
| #[test] | ||
| fn test_bootstrap_peers_parse_valid_toml() { | ||
| let toml_str = r#" | ||
| peers = [ | ||
| "127.0.0.1:10000", | ||
| "192.168.1.1:10001", | ||
| ] | ||
| "#; | ||
| let config: BootstrapPeersConfig = | ||
| toml::from_str(toml_str).expect("valid TOML should parse"); | ||
| assert_eq!(config.peers.len(), 2); | ||
| assert_eq!(config.peers[0].port(), 10000); |
There was a problem hiding this comment.
These tests rely on .expect(...) (and similar) but CI runs cargo clippy --all-targets and the repo’s clippy settings deny clippy::expect_used/unwrap_used. Add a #[allow(clippy::expect_used)] (and unwrap_used if needed) on this test module/tests (as done elsewhere in the repo), or rewrite the assertions to avoid expect/unwrap, otherwise clippy will fail in CI.
There was a problem hiding this comment.
Already addressed — #[allow(clippy::unwrap_used, clippy::expect_used)] was added to the test module in the previous push.
| /// Env-var-based discovery tests must run serially because they mutate | ||
| /// a shared process-wide environment variable. | ||
| #[test] | ||
| fn test_bootstrap_peers_discover_env_var() { | ||
| // Sub-test 1: valid file with peers is discovered. | ||
| { | ||
| let dir = tempfile::tempdir().expect("create temp dir"); | ||
| let path = dir.path().join("bootstrap_peers.toml"); |
There was a problem hiding this comment.
This test mutates a process-wide environment variable (ANT_BOOTSTRAP_PEERS_PATH). Since the test suite runs in parallel by default, this can race with other tests and become flaky. Mark this test #[serial] (serial_test is already a dev-dependency) or use an explicit global mutex/guard to ensure env var mutations are isolated.
There was a problem hiding this comment.
Good catch. Added #[serial] from serial_test (already a dev-dependency) to the env var test. The two env var sub-tests were already consolidated into a single test function to reduce the race window, but #[serial] makes it robust against future additions.
| 1. **Command-line arguments** (e.g., `--bootstrap`) | ||
| 2. **Environment variables** (`ANT_*`) | ||
| 3. **Configuration file** (`~/.ant-node/config.toml`) | ||
| 3. **Configuration file** (`--config path/to/config.toml`) | ||
| 4. **Bootstrap peers file** (auto-discovered `bootstrap_peers.toml`) | ||
|
|
There was a problem hiding this comment.
README is now partially inconsistent with the actual bootstrap address format and the packaging changes in this PR: elsewhere it still describes --bootstrap/bootstrap = [...] values as libp2p multiaddrs (e.g. /ip4/.../udp/.../quic-v1), but the CLI/config types are SocketAddr and the new docs/examples use ip:port. Also, the “Running as a Service” section still references the removed systemd/ant-node.service and RPM/DEB installers. Please update those remaining sections to match the new ip:port format and the removal of installer artifacts.
There was a problem hiding this comment.
Fixed. Updated the CLI reference to show ip:port format instead of multiaddr, updated the config file example to use SocketAddr format with flat TOML structure, and updated the systemd section to provide an inline service file example instead of referencing the deleted systemd/ant-node.service.
620c01b to
6d84b90
Compare
Introduce `bootstrap_peers.toml`, a dedicated config file that provides initial bootstrap peer addresses for joining the production network. The file is auto-discovered on startup from well-known locations (next to the binary, platform config dir, /etc/ant/) when no --bootstrap CLI argument is provided. - Add BootstrapPeersConfig struct with TOML parsing and search-path discovery - Integrate into Cli::into_config() with clear precedence: --bootstrap CLI > --config file > auto-discovered bootstrap_peers.toml - Log which bootstrap source was used on startup - Ship bootstrap_peers.toml in release archives alongside binaries - Add 7 production bootstrap node addresses - Add unit tests for parsing, discovery, and edge cases - Update README with bootstrap peers file format and search paths - Clean up stale saorsa bootstrap references from CLAUDE.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6d84b90 to
3a40c14
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 12 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if path.is_file() { | ||
| match Self::from_file(&path) { | ||
| Ok(config) if !config.peers.is_empty() => return Some((config, path)), | ||
| _ => {} |
There was a problem hiding this comment.
discover() silently ignores read/parse errors for a found bootstrap_peers.toml (including the env-var override) and falls through to other candidates/None. This can make misconfiguration hard to diagnose (the node may just report 'No bootstrap peers configured'). Consider returning a Result that surfaces the first error for the highest-priority matching path, or at least emitting a warning with the path and error.
| _ => {} | |
| Ok(_) => { | |
| // Empty config: ignore and continue searching other candidates. | |
| } | |
| Err(err) => { | |
| eprintln!( | |
| "Warning: failed to load bootstrap peers from {}: {}", | |
| path.display(), | |
| err | |
| ); | |
| } |
| .\ant-node.exe --testnet | ||
| ``` |
There was a problem hiding this comment.
The release notes examples still use --testnet (e.g., .\ant-node.exe --testnet), but the current CLI does not define a --testnet flag (it uses --network-mode testnet). This PR also introduces production bootstrap auto-discovery via the shipped bootstrap_peers.toml, so the release notes should be updated to reflect the supported flags and the new default startup behavior.
Summary
bootstrap_peers.tomlconfig file that the node loads automatically on startup when no--bootstrapCLI argument is providedBootstrap peers design
BootstrapPeersConfigstruct with TOML parsing and search-path discovery$ANT_BOOTSTRAP_PEERS_PATHenv var > exe directory > platform config dir >/etc/ant/(unix)--bootstrapCLI >--configfile > auto-discoveredbootstrap_peers.toml> emptybootstrap_peers.tomlalongside the binaryTest plan
cargo test— 301 tests pass, zero failurescargo clippy— zero warnings🤖 Generated with Claude Code