Skip to content
Merged
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,23 @@ jobs:

contracts:
name: smart-contracts
# Run after the lightweight Node jobs so that at most one Rust compilation
# is active at a time, preventing the runner (or a local dev laptop) from
# being overwhelmed by concurrent cargo builds.
needs: [backend, frontend]
runs-on: ubuntu-latest
timeout-minutes: 25
env:
# ── Rust resource limits ──────────────────────────────────────────
# Run only 1 cargo job at a time (one crate compiled in parallel max).
CARGO_BUILD_JOBS: "1"
# 1 codegen unit = lower peak RAM; rustc won't split crates into many
# parallel LLVM modules. Mirrors smart-contracts/.cargo/config.toml so
# the flag is enforced even if the config file is not picked up.
RUSTFLAGS: "-C codegen-units=1"
# Disable incremental compilation in CI — it saves time only on local
# re-builds; in CI it just wastes disk/RAM building the cache layer.
CARGO_INCREMENTAL: "0"
defaults:
run:
working-directory: smart-contracts
Expand Down Expand Up @@ -142,6 +157,8 @@ jobs:
e2e-fullstack:
name: e2e-fullstack
continue-on-error: true
# Sequence after backend so it doesn't overlap with the Rust contracts job.
needs: [backend]
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/smart-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ jobs:
name: Build Wasm artifacts
runs-on: ubuntu-latest
timeout-minutes: 25
env:
# ── Rust resource limits ──────────────────────────────────────────
# Run only 1 cargo job at a time to prevent CPU/RAM saturation.
CARGO_BUILD_JOBS: "1"
# 1 codegen unit keeps peak RAM low by not splitting crates into
# many parallel LLVM modules.
RUSTFLAGS: "-C codegen-units=1"
# Skip incremental compilation artifacts — not useful in CI and
# wastes disk/RAM building the incremental cache.
CARGO_INCREMENTAL: "0"
steps:
- name: Checkout repository
uses: actions/checkout@v5
Expand Down
18 changes: 18 additions & 0 deletions smart-contracts/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Cargo workspace configuration
# Limits parallel compilation jobs and codegen units to prevent CPU/RAM spikes
# on CI runners and developer laptops.

[build]
# Run at most 1 cargo job at a time (equivalent to `cargo build -j 1`).
# Prevents multiple crates being compiled simultaneously, which can saturate
# all CPU cores and exhaust RAM on constrained machines.
jobs = 1

[profile.dev]
# 1 codegen unit means rustc emits one LLVM module per crate rather than
# splitting into many parallel units. Slower compile but much lower peak RAM.
codegen-units = 1

[profile.release]
# Same limit for release builds (Wasm targets use --release).
codegen-units = 1
50 changes: 50 additions & 0 deletions smart-contracts/contracts/agent_registry/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,53 @@ pub struct ErrorResolvedEvent {
/// How the error was closed: `Fixed`, `Ignored`, or `Escalated`.
pub resolution_code: u32,
}

// ─── Bond event data structs ──────────────────────────────────────────────────

/// Data payload for `(registry, bond_locked)`.
///
/// Published by `register_agent` when an agent successfully registers with a
/// bond. Indexers can use this to track the total bonded value per agent and
/// detect under-bonded agents after `set_min_bond` increases the minimum.
#[contracttype]
#[derive(Clone, Debug, PartialEq)]
pub struct BondLocked {
/// The agent that locked the bond.
pub agent_id: Symbol,
/// Owner address that authorised the registration.
pub owner: Address,
/// Bond amount locked in stroops.
pub amount_stroops: i128,
}

/// Data payload for `(registry, bond_slsh)`.
///
/// Published by `slash_bond` when an admin penalises an agent's bond.
/// Both the penalty applied and the resulting remaining balance are included
/// so indexers don't need to recompute the residual from prior state.
#[contracttype]
#[derive(Clone, Debug, PartialEq)]
pub struct BondSlashed {
/// The agent whose bond was reduced.
pub agent_id: Symbol,
/// The amount deducted from the bond in stroops (capped at the prior balance).
pub penalty_stroops: i128,
/// Remaining bond balance after the slash (≥ 0).
pub remaining_stroops: i128,
}

/// Data payload for `(registry, bond_ret)`.
///
/// Published by the second `deregister_agent` call once the 24-hour cooldown
/// has elapsed and the bond is eligible for return to the owner. Only emitted
/// when `bond_amount > 0`; zero-bond deregistrations skip this event.
#[contracttype]
#[derive(Clone, Debug, PartialEq)]
pub struct BondReturned {
/// The agent that was deregistered.
pub agent_id: Symbol,
/// Address that receives the returned bond.
pub owner: Address,
/// Bond amount returned in stroops.
pub amount_stroops: i128,
}
Loading