Skip to content

Commit

Permalink
Merge branch 'main' into tmp_pub
Browse files Browse the repository at this point in the history
  • Loading branch information
dirvine authored Nov 11, 2024
2 parents 5630c64 + 4402dc1 commit 5f8290c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 33 deletions.
125 changes: 108 additions & 17 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,29 +357,40 @@ jobs:
SN_LOG: "v"
timeout-minutes: 2

- name: create local user file
run: echo random > random.txt
env:
SN_LOG: "v"
timeout-minutes: 2

- name: file upload
run: ./target/release/autonomi --log-output-dest=data-dir file upload random.txt
env:
SN_LOG: "v"
timeout-minutes: 2

- name: create a local register
run: ./target/release/autonomi --log-output-dest=data-dir register create sample_new_register 1234
env:
SN_LOG: "v"
timeout-minutes: 2

- name: Estimate cost to create a vault
if: matrix.os != 'windows-latest'
run: |
echo "test-file" > upload-test.txt
./target/release/autonomi --log-output-dest=data-dir file upload ./upload-test.txt
./target/release/autonomi --log-output-dest=data-dir register create sample_new_register 1234
./target/release/autonomi --log-output-dest=data-dir vault cost
./target/release/autonomi --log-output-dest=data-dir file list 2>&1 | tee file_list.txt
./target/release/autonomi --log-output-dest=data-dir register list 2>&1 | tee register_list.txt
run: ./target/release/autonomi --log-output-dest=data-dir vault cost
env:
SN_LOG: "v"
timeout-minutes: 2

- name: create a vault with existing user data as above
if: matrix.os != 'windows-latest'
run: ./target/release/autonomi --log-output-dest=data-dir vault create
env:
SN_LOG: "v"
timeout-minutes: 2

- name: add more files
- name: add more files - linux/macos
if: matrix.os != 'windows-latest'
run: |
set -e
for i in {1..100}; do
dd if=/dev/urandom of=random_file_$i.bin bs=1M count=1 status=none
./target/release/autonomi --log-output-dest=data-dir file upload random_file_$i.bin --public
Expand All @@ -390,16 +401,36 @@ jobs:
SN_LOG: "v"
timeout-minutes: 25

- name: add more files - windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
for ($i = 1; $i -le 100; $i++) {
$fileName = "random_file_$i.bin"
$byteArray = [byte[]]@(0xFF) * (1MB) # Create a 1 MB array filled with 0xFF
[System.IO.File]::WriteAllBytes($fileName, $byteArray)
# Run autonomi commands
./target/release/autonomi --log-output-dest=data-dir file upload "random_file_$i.bin" --public
./target/release/autonomi --log-output-dest=data-dir file upload "random_file_$i.bin"
./target/release/autonomi --log-output-dest=data-dir register create $i "random_file_$i.bin"
}
env:
SN_LOG: "v"
timeout-minutes: 25

- name: sync the vault
if: matrix.os != 'windows-latest'
run: ./target/release/autonomi --log-output-dest=data-dir vault sync
env:
SN_LOG: "v"
timeout-minutes: 2

- name: vault sync validation
if: matrix.os != 'windows-latest'
shell: bash
run: |
set -e
NUM_OF_PUBLIC_FILES=""
NUM_OF_PRIVATE_FILES=""
NUM_OF_REGISTERS=""
Expand All @@ -409,34 +440,93 @@ jobs:
./target/release/autonomi --log-output-dest=data-dir file list 2>&1 > file_list.txt
# ./target/release/autonomi --log-output-dest=data-dir register list | grep archives > register_list.txt
./target/release/autonomi register list | grep register > register_list.txt
NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'`
NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'`
NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'`
# when obtaining registers we get random garbage, this is the only hack that works.
NUM_OF_REGISTERS_first=${NUM_OF_REGISTERS%%[ $'\n']*}
echo "NUM_OF_REGISTERS is $NUM_OF_REGISTERS_first"
./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 > vault_data.txt
NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'`
NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'`
# NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt | grep "register" | grep -o '[0-9]\+'`
NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt | grep "register" | grep -o '[0-9]\+'`
echo "Total Num of local public files is $NUM_OF_PUBLIC_FILES and in vault is $NUM_OF_PUBLIC_FILES_IN_VAULT"
echo "Total Num of local private files is $NUM_OF_PRIVATE_FILES and in vault is $NUM_OF_PRIVATE_FILES_IN_VAULT"
# echo "Total Num of local registers is $NUM_OF_REGISTERS and in vault is $NUM_OF_REGISTERS_IN_VAULT"
echo "Total Num of local registers is $NUM_OF_REGISTERS_first and in vault is $NUM_OF_REGISTERS_IN_VAULT"
rm -rf file_list.txt register_list.txt vault_data.txt
python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local public Files: {sys.argv[1]} and vault public files: {sys.argv[2]} are Not Equal"' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT
python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local private Files: {sys.argv[1]} and vault private files: {sys.argv[2]} are Not Equal"' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT
# python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local registers: {sys.argv[1]} and vault registers: {sys.argv[2]} are Not Equal"' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT
python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local registers: {sys.argv[1]} and vault registers: {sys.argv[2]} are Not Equal"' $NUM_OF_REGISTERS_first $NUM_OF_REGISTERS_IN_VAULT
echo "vault synced successfully!"
env:
SN_LOG: "v"
timeout-minutes: 15

- name: Set up variables - vault sync - windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
./target/release/autonomi --log-output-dest=data-dir file list > file_list.txt 2>&1
./target/release/autonomi register list > register_list.txt 2>&1
./target/release/autonomi --log-output-dest=data-dir vault load > vault_data.txt 2>&1
env:
SN_LOG: "v"
timeout-minutes: 15

- name: Vault sync validation
if: matrix.os == 'windows-latest'
shell: python
run: |
import re
def find_number_before_word(file_name, search_word):
"""
Reads a file and finds the number immediately preceding a specified word in a line.
:param file_name: Name of the file to read.
:param search_word: Word to search for in the file.
:return: The number before the word as an integer, or None if not found.
"""
try:
with open(file_name, 'r') as file:
for line in file:
if search_word in line:
match = re.search(r'(\d+)\s+' + re.escape(search_word), line)
if match:
return int(match.group(1)) # Convert to integer
return None # Return None if no match is found
except FileNotFoundError:
print(f"Error: File '{file_name}' not found.")
return None
NUM_OF_PUBLIC_FILES = find_number_before_word("file_list.txt", "public")
print("NUM_OF_PUBLIC_FILES:", NUM_OF_PUBLIC_FILES)
NUM_OF_PRIVATE_FILES = find_number_before_word("file_list.txt", "private")
print("NUM_OF_PRIVATE_FILES:", NUM_OF_PRIVATE_FILES)
NUM_OF_REGISTERS_FILES = find_number_before_word("register_list.txt", "register")
print("NUM_OF_REGISTERS_FILES:", NUM_OF_REGISTERS_FILES)
NUM_OF_PUBLIC_FILES_IN_VAULT = find_number_before_word("vault_data.txt", "public")
print("NUM_OF_PUBLIC_FILES_IN_VAULT:", NUM_OF_PUBLIC_FILES_IN_VAULT)
NUM_OF_PRIVATE_FILES_IN_VAULT = find_number_before_word("vault_data.txt", "private")
print("NUM_OF_PRIVATE_FILES_IN_VAULT:", NUM_OF_PRIVATE_FILES_IN_VAULT)
NUM_OF_REGISTERS_IN_VAULT = find_number_before_word("vault_data.txt", "register")
print("NUM_OF_PRIVATE_FILES_IN_VAULT:", NUM_OF_PRIVATE_FILES_IN_VAULT)
# Assertions
assert NUM_OF_PUBLIC_FILES == NUM_OF_PUBLIC_FILES_IN_VAULT, f"Error: Local public Files: {NUM_OF_PUBLIC_FILES} and vault public files: {NUM_OF_PUBLIC_FILES_IN_VAULT} are Not Equal"
assert NUM_OF_PRIVATE_FILES == NUM_OF_PRIVATE_FILES_IN_VAULT, f"Error: Local private Files: {NUM_OF_PRIVATE_FILES} and vault private files: {NUM_OF_PRIVATE_FILES_IN_VAULT} are Not Equal"
assert NUM_OF_REGISTERS_FILES == NUM_OF_REGISTERS_IN_VAULT, f"Error: Local registers: {NUM_OF_REGISTERS_FILES} and vault registers: {NUM_OF_REGISTERS_IN_VAULT} are Not Equal"
print("Vault synced successfully!")
env:
SN_LOG: "v"
timeout-minutes: 2

- name: load an existing vault from the network
if: matrix.os != 'windows-latest'
run: ./target/release/autonomi --log-output-dest=data-dir vault load
env:
SN_LOG: "v"
Expand All @@ -445,6 +535,7 @@ jobs:
- name: Time profiling for Different files
if: matrix.os != 'windows-latest'
run: |
set -e
# 1 MB
python3 -c "with open('random_1MB.bin', 'wb') as f: f.write(bytearray([0xff] * 1 * 1024 * 1024))"
# 10 MB
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions node-launchpad/src/components/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ impl StatefulWidget for Footer {
let commands = vec![
Span::styled("[Ctrl+G] ", Style::default().fg(GHOST_WHITE)),
Span::styled("Manage Nodes", Style::default().fg(EUCALYPTUS)),
Span::styled(" ", Style::default()),
Span::styled(" ", Style::default()),
Span::styled("[Ctrl+S] ", command_style),
Span::styled("Start Nodes", text_style),
Span::styled(" ", Style::default()),
Span::styled(" ", Style::default()),
Span::styled("[L] ", command_style),
Span::styled("Open Logs", Style::default().fg(EUCALYPTUS)),
Span::styled(" ", Style::default()),
Span::styled(" ", Style::default()),
Span::styled("[Ctrl+X] ", command_style),
Span::styled(
"Stop All",
Expand Down
25 changes: 12 additions & 13 deletions node-launchpad/src/components/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const NODE_WIDTH: usize = 10;
const VERSION_WIDTH: usize = 7;
const ATTOS_WIDTH: usize = 5;
const MEMORY_WIDTH: usize = 7;
const MBITS_WIDTH: usize = 13;
const MB_WIDTH: usize = 15;
const RECORDS_WIDTH: usize = 4;
const PEERS_WIDTH: usize = 5;
const CONNS_WIDTH: usize = 5;
Expand Down Expand Up @@ -220,10 +220,10 @@ impl Status<'_> {
{
item.attos = stats.rewards_wallet_balance;
item.memory = stats.memory_usage_mb;
item.mbits = format!(
"↓{:0>5.0} ↑{:0>5.0}",
(stats.bandwidth_inbound_rate * 8) as f64 / 1_000_000.0,
(stats.bandwidth_outbound_rate * 8) as f64 / 1_000_000.0,
item.mb = format!(
"↓{:06.02} ↑{:06.02}",
stats.bandwidth_inbound as f64 / (1024_f64 * 1024_f64),
stats.bandwidth_outbound as f64 / (1024_f64 * 1024_f64)
);
item.records = stats.max_records;
item.connections = stats.connections;
Expand All @@ -235,7 +235,7 @@ impl Status<'_> {
version: node_item.version.to_string(),
attos: 0,
memory: 0,
mbits: "-".to_string(),
mb: "-".to_string(),
records: 0,
peers: 0,
connections: 0,
Expand Down Expand Up @@ -269,7 +269,7 @@ impl Status<'_> {
version: node_item.version.to_string(),
attos: 0,
memory: 0,
mbits: "-".to_string(),
mb: "-".to_string(),
records: 0,
peers: 0,
connections: 0,
Expand Down Expand Up @@ -930,7 +930,7 @@ impl Component for Status<'_> {
Constraint::Min(VERSION_WIDTH as u16),
Constraint::Min(ATTOS_WIDTH as u16),
Constraint::Min(MEMORY_WIDTH as u16),
Constraint::Min(MBITS_WIDTH as u16),
Constraint::Min(MB_WIDTH as u16),
Constraint::Min(RECORDS_WIDTH as u16),
Constraint::Min(PEERS_WIDTH as u16),
Constraint::Min(CONNS_WIDTH as u16),
Expand All @@ -945,8 +945,7 @@ impl Component for Status<'_> {
Cell::new("Attos").fg(COOL_GREY),
Cell::new("Memory").fg(COOL_GREY),
Cell::new(
format!("{}{}", " ".repeat(MBITS_WIDTH - "Mbits".len()), "Mbits")
.fg(COOL_GREY),
format!("{}{}", " ".repeat(MB_WIDTH - "Mb".len()), "Mb").fg(COOL_GREY),
),
Cell::new("Recs").fg(COOL_GREY),
Cell::new("Peers").fg(COOL_GREY),
Expand Down Expand Up @@ -1180,7 +1179,7 @@ pub struct NodeItem<'a> {
version: String,
attos: usize,
memory: usize,
mbits: String,
mb: String,
records: usize,
peers: usize,
connections: usize,
Expand Down Expand Up @@ -1267,8 +1266,8 @@ impl NodeItem<'_> {
),
format!(
"{}{}",
" ".repeat(MBITS_WIDTH.saturating_sub(self.mbits.to_string().len())),
self.mbits.to_string()
" ".repeat(MB_WIDTH.saturating_sub(self.mb.to_string().len())),
self.mb.to_string()
),
format!(
"{}{}",
Expand Down

0 comments on commit 5f8290c

Please sign in to comment.