teranode-bridge

module
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0

README

teranode-bridge

CI CodeQL Release Go Reference License

Part of the BSV Layered Multicast open-source project. See the main repository for the full architecture, design docs, and BRC specifications.

A landing-tier bridge for pushed delivery into an unmodified Teranode cluster.

teranode-bridge terminates the per-class object delivery lanes on a machine in front of a Teranode cluster, hands each object class to the cluster service that owns it, and submits cluster-produced subtrees and blocks back onto the object plane — while the Teranode cluster itself stays vanilla.

   object plane ══push══▶  teranode-bridge                Teranode LAN
                           ├── tx lane      → propagation      (cluster ingest)
                           ├── subtree lane → cache + announce ─────┐
                           ├── block lane   → cache + announce ─────┤
                           ├── retrieval plane   ◀────── asset pull ┘
                           └── reverse: blockchain Subscribe → BRC-143/144 → up

Why an announce shim

Teranode learns about subtrees and blocks by announcement plus pull. The bridge already has the bytes — they were pushed to it — so it stores them, announces itself as the source, and serves the resulting pull from the same LAN. That buys a fully pushed wide-area path with no fork of Teranode, and the cluster still fetches and validates exactly as it would from a peer.

See Architecture › Why an announce shim.

Four planes (ingest, cache, retrieval, reverse) run in one process by default (-mode all); splitting them is deployment topology. See Architecture.

Documentation

Requirements

  • Go 1.26 or later
  • A reachable Teranode cluster (propagation HTTP, Kafka, asset HTTP, blockchain gRPC); -mode tx needs only propagation HTTP, and -mode sink none of them
  • Network reachability from the cluster back to the bridge's retrieval plane

Build

make build          # static binary at ./teranode-bridge
make test           # go test -race ./...
make ci             # full containerised pipeline

Development covers CI, the container image and dependencies.

Run

# Delivery only: terminate the lanes, submit transactions, announce and serve
# subtrees and blocks.
./teranode-bridge \
  -retrieval-listen '[2001:db8:3f::1]:9145' \
  -advertise        'http://[2001:db8:3f::1]:9145' \
  -propagation      'http://192.0.2.10:20833' \
  -kafka            '192.0.2.10:19092'

# Transaction lane only: subtrees and blocks stay on the cluster's libp2p.
./teranode-bridge -mode tx -propagation 'http://192.0.2.10:8833'

# Sink: receive, parse, verify and count with no cluster targets at all.
./teranode-bridge -mode sink -stats-every 10s

See docs/configuration.md for the full flag reference.

Default ports

Port Direction Carries
8725 in transaction lane (BRC-30 extended format only; standard-format transactions are refused)
9143 in subtree lane (BRC-143 push frames)
9144 in block lane (BRC-144 push frames)
9145 in retrieval plane — the cluster's pulls
9146 in /metrics, /health*, /healthz, /readyz, /loglevel, /debug/pprof
8726 out BRC-143 subtree submits to the edge proxy's object ingress (-edge-subtree-port)
8727 out BRC-144 block submits to the edge proxy's object ingress (-edge-block-port)

Ports encode the side of the fabric a lane sits on; see lane numbering.

Observability

Series are teranode_bridge_* on -metrics-addr (default [::]:9146), shaped like Teranode's own (same Namespace/Subsystem grid, bucket sets and /health* JSON). The alert that matters is teranode_bridge_echo_mismatch_total: non-zero means the object plane returned different bytes than were published. sum(teranode_bridge_submitter_active) must be exactly 1 per cluster per class.

Helm chart

A Kubernetes Helm chart is published from a dedicated chart repository:

  • Repository: charts/teranode-bridge
  • OCI: helm install bridge oci://ghcr.io/lightwebinc/charts/teranode-bridge

config.peerId is required, and config.advertise, config.propagation and config.kafka unless config.mode=sink. See the chart README for scaling rules.

Layout

.
├── cmd/teranode-bridge/     # entrypoint: flags, wiring, per-class handlers
├── lanes/                   # per-class TCP listeners over bare object streams
├── announce/                # Kafka {hash, URL, peer_id} producer + wire codec
├── cache/                   # hash-keyed LRU (objects) + generational (txs), TTL + byte ceiling
├── registry/                # TTL'd seen-set with direction
├── retrieval/               # the asset-API subset the cluster pulls from
├── reverse/                 # blockchain Subscribe → origin filter → publish up; TLS, keepalive, promoter
├── encode/                  # BRC-143 / BRC-144 push-frame builders
├── tnwire/                  # BRC-144 ⇄ Teranode block serialization
├── hashid/                  # internal ⇄ display byte order, in one place
├── internal/                # submit, txpipe, tnasset, health, obs, metrics, tracing
├── proto/blockchain_api/    # minimal wire-compatible Subscribe subset
├── ci/                      # Dagger CI driver
├── deploy/grafana/          # dashboard JSON
├── hack/                    # tnbench and propbench rigs
├── docs/                    # architecture, configuration, development, metrics reference
├── Dockerfile
├── Makefile
└── .github/workflows/{ci,codeql,image-publish,release,vuln}.yml

The top-level packages are the public extension seams an importing module (such as arcade-bridge) builds on; internal/ stays private to this binary.

Releases

Releases and notes live on GitHub Releases; there is no CHANGELOG. Images (ghcr.io/lightwebinc/teranode-bridge:<tag>) are published by a manual workflow run.

License

Apache 2.0. See LICENSE and NOTICE.

Directories

Path Synopsis
Package announce publishes subtree and block announcements into the Teranode cluster's Kafka, pointing them at this bridge's retrieval plane.
Package announce publishes subtree and block announcements into the Teranode cluster's Kafka, pointing them at this bridge's retrieval plane.
Package cache holds pushed object bytes between delivery and the moment the Teranode cluster pulls and validates them.
Package cache holds pushed object bytes between delivery and the moment the Teranode cluster pulls and validates them.
cmd
teranode-bridge command
Command teranode-bridge is the landing-tier bridge for pushed delivery into a Teranode cluster.
Command teranode-bridge is the landing-tier bridge for pushed delivery into a Teranode cluster.
Package encode builds the push frames the bridge sends back up the tunnel.
Package encode builds the push frames the bridge sends back up the tunnel.
hack
tnbench command
Command tnbench drives the teranode-bridge tx lane at saturation.
Command tnbench drives the teranode-bridge tx lane at saturation.
Package hashid handles the one byte-order trap that runs through this whole bridge.
Package hashid handles the one byte-order trap that runs through this whole bridge.
internal
activation
Package activation adopts listening sockets passed by systemd socket activation (sd_listen_fds(3)): LISTEN_PID names this process, LISTEN_FDS counts the sockets, which start at file descriptor 3, and LISTEN_FDNAMES carries each socket's FileDescriptorName.
Package activation adopts listening sockets passed by systemd socket activation (sd_listen_fds(3)): LISTEN_PID names this process, LISTEN_FDS counts the sockets, which start at file descriptor 3, and LISTEN_FDNAMES carries each socket's FileDescriptorName.
health
Package health implements the bridge's dependency-aggregating health surface, shaped to match Teranode's own (teranode/util/health + daemon/daemon.go).
Package health implements the bridge's dependency-aggregating health surface, shaped to match Teranode's own (teranode/util/health + daemon/daemon.go).
metrics
Package metrics exposes the bridge's counters on a Prometheus endpoint, alongside the health, profiling and runtime-log-level routes every service in the stack serves.
Package metrics exposes the bridge's counters on a Prometheus endpoint, alongside the health, profiling and runtime-log-level routes every service in the stack serves.
obs
Package obs owns the bridge's latency, size and freshness instrumentation — everything the scrape-time collector in internal/metrics cannot express.
Package obs owns the bridge's latency, size and freshness instrumentation — everything the scrape-time collector in internal/metrics cannot express.
obs/kafka
Package kafka holds the Kafka client instrumentation.
Package kafka holds the Kafka client instrumentation.
submit
Package submit hands delivered transactions to the Teranode cluster.
Package submit hands delivered transactions to the Teranode cluster.
tnasset
Package tnasset reads objects back out of the local Teranode cluster so the bridge can publish what the cluster produced.
Package tnasset reads objects back out of the local Teranode cluster so the bridge can publish what the cluster produced.
tracing
Package tracing initialises OpenTelemetry tracing for the bridge, matching Teranode's tracing setup (teranode/util/tracing) so a trace crosses the bridge instead of ending at it.
Package tracing initialises OpenTelemetry tracing for the bridge, matching Teranode's tracing setup (teranode/util/tracing) so a trace crosses the bridge instead of ending at it.
txpipe
Package txpipe decouples the tx lane's read loop from cluster submission and turns per-transaction round trips into batched ones.
Package txpipe decouples the tx lane's read loop from cluster submission and turns per-transaction round trips into batched ones.
Package lanes terminates the per-class object delivery lanes.
Package lanes terminates the per-class object delivery lanes.
proto
Package registry remembers which object hashes crossed the bridge, and in which direction.
Package registry remembers which object hashes crossed the bridge, and in which direction.
Package retrieval serves the pulls a Teranode cluster makes after the bridge announces an object — the half of the announce shim that makes a pushed object look, to the cluster, exactly like one fetched from a peer's Asset service.
Package retrieval serves the pulls a Teranode cluster makes after the bridge announces an object — the half of the announce shim that makes a pushed object look, to the cluster, exactly like one fetched from a peer's Asset service.
Package reverse carries this cluster's own subtrees and blocks back into the fabric.
Package reverse carries this cluster's own subtrees and blocks back into the fabric.
Package tnwire converts between Teranode's block serialization and the BRC-144 push frame.
Package tnwire converts between Teranode's block serialization and the BRC-144 push frame.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL