1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// SPDX-License-Identifier: GPL-3.0
//! 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
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ 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
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use LocalStorageLayer;
pub use BlockRow;
pub use RemoteStorageLayer;
pub use ForkRpcClient;
pub use TxPool;