Skip to main content
Navigation
HomeTechnical ReferenceJournalGitHubGitHub
Sidebar — toggle document categories via the logo
Orion Chain — Custom Blockchain in Rust

Orion Chain — Custom Blockchain in Rust

August 23, 2024

Overview

Orion Chain is a blockchain platform built from the ground up in Rust. Unlike projects that fork existing chains, Orion implements its own custom P2P networking protocol over raw TCP, its own transaction pool and block validation logic, and its own validator runtime for transaction execution.

The codebase is structured into 7 cohesive modules — api, core, crypto, network, rpc, state, and vm — across 55 source files. It is designed as a full-node platform: a single ChainNode binary that runs an HTTP API (Actix-web), a P2P networking layer, and a blockchain validator loop, all backed by RocksDB for persistent storage.


Key Features

  • Custom TCP P2P protocol: Nodes communicate over a custom binary protocol with message types encoded via borsh serialization — no gRPC, no libp2p — just raw TCP sockets with manual binary framing
  • ECDSA cryptography: Transaction signing and verification using both k256 (secp256k1) and p256 curves, with DER/PEM encoding support
  • RocksDB persistence: Block storage and chain state persisted to disk via RocksDB, with support for in-memory operation during testing
  • Block production: Validator loop runs every 5 seconds (configurable block time), proposing new blocks containing transactions from the mempool
  • Transaction pool: In-memory mempool with configurable size (default 50 transactions), fed by peer gossip and RPC submissions
  • Validator runtime: VM module that executes transactions against chain state, with a ValidatorRuntime that validates blocks before commitment
  • HTTP API: Actix-web server exposing REST endpoints for blocks, transactions, and chain state queries
  • RPC controller: Bridges peer TCP messages and client HTTP requests, routing RpcHeader enum variants (GetBlock, NewTx, CommitBlock, GetChainHeight, etc.) to appropriate handlers

Architecture

Seven modules forming a complete blockchain node:

┌────────────────────────────────────────────┐
│ ChainNode │
│ orchestrates: TcpController, TxPool, │
│ BlockValidator, Blockchain, RpcController │
└──────────────┬─────────────────────────────┘

┌───────────┼───────────┬──────────┬───────────┬──────────┐
▼ ▼ ▼ ▼ ▼ ▼
api/ core/ crypto/ network/ rpc/ state/
(HTTP) (blockchain) (ECDSA) (TCP P2P) (bridge) (accounts)
│ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼
Actix-web BlockMgr k256/p256 Node/Peer Handlers AcctMgr
Routes StateMgr Address TxPool Controller Storage
RocksDB Signature Encoder RocksDB
Validator Hash Message
Runtime Types

Tech Stack

LayerTechnology
LanguageRust (edition 2021)
HTTP APIActix-web 4.9, Actix-CORS
P2P NetworkingCustom TCP protocol, borsh serialization
Cryptographyecdsa (k256/p256 curves), sha256, rand
Serializationborsh, serde, serde_json, bincode, hex
DatabaseRocksDB (rocksdb crate), tempfile
Async runtimeTokio (full features)
Loggingenv_logger, log, pretty_env_logger
Buildcargo build --release, make build
LicenseMIT