$ show wormhole-foundation/wormhole
Wormhole is a generic cross-chain messaging protocol that allows smart contracts on different blockchain networks to communicate with each other. This monorepo contains the full protocol implementation: a guardian node (Go) that observes events on supported blockchains, signs Verifiable Action Approvals (VAAs), and relays them; smart contracts deployed on Solana, Ethereum, CosmWasm, NEAR, Sui, Aptos, Algorand, and a custom Cosmos SDK chain (Wormchain); multi-language SDKs (JavaScript, Go, Rust) for integrating with the protocol; and a CLI tool for governance and bridge operations. The system supports token bridging, NFT bridging, cross-chain queries (CCQ), and native token transfers (NTT) with an accountant contract for balance tracking. The architecture follows a microservices pattern within the guardian node: chain-specific watchers feed events into a processor that builds VAAs, which are signed by a quorum of guardians and then broadcasted via P2P/gRPC. On the smart contract side, each blockchain has its own implementation of core bridge logic, token bridge, NFT bridge, and governance modules. The codebase uses a variety of frameworks including Solitaire (a custom Solana framework), Anchor (for SVM shims), CosmWasm contracts, and standard Solidity patterns. Extensive testing infrastructure exists with unit tests, integration tests (some hitting live testnets), and formal verification (KEVM for EVM contracts). While the code is large and spans many languages, the core abstractions (VAA structs, guardian set management, watcher interfaces, supervisor pattern, and the Solitaire framework) are well-designed and demonstrate professional engineering maturity. The monorepo also includes generated protobuf code, deployment scripts, devnet configurations, and audit reports, making it a complete reference implementation but also introducing maintenance complexity and some technical debt (e.g., deprecated chain handling, hardcoded keys in tests, and occasional use of panic).
The LLM identified 5 files worth highlighting for reuse:
Defines a `GuardianSigner` interface that abstracts over different signing backends (file-based, AWS KMS). Implements a URI scheme parser (e.g., `file://`, `amazonkms://`) to instantiate the correct signer from configuration strings. Includes a `BenchmarkSigner` wrapper for metrics. This is a clean, extensible design that can be reused in any application requiring pluggable cryptographic signing.
Implements a generic supervisor tree for managing the lifecycle of goroutines (runnables). Provides methods to `Open`, `Close`, and propagate errors, with support for restarts and group supervision. The `supervisor_node.go` extends this with a state machine. This pattern is reusable in any Go service that needs robust concurrent task management.
Defines the core VAA (Verifiable Action Approval) data structures in Go, including `VAA`, `Body`, `Transfer`, and various governance payloads. Includes methods for serialization/deserialization from binary format, quorum calculation, and signing/verification. This is a clean, self-contained package that could be extracted and reused as a VAA library for any Go project interacting with the Wormhole protocol.
A pure TypeScript binary reader for decoding CCQ (Cross-Chain Query) protocol messages. Implements methods for reading various integer types, byte arrays, and big-endian values with automatic buffer advancement. This is a clean, reusable module that can be extracted as a general-purpose binary parsing helper for any TypeScript project.
The Solitaire framework provides a set of abstractions for writing Solana programs: account peeling (`peel` trait), seeded PDA derivation (`Seeded` trait), and error handling. It simplifies account deserialization and validation in Solana instructions. Although coupled to Solana, the pattern of using traits for account management is a non-obvious design that reduces boilerplate and improves auditability in Solana smart contract development.