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

SYS-4125 Fix try runtime compilation error #423

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
36 changes: 18 additions & 18 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lto = "fat"
codegen-units = 1

[workspace.package]
version = "5.4.1"
version = "5.4.2"
authors = ["Aventus systems team"]
homepage = "https://www.aventus.io/"
repository = "https://github.com/Aventus-Network-Services/avn-node-parachain/"
Expand Down
38 changes: 23 additions & 15 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,30 @@ pub fn run() -> Result<()> {
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;

//Err("try-runtime is deprecated. Use the CLI".into())
use crate::common::AvnParachainExecutor;
use avn_parachain_runtime::SLOT_DURATION;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
>;

// grab the task manager.
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
.map_err(|e| format!("Error: {:?}", e))?;

runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<ParachainExecutor>>(), task_manager))
use try_runtime_cli::block_building_info::substrate_info;

let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
// we don't need any of the components of new_partial, just a runtime, or a task
// manager to do `async_run`.
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;

let info_provider = substrate_info(SLOT_DURATION);

Ok((
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<AvnParachainExecutor as NativeExecutionDispatch>::ExtendHostFunctions,
>, _>(Some(info_provider)),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Expand Down
7 changes: 5 additions & 2 deletions pallets/token-manager/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use frame_system::pallet_prelude::BlockNumberFor;
#[cfg(feature = "try-runtime")]
use crate::Vec;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;

pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

pub fn set_lower_schedule_period<T: Config>() -> Weight {
Expand Down Expand Up @@ -54,14 +57,14 @@ impl<T: Config> OnRuntimeUpgrade for SetLowerSchedulePeriod<T> {
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
use codec::Encode;

Ok(<LowerSchedulePeriod<T>>::get().encode())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(input: Vec<u8>) -> Result<(), &'static str> {
fn post_upgrade(input: Vec<u8>) -> Result<(), TryRuntimeError> {
use codec::Decode;
use sp_runtime::traits::Zero;

Expand Down
4 changes: 2 additions & 2 deletions runtime/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade avn-parachain.");
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade avn-test-parachain.");
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, RuntimeBlockWeights::get().max_block)
}
Expand Down
Loading