Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat autonomi client init #2525

Closed
wants to merge 10 commits into from
4 changes: 2 additions & 2 deletions .github/workflows/benchmark-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
env:
ANT_LOG: "all"
with:
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:

- name: Stop the local network
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_benchmark
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-benchmark-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
platform: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_memcheck
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand All @@ -222,7 +222,7 @@ jobs:

# only these unit tests require a network, the rest are run above in unit test section
- name: Run autonomi --tests
run: cargo test --package autonomi --tests -- --nocapture
run: cargo test --package autonomi --tests -- --nocapture --test-threads=1
env:
ANT_LOG: "v"
# only set the target dir for windows to bypass the linker issue.
Expand Down Expand Up @@ -578,7 +578,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_e2e
Expand Down Expand Up @@ -608,7 +608,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -643,7 +643,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: safe_test_logs_transaction
Expand Down Expand Up @@ -682,7 +682,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -710,7 +710,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: safe_test_logs_transaction_simulation
Expand Down Expand Up @@ -748,7 +748,7 @@ jobs:
# timeout-minutes: 35

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -776,7 +776,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: safe_test_logs_token_distribution
Expand Down Expand Up @@ -818,7 +818,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -855,7 +855,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_churn
Expand Down Expand Up @@ -965,7 +965,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -1013,7 +1013,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_data_location
Expand Down Expand Up @@ -1084,7 +1084,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -1230,7 +1230,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# platform: ubuntu-latest
Expand Down Expand Up @@ -1280,7 +1280,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -1372,7 +1372,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
platform: ubuntu-latest
Expand Down Expand Up @@ -1443,7 +1443,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -1590,7 +1590,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: safe_test_logs_heavy_replicate_bench
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_e2e
Expand Down Expand Up @@ -319,7 +319,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand All @@ -338,7 +338,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_churn
Expand Down Expand Up @@ -472,7 +472,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: start
enable-evm-testnet: true
Expand Down Expand Up @@ -501,7 +501,7 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/ant-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
with:
action: stop
log_file_prefix: safe_test_logs_data_location
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/node_man_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand All @@ -81,7 +81,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: node_man_tests_user_mode
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
# timeout-minutes: 30

# - name: Start a local network
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: start
# interval: 2000
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:

# - name: Stop the local network and upload logs
# if: always()
# uses: maidsafe/ant-local-testnet-action@main
# uses: maidsafe/ant-local-testnet-action@feat-addrs-logs
# with:
# action: stop
# log_file_prefix: node_man_tests_system_wide
Expand Down
33 changes: 25 additions & 8 deletions ant-bootstrap/src/initial_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ pub struct PeersArgs {
}

impl PeersArgs {
/// Get bootstrap peers sorted by the failure rate. The peer with the lowest failure rate will be
/// the first in the list.
/// Get bootstrap peers sorted by the failure rate.
/// The peer with the lowest failure rate will be the first in the list.
///
/// Order of precedence:
/// 1. Addresses from arguments
/// 2. Addresses from environment variable `ANT_PEERS`
/// 3. Addresses from cache
/// 4. Addresses from network contacts URL
pub async fn get_addrs(
&self,
config: Option<BootstrapCacheConfig>,
Expand All @@ -94,8 +100,14 @@ impl PeersArgs {
.collect())
}

/// Get bootstrap peers sorted by the failure rate. The peer with the lowest failure rate will be
/// the first in the list.
/// Get bootstrap peers sorted by the failure rate.
/// The peer with the lowest failure rate will be the first in the list.
///
/// Order of precedence:
/// 1. Addresses from arguments
/// 2. Addresses from environment variable `ANT_PEERS`
/// 3. Addresses from cache
/// 4. Addresses from network contacts URL
pub async fn get_bootstrap_addr(
&self,
config: Option<BootstrapCacheConfig>,
Expand All @@ -107,14 +119,21 @@ impl PeersArgs {
return Ok(vec![]);
}

let mut bootstrap_addresses = vec![];

// Read from ANT_PEERS environment variable if present
bootstrap_addresses.extend(Self::read_bootstrap_addr_from_env());

if !bootstrap_addresses.is_empty() {
return Ok(bootstrap_addresses);
}

// If local mode is enabled, return empty store (will use mDNS)
if self.local || cfg!(feature = "local") {
info!("Local mode enabled, using only local discovery.");
return Ok(vec![]);
}

let mut bootstrap_addresses = vec![];

// Add addrs from arguments if present
for addr in &self.addrs {
if let Some(addr) = craft_valid_multiaddr(addr, false) {
Expand All @@ -124,8 +143,6 @@ impl PeersArgs {
warn!("Invalid multiaddress format from arguments: {addr}");
}
}
// Read from ANT_PEERS environment variable if present
bootstrap_addresses.extend(Self::read_bootstrap_addr_from_env());

if let Some(count) = count {
if bootstrap_addresses.len() >= count {
Expand Down
Loading
Loading