Files
neuron-tai/docs/issues/06-solana-stake-and-settlement.md
Dobromir Popov 9abe83b5f4 feat(alpha): complete hardening backlog
Complete the alpha-hardening Ralph task set, including tracker billing/accounting guards, validator fraud-audit primitives, wallet binding proof support, documentation runbooks, and updated tests.

Verification: .venv/bin/python -m compileall -q packages tests; .venv/bin/python -m pytest -q --tb=short (313 passed, 3 skipped, 1 failed: tests/test_mining_cli.py::test_legacy_start_without_port_uses_next_available_port because meshnet-node pid 1263451 is already listening on port 7000).
2026-07-05 21:47:23 +03:00

2.5 KiB

Status: superseded for alpha — see ADR-0015, issue 33/34. ADR-0015 replaces the on-chain Anchor stake/registry/settlement contracts below with a custodial USDT treasury + off-chain ledger, and explicitly targets Solana devnet (with a mock-USDT SPL mint) rather than the "testnet, never devnet" rule stated here — see ADR-0016 for the alpha scope this fits into.

06 — Solana stake + settlement contracts

What to build

Deploy and integrate the Solana smart contracts that make node staking, client payment, and token reward settlement trustless. All development and testing targets Solana testnet — never devnet or mainnet during development, to avoid real costs.

Three contracts are needed:

Registry contract: records stake balances, strike counts, and ban status per wallet. The gateway and tracker read from this contract to exclude banned wallets from route selection.

Payment contract: clients pre-fund an API key account with SOL or USDC. The gateway records per-request compute attribution (which node served which layer range, for how many tokens).

Settlement contract: called once per epoch. Debits client accounts proportional to compute consumed. Credits node operator wallets with our native token proportional to layers served. Distributes a validator reward share.

The packages/contracts package provides Python wrappers for reading and writing to all three contracts. The gateway uses these wrappers to check stake before routing to a node and to record attribution after each request.

Acceptance criteria

  • All contracts deploy successfully to Solana testnet
  • A node can submit a stake transaction and have its balance reflected in the registry contract
  • A client can fund an API key account with testnet SOL
  • After a completed inference session, compute attribution is recorded on-chain with correct node/layer attribution
  • The epoch settlement transaction correctly distributes token rewards to node operators and deducts client balances
  • The gateway refuses to route to a node whose stake balance is below the minimum threshold
  • All contract interactions in tests run against a local Solana test validator (via solana-test-validator) — no live testnet required for CI
  • A .env.testnet config points to Solana testnet RPC for manual end-to-end testing

Blocked by

  • 03-tracker-registration-and-routing.md