Skip to content

Commit

Permalink
Merge branch 'rc-2024.12.1' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jacderida committed Dec 18, 2024
2 parents cccc981 + 8a1957c commit 7256ced
Show file tree
Hide file tree
Showing 408 changed files with 20,088 additions and 37,499 deletions.
9 changes: 9 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
You are an AI assistant specialized in Python and Rust development.

For python

Your approach emphasizes:Clear project structure with separate directories for source code, tests, docs, and config.Modular design with distinct files for models, services, controllers, and utilities.Configuration management using environment variables.Robust error handling and logging, including context capture.Comprehensive testing with pytest.Detailed documentation using docstrings and README files.Dependency management via https://github.com/astral-sh/uv and virtual environments.Code style consistency using Ruff.CI/CD implementation with GitHub Actions or GitLab CI.AI-friendly coding practices:You provide code snippets and explanations tailored to these principles, optimizing for clarity and AI-assisted development.Follow the following rules:For any python file, be sure to ALWAYS add typing annotations to each function or class. Be sure to include return types when necessary. Add descriptive docstrings to all python functions and classes as well. Please use pep257 convention for python. Update existing docstrings if need be.Make sure you keep any comments that exist in a file.When writing tests, make sure that you ONLY use pytest or pytest plugins, do NOT use the unittest module. All tests should have typing annotations as well. All tests should be in ./tests. Be sure to create all necessary files and folders. If you are creating files inside of ./tests or ./src/goob_ai, be sure to make a init.py file if one does not exist.All tests should be fully annotated and should contain docstrings. Be sure to import the following if TYPE_CHECKING:from _pytest.capture import CaptureFixturefrom _pytest.fixtures import FixtureRequestfrom _pytest.logging import LogCaptureFixturefrom _pytest.monkeypatch import MonkeyPatchfrom pytest_mock.plugin import MockerFixture

For Rust

Please do not use unwraps or panics. Please ensure all methods are fully tested and annotated.
75 changes: 21 additions & 54 deletions .github/workflows/benchmark-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on: pull_request
env:
CARGO_INCREMENTAL: "0"
RUST_BACKTRACE: 1
CLIENT_DATA_PATH: /home/runner/.local/share/safe/autonomi
NODE_DATA_PATH: /home/runner/.local/share/safe/node
CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client
NODE_DATA_PATH: /home/runner/.local/share/autonomi/node

jobs:
benchmark-cli:
Expand Down Expand Up @@ -43,23 +43,23 @@ jobs:
# it will be better to execute bench test with `local`,
# to make the measurement results reflect speed improvement or regression more accurately.
- name: Build binaries
run: cargo build --release --features local --bin safenode --bin autonomi
run: cargo build --release --features local --bin antnode --bin ant
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@main
env:
SN_LOG: "all"
ANT_LOG: "all"
with:
action: start
enable-evm-testnet: true
node-path: target/release/safenode
node-path: target/release/antnode
platform: ubuntu-latest
build: true

- name: Check SAFE_PEERS was set
- name: Check ANT_PEERS was set
shell: bash
run: echo "The SAFE_PEERS variable has been set to $SAFE_PEERS"
run: echo "The ANT_PEERS variable has been set to $ANT_PEERS"

- name: export default secret key
run: echo "SECRET_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" >> $GITHUB_ENV
Expand All @@ -71,9 +71,9 @@ jobs:

- name: Start a client instance to compare memory usage
shell: bash
run: ./target/release/autonomi --log-output-dest=data-dir file upload "./the-test-data.zip"
run: ./target/release/ant --log-output-dest=data-dir file upload "./the-test-data.zip"
env:
SN_LOG: "all"
ANT_LOG: "all"
timeout-minutes: 5

- name: Cleanup uploaded_files folder to avoid pollute download benchmark
Expand All @@ -85,15 +85,17 @@ jobs:
###########################
### Client Mem Analysis ###
###########################
### The peak limit shall be restored back to 50MB,
### Once client side chunking/quoting flow got re-examined.

- name: Check client memory usage
shell: bash
run: |
client_peak_mem_limit_mb="1024" # mb
client_peak_mem_limit_mb="1500" # mb
client_avg_mem_limit_mb="512" # mb
peak_mem_usage=$(
rg '"memory_used_mb":[^,]*' $CLIENT_DATA_PATH/logs --glob autonomi.* -o --no-line-number --no-filename |
rg '"memory_used_mb":[^,]*' $CLIENT_DATA_PATH/logs --glob ant.* -o --no-line-number --no-filename |
awk -F':' '/"memory_used_mb":/{print $2}' |
sort -n |
tail -n 1
Expand All @@ -105,11 +107,11 @@ jobs:
fi
total_mem=$(
rg '"memory_used_mb":[^,]*' $CLIENT_DATA_PATH/logs --glob autonomi.* -o --no-line-number --no-filename |
rg '"memory_used_mb":[^,]*' $CLIENT_DATA_PATH/logs --glob ant.* -o --no-line-number --no-filename |
awk -F':' '/"memory_used_mb":/ {sum += $2} END {printf "%.0f\n", sum}'
)
num_of_times=$(
rg "\"memory_used_mb\"" $CLIENT_DATA_PATH/logs --glob autonomi.* -c --stats |
rg "\"memory_used_mb\"" $CLIENT_DATA_PATH/logs --glob ant.* -c --stats |
rg "(\d+) matches" |
rg "\d+" -o
)
Expand Down Expand Up @@ -217,7 +219,7 @@ jobs:

- name: Stop the local network
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@main
with:
action: stop
log_file_prefix: safe_test_logs_benchmark
Expand Down Expand Up @@ -286,13 +288,13 @@ jobs:
shell: bash
run: |
num_of_times=$(
rg "SwarmCmd handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob safenode.* -c --stats |
rg "SwarmCmd handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob antnode.* -c --stats |
rg "(\d+) matches" |
rg "\d+" -o
)
echo "Number of long cmd handling times: $num_of_times"
total_long_handling_ms=$(
rg "SwarmCmd handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob safenode.* -o --no-line-number --no-filename |
rg "SwarmCmd handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob antnode.* -o --no-line-number --no-filename |
awk -F' |ms:' '{sum += $4} END {printf "%.0f\n", sum}'
)
echo "Total cmd long handling time is: $total_long_handling_ms ms"
Expand All @@ -301,13 +303,13 @@ jobs:
total_long_handling=$(($total_long_handling_ms))
total_num_of_times=$(($num_of_times))
num_of_times=$(
rg "SwarmEvent handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob safenode.* -c --stats |
rg "SwarmEvent handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob antnode.* -c --stats |
rg "(\d+) matches" |
rg "\d+" -o
)
echo "Number of long event handling times: $num_of_times"
total_long_handling_ms=$(
rg "SwarmEvent handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob safenode.* -o --no-line-number --no-filename |
rg "SwarmEvent handled in [0-9.]+ms:" $NODE_DATA_PATH/*/logs/* --glob antnode.* -o --no-line-number --no-filename |
awk -F' |ms:' '{sum += $4} END {printf "%.0f\n", sum}'
)
echo "Total event long handling time is: $total_long_handling_ms ms"
Expand Down Expand Up @@ -377,38 +379,3 @@ jobs:
alert-threshold: "200%"
# Enable Job Summary for PRs
summary-always: true

benchmark-cash:
name: Compare sn_transfer benchmarks to main
# right now only ubuntu, running on multiple systems would require many pushes...\
# perhaps this can be done with one consolidation action in the future, pulling down all results and pushing
# once to the branch..
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2
continue-on-error: true

########################
### Setup ###
########################
- run: cargo install cargo-criterion

- name: install ripgrep
run: sudo apt-get -y install ripgrep

########################
### Benchmark ###
########################
- name: Bench `sn_transfers`
shell: bash
# Criterion outputs the actual bench results to stderr "2>&1 tee output.txt" takes stderr,
# passes to tee which displays it in the terminal and writes to output.txt
run: |
cargo criterion --message-format=json 2>&1 -p sn_transfers | tee -a output.txt
cat output.txt
16 changes: 8 additions & 8 deletions .github/workflows/build-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: just build-release-artifacts "${{ matrix.target }}"
- uses: actions/upload-artifact@main
with:
name: safe_network-${{ matrix.target }}
name: autonomi-${{ matrix.target }}
path: |
artifacts
!artifacts/.cargo-lock
Expand All @@ -66,31 +66,31 @@ jobs:
ref: ${{ inputs.tag || inputs.branch }}
- uses: actions/download-artifact@master
with:
name: safe_network-x86_64-pc-windows-msvc
name: autonomi-x86_64-pc-windows-msvc
path: artifacts/x86_64-pc-windows-msvc/release
- uses: actions/download-artifact@master
with:
name: safe_network-x86_64-unknown-linux-musl
name: autonomi-x86_64-unknown-linux-musl
path: artifacts/x86_64-unknown-linux-musl/release
- uses: actions/download-artifact@master
with:
name: safe_network-aarch64-apple-darwin
name: autonomi-aarch64-apple-darwin
path: artifacts/aarch64-apple-darwin/release
- uses: actions/download-artifact@master
with:
name: safe_network-x86_64-apple-darwin
name: autonomi-x86_64-apple-darwin
path: artifacts/x86_64-apple-darwin/release
- uses: actions/download-artifact@master
with:
name: safe_network-arm-unknown-linux-musleabi
name: autonomi-arm-unknown-linux-musleabi
path: artifacts/arm-unknown-linux-musleabi/release
- uses: actions/download-artifact@master
with:
name: safe_network-armv7-unknown-linux-musleabihf
name: autonomi-armv7-unknown-linux-musleabihf
path: artifacts/armv7-unknown-linux-musleabihf/release
- uses: actions/download-artifact@master
with:
name: safe_network-aarch64-unknown-linux-musl
name: autonomi-aarch64-unknown-linux-musl
path: artifacts/aarch64-unknown-linux-musl/release
- uses: cargo-bins/cargo-binstall@main
- shell: bash
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ jobs:
run: wasm-pack build --dev --target=web autonomi
timeout-minutes: 30

websocket:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: Standard Websocket builds
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Build all for `websockets`
run: cargo build --features="websockets"
- name: Cargo check for WASM
# Allow clippy lints (these can be pedantic on WASM), but deny regular Rust warnings
run: cargo clippy --target=wasm32-unknown-unknown --package=autonomi --lib --tests -- --allow=clippy::all --deny=warnings
timeout-minutes: 30
16 changes: 8 additions & 8 deletions .github/workflows/generate-benchmark-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ permissions:
env:
CARGO_INCREMENTAL: "0"
RUST_BACKTRACE: 1
CLIENT_DATA_PATH: /home/runner/.local/share/safe/autonomi
NODE_DATA_PATH: /home/runner/.local/share/safe/node
CLIENT_DATA_PATH: /home/runner/.local/share/autonomi/client
NODE_DATA_PATH: /home/runner/.local/share/autonomi/node

jobs:
benchmark-cli:
Expand Down Expand Up @@ -46,15 +46,15 @@ jobs:
run: wget https://sn-node.s3.eu-west-2.amazonaws.com/the-test-data.zip

- name: Build node and cli binaries
run: cargo build --release --features local --bin safenode --bin autonomi
run: cargo build --release --features local --bin antnode --bin ant
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@main
with:
action: start
enable-evm-testnet: true
node-path: target/release/safenode
node-path: target/release/antnode
platform: ubuntu-latest
build: true
sn-log: "all"
Expand Down Expand Up @@ -100,17 +100,17 @@ jobs:

- name: Start a client instance to compare memory usage
shell: bash
run: cargo run --bin autonomi --release -- --log-output-dest=data-dir file upload the-test-data.zip
run: cargo run --bin ant --release -- --log-output-dest data-dir file upload the-test-data.zip
env:
SN_LOG: "all"
ANT_LOG: "all"

#########################
### Stop Network ###
#########################

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: maidsafe/ant-local-testnet-action@main
with:
action: stop
platform: ubuntu-latest
Expand Down
Loading

0 comments on commit 7256ced

Please sign in to comment.