Rust node for Verinoo — an AI chain network with optimistic inference verification.
Status: testnet node with a working verifiable-inference vertical slice.
Single- and multi-validator testnets run, and inference tasks are executed by
consensus against a real (small) model with on-chain receipts and a
verification endpoint. Consensus block production is round-robin; VNN_CONSENSUS=bft adds quorum finality certificates over validated blocks (no view-change liveness).
Models come from the compiled-in reference classifier, operator graph models
loaded from VNN_MODEL_DIR, and a transformer encoder classifier
(intent-transformer-v1). Dense/relu/softmax classifiers convert from ONNX
(onnx-import) and GGUF (gguf-import, dequantising Q4/Q5/Q8 and Q2_K–Q6_K).
A transformer encoder and a GPT-style decoder runtime run in consensus. The
decoder supports GPT-2 byte-level BPE, deterministic temperature/top-k/top-p
sampling and binary .vnnw weights. It runs a synthetic char-BPE model, a
3.75M-parameter GPT-Neo demo (tiny-stories-1m) and a locally imported
Apache-2.0 82M-parameter DistilGPT-2 with 1,024-token context. A config-driven
importer (scripts/import_hf_gpt.py) accepts other GPT-2/GPT-Neo checkpoints
with the GPT-2 byte-level BPE tokenizer; LLaMA/SentencePiece and rotary
architectures are still unsupported. Production LLM serving (GPU execution,
batching, streaming, safety) is not deployed; the public node serves a small
decoder demo, not DistilGPT-2. See
docs/product.md for the product and
docs/readiness.md for the matrix, and
docs/pilot.md for the design-partner proof summary,
docs/privacy.md for input encryption, and
docs/transformer.md,
docs/decoder.md and
docs/adr/004-bft-finality.md for the
transformer runtimes and the BFT finality layer.
| Crate | Purpose |
|---|---|
types |
Canonical codec, tx model — byte-parity with the reference client |
conformance |
Golden-vector tests generated by the TS oracle |
state |
RocksDB-backed state (accounts, models, tasks, nodes, validators) |
exec |
Validation, gas market, block production/application, dispute ops |
network |
libp2p gossipsub block/tx propagation + mDNS |
model |
intent-classifier-v1: deterministic Q16.16 inference + trainer |
runtime |
integer-only graph runtime + transformer encoder + GPT decoder |
onnx |
ONNX classifier → runtime graph (onnx-import), with float/integer parity |
gguf |
GGUF dense classifier → runtime graph (gguf-import), Q4/Q5/Q8 + K-quant dequantisation |
zk |
Q16.16 op vectors and conformance against the WASM runtime |
node |
Binary: wiring, RPC API, wallet CLI, systemd/deploy assets |
The TypeScript repository (iguha0/Verinoo)
is the reference client: its engine defines validation semantics, and its
test-suite exports the golden fixtures this workspace reproduces exactly. See
crates/conformance/fixtures/.
Prebuilt x86_64 Linux binary:
https://github.com/iguha0/verinoo-node/releases/tag/v0.11.0-testnet
The /v1 API is deployed behind https://verinoo.com (single validator,
testnet, no SLA):
curl -s https://verinoo.com/v1/models | jq
verinoo-node wallet generate --output key.json
ADDR=$(jq -r .address key.json)
curl -s -X POST https://verinoo.com/faucet \
-H 'content-type: application/json' -d "{\"address\":\"$ADDR\"}"
sleep 12
verinoo-node infer --key-file key.json \
--input "my parcel was never delivered" --node https://verinoo.com
./scripts/verify.sh <taskId> --node https://verinoo.comsdk/typescript— zero-dependency ESM, Node >= 20; built-in canonical JSON, Ed25519 signing, X25519 input encryption, polling and verify.sdk/python—cryptography+ stdlib; same transaction and encryption semantics.
Both encrypt inputs by default when the node advertises /v1/input-key. See
docs/privacy.md for the threat model: encryption protects
inputs from API/block readers, but the operator can decrypt.
cargo build --release --locked
VNN_KEY_SEED="$(openssl rand -hex 32)" \
VNN_VALIDATOR=1 \
VNN_API_PORT=7100 \
VNN_P2P_PORT=7101 \
./target/release/verinoo-nodeA lone validator authorizes itself, so blocks start immediately. To run more than one node you must give every node the same full set, or peers will reject each other's blocks:
# derive each node's address before starting it
verinoo-node address --seed <that-node's-VNN_KEY_SEED>
VNN_VALIDATORS=ai_aaaa...,ai_bbbb... VNN_SEEDS=/ip4/203.0.113.10/tcp/7101 ...Reproduce a two-validator consensus + independent-verification run locally:
./scripts/demo-2node.sh # 11 checks: replication, identical result hash, verify on both nodes| Variable | Default | Notes |
|---|---|---|
VNN_DB |
./vnn-data |
RocksDB path |
VNN_API_PORT |
7100 |
HTTP RPC |
VNN_P2P_PORT |
7101 |
libp2p TCP |
VNN_KEY_SEED |
(empty) | required for validators; unique per node |
VNN_VALIDATOR |
false |
produce blocks |
VNN_VALIDATORS |
self if validator | active set, comma-separated |
VNN_SEEDS |
(none) | /ip4/<host>/tcp/<port> peers |
VNN_SYNC_URLS |
(none) | peer HTTP APIs for catch-up replay, comma-separated |
VNN_API_KEYS_FILE |
/etc/verinoo/api-keys.json if present |
tenant keys; absent = public demo mode |
VNN_SELF_SERVE_KEYS |
false |
enable self-serve key issuance at POST /v1/keys |
VNN_SELF_SERVE_QUOTA |
1000 |
daily quota for self-serve keys (0 = unlimited) |
VNN_INPUT_KEY |
(none) | network X25519 secret (64 hex); enables encrypted inputs |
VNN_REQUIRE_ENCRYPTED_INPUT |
false |
reject plaintext inference submissions |
VNN_POLICY_FILE |
(none) | node-local request policy JSON; invalid or missing file fails startup |
VNN_BLOCK_TIME_MS |
chain default (10 000) | block interval; identical on every validator |
VNN_PEER_LAG_BLOCKS |
2 |
allowed lag behind the best valid sync peer before /ready fails |
VNN_CONSENSUS |
legacy |
legacy or bft; bft adds prevote/precommit certificates and requires a validator set |
Catch-up: a node that starts late or falls behind replays validated blocks from
VNN_SYNC_URLS. Peer heights are only used when the peer reports the same
chainId, and they are refreshed on every sync poll so a stale value cannot
keep /ready failing. Proof: ./scripts/demo-sync.sh.
| Endpoint | Purpose |
|---|---|
GET /health |
liveness + head age + validator count |
GET /ready |
readiness probe: 200 only when fresh, caught up, and the validator set is consistent |
GET /status |
chain id, height, head hash, finalized height/hash, consensus mode, mempool depth, validator-set consistency |
GET /metrics |
height, head age, mempool, validator count |
GET /blocks |
latest 20 blocks |
GET /blocks/since/:index |
up to 200 blocks after index (catch-up sync) |
GET /account/:address |
balance + nonce |
GET /validators |
active validator set |
GET /mempool |
mempool depth |
POST /tx |
validate, enqueue, and gossip a signed tx |
POST /faucet |
testnet drip (10 000, 60 s per address) |
GET /v1/models |
models this node executes, with weights hash |
GET /v1/input-key |
network X25519 key for encrypted inputs |
POST /v1/keys |
issue a self-serve key ({"address":"ai_..."}); 404 unless VNN_SELF_SERVE_KEYS=1 |
POST /v1/infer |
submit a signed inference transaction (Authorization: Bearer <key> when keys are enabled) |
POST /v1/infer/batch |
submit 1–32 signed transactions with per-item results |
GET /v1/tasks/:id |
task status, output and receipt |
GET /v1/tasks/:id/events |
task status/result Server-Sent Events (SSE) stream |
GET /v1/verify/:id |
recompute the output and compare with the chain |
GET /v1/usage/:addr |
per-address metering (JSON) |
GET /v1/usage/:addr/csv |
metering export for invoicing |
Inference tasks are executed by consensus: every node applying a block
re-runs the model over the task input in integer arithmetic, so the output is
part of state transition rather than the producer's claim. Each finished task
gets a receipt anchored to the block that carried it. Decoder tasks may include
an optional sampling object (temperatureMilli, topK, topPMilli,
seed) in the signed transaction data; it is bound to the task id and a
per-task override adds sampling/samplingHash to the receipt. Without it the
model's fixed default is used and the receipt keeps its historical shape.
Sampling requires block format v2, so validators and replicas must be upgraded
together before it is used.
cargo build --workspace
./scripts/demo.sh # local node → faucet → inference → verification
# or manually, against a running node
verinoo-node infer --key-file key.json --input "my parcel was never delivered"
curl -s localhost:7100/v1/verify/<taskId> | jq '{verified, output}'POST /v1/infer/batch accepts {"transactions":[<signed TxEnvelope>, ...]} with
1–32 items. The item count is only a transport cap: the batch must also fit in
one block's gas. A block carries 1000 gas; submitInference costs 60 gas
(120 for sampled, 240 for full-zk), so at most 16 optimistic inference
items fit in one batch. A batch whose total gas exceeds the block limit is
rejected with 400 before any item is admitted, so accepted items are never
silently dropped by the producer for gas exhaustion.
Each item runs the same auth, signature, sampling, encryption and policy checks
as POST /v1/infer. Nonce and balance are checked against a batch-local overlay
seeded from committed state, so consecutive nonces from one sender are accepted
in order. The overlay advances only when an item is admitted; a rejected item
leaves it unchanged. That means a rejected middle item cascades to later items
from the same sender: if nonce 2 fails, a later nonce 3 fails its nonce check
too. Other senders are unaffected. Accepted transactions enter the mempool and
are gossiped independently; the response reports every item in input order:
{
"accepted": 1,
"rejected": 1,
"results": [
{"index": 0, "accepted": true, "txId": "...", "taskId": "..."},
{"index": 1, "accepted": false, "error": "...", "txId": "..."}
]
}After request-level checks (shape, size, auth, gas capacity), batch submission
always returns 200 with per-item results, even when every item is rejected.
Partial success is intentional: a bad item does not roll back its siblings.
Batching is not a consensus batch and gives no gas discount; each transaction
keeps its own task id and receipt. Batch admission is not a reservation: block
production re-validates against evolving state and may skip an admitted
transaction if a competing submission wins the nonce or balance. An empty,
oversized or over-gas batch is 400, and an unauthenticated request is 401.
The mempool is capped at 5000 transactions across both RPC admission and
gossip. When it is full, /v1/infer returns 429, and a batch reports a
per-item mempool is full rejection while still returning 200 for the
request.
GET /v1/tasks/:id/events returns text/event-stream. The node polls the task
store about once per second for up to 60 seconds:
status—{taskId,status,height,resultHash,updatedAt}, with input and ciphertext redacted.result—{taskId,task,receipt}after the task iscompletedorfailed, followed bydone.timeout— after 60 seconds without a terminal state, followed bydone.
Heartbeat comments keep idle proxies open. The stream carries only the
consensus-committed result; token-level previews from unverified execution are
not implemented. A task row is created only when the block carrying its
submitInference is applied, so a stream requested before that point returns
404; poll /v1/tasks/:id (also 404 until then) or retry the stream. A
global limit of 64 concurrent streams per process applies; a request beyond
it returns 429.
VNN_POLICY_FILE points at a JSON policy (see
docs/policy.md). It is node-local and never changes
consensus execution or committed results. Plaintext input is inspected for
blocked content, and maxInputBytes applies to the plaintext or the serialized
encryptedInput payload at the submission boundary. A blocked term or
over-limit payload returns 422 with reason: "policy". Encrypted payloads are
opaque for content: they are allowed unless the policy sets requirePlaintext,
and they are never decrypted or inspected by the policy. Because a redacted
input cannot be written back into a signed transaction, a policy redaction
rejects the request with "input requires client-side redaction" instead of
mutating the signature. An invalid policy file fails startup rather than
silently falling back to permissive defaults.
The reference model (intent-classifier-v1, 8,196 parameters) is trained from
the committed corpus with cargo run --release -p verinoo-model --bin train.
Additional models are loaded from VNN_MODEL_DIR (default ./models) and
executed in consensus the same way. They must be dense/relu/softmax graphs over
the hashed-unigram featuriser; see docs/runtime.md for the
format and models/acme-support-v1.graph.json for a working example. Every
node must load the same set — /v1/models exposes the set and its hash.
cargo run -p verinoo-model --bin export -- \
--model-id acme-support-v1 --out models/acme-support-v1.graph.json
verinoo-node infer --model acme-support-v1 --input "my parcel was never delivered"
# a real transformer encoder in consensus (5,508 params, 80/80 label parity)
verinoo-node infer --model intent-transformer-v1 --input "my parcel is delayed again"
# a synthetic causal decoder with char-BPE, KV cache and greedy generation
verinoo-node infer --model tiny-gpt-v1 --input "please cancel"
# a real 3.75M-param pretrained TinyStories-1M decoder (GPT-2 BPE)
# weights are downloaded locally, not redistributed (no license on the model card)
python3 scripts/import_tiny_stories.py
verinoo-node infer --model tiny-stories-1m --input "Once upon a time"
# Apache-2.0 DistilGPT-2: 81.9M params, 1,024 context, 328 MB binary weights.
# Local/GPU path only; not served on the public 1-CPU node.
python3 scripts/import_distilgpt2.py
verinoo-node infer --model distilgpt2 --input "Once upon a time"
# generic GPT-2/GPT-Neo importer: HuggingFace id or local directory
python3 scripts/import_hf_gpt.py --model distilgpt2 --skip-generation
python3 scripts/import_hf_gpt.py --model roneneldan/TinyStories-1M \
--max-context 256 --out-name tiny-stories-1mThe generic importer supports GPT-2 (GPT2LMHeadModel) and GPT-Neo
(GPTNeoForCausalLM) checkpoints only, with tied/untied heads, gelu_new or
relu, and vocab.json + merges.txt. It transposes GPT-2 Conv1D weights but
not GPT-Neo Linear weights, and rejects LLaMA/SentencePiece tokenizers,
rotary-embedding architectures, other activations and GPT-Neo contexts longer
than the local-attention window. Weights are downloaded or read locally, not
redistributed.
The vertical demo for the design-partner profile is a realistic claims classifier over the production hashed-unigram featuriser:
./scripts/demo-claims.sh
# or against the live testnet
CLAIMS_NODE=https://verinoo.com ./scripts/demo-claims.shIt submits three claim notes, verifies each receipt and writes a pilot report to
reports/. See docs/claims-pilot.md.
verinoo-node wallet generate --output key.json
verinoo-node wallet balance --key-file key.json --node http://localhost:7100
verinoo-node wallet send --key-file key.json --to ai_... --amount 100
# tenant key bound to the wallet address, 5 000 inference calls/day
verinoo-node apikey new --tenant acme --address ai_... --quota 5000 \
--file /etc/verinoo/api-keys.json
systemctl kill -s HUP verinoo-node # reload without downtimeKeys are stored as hashes and reloaded with SIGHUP. See
docs/operations.md for backups, restore, rotation,
replica/HA and incident response.
With VNN_SELF_SERVE_KEYS=1, clients can issue their own address-bound key:
curl -s -X POST localhost:7100/v1/keys \
-H 'content-type: application/json' -d '{"address":"ai_..."}'The raw key is shown once; only its SHA-256 hash is stored in RocksDB. One
active key per address (a second request returns 409), daily quota from
VNN_SELF_SERVE_QUOTA, and issuance is limited to 5 requests/hour per IP.
Self-serve keys live in the database and are not listed by
verinoo-node apikey list, which only reads the operator key file.
cargo build --workspace --locked
cargo test --workspace --locked # 274 tests (model-parity tests skip without local weights)
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --all -- --check
./scripts/demo.sh # single node, ~45 s
./scripts/demo-2node.sh # two validators, ~2 min
./scripts/demo-sync.sh # late replica catches up
sudo ./scripts/backup.sh # consistent DB backup
sudo REPO_DIR=/opt/verinoo ./deploy/setup-vps.sh # Ubuntu 24.04AGPL-3.0. Research prototype.