Skip to content

v0.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Dec 17:29
· 2 commits to main since this release

First tagged release. It loads a PATH config unmodified. ARCHITECTURE.md holds
the design and the reasoning behind it; docs/ holds the generated reference for
every config key, admin route and metric.

Much of what follows is behind feature flags, global and per service. An entry
marked off ships disabled; featureflag/defaults.go holds every default, and
GET /admin/flags shows what is in force.

Relay pipeline

  • One concern per middleware. Parse, validate, cache, batch, coalescing,
    retry, hedge, circuit break, method blocks, endpoint selection, send and
    response grading are each one small middleware. gateway_config.middleware_chain
    sets the order and relay.DefaultChainOrder() is the default. Startup refuses an
    order that breaks a load-bearing rule, such as selection outside retry.
  • Retry and hedging. A retry rotates to another endpoint. A hedge races a
    delayed second arm and never sends an arm into a pool already ruled out; with
    rehedge (off) it sends one more arm when the hedge fails before the
    primary. Large batches hedge only up to hedge_max_batch_size items.
  • Batches fan out under per-service size and concurrency limits that are
    runtime knobs, stream their answers back in order, and grade each item on its
    own. An item that ends on a retry verdict still gets the node's answer.
  • Response cache for finalized data, bounded in bytes; singleflight
    coalescing keyed by method and route. A null or error answer is never cached.
  • Quorum (quorum, off): a client asks for one request to go to several
    operators and gets the majority answer, through Target-Quorum-* headers.
  • Shadow mode (shadow_mode, off) runs relays to the supplier without
    answering the client, for dark launches.

Transports

  • JSON-RPC, REST, CometBFT (by path or by JSON-RPC method), WebSocket
    with subscriptions, and gRPC (native, with an auto-detected gRPC-Web
    fallback).
  • Relays are signed for the session at the current height, by the application
    itself or by a delegated gateway. Relay connections are pooled with TLS session
    resumption, and a supplier's redirect is never followed.
  • When every stake of a service's RPC type is unusable, rpc_type_fallbacks
    moves the request one hop to another type, with PATH's key and semantics.

Chains and endpoint selection

  • QoS plugins for EVM, Cosmos/CometBFT (including the EVM face of chains that
    have one), Solana, TRON, and a declarative JSON-height plugin for chains such
    as NEAR. A service with no plugin is passed through, and startup says which
    services those are and why.
  • Height tracking. A per-service head comes from heights that more than one
    party corroborates, one vote per party. Endpoint heights come from probes and
    from clients' head answers, judged at the moment the head was read. Selection
    prefers endpoints inside the sync allowance, in tiers, and retry and hedge never
    narrow into hosts far behind the head.
  • Archival routing (EVM). Hosts are marked by the state and log depth they
    have served or refused, and requests for history go to hosts that hold it.
    With archival_retry (off), a refused historical read is retried where the
    history is. A health check with expect_nonempty_result can prove a host
    answers history empty, and archival_empty_keep_out (off) keeps that host
    out of history requests.
  • Stale answers are measured per party: EVM and JSON-height chains by head,
    Cosmos by block time. Acting on them is off by default: stale_response
    grades and retries a stale answer, stale_share charges the party its stale
    share, and state_canary grades a fixed state call by its block's timestamp.

Response grading and reputation

  • Every response gets a verdict and an attribution: supplier, blockchain,
    client or unknown. A chain's own answer (a reverted call, a missing block,
    pruned state) is delivered to the client and does not cost the supplier. Relay
    miner refusals, timeouts, rate limits, spent quotas and capacity errors are
    graded by one table on every path.
  • Retry and circuit breaking are separate decisions. A retry never escalates
    into a domain-wide lockout; the breaker keys on the host an attempt dialed and
    fails open when every domain in the pool is broken.
  • Reputation per backend key, one signal per attempt. Retries and hedges do
    not move a key's failure rate, and a cancelled attempt is never evidence about
    the endpoint. Party-level penalties apply to every key an operator holds, and
    owners link operators through their dedicated domains. A policy penalty is set
    by hand, with its reason, and an operator can be reset; the measured ones
    (stale_share, throttle_share, class_share, trust_penalty) are off.
  • Method-aware blocks keep a method away from a host that refuses or cannot
    serve it, without blocking the host for everything else.
  • A new pod starts from the fleet's state: it hydrates reputation and party
    penalties from Redis and warms sessions before it reports ready.

WebSocket

  • A bridge with ping/pong liveness on both legs, subscription tracking, and
    replay on rebind: pending subscribes and reads are resent, and writes are
    answered "may or may not have been applied". Each client is answered in the
    frame type it sends.
  • Connections move off a supplier at a session end, on a drain and on a
    no-answer stall, staying in the best tier; with stale_response (off), also
    off a stale head.
  • Repeated notifications are dropped and charged to the supplier, and one client
    address may hold a limited number of live connections (a tuning knob).
  • Per-service controls, off until an operator sets them: deny or answer
    chain-wide feeds in the gateway, with a message the operator writes; a
    per-connection notification budget; a share cap per party (ws_share_cap).

Operation

  • Three ports, by design: relays and health on 3069, the admin API on
    loopback 9091, Prometheus on 9090. pprof is off unless set, because heap
    dumps hold signing keys.
  • Admin API (optional bearer token, admin_config.auth_token): reputation and
    per-key timelines, operator drains and resets, reputation policy, per-service
    feature flags, runtime tuning knobs with the value in force per service, and a
    debug probe that pins one supplier for an HTTP relay or a WebSocket
    subscription.
  • Feature flags, global and per service, defined once in
    featureflag.DefaultFlags; config carries only the overrides.
  • Redis is optional. With it, flags, drains, bans, health-probe results and
    circuit-breaker state are shared across replicas, only the elected leader
    sends probes, and a replica that starts adopts the reputation the leader saved;
    after that each replica scores from its own traffic. Sentinel is supported, and a pod joins a Redis that
    was down when it booted. Without Redis, SAGE runs local-only.
  • Health checks are config-driven, sent once by the leader and applied fleet
    wide, grouped by the URL each check dials.
  • Auto-drain runs in shadow by default: the engine records which operator it
    would drain from a failing pool, and acts only with auto_drain (off).
  • Readiness holds traffic until sessions are warm, releases on a deadline,
    and exports which half of readiness is failing.
  • Graceful shutdown on SIGINT/SIGTERM with a 10s drain; open WebSockets are
    closed with 1012. Every goroutine contains its panics, counted in
    sage_recovered_panics_total.

Observability

  • Prometheus series for client requests and whose answer each status was,
    attempts and latency per operator, retry and hedge outcomes, selection tiers,
    batches, WebSocket sessions and frames, reputation, and health checks. The
    reference is generated: docs/metrics.md.
  • A client-facing failure logs its attempt trail and what the request asked for.
  • Grafana dashboards, a public quality view and a gateway operator view, generated
    from one source in grafana/.

Config and PATH compatibility

  • Loads a PATH config unmodified. Parsing is lenient but never silent: an
    unknown key goes to cfg.Ignored and is warned at startup, and a key SAGE
    parses but does not honour is reported as unimplemented or inert, with what
    decides the behaviour instead.
  • The client contract is a table. SAGE's headers, error envelopes and health
    routes sit beside PATH's in docs/path-compat.md, each row pinned by a test.
  • Value types throughout: the zero value is the safe default. Chain semantics
    such as chain IDs belong to the QoS plugin, validated at wire time.
  • A config value may be ${VAR}, expanded from the environment.

Build and release

  • make sage_build (CGO-free), make test_unit (-short -race), make go_lint
    (with deadcode), make docs, and an in-process mock backend
    (bench/mock-config.yaml) to run and load-test with no fullnode or suppliers.
  • Tagged releases build linux and darwin binaries for amd64 and arm64 with
    checksums, and push ghcr.io/pokt-network/sage:<tag>; a release that is not a
    pre-release also moves :latest. A tag publishes only if CI passed on its
    commit.
  • CI gates on govulncheck against a reviewed allowlist
    (.github/vuln-allowlist.txt), which records why each accepted finding is
    acceptable and flags entries that have stopped being reported. Dependabot
    covers Go modules, Docker and GitHub Actions.

Security

  • SAGE authenticates no clients and rate-limits nothing. Every relay it
    accepts is signed with the gateway key and spends staked POKT, so 3069 belongs
    behind an authenticating, rate-limiting edge. README and SECURITY.md say so.
  • Error responses carry no internal detail: clients get the error kind and
    SAGE's message, and the cause chain stays in the log.
  • Prometheus label values are bounded by policy, so a new metric cannot add an
    unbounded label.
  • Outbound gRPC sets TLS 1.2 as the floor for supplier and fullnode connections.

Notes

  • Built against poktroll v0.1.37. Relay signing is tested against its
    relay-miner verifier, for an application signing for itself and for a
    delegated gateway.
  • SAGE is a restructured successor to PATH. Bugs from PATH production are
    structurally prevented, listed in ARCHITECTURE.md under Production Lessons
    Baked Into Architecture
    .