Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy loading #2840

Merged
merged 32 commits into from
Sep 11, 2024
Merged

Lazy loading #2840

merged 32 commits into from
Sep 11, 2024

Conversation

RomarQ
Copy link
Contributor

@RomarQ RomarQ commented Jun 7, 2024

What does it do?

The objective of this PR is to provide a solution for allowing lazy downloading of the state of a live network instead of requiring its state to be downloaded in advance, which may take a long time for chains that have been running for a few years.

What important points reviewers should know?

Building with lazy-loading features enabled:

cargo build --features lazy-loading

New parameters:

--fork-chain-from-rpc <CHAIN_RPC> # Mandatory
--block <BLOCK_FROM_WHICH_TO_START_THE_FORK> # Optional
--fork-state-overrides <STATE_OVERRIDES_JSON_FILE> # Optional 
--runtime-override <WASM_FILE> # Optional 

Example state overrides files:

[
 {
     "pallet": "System",
     "storage": "SelectedCandidates",
     "value": "0x04f24ff3a9cf04c71dbc94d0b566f7a27b94566cac"
 }
]

Running lazy loading:

./target/debug/moonbeam \
--fork-chain-from-rpc https://moonbeam.unitedbloc.com/ \
--fork-state-overrides state_overrides.json  \
--alice \
--no-grandpa \
--reserved-only \
--sealing 6000 \
--unsafe-rpc-external \
--rpc-external \
--rpc-cors all \
--rpc-methods Unsafe \
--force-authoring \
--unsafe-force-node-key-generation

Is there something left for follow-up PRs?

  • Add documentation on how to use the lazy loading feature;
  • Add lazy loading tests against Moonbeam and Moonriver (done for moonbeam)

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

This feature enables testing of client code against live chains, which is not possible with Chopsticks. Allowing testing both the client and runtime simultaneously, we can thoroughly verify client-specific components, such as RPCs.

@RomarQ RomarQ added the B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes label Jun 7, 2024
@RomarQ RomarQ added the dependencies Pull requests that update a dependency file label Jul 18, 2024
@RomarQ RomarQ self-assigned this Jul 18, 2024
@RomarQ RomarQ added the not-breaking Does not need to be mentioned in breaking changes label Aug 22, 2024
@RomarQ RomarQ added the D2-notlive PR doesn't change runtime code (so can't be audited) label Aug 22, 2024
Copy link
Contributor

github-actions bot commented Aug 22, 2024

Coverage Report

@@                 Coverage Diff                 @@
##           master   rq/lazy-loading      +/-   ##
===================================================
- Coverage   80.93%            78.65%   -2.28%     
+ Files         286               294       +8     
+ Lines       81965             84225    +2260     
===================================================
- Hits        66331             66244      -87     
+ Misses      15634             17981    +2347     
Files Changed Coverage
/client/evm-tracing/src/listeners/call_list.rs 72.55% (-4.84%) 🔽
/client/rpc/finality/src/lib.rs 88.14% (+6.89%) 🔼
/node/cli/src/cli.rs 33.33% (-1.73%) 🔽
/node/cli/src/command.rs 23.13% (+3.90%) 🔼
/node/service/src/lib.rs 61.96% (+0.06%) 🔼
/precompiles/proxy/src/tests.rs 96.68% (-0.09%) 🔽

Coverage generated Wed Sep 11 10:45:02 UTC 2024

Copy link
Contributor

github-actions bot commented Aug 27, 2024

WASM runtime size check:

Compared to target branch

Moonbase runtime: 2188 KB (no changes) ✅

Moonbeam runtime: 2120 KB (no changes) ✅

Moonriver runtime: 2128 KB (no changes) ✅

Compared to latest release (runtime-3102)

Moonbase runtime: 2188 KB (+248 KB compared to latest release) ⚠️

Moonbeam runtime: 2120 KB (+220 KB compared to latest release) ⚠️

Moonriver runtime: 2128 KB (+228 KB compared to latest release) ⚠️

@RomarQ RomarQ marked this pull request as ready for review September 2, 2024 08:45
@RomarQ RomarQ requested review from a team as code owners September 2, 2024 08:45
@noandrea noandrea added the A8-mergeoncegreen Pull request is reviewed well. label Sep 5, 2024
Copy link
Contributor

@pLabarta pLabarta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good to me. It mostly needs some documentation on the new feature and the tradeoffs of using this particular client for tests, but I know its coming in a future PR.

Also could use a script for setting up the binary as the test suite expects when running it locally. Wrote this one:

#!/bin/bash

# Build lazy-loading client
echo '😴 Building lazy-loading client...'
cargo build --release --features lazy-loading

# Rename
echo '✍️ Renaming lazy-loading client...'
mv target/release/moonbeam target/release/lazy-loading

echo '✅ Lazy loading client ready!'

node/service/src/lazy_loading/state_overrides.rs Outdated Show resolved Hide resolved
node/cli/src/command.rs Outdated Show resolved Hide resolved
test/suites/lazy-loading/test-runtime-upgrade.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@gonzamontiel gonzamontiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good, great changes 💯
Maybe we can add this parameter to the description of the PR because it might be needed for testing (I had to add it) —unsafe-force-node-key-generation.

There's a lot of code implementing the substrate client api, I compared to the in_mem.rs to see the actual changes. I paid more attention to backend.rs and call_executor.rs. It looks good to me!

@RomarQ
Copy link
Contributor Author

RomarQ commented Sep 11, 2024

The PR looks good, great changes 💯 Maybe we can add this parameter to the description of the PR because it might be needed for testing (I had to add it) —unsafe-force-node-key-generation.

There's a lot of code implementing the substrate client api, I compared to the in_mem.rs to see the actual changes. I paid more attention to backend.rs and call_executor.rs. It looks good to me!

Improved the PR description 👍

@noandrea noandrea dismissed pLabarta’s stale review September 11, 2024 10:52

changes implemented

@noandrea noandrea merged commit 30e29c4 into master Sep 11, 2024
43 checks passed
@noandrea noandrea deleted the rq/lazy-loading branch September 11, 2024 10:52
@RomarQ RomarQ added the lazy-loading These changes affect the lazy loading feature label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A8-mergeoncegreen Pull request is reviewed well. B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes D2-notlive PR doesn't change runtime code (so can't be audited) dependencies Pull requests that update a dependency file lazy-loading These changes affect the lazy loading feature not-breaking Does not need to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants