Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c0abc5
A clean new attempt
kianenigma Feb 3, 2021
7f9b5b8
Checkpoint to move remote.
kianenigma Feb 10, 2021
4883812
A lot of dependency wiring to make it feature gated.
kianenigma Feb 10, 2021
be549b4
bad macro, bad macro.
kianenigma Feb 10, 2021
8e97733
Master.into()
kianenigma Feb 11, 2021
7edef9e
refactor(remote ext): use jsonrpsee
niklasad1 Feb 11, 2021
99e7818
refactor(remote ext): use jsonrpsee
niklasad1 Feb 11, 2021
89f4c2a
Merge branch 'na-remote-ext-jsonrpsee-show-kian' of github.com:parity…
niklasad1 Feb 11, 2021
fd9c2b1
Merge remote-tracking branch 'origin/kiz-finally-finally-finally-fina…
niklasad1 Feb 11, 2021
d84dad4
Undo the DB mess.
kianenigma Feb 11, 2021
bd7f87c
fix(remote ext): use max limit `u32::MAX`
niklasad1 Feb 11, 2021
d9c7951
resolve TODOs
niklasad1 Feb 11, 2021
9d0717a
jsonrpsee switch to `hyper` as backend
niklasad1 Feb 11, 2021
c95c215
Merge remote-tracking branch 'origin/kiz-finally-finally-finally-fina…
niklasad1 Feb 11, 2021
8b7c7c3
Update utils/frame/try-runtime/remote-externalities/src/lib.rs
niklasad1 Feb 11, 2021
2f1206a
update jsonrpsee
niklasad1 Feb 15, 2021
79c7dee
Merge branch 'na-remote-ext-jsonrpsee-show-kian' of github.com:parity…
niklasad1 Feb 15, 2021
c893bd7
Merge remote-tracking branch 'origin/master' into na-remote-ext-jsonr…
niklasad1 Mar 4, 2021
df8d9fe
remove boiler-plate
niklasad1 Mar 4, 2021
a9a4a19
suppress warnings to CI happy
niklasad1 Mar 4, 2021
a0e8bae
Merge remote-tracking branch 'origin/master' into na-remote-ext-jsonr…
niklasad1 Mar 5, 2021
cc248a0
Unbreak his build
kianenigma Mar 5, 2021
c8796c7
Use option
kianenigma Mar 5, 2021
01688f2
fix nit; make it work again
niklasad1 Mar 5, 2021
eced71c
fix err message.
kianenigma Mar 6, 2021
195fee3
Merge branch 'master' of github.com:paritytech/substrate into na-remo…
kianenigma Mar 6, 2021
4e696c4
Update utils/frame/remote-externalities/Cargo.toml
niklasad1 Mar 6, 2021
8c6c859
Fix uri stuff
kianenigma Mar 6, 2021
12ca19a
ccccrbvlhchdlejdhiiuefuiurbntlrjlviuilcnhl
kianenigma Mar 6, 2021
7f08f50
remove needless clone
niklasad1 Mar 6, 2021
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
Prev Previous commit
Next Next commit
A lot of dependency wiring to make it feature gated.
  • Loading branch information
kianenigma committed Feb 10, 2021
commit 488381208643692077b42badf04f0907427f6c29
5 changes: 4 additions & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,7 @@ runtime-benchmarks = [
"node-runtime/runtime-benchmarks",
"frame-benchmarking-cli",
]
runtime-upgrade-dry-run = []
runtime-upgrade-dry-run = [
"node-runtime/runtime-upgrade-dry-run",
"dry-run-runtime-upgrade-cli",
]
7 changes: 5 additions & 2 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ frame-support = { version = "2.0.0", default-features = false, path = "../../../
frame-system = { version = "2.0.0", default-features = false, path = "../../../frame/system" }
frame-system-benchmarking = { version = "2.0.0", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
frame-dry-run-runtime-upgrade = { default-features = false, path = "../../../frame/dry-run-runtime-upgrade", optional = true }
pallet-assets = { version = "2.0.0", default-features = false, path = "../../../frame/assets" }
pallet-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "2.0.0", default-features = false, path = "../../../frame/authorship" }
Expand Down Expand Up @@ -83,8 +84,6 @@ pallet-transaction-payment = { version = "2.0.0", default-features = false, path
pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }
pallet-vesting = { version = "2.0.0", default-features = false, path = "../../../frame/vesting" }

frame-dry-run-runtime-upgrade = { default-features = false, path = "../../../frame/dry-run-runtime-upgrade" }

[build-dependencies]
substrate-wasm-builder = { version = "3.0.0", path = "../../../utils/wasm-builder" }

Expand Down Expand Up @@ -189,3 +188,7 @@ runtime-benchmarks = [
"frame-system-benchmarking",
"hex-literal",
]
runtime-upgrade-dry-run = [
"frame-executive/runtime-upgrade-dry-run",
"frame-dry-run-runtime-upgrade",
]
30 changes: 13 additions & 17 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,27 +1332,23 @@ impl_runtime_apis! {

#[cfg(feature = "runtime-upgrade-dry-run")]
impl frame_dry_run_runtime_upgrade::DryRunRuntimeUpgrade<Block> for Runtime {
fn dry_run_runtime_upgrade(pallet: &str) -> Weight {
fn dry_run_runtime_upgrade(target: frame_dry_run_runtime_upgrade::Target) -> Weight {
frame_support::debug::RuntimeLogger::init();

frame_support::debug::info!("!!! DRYRUN MIGRATION UP AHEAD !!!");
let weight = Executive::dry_run_runtime_upgrade();
frame_support::debug::info!("!!! DRYRUN MIGRATION DONE !!!");

weight
let weight = match target {
frame_dry_run_runtime_upgrade::Target::All => {
frame_support::debug::info!("Dru-running all on-runtime-upgrades.");
Executive::dry_run_runtime_upgrade()
},
frame_dry_run_runtime_upgrade::Target::Pallet(name) => {
let name = sp_std::str::from_utf8(&name).unwrap();
frame_support::debug::info!("Dru-running on-runtime-upgrade of {}", name);
todo!();
}
};

// \migration_bot pallet:staking state:polkadot
// pseudo code:
// match config.pallet {
// "System" => {
// <Pallet as OnRuntimeUpgrade>::pre_upgrade();
// <Pallet as OnRuntimeUpgrade>::on_runtime_upgrade();
// <Pallet as OnRuntimeUpgrade>::post_upgrade();
// },
// "All" => {
// Executive::dry_run_runtime_upgrade()
// }
// }
weight
}
}

Expand Down
10 changes: 7 additions & 3 deletions frame/dry-run-runtime-upgrade/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#![cfg_attr(not(feature = "std"), no_std)]

use codec::Encode;
use codec::{Decode, Encode};
use sp_std::prelude::*;

/// Possible targets for dry-run runtime upgrade.
#[derive(Debug, Encode)]
#[derive(Debug, Encode, Decode)]
pub enum Target {
/// All pallets.
All,
Expand All @@ -35,7 +35,11 @@ pub enum Target {
impl sp_std::str::FromStr for Target {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(if s.to_lowercase() == "All" { Target::All } else { Target::Pallet(s.encode()) })
Ok(if s.to_lowercase() == "All" {
Target::All
} else {
Target::Pallet(s.as_bytes().to_vec())
})
}
}

Expand Down
4 changes: 3 additions & 1 deletion frame/executive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ std = [
"sp-tracing/std",
"sp-std/std",
]
runtime-upgrade-dry-run = []
runtime-upgrade-dry-run = [
"frame-support/runtime-upgrade-dry-run"
]
16 changes: 15 additions & 1 deletion utils/frame/dry-run-runtime-upgrade/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,20 @@ impl DryRunRuntimeUpgradeCmd {
let heap_pages = Some(1024);
let executor = NativeExecutor::<ExecDispatch>::new(wasm_method, heap_pages, 2);

let ext = remote_externalities::Builder::new().inject(&[(code_key, code)]).build().await;
let ext = {
use remote_externalities::{Builder, Mode, CacheConfig, OfflineConfig, OnlineConfig};
let builder = match &self.state {
State::Snap(file_path) => Builder::new().mode(Mode::Offline(OfflineConfig {
cache: CacheConfig { name: file_path.into(), ..Default::default() },
})),
State::Live(http_uri) => Builder::new().mode(Mode::Online(OnlineConfig {
uri: http_uri.into(),
..Default::default()
})),
};

builder.inject(&[(code_key, code)]).build().await
};

let consumed_weight = StateMachine::<_, _, NumberFor<B>, _>::new(
&ext.backend,
Expand All @@ -105,6 +118,7 @@ impl DryRunRuntimeUpgradeCmd {
)
.execute(strategy.into())
.unwrap();
// TODO: if MethodNotFound, then it must be wrong feature.

let weight = <u64 as Decode>::decode(&mut &*consumed_weight).unwrap();
log::info!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,23 @@ pub enum Mode {
/// A cache config must be present.
#[derive(Clone)]
pub struct OfflineConfig {
cache: CacheConfig,
/// The configuration of the cache file to use. It must be present.
pub cache: CacheConfig,
}

/// Configuration of the online execution.
///
/// A cache config may be present and will be written to in that case.
#[derive(Clone)]
pub struct OnlineConfig {
uri: String,
at: Option<Hash>,
cache: Option<CacheConfig>,
modules: Vec<String>,
/// The HTTP uri to use.
pub uri: String,
/// The block number at which to connect. Will be latest finalized head if not provided.
pub at: Option<Hash>,
/// An optional cache file to WRITE to, not for reading. Not cached if set to `None`.
pub cache: Option<CacheConfig>,
/// The modules to scrape. If empty, entire chain state will be scraped.
pub modules: Vec<String>,
}

impl Default for OnlineConfig {
Expand All @@ -194,8 +199,12 @@ impl Default for OnlineConfig {
/// Configuration of the cache.
#[derive(Clone)]
pub struct CacheConfig {
name: String,
directory: String,
// TODO: I could mix these two into one filed, but I think separate is better bc one can be
// configurable while one not.
/// File name.
pub name: String,
/// Base directory.
pub directory: String,
}

impl Default for CacheConfig {
Expand Down Expand Up @@ -355,6 +364,11 @@ impl Builder {
}
};

info!(
target: LOG_TARGET,
"extending externalities with {} manually injected keys",
self.inject.len()
);
base_kv.extend(self.inject.clone());
base_kv
}
Expand Down Expand Up @@ -389,7 +403,6 @@ impl Builder {
info!(target: LOG_TARGET, "injecting a total of {} keys", kv.len());
for (k, v) in kv {
let (k, v) = (k.0, v.0);
trace!(target: LOG_TARGET, "injecting {:?} -> {:?}", k.hex_display(), v.hex_display());
ext.insert(k, v);
}
ext
Expand Down