companion for try-runtime revamp (#6187)

* update to reflect latest try-runtime stuff

* update to latest version

* fix

* fix miner

* update

* update

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Kian Paimani
2022-12-15 09:10:16 +00:00
committed by GitHub
parent 193c8de9db
commit a3c81fe2a9
7 changed files with 246 additions and 232 deletions
+193 -184
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -26,6 +26,7 @@ polkadot-node-core-pvf = { path = "../node/core/pvf", optional = true }
polkadot-performance-test = { path = "../node/test/performance-test", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
@@ -34,6 +35,7 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
polkadot-node-metrics = { path = "../node/metrics" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
+11 -9
View File
@@ -638,9 +638,14 @@ pub fn run() -> Result<()> {
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
>;
use sc_service::TaskManager;
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
@@ -651,10 +656,9 @@ pub fn run() -> Result<()> {
#[cfg(feature = "kusama-native")]
if chain_spec.is_kusama() {
return runner.async_run(|config| {
return runner.async_run(|_| {
Ok((
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutorDispatch>(
config,
cmd.run::<service::kusama_runtime::Block, HostFunctionsOf<service::KusamaExecutorDispatch>>(
)
.map_err(Error::SubstrateCli),
task_manager,
@@ -664,10 +668,9 @@ pub fn run() -> Result<()> {
#[cfg(feature = "westend-native")]
if chain_spec.is_westend() {
return runner.async_run(|config| {
return runner.async_run(|_| {
Ok((
cmd.run::<service::westend_runtime::Block, service::WestendExecutorDispatch>(
config,
cmd.run::<service::westend_runtime::Block, HostFunctionsOf<service::WestendExecutorDispatch>>(
)
.map_err(Error::SubstrateCli),
task_manager,
@@ -677,10 +680,9 @@ pub fn run() -> Result<()> {
// else we assume it is polkadot.
#[cfg(feature = "polkadot-native")]
{
return runner.async_run(|config| {
return runner.async_run(|_| {
Ok((
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutorDispatch>(
config,
cmd.run::<service::polkadot_runtime::Block, HostFunctionsOf<service::PolkadotExecutorDispatch>>(
)
.map_err(Error::SubstrateCli),
task_manager,
+12 -12
View File
@@ -1913,21 +1913,21 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade kusama.");
let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::kusama", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
@@ -2233,6 +2233,6 @@ mod remote_tests {
.build()
.await
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade());
ext.execute_with(|| Runtime::on_runtime_upgrade(true));
}
}
+12 -12
View File
@@ -2015,21 +2015,21 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade polkadot.");
let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
@@ -2441,6 +2441,6 @@ mod remote_tests {
.build()
.await
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade());
ext.execute_with(|| Runtime::on_runtime_upgrade(true));
}
}
+12 -12
View File
@@ -1630,21 +1630,21 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade westend.");
let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::westend", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
@@ -1832,6 +1832,6 @@ mod remote_tests {
.build()
.await
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade());
ext.execute_with(|| Runtime::on_runtime_upgrade(true));
}
}
+4 -3
View File
@@ -302,7 +302,7 @@ async fn create_election_ext<T, B>(
) -> Result<Ext, Error<T>>
where
T: EPM::Config,
B: BlockT,
B: BlockT + DeserializeOwned,
B::Header: DeserializeOwned,
{
use frame_support::{storage::generator::StorageMap, traits::PalletInfo};
@@ -317,13 +317,14 @@ where
transport: client.into_inner().into(),
at,
pallets,
hashed_prefixes: vec![<frame_system::BlockHash<T>>::prefix_hash()],
hashed_keys: vec![[twox_128(b"System"), twox_128(b"Number")].concat()],
..Default::default()
}))
.inject_hashed_prefix(&<frame_system::BlockHash<T>>::prefix_hash())
.inject_hashed_key(&[twox_128(b"System"), twox_128(b"Number")].concat())
.build()
.await
.map_err(|why| Error::RemoteExternalities(why))
.map(|rx| rx.inner_ext)
}
/// Compute the election. It expects to NOT be `Phase::Off`. In other words, the snapshot must