Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 91 additions & 112 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# https://releases.rs/docs/1.83.0/ release date
NIGHTLY_TOOLCHAIN: nightly-2024-11-28
NIGHTLY_TOOLCHAIN: nightly-2025-02-20

# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand All @@ -15,46 +15,6 @@ concurrency:
cancel-in-progress: true

jobs:
# TODO move to a release ci
# build:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# path: snarkos-test

# - name: Checkout snarkOS
# uses: actions/checkout@v4
# with:
# repository: AleoNet/snarkOS
# path: snarkos

# - name: Checkout snarkVM
# uses: actions/checkout@v4
# with:
# repository: AleoNet/snarkVM
# path: snarkvm

# - name: Use mold linker
# uses: rui314/setup-mold@v1

# - name: Install nightly and cranelift
# uses: dtolnay/rust-toolchain@nightly
# with:
# toolchain: nightly
# components: rustc-codegen-cranelift-preview

# - uses: Swatinem/rust-cache@v2
# with:
# key: cache-v1

# - name: Build
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
# run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} build --verbose

fmt:
runs-on: ubuntu-latest

Expand All @@ -71,12 +31,63 @@ jobs:
- name: 📋 Format Check
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} fmt -- --check

test:
filter:
runs-on: ubuntu-latest
permissions: read-all
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
outputs:
top_toml: ${{ steps.filter.outputs.top_toml }}
aot: ${{ steps.filter.outputs.aot }}
checkpoint: ${{ steps.filter.outputs.checkpoint }}
common: ${{ steps.filter.outputs.common }}
snops: ${{ steps.filter.outputs.snops }}
agent: ${{ steps.filter.outputs.agent }}
scli: ${{ steps.filter.outputs.scli }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
base: ${{ github.ref_name }}
filters: |
top_toml:
- 'Cargo.toml'
aot:
- 'crates/aot/**/*'
checkpoint:
- 'crates/checkpoint/**/*'
snops:
- 'crates/controlplane/**/*'
agent:
- 'crates/agent/**/*'
scli:
- 'crates/cli/**/*'
common:
- 'crates/common/**/*'

crate-checks:
runs-on: ubuntu-latest
needs: [filter]
env:
TOP_TOML: ${{ needs.filter.outputs.top_toml }}
AOT: ${{ needs.filter.outputs.aot }}
CHECKPOINT: ${{ needs.filter.outputs.checkpoint }}
COMMON: ${{ needs.filter.outputs.common }}
SNOPS: ${{ needs.filter.outputs.snops }}
AGENT: ${{ needs.filter.outputs.agent }}
SCLI: ${{ needs.filter.outputs.scli }}
strategy:
fail-fast: false
matrix:
crate:
- { name: "aot", package: "snarkos-aot", dir: "crates/aot" }
- {
name: "checkpoint",
package: "snops-checkpoint",
dir: "crates/checkpoint",
}
- { name: "common", package: "snops-common", dir: "crates/common" }
- { name: "snops", package: "snops", dir: "crates/controlplane" }
- { name: "agent", package: "snops-agent", dir: "crates/agent" }
- { name: "snops-cli", package: "snops-cli", dir: "crates/cli" }
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
Expand All @@ -99,74 +110,42 @@ jobs:
- name: ☁️ Install Nextest
uses: taiki-e/install-action@nextest

# - name: ☁️ Install cargo-machete
# run: cargo install cargo-machete
- name: ☁️ Install cargo-machete
uses: taiki-e/install-action@cargo-machete

# - name: 📋 Clippy Check
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
# run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} clippy --all --all-targets -- -D warnings
- name: ☁️ Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall

# - name: 📋 Check Unused Deps
# if: always()
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
# run: cargo machete
- name: ☁️ Install cargo-msrv
run: cargo binstall --version 0.18.1 --no-confirm cargo-msrv --force

- uses: dorny/paths-filter@v3
id: changes
with:
base: ${{ github.ref_name }}
filters: |
top_toml:
- 'Cargo.toml'
aot:
- 'crates/aot/**/*'
checkpoint:
- 'crates/checkpoint/**/*'
control_plane:
- 'crates/controlplane/**/*'
agent:
- 'crates/agent/**/*'
scli:
- 'crates/cli/**/*'
common:
- 'crates/common/**/*'
- name: ☁️ Install cargo-hack
uses: taiki-e/install-action@cargo-hack

- name: ☁️ Install cargo-minimal-versions
uses: taiki-e/install-action@cargo-minimal-versions

- name: 🧪 Test ${{ matrix.crate.name }}
if: always() && ${{ env.TOP_TOML == 'true' || (matrix.crate.name == 'aot' && env.AOT == 'true') || (matrix.crate.name == 'checkpoint' && env.CHECKPOINT == 'true') || (matrix.crate.name == 'common' && env.COMMON == 'true') || (matrix.crate.name == 'snops' && env.CONTROL_PLANE == 'true') || (matrix.crate.name == 'agent' && env.AGENT == 'true') || (matrix.crate.name == 'scli' && env.SCLI == 'true') }}
env:
RUSTFLAGS: ${{ (matrix.crate.name == 'aot' || matrix.crate.name == 'checkpoint' || matrix.crate.name == 'common' || matrix.crate.name == 'snops') && '-Zcodegen-backend=cranelift' || '' }}
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p ${{ matrix.crate.package }} --verbose --fail-fast --all-features --no-tests=warn

- name: 🚯 Unused Deps ${{ matrix.crate.name }}
if: always() && ${{ env.TOP_TOML == 'true' || (matrix.crate.name == 'aot' && env.AOT == 'true') || (matrix.crate.name == 'checkpoint' && env.CHECKPOINT == 'true') || (matrix.crate.name == 'common' && env.COMMON == 'true') || (matrix.crate.name == 'snops' && env.CONTROL_PLANE == 'true') || (matrix.crate.name == 'agent' && env.AGENT == 'true') || (matrix.crate.name == 'scli' && env.SCLI == 'true') }}
run: cd ${{ matrix.crate.dir }} && cargo +${{ env.NIGHTLY_TOOLCHAIN }} machete

- name: 🦀 MSRV ${{ matrix.crate.name }}
if: always() && ${{ env.TOP_TOML == 'true' || (matrix.crate.name == 'aot' && env.AOT == 'true') || (matrix.crate.name == 'checkpoint' && env.CHECKPOINT == 'true') || (matrix.crate.name == 'common' && env.COMMON == 'true') || (matrix.crate.name == 'snops' && env.CONTROL_PLANE == 'true') || (matrix.crate.name == 'agent' && env.AGENT == 'true') || (matrix.crate.name == 'scli' && env.SCLI == 'true') }}
run: cargo msrv --manifest-path ${{ matrix.crate.dir }}/Cargo.toml verify --output-format minimal

- name: 🕵️ Minimal Versions ${{ matrix.crate.name }}
if: always() && ${{ env.TOP_TOML == 'true' || (matrix.crate.name == 'aot' && env.AOT == 'true') || (matrix.crate.name == 'checkpoint' && env.CHECKPOINT == 'true') || (matrix.crate.name == 'common' && env.COMMON == 'true') || (matrix.crate.name == 'snops' && env.CONTROL_PLANE == 'true') || (matrix.crate.name == 'agent' && env.AGENT == 'true') || (matrix.crate.name == 'scli' && env.SCLI == 'true') }}
continue-on-error: true
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} minimal-versions check -p ${{ matrix.crate.package }}

- name: 🧪 Test All
if: steps.changes.outputs.top_toml == 'true'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run --all --verbose --fail-fast --all-features --exclude snops-agent --exclude xtask --no-tests=warn

- name: 🧪 Test Aot
if: steps.changes.outputs.aot == 'true' && steps.changes.outputs.top_toml == 'false'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snarkos-aot --verbose --fail-fast --all-features --no-tests=warn

- name: 🧪 Test Checkpoint
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
if: steps.changes.outputs.checkpoint == 'true' && steps.changes.outputs.top_toml == 'false'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snops-checkpoint --verbose --fail-fast --all-features --no-tests=warn

- name: 🧪 Test Common
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
if: steps.changes.outputs.common == 'true' && steps.changes.outputs.top_toml == 'false'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snops-common --verbose --fail-fast --all-features --no-tests=warn

- name: 🧪 Test Control Plane
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
if: (steps.changes.outputs.control_plane == 'true' || steps.changes.outputs.common == 'true') && steps.changes.outputs.top_toml == 'false'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snops --verbose --fail-fast --all-features --no-tests=warn

- name: 🧪 Test Agent
# env:
# RUSTFLAGS: ""
if: (steps.changes.outputs.agent == 'true' || steps.changes.outputs.common == 'true')
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snops-agent --verbose --fail-fast --all-features --no-tests=warn

- name: 🧪 Test Scli
# env:
# RUSTFLAGS: -Zcodegen-backend=cranelift
if: (steps.changes.outputs.scli == 'true' || steps.changes.outputs.common == 'true') && steps.changes.outputs.top_toml == 'false'
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} nextest run -p snops-cli --verbose --fail-fast --all-features --no-tests=warn
- name: 📋 Clippy ${{ matrix.crate.name }}
if: always() && ${{ env.TOP_TOML == 'true' || (matrix.crate.name == 'aot' && env.AOT == 'true') || (matrix.crate.name == 'checkpoint' && env.CHECKPOINT == 'true') || (matrix.crate.name == 'common' && env.COMMON == 'true') || (matrix.crate.name == 'snops' && env.CONTROL_PLANE == 'true') || (matrix.crate.name == 'agent' && env.AGENT == 'true') || (matrix.crate.name == 'scli' && env.SCLI == 'true') }}
env:
RUSTFLAGS: ${{ (matrix.crate.name == 'aot' || matrix.crate.name == 'checkpoint' || matrix.crate.name == 'common' || matrix.crate.name == 'snops') && '-Zcodegen-backend=cranelift' || '' }}
run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} clippy -p ${{ matrix.crate.package }} --all-targets --locked -- -D warnings
8 changes: 4 additions & 4 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ members = [
]
resolver = "2"

[workspace.package]
authors = []
edition = "2024"
homepage = "https://github.com/monadicus/snarkops"
license = "MIT"
rust-version = "1.85.0"

[profile.dev]
codegen-units = 512
opt-level = 1
Expand Down
8 changes: 6 additions & 2 deletions crates/agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[package]
name = "snops-agent"
version = "0.2.0"
edition = "2021"
license = "MIT"

description = "A snarkops agent for communicating with snarkos nodes and the control plane"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
rust-version.workspace = true

[features]
default = []
Expand Down
6 changes: 3 additions & 3 deletions crates/agent/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use http::{HeaderValue, StatusCode, Uri};
use snops_common::{
constant::{ENV_AGENT_KEY, HEADER_AGENT_KEY},
rpc::{
control::{agent::AgentService, ControlServiceClient, PING_HEADER},
RpcTransport, PING_INTERVAL_SEC, PING_LENGTH,
PING_INTERVAL_SEC, PING_LENGTH, RpcTransport,
control::{ControlServiceClient, PING_HEADER, agent::AgentService},
},
};
use tarpc::server::Channel;
Expand Down Expand Up @@ -56,7 +56,7 @@ pub async fn ws_connection(ws_req: Request, state: Arc<GlobalState>) {
// Ignore connection refused errors, we only care if something interesting is
// causing the connection to fail.
tungstenite::Error::Io(e) if e.kind() == std::io::ErrorKind::ConnectionRefused => {
return
return;
}
// Shutdown the agent if the control plane requires an upgrade
tungstenite::Error::Http(e) if e.status() == StatusCode::UPGRADE_REQUIRED => {
Expand Down
6 changes: 2 additions & 4 deletions crates/agent/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use indexmap::IndexMap;
use snops_common::{
api::AgentEnvInfo,
db::{
Database as DatabaseTrait,
error::DatabaseError,
tree::{DbRecords, DbTree},
Database as DatabaseTrait,
},
format::{DataFormat, DataReadError, DataWriteError, PackedUint},
state::{AgentId, AgentState, EnvId, HeightRequest},
Expand Down Expand Up @@ -123,9 +123,7 @@ impl Database {
}

pub fn env_info(&self) -> Result<Option<(EnvId, Arc<AgentEnvInfo>)>, DatabaseError> {
self.documents
.restore(&AgentDbString::EnvInfo)
.map_err(DatabaseError::from)
self.documents.restore(&AgentDbString::EnvInfo)
}

pub fn set_env_info(
Expand Down
2 changes: 1 addition & 1 deletion crates/agent/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tracing::level_filters::LevelFilter;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::{layer::SubscriberExt, reload, util::SubscriberInitExt, EnvFilter};
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, reload, util::SubscriberInitExt};

pub type ReloadHandler = reload::Handle<EnvFilter, tracing_subscriber::Registry>;

Expand Down
4 changes: 2 additions & 2 deletions crates/agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use reconcile::agent::{AgentStateReconciler, AgentStateReconcilerContext};
use snops_common::{db::Database, util::OpaqueDebug};
use tokio::{
select,
signal::unix::{signal, Signal, SignalKind},
sync::{mpsc, RwLock},
signal::unix::{Signal, SignalKind, signal},
sync::{RwLock, mpsc},
};
use tracing::{error, info};

Expand Down
2 changes: 1 addition & 1 deletion crates/agent/src/metrics/tps.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use simple_moving_average::{SingleSumSMA, SMA};
use simple_moving_average::{SMA, SingleSumSMA};

use super::*;

Expand Down
5 changes: 4 additions & 1 deletion crates/agent/src/reconcile/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ impl Reconcile<(), ReconcileError> for AddressResolveReconciler {
}

let Some(client) = state.client.read().await.clone() else {
warn!("Agent state contains {} addresses that need to be resolved, but client is not connected", unresolved_addrs.len());
warn!(
"Agent state contains {} addresses that need to be resolved, but client is not connected",
unresolved_addrs.len()
);

// Client is offline so new addrs cannot be requested
return Ok(ReconcileStatus::default());
Expand Down
8 changes: 4 additions & 4 deletions crates/agent/src/reconcile/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ use snops_common::{
use tarpc::context;
use tokio::{
select,
sync::{mpsc::Receiver, Mutex},
sync::{Mutex, mpsc::Receiver},
task::AbortHandle,
time::sleep_until,
};
use tracing::{error, info, trace};

use super::{
Reconcile, ReconcileStatus,
command::NodeCommand,
process::ProcessContext,
state::EnvState,
storage::{BinaryReconciler, GenesisReconciler, LedgerModifyResult, StorageVersionReconciler},
Reconcile, ReconcileStatus,
};
use crate::{
db::Database,
Expand Down Expand Up @@ -103,10 +103,10 @@ impl AgentStateReconcilerContext {
/// added to the scope when a requeue is needed to provide more context when
/// monitoring the agent.
macro_rules! reconcile {
($id:ident, $e:expr) => {
($id:ident, $e:expr_2021) => {
reconcile!($id, $e, res => {})
};
($id:ident, $e:expr, $v:ident => $rest:expr) => {
($id:ident, $e:expr_2021, $v:ident => $rest:expr_2021) => {
let $v = $e.reconcile().await?;
if $v.is_requeue() {
trace!("Requeue needed for {} ({:?}) {:?}", stringify!($id), $v.scopes, $v.conditions);
Expand Down
Loading
Loading