Skip to content

Commit

Permalink
Merge branch 'main' into expose-register-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
happybeing committed Feb 15, 2024
2 parents 98532de + 07afae7 commit 53ef619
Show file tree
Hide file tree
Showing 24 changed files with 686 additions and 110 deletions.
76 changes: 73 additions & 3 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ jobs:
- shell: bash
run: cargo test --release --bin safenode-manager

node-manager-integration-tests:
name: node manager integration tests
node-manager-e2e-tests:
name: node manager e2e tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -169,7 +169,7 @@ jobs:
${{ matrix.elevated }} rustup default stable
${{ matrix.elevated }} cargo test --package sn-node-manager --release --test e2e -- --nocapture
# A simple test seemed to confirm that the Powershell step runs as admin by default.
# Powershell step runs as admin by default.
- name: run integration test in powershell
if: matrix.os == 'windows-latest'
shell: pwsh
Expand All @@ -182,6 +182,54 @@ jobs:
cargo test --release --package sn-node-manager --test e2e -- --nocapture
# Each upgrade test needs its own VM, otherwise they will interfere with each other.
node-manager-upgrade-tests:
name: node manager upgrade tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, elevated: sudo env PATH="$PATH", test: upgrade_to_latest_version }
- { os: ubuntu-latest, elevated: sudo env PATH="$PATH", test: force_upgrade_when_two_binaries_have_the_same_version }
- { os: ubuntu-latest, elevated: sudo env PATH="$PATH", test: force_downgrade_to_a_previous_version }
- { os: ubuntu-latest, elevated: sudo env PATH="$PATH", test: upgrade_from_older_version_to_specific_version }
- { os: macos-latest, elevated: sudo, test: upgrade_to_latest_version }
- { os: macos-latest, elevated: sudo, test: force_upgrade_when_two_binaries_have_the_same_version }
- { os: macos-latest, elevated: sudo, test: force_downgrade_to_a_previous_version }
- { os: macos-latest, elevated: sudo, test: upgrade_from_older_version_to_specific_version }
- { os: windows-latest, test: upgrade_to_latest_version }
- { os: windows-latest, test: force_upgrade_when_two_binaries_have_the_same_version }
- { os: windows-latest, test: force_downgrade_to_a_previous_version }
- { os: windows-latest, test: upgrade_from_older_version_to_specific_version }
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- shell: bash
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
${{ matrix.elevated }} rustup default stable
${{ matrix.elevated }} cargo test --package sn-node-manager --release \
--test upgrades ${{ matrix.test }} -- --nocapture
# Powershell step runs as admin by default.
- name: run integration test in powershell
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
curl -L -o WinSW.exe $env:WINSW_URL
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\bin"
Move-Item -Path WinSW.exe -Destination "$env:GITHUB_WORKSPACE\bin"
$env:PATH += ";$env:GITHUB_WORKSPACE\bin"
cargo test --package sn-node-manager --release `
--test upgrades ${{ matrix.test }} -- --nocapture
e2e:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: E2E tests
Expand Down Expand Up @@ -518,6 +566,28 @@ jobs:
log_file_prefix: safe_test_logs_royalty_reward
platform: ${{ matrix.os }}

token_distribution_test:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: token distribution test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: execute token_distribution tests
run: cargo test --release --features=local-discovery,distribution token_distribution -- --nocapture --test-threads=1
env:
SN_LOG: "all"
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 25

churn:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: Network churning tests
Expand Down
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sn_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.89.68](https://github.com/maidsafe/safe_network/compare/sn_cli-v0.89.67...sn_cli-v0.89.68) - 2024-02-15

### Other
- updated the following local packages: sn_protocol, sn_protocol

## [0.89.67](https://github.com/maidsafe/safe_network/compare/sn_cli-v0.89.66...sn_cli-v0.89.67) - 2024-02-14

### Other
Expand Down
8 changes: 4 additions & 4 deletions sn_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "sn_cli"
readme = "README.md"
repository = "https://github.com/maidsafe/safe_network"
version = "0.89.67"
version = "0.89.68"

[[bin]]
path="src/main.rs"
Expand Down Expand Up @@ -44,12 +44,12 @@ reqwest = { version="0.11.18", default-features=false, features = ["rustls"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive"]}
sn_build_info = { path="../sn_build_info", version = "0.1.5" }
sn_client = { path = "../sn_client", version = "0.104.12" }
sn_client = { path = "../sn_client", version = "0.104.14" }
sn_transfers = { path = "../sn_transfers", version = "0.15.5" }
sn_registers = { path = "../sn_registers", version = "0.3.9" }
sn_logging = { path = "../sn_logging", version = "0.2.21" }
sn_peers_acquisition= { path="../sn_peers_acquisition", version = "0.2.6" }
sn_protocol = { path = "../sn_protocol", version = "0.14.0" }
sn_protocol = { path = "../sn_protocol", version = "0.14.1" }
tempfile = "3.6.0"
tokio = { version = "1.32.0", features = ["io-util", "macros", "parking_lot", "rt", "sync", "time", "fs"] }
tracing = { version = "~0.1.26" }
Expand All @@ -63,7 +63,7 @@ eyre = "0.6.8"
criterion = "0.5.1"
tempfile = "3.6.0"
rand = { version = "~0.8.5", features = ["small_rng"] }
sn_protocol = { path = "../sn_protocol", version = "0.14.0", features = ["test-utils"]}
sn_protocol = { path = "../sn_protocol", version = "0.14.1", features = ["test-utils"]}

[lints]
workspace = true
10 changes: 10 additions & 0 deletions sn_client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.104.14](https://github.com/maidsafe/safe_network/compare/sn_client-v0.104.13...sn_client-v0.104.14) - 2024-02-15

### Other
- updated the following local packages: sn_networking

## [0.104.13](https://github.com/maidsafe/safe_network/compare/sn_client-v0.104.12...sn_client-v0.104.13) - 2024-02-15

### Other
- updated the following local packages: sn_protocol

## [0.104.12](https://github.com/maidsafe/safe_network/compare/sn_client-v0.104.11...sn_client-v0.104.12) - 2024-02-14

### Other
Expand Down
6 changes: 3 additions & 3 deletions sn_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "sn_client"
readme = "README.md"
repository = "https://github.com/maidsafe/safe_network"
version = "0.104.12"
version = "0.104.14"

[features]
default=[]
Expand All @@ -35,8 +35,8 @@ rayon = "1.8.0"
rmp-serde = "1.1.1"
self_encryption = "~0.29.0"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
sn_networking = { path = "../sn_networking", version = "0.13.17" }
sn_protocol = { path = "../sn_protocol", version = "0.14.0" }
sn_networking = { path = "../sn_networking", version = "0.13.19" }
sn_protocol = { path = "../sn_protocol", version = "0.14.1" }
sn_registers = { path = "../sn_registers", version = "0.3.9" }
sn_transfers = { path = "../sn_transfers", version = "0.15.5" }
tempfile = "3.6.0"
Expand Down
11 changes: 11 additions & 0 deletions sn_faucet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.67](https://github.com/maidsafe/safe_network/compare/sn_faucet-v0.3.66...sn_faucet-v0.3.67) - 2024-02-15

### Other
- *(release)* sn_protocol-v0.14.1/sn-node-manager-v0.3.1/sn_cli-v0.89.68/sn_client-v0.104.13/sn_networking-v0.13.18/sn_node-v0.104.21/sn_node_rpc_client-v0.4.54

## [0.3.66](https://github.com/maidsafe/safe_network/compare/sn_faucet-v0.3.65...sn_faucet-v0.3.66) - 2024-02-15

### Other
- token_distribution
- *(release)* sn_protocol-v0.14.0/sn-node-manager-v0.3.0/sn_cli-v0.89.67/sn_client-v0.104.12/sn_networking-v0.13.17/sn_node-v0.104.20/sn_node_rpc_client-v0.4.53

## [0.3.65](https://github.com/maidsafe/safe_network/compare/sn_faucet-v0.3.64...sn_faucet-v0.3.65) - 2024-02-14

### Other
Expand Down
4 changes: 2 additions & 2 deletions sn_faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "sn_faucet"
readme = "README.md"
repository = "https://github.com/maidsafe/safe_network"
version = "0.3.65"
version = "0.3.67"

[features]
default = []
Expand All @@ -32,7 +32,7 @@ rmp-serde = "1.1.2"
serde = { version = "1.0.193", features = ["derive"] }
serde_bytes = { version = "0.11.12", optional = true }
serde_json = "1.0.108"
sn_client = { path = "../sn_client", version = "0.104.12" }
sn_client = { path = "../sn_client", version = "0.104.14" }
sn_logging = { path = "../sn_logging", version = "0.2.21" }
sn_peers_acquisition = { path = "../sn_peers_acquisition", version = "0.2.6" }
sn_transfers = { path = "../sn_transfers", version = "0.15.5" }
Expand Down
45 changes: 41 additions & 4 deletions sn_faucet/src/token_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ fn parse_snapshot(json_str: String) -> Result<Snapshot> {
Ok(balances_map)
}

pub fn load_maid_pubkeys() -> Result<HashMap<MaidAddress, MaidPubkey>> {
info!("Loading public keys for distributions");
let mut pubkeys: HashMap<MaidAddress, MaidPubkey> = HashMap::new();
fn load_maid_pubkeys_from_local() -> Result<HashMap<MaidAddress, MaidPubkey>> {
let mut pubkeys = HashMap::new();
// load from existing files
let pk_dir = get_pubkeys_data_dir_path()?;
let file_list = std::fs::read_dir(pk_dir)?;
Expand All @@ -167,13 +166,26 @@ pub fn load_maid_pubkeys() -> Result<HashMap<MaidAddress, MaidPubkey>> {
};
pubkeys.insert(address, pk_hex);
}
Ok(pubkeys)
}

pub fn load_maid_pubkeys() -> Result<HashMap<MaidAddress, MaidPubkey>> {
info!("Loading public keys for distributions");
let mut pubkeys = match load_maid_pubkeys_from_local() {
Ok(pubkeys) => pubkeys,
Err(err) => {
info!("Failed to load pubkeys from local, {err:?}");
HashMap::new()
}
};
info!("{} pubkeys after reading existing files", pubkeys.len());

// load from blockchain list on internet
info!("Fetching pukeys from {PUBKEYS_URL}");
let response = minreq::get(PUBKEYS_URL).send()?;
// check the request is ok
if response.status_code != 200 {
info!(
println!(
"Pubkey request failed with http status {}",
response.status_code
);
Expand Down Expand Up @@ -387,3 +399,28 @@ async fn create_distribution(
};
Ok(dist_hex)
}

#[cfg(all(test, feature = "distribution"))]
mod tests {
use super::*;

#[test]
fn fetching_from_network() -> Result<()> {
let snapshot = load_maid_snapshot()?;
println!("Maid snapshot got {:?} entries", snapshot.len());
assert_eq!(snapshot.len(), 16214);

let pubkeys = load_maid_pubkeys()?;
println!("Got {:?} distribution keys", pubkeys.len());
assert_eq!(pubkeys.len(), 1227);

let candidates = snapshot
.iter()
.filter(|(addr, _amount)| pubkeys.contains_key(*addr))
.count();
println!("Got {candidates:?} distribution candidates");
assert_eq!(candidates, 1212);

Ok(())
}
}
14 changes: 14 additions & 0 deletions sn_networking/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.13.19](https://github.com/maidsafe/safe_network/compare/sn_networking-v0.13.18...sn_networking-v0.13.19) - 2024-02-15

### Added
- *(networking)* log only unconfirmed ext. addrs
- *(networking)* add candidate addr as external

### Fixed
- *(networking)* no external addr if client

## [0.13.18](https://github.com/maidsafe/safe_network/compare/sn_networking-v0.13.17...sn_networking-v0.13.18) - 2024-02-15

### Other
- updated the following local packages: sn_protocol

## [0.13.17](https://github.com/maidsafe/safe_network/compare/sn_networking-v0.13.16...sn_networking-v0.13.17) - 2024-02-14

### Other
Expand Down

0 comments on commit 53ef619

Please sign in to comment.