pop-fork 0.14.0

Library for forking live Substrate chains.
Documentation

Fork functionality for creating local forks of live Polkadot SDK chains.

This crate provides the infrastructure for lazy-loading state from live chains, enabling instant local forks without full state sync.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         pop fork chain                          │
│                              CLI                                 │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                         RPC Server                               │
│           (Polkadot SDK compatible JSON-RPC)                     │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                     Layered Storage                              │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────────┐  │
│  │ Local Layer │─▶│ Cache Layer │─▶│ Remote Layer (Live RPC) │  │
│  │(modifications)│ │  (SQLite)   │  │    (lazy fetch)         │  │
│  └─────────────┘  └─────────────┘  └─────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Main Types

Blockchain Manager

  • [Blockchain] - Main entry point for creating and managing forked chains
  • [ChainType] - Identifies whether the chain is a relay chain or parachain

Block and Block Building

  • [Block] - Represents a block in the forked chain with its storage state
  • [BlockBuilder] - Constructs new blocks by applying inherents and extrinsics
  • [InherentProvider] - Trait for generating inherent (timestamp, etc.)

Storage Layers

  • [LocalStorageLayer] - Tracks local modifications to forked state
  • [RemoteStorageLayer] - Cache-through layer that lazily fetches from RPC
  • [StorageCache] - SQLite-based persistent cache for storage values

Runtime Execution

  • [RuntimeExecutor] - Executes Polkadot SDK runtime calls against forked state
  • [ForkRpcClient] - RPC client for connecting to live chains

Transaction Pool

  • [TxPool] - Minimal FIFO queue for pending extrinsics