How spacemeshos/go-spacemesh works
go-spacemesh is a Go implementation of the Spacemesh peer-to-peer full node: it participates in consensus, maintains blockchain state, and exposes node services to operators and applications. A typical transaction workflow starts at the public gRPC API, enters transaction handling, and is incorporated into the mesh and processed by the VM; consensus and peer synchronization supply and validate chain data. The tree and README establish the major subsystems, but most implementation excerpts were not sampled, so edges show only high-level relationships and omit uncertain internal wiring.
Main entry points: node.go Node runtime · grpc.go gRPC services · mesh.go Mesh and blocks · handler.go Transaction pool
Components 20
Node and API
- Node runtime
node/node.go - gRPC services
api/grpcserver/grpc.go - Transaction API
api/grpcserver/v1/transaction_service.go
Peer Network
- P2P transport
p2p/host.go - Chain synchronizer
syncer/syncer.go - Peer data fetch
fetch/fetch.go - Bootstrap updates
bootstrap/updater.go
Consensus and Mesh
- Smeshing and ATX
activation/handler.go - Proposals
proposals/handler.go - Hare consensus
hare4/hare.go - Tortoise consensus
tortoise/tortoise.go - Mesh and blocks
mesh/mesh.go
Transactions and VM
- Transaction pool
txs/handler.go - Smart-contract VM
genvm/vm.go - Contract templates
genvm/templates
Node State
- Persistent state
sql/database.go - Checkpoint recovery
checkpoint/recovery.go - Events and subscriptions
events/events.go
Other components
- Node operator
- Applications
Connections 24
- Node operator → Node runtime: operates
- Applications → gRPC services: calls
- Node runtime → gRPC services: starts
- gRPC services → Transaction API: dispatches
- Transaction API → Transaction pool: submits
- Node runtime → P2P transport: starts
- Chain synchronizer → P2P transport: exchanges data
- Chain synchronizer → Peer data fetch: requests chain data
- Bootstrap updates → P2P transport: distributes updates
- Node runtime → Smeshing and ATX: starts
- Node runtime → Proposals: starts
- Proposals → Hare consensus: participates in rounds
- Hare consensus → Tortoise consensus: supplies consensus data
- Tortoise consensus → Mesh and blocks: determines validity
- Proposals → Mesh and blocks: adds proposals
- Mesh and blocks → Transaction pool: executes transactions
- Transaction pool → Smart-contract VM: executes contracts
- Smart-contract VM → Contract templates: dispatches
- Node runtime → Persistent state: opens state
- Mesh and blocks → Persistent state: persists chain state
- Transaction pool → Persistent state: reads and writes
- Checkpoint recovery → Persistent state: recovers state
- Node runtime → Events and subscriptions: publishes events
- gRPC services → Events and subscriptions: serves subscriptions