Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17,982 changes: 11,215 additions & 6,767 deletions Cargo.lock

Large diffs are not rendered by default.

101 changes: 53 additions & 48 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"
members = ["cli", "core"]

[workspace.package]
version = "0.8.0"
version = "0.9.0"
authors = ["Parity Technologies <[email protected]>"]
description = "Substrate's programmatic testing framework."
edition = "2021"
Expand All @@ -13,60 +13,65 @@ homepage = "https://github.com/paritytech/try-runtime-cli"
repository = "https://github.com/paritytech/try-runtime-cli/"

[workspace.dependencies]
array-bytes = { version = "6.2.3" }
assert_cmd = { version = "2.0.16" }
async-trait = { version = "0.1.83" }
bytesize = { version = "1.3.0" }
clap = { version = "4.5.18" }
env_logger = { version = "0.11.5" }
# This means >=9.3.0, <9.4.0
array-bytes = { version = "~9.3" }
assert_cmd = { version = "~2.1" }
async-trait = { version = "~0.1" }
bytesize = { version = "~2.3" }
clap = { version = "~4.5" }
env_logger = { version = "~0.11" }
hex = { version = "0.4.3", default-features = false }
itertools = { version = "0.13.0" }
log = { version = "0.4.22" }
parity-scale-codec = { version = "3.6.12" }
regex = { version = "1.11.0" }
serde = { version = "1.0.210" }
serde_json = { version = "1.0.128" }
strum = "0.26"
strum_macros = "0.26"
tempfile = { version = "3.13.0" }
tokio = { version = "1.44.2" }
zstd = { version = "0.13.2", default-features = false }
itertools = { version = "~0.14" }
log = { version = "~0.4.29" }
parity-scale-codec = { version = "~3.7" }
regex = { version = "~1.12" }
serde = { version = "~1.0" }
serde_json = { version = "~1.0" }
strum = "~0.27"
strum_macros = "~0.27"
tempfile = { version = "~3.24" }
tokio = { version = "~1.49" }
zstd = { version = "~0.13", default-features = false }

# Integration test-only dependency.
# Across the whole workspace, it is used solely as a dev dependency; thus it may be pinned to a git revision
# without impacting publication to crates.io .
substrate-cli-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", rev = "1b9a876861ac022c5d00f0a4d18b5343b0039bb5" }

# Polkadot SDK
frame-remote-externalities = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
frame-remote-externalities = { version = "0.56.0" }
frame-try-runtime = { version = "0.51.0" }
frame-support = { version = "45.0.0" }
frame-system = { version = "45.0.0" }

sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sc-service = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sc-cli = { version = "0.57.0" }
sc-executor = { version = "0.47.0" }
sc-service = { version = "0.56.0" }

sp-api = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-externalities = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-rpc = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-storage = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-transaction-storage-proof = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-version = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
sp-api = { version = "40.0.0" }
sp-consensus-aura = { version = "0.46.0" }
sp-consensus-babe = { version = "0.46.0" }
sp-core = { version = "39.0.0" }
sp-externalities = { version = "0.31.0" }
sp-inherents = { version = "40.0.0" }
sp-io = { version = "44.0.0" }
sp-keystore = { version = "0.45.0" }
sp-rpc = { version = "37.0.0" }
sp-runtime = { version = "45.0.0" }
sp-state-machine = { version = "0.49.0" }
sp-storage = { version = "22.0.0" }
sp-std = { version = "14.0.0" }
sp-timestamp = { version = "40.0.0" }
sp-transaction-storage-proof = { version = "40.0.0" }
sp-version = { version = "43.0.0" }
sp-weights = { version = "33.2.0" }

substrate-cli-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
substrate-rpc-client = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
substrate-rpc-client = { version = "0.54.0" }

polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
cumulus-client-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", rev = "8279d1046cca51a317dec15df5a9b29240545163" }
polkadot-primitives = { version = "22.0.0" }
cumulus-primitives-parachain-inherent = { version = "0.22.0" }
cumulus-primitives-core = { version = "0.22.0" }
cumulus-client-parachain-inherent = { version = "0.22.0" }

# Local
try-runtime-core = { path = "core" }
8 changes: 8 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ sp-storage = { workspace = true }
try-runtime-core = { workspace = true }

frame-support = { workspace = true }

[dev-dependencies]
# Only needed in tests
assert_cmd = { workspace = true }
frame-remote-externalities = { workspace = true }
regex = { workspace = true }
substrate-cli-test-utils = { workspace = true, features = ["try-runtime"] }
tempfile = { workspace = true }
10 changes: 7 additions & 3 deletions core/tests/create_snapshot.rs → cli/tests/create_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
time::Duration,
};

use assert_cmd::cargo::cargo_bin;
use assert_cmd::cargo_bin;
use frame_remote_externalities::{Builder, Mode, OfflineConfig, SnapshotConfig};
use sp_runtime::{
generic::{Block, Header},
Expand All @@ -42,7 +42,11 @@ async fn create_snapshot_works() {
match common::start_node_inline(vec![
"--no-hardware-benchmarks",
"--dev",
"--tmp",
format!("--rpc-port={}", port).as_str(),
"--no-telemetry",
"--no-prometheus",
"--rpc-max-response-size=1000", // Allow large RPC responses for snapshot creation
]) {
Ok(_) => {}
Err(e) => {
Expand All @@ -51,7 +55,7 @@ async fn create_snapshot_works() {
}
});
// Wait some time to ensure the node is warmed up.
std::thread::sleep(Duration::from_secs(90));
std::thread::sleep(Duration::from_secs(180));

// Run the command with tokio
let temp_dir = tempfile::Builder::new()
Expand All @@ -66,7 +70,7 @@ async fn create_snapshot_works() {
snap_file: &PathBuf,
at: sp_core::H256,
) -> tokio::process::Child {
Command::new(cargo_bin("try-runtime"))
Command::new(cargo_bin!("try-runtime"))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.arg("--runtime=existing")
Expand Down
12 changes: 8 additions & 4 deletions core/tests/execute_block.rs → cli/tests/execute_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use std::time::Duration;

use assert_cmd::cargo::cargo_bin;
use assert_cmd::cargo_bin;
use regex::Regex;
use substrate_cli_test_utils as common;
use tokio::process::Command;
Expand All @@ -33,7 +33,11 @@ async fn execute_block_works() {
match common::start_node_inline(vec![
"--no-hardware-benchmarks",
"--dev",
"--tmp",
format!("--rpc-port={}", port).as_str(),
"--no-telemetry",
"--no-prometheus",
"--rpc-max-response-size=1000", // Allow large RPC responses
]) {
Ok(_) => {}
Err(e) => {
Expand All @@ -42,14 +46,14 @@ async fn execute_block_works() {
}
});
// Wait some time to ensure the node is warmed up.
std::thread::sleep(Duration::from_secs(90));
std::thread::sleep(Duration::from_secs(180));

// Test passing --at
common::run_with_timeout(Duration::from_secs(60), async move {
let ws_url = format!("ws://localhost:{}", port);

fn execute_block(ws_url: &str, at: sp_core::H256) -> tokio::process::Child {
Command::new(cargo_bin("try-runtime"))
Command::new(cargo_bin!("try-runtime"))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.arg("--runtime=existing")
Expand Down Expand Up @@ -91,7 +95,7 @@ async fn execute_block_works() {
let ws_url = format!("ws://localhost:{}", port);

fn execute_block(ws_url: &str) -> tokio::process::Child {
Command::new(cargo_bin("try-runtime"))
Command::new(cargo_bin!("try-runtime"))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.arg("--runtime=existing")
Expand Down
9 changes: 6 additions & 3 deletions core/tests/follow_chain.rs → cli/tests/follow_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use std::time::Duration;

use assert_cmd::cargo::cargo_bin;
use assert_cmd::cargo_bin;
use regex::Regex;
use substrate_cli_test_utils as common;
use tokio::process::Command;
Expand All @@ -35,6 +35,9 @@ async fn follow_chain_works() {
"--no-hardware-benchmarks",
"--dev",
format!("--rpc-port={}", port).as_str(),
"--no-telemetry",
"--no-prometheus",
"--rpc-max-response-size=1000", // Allow large RPC responses for snapshot creation
]) {
Ok(_) => {}
Err(e) => {
Expand All @@ -43,11 +46,11 @@ async fn follow_chain_works() {
}
});
// Wait some time to ensure the node is warmed up.
std::thread::sleep(Duration::from_secs(90));
std::thread::sleep(Duration::from_secs(180));

common::run_with_timeout(Duration::from_secs(60), async move {
fn start_follow(ws_url: &str) -> tokio::process::Child {
Command::new(cargo_bin("try-runtime"))
Command::new(cargo_bin!("try-runtime"))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.arg("--runtime=existing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod on_runtime_upgrade {
use std::{path::PathBuf, time::Duration};

use assert_cmd::cargo::cargo_bin;
use assert_cmd::cargo_bin;
use substrate_cli_test_utils as common;
use tokio::process::Command;

Expand Down Expand Up @@ -40,7 +40,7 @@ mod on_runtime_upgrade {
}

async fn run_test(config: TestConfig, expected_success: bool) {
common::run_with_timeout(Duration::from_secs(300), async move {
common::run_with_timeout(Duration::from_secs(600), async move {
let child = on_runtime_upgrade(&config);
let out = child.wait_with_output().await.unwrap();
if expected_success {
Expand All @@ -53,7 +53,7 @@ mod on_runtime_upgrade {
}

fn on_runtime_upgrade(config: &TestConfig) -> tokio::process::Child {
let path = cargo_bin("try-runtime");
let path = cargo_bin!("try-runtime");
assert!(
path.exists(),
"try-runtime binary not found at path: {}",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 1 addition & 9 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,4 @@ cumulus-client-parachain-inherent = { workspace = true }

substrate-rpc-client = { workspace = true }
paris = "1.5.15"
similar-asserts = "1.6.0"

[dev-dependencies]
assert_cmd = { workspace = true }
regex = { workspace = true }
tempfile = { workspace = true }

sc-service = { workspace = true }
substrate-cli-test-utils = { workspace = true, features = ["try-runtime"] }
similar-asserts = "1.7.0"
3 changes: 3 additions & 0 deletions core/src/commands/on_runtime_upgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ where
/// Check that the migrations are idempotent.
///
/// Expects the overlayed changes from the first execution of the migrations.
#[allow(clippy::result_large_err)]
fn check_idempotency(
&self,
ext: &mut RemoteExternalities<Block>,
Expand Down Expand Up @@ -252,6 +253,7 @@ where
}

/// Check that the migrations don't use more weights than a block.
#[allow(clippy::result_large_err)]
fn check_weight(&self, ext: &RemoteExternalities<Block>) -> sc_cli::Result<bool> {
if self.command.no_weight_warnings {
log::info!("ℹ Skipping weight safety check");
Expand Down Expand Up @@ -300,6 +302,7 @@ where
}

/// Whether any storage was changed.
#[allow(clippy::result_large_err)]
fn changed(
&self,
ext: &RemoteExternalities<Block>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use std::{ops::DerefMut, sync::Arc};

use cumulus_primitives_core::relay_chain::UpgradeGoAhead;
use parity_scale_codec::{Decode, Encode};
use polkadot_primitives::{BlockNumber, HeadData};
use sp_consensus_babe::SlotDuration;
Expand Down Expand Up @@ -57,6 +58,17 @@ pub fn get_last_relay_chain_block_number<B: BlockT>(
})
}

/// Check if `PendingValidationCode` is set in storage.
pub fn has_pending_validation_code<B: BlockT>(ext: &mut TestExternalities<HashingFor<B>>) -> bool {
let pending_validation_code_key = [
twox_128(b"ParachainSystem"),
twox_128(b"PendingValidationCode"),
]
.concat();

ext.execute_with(|| sp_io::storage::exists(&pending_validation_code_key))
}

/// Provides parachain-system pallet inherents.
pub struct InherentDataProvider<B: BlockT> {
pub timestamp: sp_timestamp::Timestamp,
Expand Down Expand Up @@ -107,6 +119,16 @@ impl<B: BlockT> sp_inherents::InherentDataProvider for InherentDataProvider<B> {
),
];

// Check if `PendingValidationCode` exists in storage before setting `GoAhead`.
// The parachain-system pallet panics if `GoAhead` is provided without a pending validation
// code. See: https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/pallets/parachain-system/src/lib.rs#L667
let has_pending = has_pending_validation_code::<B>(ext);
let upgrade_go_ahead = if has_pending {
Some(UpgradeGoAhead::GoAhead)
} else {
None
};

cumulus_client_parachain_inherent::MockValidationDataInherentDataProvider {
current_para_block: Default::default(),
current_para_block_head: Default::default(),
Expand All @@ -119,6 +141,7 @@ impl<B: BlockT> sp_inherents::InherentDataProvider for InherentDataProvider<B> {
raw_horizontal_messages: Default::default(),
additional_key_values: Some(additional_key_values),
para_id: para_id.into(),
upgrade_go_ahead,
}
.provide_inherent_data(inherent_data)
.await
Expand Down
2 changes: 2 additions & 0 deletions core/src/common/empty_block/production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ async fn call<T: Decode, Block: BlockT, HostFns: HostFunctions>(
T::decode(&mut &*result).map_err(|e| sc_cli::Error::Input(format!("{:?}", e)))
}

#[allow(clippy::result_large_err)]
pub fn core_version<Block: BlockT, HostFns: HostFunctions>(
externalities: &TestExternalities<HashingFor<Block>>,
executor: &WasmExecutor<HostFns>,
) -> Result<u32> {
dry_call::<u32, Block, HostFns>(externalities, executor, "Core_version", &[])
}

#[allow(clippy::result_large_err)]
/// Call `method` with `data` and return the result. `externalities` will not change.
fn dry_call<T: Decode, Block: BlockT, HostFns: HostFunctions>(
externalities: &TestExternalities<HashingFor<Block>>,
Expand Down
Loading
Loading