How availproject/avail works
Project type and purpose
• This is a Substrate‑based blockchain node implementation (“Avail Node”).
• Purpose: run a full node for the Avail blockchain, exposing JSON‑RPC, consensus (BABE/GRANDPA), runtime rules (pallets), and state storage.
File structure
• Top‑level crates:
• node/ : the binary entrypoint (CLI, service, RPC, network, consensus).
• runtime/ : the WebAssembly runtime logic (pallet wiring, weights, transaction filter).
• pallets/ : on‑chain modules (system, vector, dactr, mandate, mocked_runtime).
• client/ : library crates for subsystem utilities (e.g., basic‑authorship).
• base/ : common utilities (metrics, temporary storage, header extension).
• rpc/ : custom RPC extensions (kate‑rpc, testing‑rpc).
• patricia-merkle-trie/ : standalone trie library for proofs.
• e2e/ : end‑to‑end test harness.
• dockerfiles/, scripts/, misc/genesis/ : deployment, CI, dev‑chain assets.
• Config and automation: Cargo.toml, Dockerfile, GitHub workflows under .github/workflows.
README for additional insights
• Confirms this is an “official client” for Avail blockchain.
• Describes network roles (authority vs. full), JSON‑RPC server, Prometheus metrics.
• Outlines custom flags (kate‑RPC), supported chains, and Docker usage.
• Mentions benchmarks and external SDKs (avail‑js, avail‑rust, avail‑go).
Main components
a. Node Binary (node/):
– CLI interface (node/src/cli.rs)
– Service orchestrator (networking, consensus, RPC registration)
– Consensus workers (BABE authoring, GRANDPA finality)
b. Runtime Engine (runtime/):
– Wasm executor loading compiled runtime
– Runtime APIs (header extension, custom RPC hooks)
– Pallet dispatch (system, balances, vector, dactr, mandate, etc.)
c. On‑chain Modules (pallets/):
– Transaction validation, state transitions, storage schema
d. Storage Layer:
– ParityDB (persistent key‑value store)
– Patricia Merkle Trie (proof generation)
– Temporary in‑memory caches (base/src/mem_tmp_storage.rs)
e. Networking Layer:
– libp2p or Substrate network subsystem (block propagation, gossip)
– RPC server (node/src/rpc.rs) exposing JSON‑RPC on port 9944
– Metrics exporter (Prometheus endpoint on 9615)
f. Clients & Tests:
– e2e harness (e2e/src/) invoking RPCs, block submission
g. Build and Deployment:
– Docker images (dockerfiles/avail-node.Dockerfile)
– CI/CD (GitHub Actions workflows)
– Scripts for chainspec and devnet management
Relationships and interactions
• CLI → Node Service
• Node Service ↔ Network subsystem (peer discovery, block/extrinsic gossip)
• Node Service → Consensus workers → Runtime Engine
• Runtime Engine → Pallets → Storage Layer
• Node Service ←→ RPC Layer → External Clients / SDKs / e2e tests
• Node Service → Metrics exporter → Prometheus
• Build/CI pipelines → Docker image → Node container
Architectural patterns and design principles
• Modular Runtime: pallets plugged into a Wasm runtime.
• Service‑oriented: clear separation of concerns (network, consensus, RPC, state).
• Pluggable RPC: kate‑RPC and testing RPC layered on top of core JSON‑RPC.
• Layered storage: in‑memory buffers, ParityDB, Merkle proofs.