$ show coinbase/mesh-sdk-go
mesh-sdk-go is a Go SDK for building Rosetta/Mesh API integrations, the blockchain-agnostic API standard originally developed by Coinbase. It ships both sides of the wire: generated OpenAPI HTTP clients (client/), generated server controllers with router wiring (server/), and a set of runtime engines layered on top. The fetcher wraps API calls with exponential-backoff retries, a connection semaphore, and mandatory response validation; the syncer performs concurrent block fetching with reorg detection; the reconciler compares locally computed account balances against live node state; the parser extracts balance changes, groups operations, and matches operation intents; and the constructor module defines transaction-building workflows in a custom DSL (.ros files) executed by a worker/coordinator pipeline. The keys package implements signers for secp256k1 (including BIP-340 Schnorr), secp256r1, ed25519, and Pallas curves. Architecturally this is a library, not a standalone service: host applications implement service interfaces (BlockAPIServicer, AccountAPIServicer, etc.) and either serve HTTP via server.NewRouter or consume a node through client/fetcher. The block/transaction data flow is node → fetcher → asserter validation → syncer → storage (BadgerDB) → reconciler; construction flows in the reverse direction: DSL workflow → worker execution → key signing → broadcast submission. The types/ directory holds roughly 85 auto-generated Rosetta data models, and templates/ plus codegen.sh regenerate client, server, and types from the mesh-specifications OpenAPI spec. Key external dependencies include BadgerDB, btcec, kryptology, and go-ethereum crypto packages. The codebase is professionally structured: 10+ packages, essentially all with table-driven tests, functional-options configuration, error-sentinel patterns, and mockery-generated mocks. Maintenance is active as of late 2026, with CI, dependabot (0 alerts), and regular commit activity. Technical drift is medium: the repo is mid-rebrand from rosetta-sdk-go (internal import paths and RosettaAPIVersion constants still use the old name), BadgerDB v2 is aging, and a zstd dictionary-training step shells out to a system binary. None of this blocks use today, but adopters should expect regeneration friction and naming inconsistencies as the Mesh rebrand completes.
The LLM identified 6 files worth highlighting for reuse:
A writer-priority RWMutex that allows high-priority callers (e.g., cache evictions or critical reads) to acquire the lock ahead of queued writers, preventing priority inversion. Pure stdlib, zero internal imports, fully extractable into any Go concurrent service. Demonstrates non-obvious lock-starvation engineering rarely seen in SDK code.
A clean Signer interface with concrete implementations for secp256k1 (including BIP-340 Schnorr), secp256r1, ed25519, and Pallas curves, including hex marshaling and curve-specific hashing. The abstraction cleanly separates key representation from signing backend and could be lifted into a standalone Go crypto library with minimal modification.
The Fetcher's request pipeline combines exponential backoff, semaphore-limited concurrency, context cancellation, and transient-vs-permanent error classification (retriable HTTP codes versus permanent asserter validation failures, so doomed requests are never retried). The retry-classification pattern is domain-agnostic and separable despite the file's Rosetta-specific imports.
An encoding layer combining msgpack with zstd compression, optionally trained on domain data to improve compression ratios for small payloads, paired with a sync.Pool-backed BufferPool to minimize allocations on hot paths. A solid reference implementation for any embedded storage engine needing compact serialization.
HTTP middleware that captures request headers into context and replays them onto outgoing backend requests, with a custom ResponseWriter wrapper propagating response headers back. A clean, self-contained header-baggage pattern reusable for API-gateway or gRPC-transcoding use cases.
A hand-written parser for the .ros workflow language (scenarios, actions with variable set/get, concurrency directives) backed by extensive negative test fixtures covering malformed inputs such as EOF, duplicate workflows, and invalid syntax. Internally coupled to the constructor module, but the parser design and test strategy are instructive for anyone implementing a small domain-specific language in Go.