mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Add try-runtime to Rococo runtime (#6501)
* Add `try-runtime` to Rococo runtime * Enable try-runtime in all pallets * Update runtime/rococo/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add dev-dependencies for the try-runtime test Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
committed by
GitHub
parent
1a25f8125f
commit
87ef83684b
@@ -1926,6 +1926,26 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
|
||||
log::info!("try-runtime::on_runtime_upgrade rococo.");
|
||||
let weight = Executive::try_runtime_upgrade(checks).unwrap();
|
||||
(weight, BlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn benchmark_metadata(extra: bool) -> (
|
||||
@@ -2047,3 +2067,38 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, feature = "try-runtime"))]
|
||||
mod remote_tests {
|
||||
use super::*;
|
||||
use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime;
|
||||
use remote_externalities::{
|
||||
Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport,
|
||||
};
|
||||
use std::env::var;
|
||||
|
||||
#[tokio::test]
|
||||
async fn run_migrations() {
|
||||
sp_tracing::try_init_simple();
|
||||
let transport: Transport =
|
||||
var("WS").unwrap_or("wss://rococo-rpc.polkadot.io:443".to_string()).into();
|
||||
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
|
||||
let mut ext = Builder::<Block>::default()
|
||||
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
|
||||
Mode::OfflineOrElseOnline(
|
||||
OfflineConfig { state_snapshot: state_snapshot.clone() },
|
||||
OnlineConfig {
|
||||
transport,
|
||||
state_snapshot: Some(state_snapshot),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
} else {
|
||||
Mode::Online(OnlineConfig { transport, ..Default::default() })
|
||||
})
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
ext.execute_with(|| Runtime::on_runtime_upgrade(true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user