Skip to content

Conversation

@dimartiro
Copy link

Motivation

Add initial forking support by introducing a lazy-loading backend that retrieves state from the forked chain on demand.

Solution

Replace Substrate’s default backend with the new ForkedLazyBackend, which is composed of:

1. ForkedLazyBackend

  • Core backend implementing the sp_state_machine::Backend trait
  • Lazily fetches storage values from the forked network via RPC
  • Maintains an in-memory cache (db) of previously accessed state
  • Tracks removed keys to prevent unnecessary remote fetches

2. RPCClient

  • Abstraction layer for RPC communication with the forked network
  • Provides methods to fetch blocks, headers, storage values, storage hashes, and paginated keys

3. Blockchain

  • In-memory blockchain storage for cached blocks and headers
  • Lazily loads block data via RPC when not available locally
  • Maintains fork metadata (best block, finalized block, leaves)

4. RawIter

  • Custom storage iterator that merges local and remote state
  • Iterates over storage keys by checking the local cache first, then falling back to RPC
  • Respects prefix filters and removed keys during iteration

Note: Basic tests were also added to verify the lazy-loading behavior.


Closes: ChainSafe/gossamer-parity#59, ChainSafe/gossamer-parity#61, ChainSafe/gossamer-parity#62, ChainSafe/gossamer-parity#63, ChainSafe/gossamer-parity#65

dimartiro and others added 3 commits November 3, 2025 13:06
* fix fuzzer

Signed-off-by: Alexandru Gheorghe <[email protected]>

* update snapshots as temporary solution

* make the CI runs a bit more stable

Signed-off-by: Alexandru Gheorghe <[email protected]>

---------

Signed-off-by: Alexandru Gheorghe <[email protected]>
Co-authored-by: Pavlo Khrystenko <[email protected]>
@timwu20
Copy link

timwu20 commented Nov 4, 2025

Can you fix the CI checks?

alexggh and others added 4 commits November 4, 2025 17:14
* implement tx_pool inspect

* add txpool_inspect RPC test

* implement txpool_content

* add txpool_content RPC test

* implement remove_pool_transactions

* add remove_pool_transactions RPC test

* Implements sender recovery logic for impersonated transactions in txpool

* add impersonation support test for txpool RPCs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants