Expand description
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 chainsChainType- 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 stateBlockBuilder- Constructs new blocks by applying inherents and extrinsicsInherentProvider- Trait for generating inherent (timestamp, etc.)
§Storage Layers
LocalStorageLayer- Tracks local modifications to forked stateRemoteStorageLayer- Cache-through layer that lazily fetches from RPCStorageCache- SQLite-based persistent cache for storage values
§Runtime Execution
RuntimeExecutor- Executes Polkadot SDK runtime calls against forked stateForkRpcClient- RPC client for connecting to live chains
§Transaction Pool
TxPool- Minimal FIFO queue for pending extrinsics
Re-exports§
pub use error::BlockBuilderError;pub use error::BlockError;pub use error::CacheError;pub use error::ExecutorError;pub use error::LocalStorageError;pub use error::RemoteStorageError;pub use error::RpcClientError;pub use error::TxPoolError;pub use executor::ExecutorConfig;pub use executor::RuntimeCallResult;pub use executor::RuntimeExecutor;pub use executor::RuntimeLog;pub use executor::RuntimeVersion;pub use executor::SignatureMockMode;pub use inherent::InherentProvider;pub use inherent::ParachainInherent;pub use inherent::TimestampInherent;pub use inherent::default_providers;
Modules§
- consensus_
engine - Well-known consensus engine identifiers.
- dev
- Dev account utilities for forked chains.
- error
- Error types for fork operations.
- executor
- Runtime executor using smoldot to execute Substrate runtime calls.
- inherent
- Inherent extrinsic providers for block building.
- rpc_
server - JSON-RPC server for forked blockchain.
Structs§
- Block
- A block in a forked blockchain.
- Block
Builder - Builder for constructing new blocks on a forked chain.
- Block
Row - Block row for query results (uses owned data).
- Blockchain
- The blockchain manager for a forked chain.
- Build
Block Result - Result of building a block, including information about extrinsic processing.
- Failed
Extrinsic - An extrinsic that failed during block building.
- Fork
RpcClient - RPC client wrapper for fork operations.
- Local
Storage Layer - Local storage layer that tracks modifications on top of a remote layer.
- Prefix
Scan Progress - Progress information for a prefix scan operation.
- Remote
Storage Layer - Remote storage layer that lazily fetches state from a live chain.
- Storage
Cache - SQLite-backed persistent cache for storage values.
- TxPool
- A minimal transaction pool that stores pending extrinsics.
- Valid
Transaction - Information about a valid transaction.
Enums§
- Apply
Extrinsic Result - Result of applying an extrinsic to the block.
- Block
Fork Point - Handy type to allow specifying both number and hash as the fork point.
- Blockchain
Error - Errors that can occur when working with the blockchain manager.
- Blockchain
Event - Events emitted by the blockchain when state changes.
- Chain
Type - Type of chain being forked.
- Digest
Item - Digest item for block headers.
- Invalid
Transaction - Reasons a transaction is invalid.
- Transaction
Validity - Result of transaction validation.
- Transaction
Validity Error - Error when transaction validation fails.
- Unknown
Transaction - Reasons transaction validity is unknown.
Functions§
- create_
next_ header - Create a header for the next block.
- create_
next_ header_ with_ slot - Create a header for the next block with automatic slot digest injection.
Type Aliases§
- Consensus
Engine Id - Consensus engine identifier (4-byte ASCII).