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
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b131fcd
feat: implement lazy loading backend and call executor
RomarQ Jun 7, 2024
b29ee2b
code cleanup
RomarQ Jul 25, 2024
c060274
add lazy loading chain spec
RomarQ Aug 8, 2024
6d43cbf
feat(lazy-loading): replace async-std with tokio and retry failed req…
RomarQ Aug 8, 2024
75d6e1e
remove local polkadot-sdk dependencies
RomarQ Aug 22, 2024
6a9351d
fix Cargo.toml
RomarQ Aug 22, 2024
5673065
chore: update Cargo.lock file
RomarQ Aug 22, 2024
7b7f631
fix editor config errors
RomarQ Aug 22, 2024
7a77822
Merge branch 'master' into rq/lazy-loading
RomarQ Aug 22, 2024
cf3c58b
fix editor config errors
RomarQ Aug 22, 2024
5d4e01d
fix build
RomarQ Aug 22, 2024
14d3ba5
fix lazy-loading feature
RomarQ Aug 23, 2024
ee041a9
Merge branch 'master' into rq/lazy-loading
RomarQ Aug 27, 2024
859d383
cleanup
RomarQ Aug 31, 2024
a40966c
reset AsyncBacking > SlotInfo
RomarQ Sep 1, 2024
7840884
test: add lazy loading tests
RomarQ Sep 1, 2024
c6a3e65
remove parent field
RomarQ Sep 1, 2024
d6609ac
remove files
RomarQ Sep 1, 2024
b1a4728
test: fix formatting
RomarQ Sep 1, 2024
d48bb89
fix(ci): lazy loading test
RomarQ Sep 1, 2024
e3a83af
fix test
RomarQ Sep 2, 2024
43e2b2f
fix format
RomarQ Sep 2, 2024
f18d93d
Merge branch 'master' into rq/lazy-loading
RomarQ Sep 2, 2024
7e8d7d4
test: move lazy loading state overrides to configs folder
RomarQ Sep 2, 2024
e9ecf17
fix build and add mandatory storage override
RomarQ Sep 2, 2024
38da6e8
fix pipeline
RomarQ Sep 2, 2024
0605a69
add state overrides for dev accounts
RomarQ Sep 2, 2024
67f51c2
fix build
RomarQ Sep 2, 2024
92445c0
Merge branch 'master' into rq/lazy-loading
RomarQ Sep 5, 2024
6c7bd5f
remove redundant test
RomarQ Sep 10, 2024
3c677e2
fix remark from review
RomarQ Sep 11, 2024
8953ef4
improve lazy loading test
RomarQ Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflow-templates/cargo-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ runs:
params="$params --features ${{ inputs.features }}"
fi
echo "cargo build $params"
cargo build $params --features lazy-loading
pLabarta marked this conversation as resolved.
Show resolved Hide resolved
cp target/release/moonbeam target/release/lazy-loading
cargo build $params
- name: Display binary comments
shell: bash
Expand All @@ -74,3 +76,4 @@ runs:
run: |
mkdir -p build
cp target/release/moonbeam build/moonbeam;
cp target/release/lazy-loading build/lazy-loading;
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,63 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}

lazy-loading-tests:
runs-on:
labels: bare-metal
needs: ["set-tags", "build"]
strategy:
fail-fast: false
matrix:
chain: ["moonbeam"]
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain }}
DEBUG_COLORS: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20.10.0
- name: Create local folders
run: |
mkdir -p target/release/wbuild/${{ matrix.chain }}-runtime/
mkdir -p test/tmp
- name: "Download branch built runtime"
uses: actions/download-artifact@v4
with:
name: runtimes
path: target/release/wbuild/${{ matrix.chain }}-runtime/
- name: "Download branch built node"
uses: actions/download-artifact@v4
with:
name: moonbeam
path: target/release
- name: "Run lazy loading tests"
run: |
cd test
pnpm install
chmod uog+x ../target/release/lazy-loading
pnpm moonwall test lazy_loading_${{ matrix.chain }}
- name: Zip and Upload Node Logs on Failure
if: failure()
run: |
TIMESTAMP=$(date +%Y%m%d%H%M%S)
export NODE_LOGS_ZIP="node_logs_$TIMESTAMP.zip"
MOST_RECENT_ZOMBIE_DIR=$(ls -td /tmp/zombie-* | head -n 1)
find $MOST_RECENT_ZOMBIE_DIR -maxdepth 1 -type f -name '*.log' -exec zip -r $NODE_LOGS_ZIP {} \;
echo "NODE_LOGS_ZIP=${NODE_LOGS_ZIP}" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-node-logs
path: ${{ env.NODE_LOGS_ZIP }}

chopsticks-upgrade-test:
runs-on:
labels: bare-metal
Expand Down
71 changes: 64 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ sp-consensus = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", br
sp-storage = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
sp-timestamp = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
sp-wasm-interface = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
sp-rpc = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-build-script-utils = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-frame-rpc-system = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-prometheus-endpoint = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-test-client = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-test-runtime = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-test-runtime-client = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-wasm-builder = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
substrate-rpc-client = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }

# Frontier (wasm)

Expand Down Expand Up @@ -404,10 +406,12 @@ schnorrkel = { version = "0.11.4", default-features = false, features = [
"preaudit_deprecated",
] }
tokio = { version = "1.36" }
tokio-retry = { version = "0.3.0" }
tracing = "0.1.34"
tracing-core = "0.1.29"
trie-root = "0.15.2"
url = "2.2.2"
thiserror = "1.0.63"

# The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
Expand Down Expand Up @@ -493,4 +497,4 @@ inherits = "release"
overflow-checks = true

[patch."https://github.com/paritytech/polkadot-sdk"]
sp-crypto-ec-utils = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
sp-crypto-ec-utils = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0" }
2 changes: 2 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ moonriver-native = [ "moonbeam-cli/moonriver-native", "moonbeam-service/moonrive

metadata-hash = ["moonbeam-service/metadata-hash"]

lazy-loading = ["moonbeam-service/lazy-loading", "moonbeam-cli/lazy-loading"]

test-spec = []

runtime-benchmarks = [
Expand Down
10 changes: 10 additions & 0 deletions node/cli-opt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use std::path::PathBuf;
// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
use primitive_types::H256;
use std::str::FromStr;

pub mod account_key;
Expand Down Expand Up @@ -110,3 +112,11 @@ pub struct RpcConfig {
pub frontier_backend_config: FrontierBackendConfig,
pub no_prometheus_prefix: bool,
}

#[derive(Clone)]
pub struct LazyLoadingConfig {
pub state_rpc: String,
pub from_block: Option<H256>,
pub state_overrides_path: Option<PathBuf>,
pub runtime_override: Option<PathBuf>,
}
2 changes: 2 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ default = [
"westend-native",
]

lazy-loading = ["sc-service/test-helpers", "moonbeam-service/lazy-loading"]

westend-native = ["polkadot-service/westend-native"]

moonbase-native = ["moonbeam-service/moonbase-native", "westend-native"]
Expand Down
22 changes: 22 additions & 0 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ use sc_cli::{Error as CliError, SubstrateCli};
use std::path::PathBuf;
use std::time::Duration;

#[cfg(feature = "lazy-loading")]
fn parse_block_hash(s: &str) -> Result<sp_core::H256, String> {
use std::str::FromStr;
sp_core::H256::from_str(s).map_err(|err| err.to_string())
}

/// Sub-commands supported by the collator.
#[derive(Debug, clap::Subcommand)]
pub enum Subcommand {
Expand Down Expand Up @@ -136,6 +142,22 @@ pub struct RunCmd {
#[clap(long)]
pub dev_service: bool,

#[cfg(feature = "lazy-loading")]
#[clap(long)]
pub fork_chain_from_rpc: Option<String>,

#[cfg(feature = "lazy-loading")]
#[arg(long, value_name = "BLOCK", value_parser = parse_block_hash)]
pub block: Option<sp_core::H256>,

#[cfg(feature = "lazy-loading")]
#[clap(long, value_name = "PATH", value_parser)]
pub fork_state_overrides: Option<PathBuf>,

#[cfg(feature = "lazy-loading")]
#[clap(long, value_name = "PATH", value_parser)]
pub runtime_override: Option<PathBuf>,

/// When blocks should be sealed in the dev service.
///
/// Options are "instant", "manual", or timer interval in milliseconds
Expand Down
Loading
Loading