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
@@ -31,7 +31,7 @@ use sp_runtime::transaction_validity::{InvalidTransaction, TransactionValidity,
/// pallet will be used in our environment.
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>
where
@@ -77,7 +77,7 @@ where
mod tests {
use crate::{
extension::FilterCall,
mock::{run_test, Call, TestRuntime},
mock::{run_test, RuntimeCall, TestRuntime},
ParaInfo, ParasInfo, RelayBlockNumber,
};
use bp_parachains::BestParaHeadHash;
@@ -87,13 +87,14 @@ mod tests {
num: RelayBlockNumber,
parachains: Vec<(ParaId, ParaHash)>,
) -> bool {
crate::Pallet::<TestRuntime>::validate(&Call::Parachains(
crate::Call::<TestRuntime, ()>::submit_parachain_heads {
at_relay_block: (num, Default::default()),
parachains,
parachain_heads_proof: ParaHeadsProof(Vec::new()),
},
))
crate::Pallet::<TestRuntime>::validate(&RuntimeCall::Parachains(crate::Call::<
TestRuntime,
(),
>::submit_parachain_heads {
at_relay_block: (num, Default::default()),
parachains,
parachain_heads_proof: ParaHeadsProof(Vec::new()),
}))
.is_ok()
}
+17 -16
View File
@@ -29,7 +29,7 @@ pub use weights_ext::WeightInfoExt;
use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo};
use bp_polkadot_core::parachains::{ParaHash, ParaHasher, ParaHead, ParaHeadsProof, ParaId};
use bp_runtime::StorageProofError;
use frame_support::{traits::Contains, weights::PostDispatchInfo};
use frame_support::{dispatch::PostDispatchInfo, traits::Contains};
use sp_runtime::traits::Header as HeaderT;
use sp_std::vec::Vec;
@@ -132,7 +132,8 @@ pub mod pallet {
pallet_bridge_grandpa::Config<Self::BridgesGrandpaPalletInstance>
{
/// The overarching event type.
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Benchmarks results from runtime we're plugged into.
type WeightInfo: WeightInfoExt;
@@ -620,7 +621,7 @@ pub mod pallet {
mod tests {
use super::*;
use crate::mock::{
run_test, test_relay_header, Event as TestEvent, Origin, TestRuntime,
run_test, test_relay_header, RuntimeEvent as TestEvent, RuntimeOrigin, TestRuntime,
MAXIMAL_PARACHAIN_HEAD_SIZE, PARAS_PALLET_NAME, UNTRACKED_PARACHAIN_ID,
};
use codec::Encode;
@@ -650,7 +651,7 @@ mod tests {
fn initialize(state_root: RelayBlockHash) {
pallet_bridge_grandpa::Pallet::<TestRuntime, BridgesGrandpaPalletInstance>::initialize(
Origin::root(),
RuntimeOrigin::root(),
bp_header_chain::InitializationData {
header: Box::new(test_relay_header(0, state_root)),
authority_list: authority_list(),
@@ -670,7 +671,7 @@ mod tests {
let justification = make_default_justification(&header);
assert_ok!(
pallet_bridge_grandpa::Pallet::<TestRuntime, BridgesGrandpaPalletInstance>::submit_finality_proof(
Origin::signed(1),
RuntimeOrigin::signed(1),
Box::new(header),
justification,
)
@@ -736,7 +737,7 @@ mod tests {
proof: ParaHeadsProof,
) -> DispatchResultWithPostInfo {
Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(relay_chain_block, test_relay_header(relay_chain_block, relay_state_root).hash()),
parachains,
proof,
@@ -747,7 +748,7 @@ mod tests {
let db_weight = <TestRuntime as frame_system::Config>::DbWeight::get();
WeightInfoOf::<TestRuntime, ()>::submit_parachain_heads_weight(db_weight, proof, 1)
.saturating_sub(if prune_expected {
0
Weight::from_ref_time(0)
} else {
WeightInfoOf::<TestRuntime, ()>::parachain_head_pruning_weight(db_weight)
})
@@ -765,7 +766,7 @@ mod tests {
PalletOperatingMode::<TestRuntime>::put(BasicOperatingMode::Halted);
assert_noop!(
Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains.clone(),
proof.clone(),
@@ -776,7 +777,7 @@ mod tests {
// `submit_parachain_heads()` should succeed now that the pallet is resumed.
PalletOperatingMode::<TestRuntime>::put(BasicOperatingMode::Normal);
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
@@ -795,7 +796,7 @@ mod tests {
let expected_weight =
WeightInfo::submit_parachain_heads_weight(DbWeight::get(), &proof, 2);
let result = Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
@@ -969,7 +970,7 @@ mod tests {
));
initialize(state_root);
let result = Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
@@ -1159,7 +1160,7 @@ mod tests {
// parachain
initialize(state_root);
let result = Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
@@ -1303,7 +1304,7 @@ mod tests {
// => we'll leave previous value
proceed(20, state_root_10_at_20);
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(20, test_relay_header(20, state_root_10_at_20).hash()),
parachains_10_at_20,
proof_10_at_20,
@@ -1319,7 +1320,7 @@ mod tests {
// => we'll update value
proceed(30, state_root_10_at_30);
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(30, test_relay_header(30, state_root_10_at_30).hash()),
parachains_10_at_30,
proof_10_at_30,
@@ -1360,7 +1361,7 @@ mod tests {
run_test(|| {
initialize(state_root);
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
@@ -1385,7 +1386,7 @@ mod tests {
run_test(|| {
initialize(state_root);
assert_ok!(Pallet::<TestRuntime>::submit_parachain_heads(
Origin::signed(1),
RuntimeOrigin::signed(1),
(0, test_relay_header(0, state_root).hash()),
parachains,
proof,
+5 -5
View File
@@ -53,22 +53,22 @@ construct_runtime! {
parameter_types! {
pub const BlockHashCount: TestNumber = 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 = TestNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
@@ -117,7 +117,7 @@ parameter_types! {
}
impl pallet_bridge_parachains::Config for TestRuntime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
type BridgesGrandpaPalletInstance = pallet_bridge_grandpa::Instance1;
type ParasPalletName = ParasPalletName;
+22 -22
View File
@@ -61,41 +61,41 @@ pub trait WeightInfo {
pub struct BridgeWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight {
(0 as Weight)
.saturating_add((24_869_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(p as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight)))
Weight::from_ref_time(0 as u64)
.saturating_add(Weight::from_ref_time(24_869_000 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(p as u64)))
.saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(p as u64)))
}
fn submit_parachain_heads_with_1kb_proof() -> Weight {
(56_262_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(56_262_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
fn submit_parachain_heads_with_16kb_proof() -> Weight {
(105_189_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(105_189_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight {
(0 as Weight)
.saturating_add((24_869_000 as Weight).saturating_mul(p as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(p as Weight)))
.saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(p as Weight)))
Weight::from_ref_time(0 as u64)
.saturating_add(Weight::from_ref_time(24_869_000 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(p as u64)))
.saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(p as u64)))
}
fn submit_parachain_heads_with_1kb_proof() -> Weight {
(56_262_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
Weight::from_ref_time(56_262_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
fn submit_parachain_heads_with_16kb_proof() -> Weight {
(105_189_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
Weight::from_ref_time(105_189_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
}
@@ -62,8 +62,8 @@ pub trait WeightInfoExt: WeightInfo {
);
// potential pruning weight (refunded if hasn't happened)
let pruning_weight = (parachains_count as Weight)
.saturating_mul(Self::parachain_head_pruning_weight(db_weight));
let pruning_weight =
Self::parachain_head_pruning_weight(db_weight).saturating_mul(parachains_count as u64);
base_weight.saturating_add(proof_size_overhead).saturating_add(pruning_weight)
}
@@ -87,11 +87,10 @@ pub trait WeightInfoExt: WeightInfo {
/// Returns weight that needs to be accounted when storage proof of given size is received.
fn storage_proof_size_overhead(extra_proof_bytes: u32) -> Weight {
let extra_proof_bytes_in_bytes = extra_proof_bytes as Weight;
let extra_byte_weight = (Self::submit_parachain_heads_with_16kb_proof() -
Self::submit_parachain_heads_with_1kb_proof()) /
(15 * 1024);
extra_proof_bytes_in_bytes.saturating_mul(extra_byte_weight)
extra_byte_weight.saturating_mul(extra_proof_bytes as u64)
}
}