Bump Substrate/Polkadot/Cumulus refs (aka Weights v1.5) (#1597)

* update Substrate + Polkadot + Cumulus refs

* Origin -> RuntimeOrigin

* weights v1.5

* update refs once again + `cargo test -p pallet-bridge-grandpa` works

* started work on `cargo test -p pallet-bridge-messages`

* cargo test -p pallet-bridge-relayers

* cargo test -p pallet-bridge-parachains

* cargo test -p millau-runtime

* cargo test -p bridge-runtime-common

* cargo test -p rialto-runtime

* cargo test -p rialto-parachain-runtime

* cargo test -p millau-bridge-node

* cargo test -p rialto-bridge-node

* cargo test -p rialto-parachain-collator

* cargo test -p messages-relay

* cargo test -p parachains-relay

* cargo test -p substrate-relay

* cargo test --all

* cargo check -p millau-runtime --locked --features runtime-benchmarks

* fix remaining test

* fmt

* try to allow clippy failure temporarily

* Revert "try to allow clippy failure temporarily"

This reverts commit d1b6593580f07e0dbeecb7ab0aa92cee98888ed3.

* use min_by

* Revert "use min_by"

This reverts commit 33042f49ed37e8dd0505370289e17f03bf1a56ee.

* Revert "Revert "use min_by""

This reverts commit 1d2204f0b14dc81e5650bb574dedb5fa78c7097d.

* trigger CI

* Revert "trigger CI"

This reverts commit 259d91b5606743bba9d043c69f07eac6c8700ef5.

* new day, new clippy warning

* more clippy issues
This commit is contained in:
Svyatoslav Nikolsky
2022-10-20 10:27:23 +03:00
committed by Bastian Köcher
parent 9e1847d12a
commit a3dc2d2748
66 changed files with 991 additions and 893 deletions
+10 -9
View File
@@ -27,11 +27,11 @@ use sp_runtime::{
/// if there are multiple relays running and submitting the same information.
impl<
Call: IsSubType<CallableCallFor<Pallet<T, I>, T>>,
T: frame_system::Config<Call = Call> + Config<I>,
T: frame_system::Config<RuntimeCall = Call> + Config<I>,
I: 'static,
> FilterCall<Call> for Pallet<T, I>
{
fn validate(call: &<T as frame_system::Config>::Call) -> TransactionValidity {
fn validate(call: &<T as frame_system::Config>::RuntimeCall) -> TransactionValidity {
let bundled_block_number = match call.is_sub_type() {
Some(crate::Call::<T, I>::submit_finality_proof { ref finality_target, .. }) =>
*finality_target.number(),
@@ -63,18 +63,19 @@ impl<
mod tests {
use super::FilterCall;
use crate::{
mock::{run_test, test_header, Call, TestNumber, TestRuntime},
mock::{run_test, test_header, RuntimeCall, TestNumber, TestRuntime},
BestFinalized,
};
use bp_test_utils::make_default_justification;
fn validate_block_submit(num: TestNumber) -> bool {
crate::Pallet::<TestRuntime>::validate(&Call::Grandpa(
crate::Call::<TestRuntime, ()>::submit_finality_proof {
finality_target: Box::new(test_header(num)),
justification: make_default_justification(&test_header(num)),
},
))
crate::Pallet::<TestRuntime>::validate(&RuntimeCall::Grandpa(crate::Call::<
TestRuntime,
(),
>::submit_finality_proof {
finality_target: Box::new(test_header(num)),
justification: make_default_justification(&test_header(num)),
}))
.is_ok()
}
+28 -28
View File
@@ -135,7 +135,7 @@ pub mod pallet {
fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
<RequestCount<T, I>>::mutate(|count| *count = count.saturating_sub(1));
(0_u64)
Weight::from_ref_time(0)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -666,7 +666,7 @@ pub fn initialize_for_benchmarks<T: Config<I>, I: 'static>(header: BridgedHeader
mod tests {
use super::*;
use crate::mock::{
run_test, test_header, Origin, TestHeader, TestNumber, TestRuntime,
run_test, test_header, RuntimeOrigin, TestHeader, TestNumber, TestRuntime,
MAX_BRIDGED_AUTHORITIES, MAX_HEADER_SIZE,
};
use bp_runtime::BasicOperatingMode;
@@ -676,17 +676,17 @@ mod tests {
};
use codec::Encode;
use frame_support::{
assert_err, assert_noop, assert_ok, storage::generator::StorageValue,
weights::PostDispatchInfo,
assert_err, assert_noop, assert_ok, dispatch::PostDispatchInfo,
storage::generator::StorageValue,
};
use sp_runtime::{Digest, DigestItem, DispatchError};
fn initialize_substrate_bridge() {
assert_ok!(init_with_origin(Origin::root()));
assert_ok!(init_with_origin(RuntimeOrigin::root()));
}
fn init_with_origin(
origin: Origin,
origin: RuntimeOrigin,
) -> Result<
InitializationData<TestHeader>,
sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>,
@@ -708,7 +708,7 @@ mod tests {
let justification = make_default_justification(&header);
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification,
)
@@ -763,13 +763,13 @@ mod tests {
#[test]
fn init_root_or_owner_origin_can_initialize_pallet() {
run_test(|| {
assert_noop!(init_with_origin(Origin::signed(1)), DispatchError::BadOrigin);
assert_ok!(init_with_origin(Origin::root()));
assert_noop!(init_with_origin(RuntimeOrigin::signed(1)), DispatchError::BadOrigin);
assert_ok!(init_with_origin(RuntimeOrigin::root()));
// Reset storage so we can initialize the pallet again
BestFinalized::<TestRuntime>::kill();
PalletOwner::<TestRuntime>::put(2);
assert_ok!(init_with_origin(Origin::signed(2)));
assert_ok!(init_with_origin(RuntimeOrigin::signed(2)));
})
}
@@ -779,7 +779,7 @@ mod tests {
assert_eq!(BestFinalized::<TestRuntime>::get(), None,);
assert_eq!(Pallet::<TestRuntime>::best_finalized(), None);
let init_data = init_with_origin(Origin::root()).unwrap();
let init_data = init_with_origin(RuntimeOrigin::root()).unwrap();
assert!(<ImportedHeaders<TestRuntime>>::contains_key(init_data.header.hash()));
assert_eq!(BestFinalized::<TestRuntime>::get().unwrap().1, init_data.header.hash());
@@ -796,7 +796,7 @@ mod tests {
run_test(|| {
initialize_substrate_bridge();
assert_noop!(
init_with_origin(Origin::root()),
init_with_origin(RuntimeOrigin::root()),
<Error<TestRuntime>>::AlreadyInitialized
);
})
@@ -816,7 +816,7 @@ mod tests {
};
assert_noop!(
Pallet::<TestRuntime>::initialize(Origin::root(), init_data),
Pallet::<TestRuntime>::initialize(RuntimeOrigin::root(), init_data),
Error::<TestRuntime>::TooManyAuthoritiesInSet,
);
});
@@ -835,7 +835,7 @@ mod tests {
};
assert_noop!(
Pallet::<TestRuntime>::initialize(Origin::root(), init_data),
Pallet::<TestRuntime>::initialize(RuntimeOrigin::root(), init_data),
Error::<TestRuntime>::TooLargeHeader,
);
});
@@ -847,7 +847,7 @@ mod tests {
initialize_substrate_bridge();
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::root(),
RuntimeOrigin::root(),
BasicOperatingMode::Halted
));
assert_noop!(
@@ -856,7 +856,7 @@ mod tests {
);
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::root(),
RuntimeOrigin::root(),
BasicOperatingMode::Normal
));
assert_ok!(submit_finality_proof(1));
@@ -878,7 +878,7 @@ mod tests {
submit_finality_proof(1),
PostDispatchInfo {
actual_weight: None,
pays_fee: frame_support::weights::Pays::Yes,
pays_fee: frame_support::dispatch::Pays::Yes,
},
);
@@ -901,7 +901,7 @@ mod tests {
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification,
),
@@ -921,7 +921,7 @@ mod tests {
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification,
),
@@ -943,14 +943,14 @@ mod tests {
operating_mode: BasicOperatingMode::Normal,
};
assert_ok!(Pallet::<TestRuntime>::initialize(Origin::root(), init_data));
assert_ok!(Pallet::<TestRuntime>::initialize(RuntimeOrigin::root(), init_data));
let header = test_header(1);
let justification = make_default_justification(&header);
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification,
),
@@ -989,13 +989,13 @@ mod tests {
// Let's import our test header
assert_ok!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header.clone()),
justification
),
PostDispatchInfo {
actual_weight: None,
pays_fee: frame_support::weights::Pays::No,
pays_fee: frame_support::dispatch::Pays::No,
},
);
@@ -1028,7 +1028,7 @@ mod tests {
// Should not be allowed to import this header
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification
),
@@ -1053,7 +1053,7 @@ mod tests {
// Should not be allowed to import this header
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification
),
@@ -1078,7 +1078,7 @@ mod tests {
// Should not be allowed to import this header
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification
),
@@ -1103,7 +1103,7 @@ mod tests {
// Should not be allowed to import this header
assert_err!(
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification
),
@@ -1168,7 +1168,7 @@ mod tests {
invalid_justification.round = 42;
Pallet::<TestRuntime>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
invalid_justification,
)
+4 -4
View File
@@ -51,22 +51,22 @@ construct_runtime! {
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Config for TestRuntime {
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Call = Call;
type RuntimeCall = RuntimeCall;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type RuntimeEvent = ();
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
+1 -1
View File
@@ -43,7 +43,7 @@ impl<T: Config<I>, I: 'static> StoredAuthoritySet<T, I> {
///
/// Returns error if number of authorities in the provided list is too large.
pub fn try_new(authorities: AuthorityList, set_id: SetId) -> Result<Self, ()> {
Ok(Self { authorities: TryFrom::try_from(authorities)?, set_id })
Ok(Self { authorities: TryFrom::try_from(authorities).map_err(drop)?, set_id })
}
}
+10 -10
View File
@@ -59,21 +59,21 @@ pub trait WeightInfo {
pub struct BridgeWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
fn submit_finality_proof(p: u32, v: u32) -> Weight {
(105_417_000 as Weight)
.saturating_add((40_923_000 as Weight).saturating_mul(p as Weight))
.saturating_add((1_691_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
Weight::from_ref_time(105_417_000 as u64)
.saturating_add(Weight::from_ref_time(40_923_000 as u64).saturating_mul(p as u64))
.saturating_add(Weight::from_ref_time(1_691_000 as u64).saturating_mul(v as u64))
.saturating_add(T::DbWeight::get().reads(7 as u64))
.saturating_add(T::DbWeight::get().writes(6 as u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
fn submit_finality_proof(p: u32, v: u32) -> Weight {
(105_417_000 as Weight)
.saturating_add((40_923_000 as Weight).saturating_mul(p as Weight))
.saturating_add((1_691_000 as Weight).saturating_mul(v as Weight))
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
Weight::from_ref_time(105_417_000 as u64)
.saturating_add(Weight::from_ref_time(40_923_000 as u64).saturating_mul(p as u64))
.saturating_add(Weight::from_ref_time(1_691_000 as u64).saturating_mul(v as u64))
.saturating_add(RocksDbWeight::get().reads(7 as u64))
.saturating_add(RocksDbWeight::get().writes(6 as u64))
}
}