Skip to content

About

exnode: build and serve Externalize proof bundles from Stellar history archives and RPC.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Externalize

exnode builds and serves Externalize proof bundles from Stellar history archives and RPC.

CI License


A bundle packs everything needed to prove that a Stellar ledger, transaction or Soroban contract call happened: the ledger header, the validators' SCP messages, the next ledger's SCP messages and transaction set, the ledger's results, and the call's return value and events. externalize verifies it against the validators you trust.

Bundle format v2

exnode emits externalize/bundle/v2 (spec). Validators sign only a ledger's StellarValue (txSetHash, closeTime, upgrades), not its header, so the rest of header N (txSetResultHash, previousLedgerHash, …) is bound through ledger N+1: its externalized value's txSetHash is the hash of N+1's transaction set, and that set carries previousLedgerHash = SHA-256(header N). v2 adds two required fields for this:

Field Content Archive source
next_scp base64 XDR ScpHistoryEntry of ledger N+1 scp-*.xdr.gz
next_transactions base64 XDR TransactionHistoryEntry of ledger N+1 (ext v1 carries the generalized set) transactions-*.xdr.gz

Every other field is unchanged from v1. When N ends its checkpoint (N+1 is a multiple of 64), these records are in the next checkpoint's files; until that checkpoint is published, exnode refuses to build the bundle (exnode bundle fails, the HTTP routes answer 503 with Retry-After) rather than emit one without them. That takes one checkpoint interval, about six minutes.

exnode is untrusted by design. It copies archive records byte for byte and never decides whether anything is valid; the verifier does. A compromised exnode can refuse to answer, but it cannot produce a bundle that verifies.

Quick start

Install with Go, download a binary from Releases, or run the image (ghcr.io/externalize-labs/exnode, amd64 and arm64):

go install github.com/Externalize-Labs/externalize-node/cmd/exnode@latest
docker run --rm ghcr.io/externalize-labs/exnode version

# prove a contract call's return value and events (ledger looked up via RPC)
exnode bundle --rpc https://mainnet.sorobanrpc.com \
  --invocation 764c39734ec4da0b537f8c5e43b20223274064f84705b18943b1c35512f8da48 --out proof.json

# prove everything a contract did in one ledger
exnode bundle --rpc https://mainnet.sorobanrpc.com --ledger 64791359 \
  --contract CCNXGPE4AQCSNEBZO3XJDKKDI3CRLYMVS6UWBBTVDLALLWMJEXBORQ2A --out pool.json

externalize verify --events pool.json

Archives publish every 64 ledgers (about six minutes) and RPC keeps transaction meta for roughly a week, so invocation proofs must be built in that window. A ledger can be bundled once its successor is archived, so the newest bundleable ledger is the one before the archive tip. exnode status --rpc … shows how far the archive currently trails. Once built, a bundle verifies forever.

Or use the public node at https://externalize-node.vercel.app, which the online verifier uses. It runs this code (see Serverless) against mainnet, is rate limited, and is best effort. Like any exnode it is untrusted, so verify what it returns:

curl -s https://externalize-node.vercel.app/v1/transactions/<hash>/bundle?op=0 > proof.json
externalize verify --events proof.json

Commands

exnode bundle [--ledger N] [--tx HASH]... [--invocation HASH[:OP]]... [--contract C…]... [--txset] [--out FILE]
exnode serve  [--addr :8080] [--rate 5] [--burst 20] [--cors ORIGINS]
exnode status
exnode cache prune --cache DIR --max-size 2GB
Flag Env Default
--network EXNODE_NETWORK public (or testnet)
--archive EXNODE_ARCHIVE SDF's three archives for the network, comma-separated; failed or corrupt mirrors are skipped with retries and backoff
--rpc EXNODE_RPC none; needed for --invocation, --contract, or when --ledger is omitted
--cache EXNODE_CACHE none; checkpoint files are immutable, so cached files never expire
--rate, --burst 5 requests/s per client IP, bursts of 20, on /v1 routes (serve)
--cors EXNODE_CORS none; browser origins allowed to call the API, * for any (serve)
--client-ip-header EXNODE_CLIENT_IP_HEADER none (the connection's address); behind a proxy, a header it overwrites on every request, such as Vercel's X-Real-Ip (serve)
--out stdout; bundle writes the file atomically

The disk cache never expires entries on its own (checkpoint files are immutable); exnode cache prune trims it to a size budget, oldest files first.

HTTP API

The full contract is api/openapi.yaml.

Route Returns
GET /v1/ledgers/{seq}/bundle?tx=…&invocation=hash:op&contract=C…&txset=true Bundle for a ledger, with any claims
GET /v1/transactions/{hash}/bundle[?op=N][&txset=true] Transaction claim, or invocation claim for op N; txset=true adds the transaction set, as on the ledger route
GET /v1/ledgers/latest/bundle 302 to the bundle of the newest ledger whose successor is archived, the one before the archive tip (query parameters carried over)
GET /v1/status Archive tip, RPC latest ledger, and the lag between them
GET /healthz Liveness
GET /metrics Prometheus metrics: requests by status class, bundles built and failed

Bundles carry a strong ETag (If-None-Match gets a 304), are cacheable forever by browsers and CDNs (Cache-Control: immutable with s-maxage), and are gzipped for clients that accept it (about 3.3x smaller). Every response has an X-Request-ID, and every request is logged as structured JSON. Errors are JSON {"error": "…"}: 400 bad input, 404 not archived yet or outside RPC retention, 429 rate limited (with Retry-After), 501 no RPC configured, 502 upstream failure, 503 the next checkpoint (holding the successor of a checkpoint's last ledger) is not published yet (with Retry-After, never cached) or the build timed out.

docker build -t exnode .
docker run -p 8080:8080 -e EXNODE_RPC=https://mainnet.sorobanrpc.com exnode

Serverless (Vercel)

api/exnode.go runs the same server as a Vercel function, and vercel.json routes every path to it. Because the node is untrusted, a public deployment needs no secrets:

vercel deploy --prod -e EXNODE_RPC=https://mainnet.sorobanrpc.com

It reads the same EXNODE_* variables as exnode serve, with defaults for a public endpoint: any browser origin may call it, the rate limit (1 request/s, bursts of 10) keys on Vercel's X-Real-Ip, and checkpoint files are cached in the function's temp directory. Builds stop at 50 seconds, inside the platform's 60-second limit; bundles are cached at the edge, so each one is built once.

Conformance

testdata/bundle-64791359.json is externalize-core's own fixture. The tests build the same bundle from a local copy of the mainnet archive layout through the real archive and RPC clients, and require byte equality. CI also checks that the copy matches upstream.

The v2 fixture was regenerated with exnode from SDF's mainnet archive, https://history.stellar.org/prd/core-live/core_live_001/. Ledger 64791359 ends its checkpoint, so its successor's records come from the next one:

  • ledger/03/dc/a3/ledger-03dca33f.xdr.gz, scp/03/dc/a3/scp-03dca33f.xdr.gz, results/03/dc/a3/results-03dca33f.xdr.gz (ledger 64791359)
  • scp/03/dc/a3/scp-03dca37f.xdr.gz, transactions/03/dc/a3/transactions-03dca37f.xdr.gz (ledger 64791360)

The transaction meta for the invocation claim comes from testdata/rpc, since RPC no longer retains that ledger. Some files under testdata/archive are trimmed to the records the tests need; the testnet successor records (ledger 5052928) come from https://history.stellar.org/prd/core-testnet/core_testnet_001/ checkpoint 004d1a3f.

Layout

Package Responsibility
internal/archive Checkpoint math, record framing (fuzzed), mirror failover, disk and memory caches
internal/rpc getTransaction, getEvents and getLatestLedger client
internal/bundle Request validation, bundle assembly, invocation extraction from meta
internal/server HTTP routes, error mapping, ETags and gzip, metrics, rate limiting, CORS, access logs
internal/network Network passphrases and SDF's archive mirrors
cmd/exnode CLI
hosted The server built from EXNODE_* for serverless platforms (public, because platforms compile function files outside the module)
api Vercel function entry point, plus the OpenAPI description

Contributing

Run gofmt, go vet ./... and go test -race ./... before opening a PR. Issues are scoped for the Stellar Wave program; comment to get assigned first. See the verifier's CONTRIBUTING.md for the ground rules shared across Externalize repositories.

License

Apache-2.0

About

exnode: build and serve Externalize proof bundles from Stellar history archives and RPC.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages