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

Upgrade to polkadot v1.1.0 #9

Merged
merged 5 commits into from
Oct 9, 2023
Merged
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
1,939 changes: 985 additions & 954 deletions Cargo.lock

Large diffs are not rendered by default.

256 changes: 128 additions & 128 deletions Cargo.toml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pallets/author-mapping/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ mod tests {
use crate::mock::Runtime;
use frame_support::assert_ok;
use sp_io::TestExternalities;
use sp_runtime::BuildStorage;

pub fn new_test_ext() -> TestExternalities {
let t = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
let t = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.unwrap();
TestExternalities::new(t)
}
Expand Down
5 changes: 3 additions & 2 deletions pallets/author-slot-filter/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ benchmarks! {
mod tests {
use crate::tests::Test;
use sp_io::TestExternalities;
use sp_runtime::BuildStorage;

pub fn new_test_ext() -> TestExternalities {
let t = frame_system::GenesisConfig::default()
.build_storage::<Test>()
let t = frame_system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap();
TestExternalities::new(t)
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/author-slot-filter/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
AuthorSlotFilter: pallet_testing::{Pallet, Call, Storage, Event},
System: frame_system,
AuthorSlotFilter: pallet_testing,
}
);

Expand Down
5 changes: 3 additions & 2 deletions pallets/author-slot-filter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
// along with Moonkit. If not, see <http://www.gnu.org/licenses/>.

use super::*;
use crate::mock::*;
pub use crate::mock::*;
use crate::num::NonZeroU32;

use frame_support::assert_ok;
use frame_support::{traits::OnRuntimeUpgrade, weights::Weight};
use frame_support::traits::OnRuntimeUpgrade;
use frame_support::weights::Weight;
use sp_runtime::Percent;

#[test]
Expand Down
23 changes: 12 additions & 11 deletions pallets/migrations/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub struct MockMigrationManager<'test> {
name_fn_callbacks: Vec<Box<dyn 'test + FnMut() -> &'static str>>,
migrate_fn_callbacks: Vec<Box<dyn 'test + FnMut(Weight) -> Weight>>,
pre_upgrade_fn_callbacks:
Vec<Box<dyn 'test + FnMut() -> Result<(), sp_runtime::DispatchError>>>,
Vec<Box<dyn 'test + FnMut() -> Result<Vec<u8>, sp_runtime::DispatchError>>>,
post_upgrade_fn_callbacks:
Vec<Box<dyn 'test + FnMut() -> Result<(), sp_runtime::DispatchError>>>,
}
Expand All @@ -170,7 +170,8 @@ impl<'test> MockMigrationManager<'test> {
{
self.name_fn_callbacks.push(Box::new(name_fn));
self.migrate_fn_callbacks.push(Box::new(migrate_fn));
self.pre_upgrade_fn_callbacks.push(Box::new(|| Ok(())));
self.pre_upgrade_fn_callbacks
.push(Box::new(|| Ok(Vec::new())));
self.post_upgrade_fn_callbacks.push(Box::new(|| Ok(())));
}
#[cfg(feature = "try-runtime")]
Expand All @@ -183,9 +184,9 @@ impl<'test> MockMigrationManager<'test> {
) where
FN: 'test + FnMut() -> &'static str,
FM: 'test + FnMut(Weight) -> Weight,
FT1: 'test + FnMut() -> Result<(), &'static str>,
FT1: 'test + FnMut() -> Result<Vec<u8>, sp_runtime::DispatchError>,
// no two closures, even if identical, have the same type
FT2: 'test + FnMut() -> Result<(), &'static str>,
FT2: 'test + FnMut() -> Result<(), sp_runtime::DispatchError>,
{
self.name_fn_callbacks.push(Box::new(name_fn));
self.migrate_fn_callbacks.push(Box::new(migrate_fn));
Expand All @@ -206,7 +207,7 @@ impl<'test> MockMigrationManager<'test> {
pub(crate) fn invoke_pre_upgrade(
&mut self,
index: usize,
) -> Result<(), sp_runtime::DispatchError> {
) -> Result<Vec<u8>, sp_runtime::DispatchError> {
self.pre_upgrade_fn_callbacks[index]()
}

Expand Down Expand Up @@ -272,16 +273,16 @@ impl Migration for MockMigration {
result
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade(&self) -> Result<(), sp_runtime::DispatchError> {
let mut result: Result<(), &'static str> = Err("closure didn't set result");
fn pre_upgrade(&self) -> Result<Vec<u8>, sp_runtime::DispatchError> {
let mut result = Ok(vec![]);
MOCK_MIGRATIONS_LIST::with(|mgr: &mut MockMigrationManager| {
result = mgr.invoke_pre_upgrade(self.index);
});
result
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(&self) -> Result<(), sp_runtime::DispatchError> {
let mut result: Result<(), &'static str> = Err("closure didn't set result");
fn post_upgrade(&self, _state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
let mut result = Ok(());
MOCK_MIGRATIONS_LIST::with(|mgr: &mut MockMigrationManager| {
result = mgr.invoke_post_upgrade(self.index);
});
Expand Down Expand Up @@ -370,9 +371,9 @@ pub(crate) fn events() -> Vec<pallet_migrations::Event<Runtime>> {

#[cfg(feature = "try-runtime")]
pub(crate) fn invoke_all_upgrade_hooks() -> Weight {
Migrations::pre_upgrade().expect("pre-upgrade hook succeeds");
let val = Migrations::pre_upgrade().expect("pre-upgrade hook succeeds");
let weight = Migrations::on_runtime_upgrade();
Migrations::post_upgrade().expect("post-upgrade hook succeeds");
Migrations::post_upgrade(val).expect("post-upgrade hook succeeds");

weight
}
Expand Down
6 changes: 3 additions & 3 deletions pallets/migrations/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ fn try_runtime_functions_work() {
mgr.register_callback_with_try_fns(
move || "dummy_step",
move |_| -> Weight { 0u64.into() },
move || -> Result<(), &'static str> {
move || -> Result<Vec<u8>, sp_runtime::DispatchError> {
*pre_fn_called.lock().unwrap() = true;
Ok(())
Ok(vec![])
},
move || -> Result<(), &'static str> {
move || -> Result<(), sp_runtime::DispatchError> {
*post_fn_called.lock().unwrap() = true;
Ok(())
},
Expand Down
5 changes: 3 additions & 2 deletions pallets/randomness/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,11 @@ benchmarks! {
mod tests {
use crate::mock::Test;
use sp_io::TestExternalities;
use sp_runtime::BuildStorage;

pub fn new_test_ext() -> TestExternalities {
let t = frame_system::GenesisConfig::default()
.build_storage::<Test>()
let t = frame_system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap();
TestExternalities::new(t)
}
Expand Down
5 changes: 2 additions & 3 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,8 @@ impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};

impl frame_system_benchmarking::Config for Runtime {}
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
use frame_support::traits::TrackedStorageKey;

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand Down
Loading