Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 0dca40a

Browse files
committed
1 parent 6b52058 commit 0dca40a

File tree

25 files changed

+593
-347
lines changed

25 files changed

+593
-347
lines changed

Cargo.toml

Lines changed: 231 additions & 0 deletions
Large diffs are not rendered by default.

modules/grandpa/src/extension.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ use sp_runtime::{
2929
/// if there are multiple relays running and submitting the same information.
3030
impl<
3131
Call: IsSubType<CallableCallFor<Pallet<T, I>, T>>,
32-
T: frame_system::Config<Call = Call> + Config<I>,
32+
T: frame_system::Config<RuntimeCall = Call> + Config<I>,
3333
I: 'static,
3434
> FilterCall<Call> for Pallet<T, I>
3535
{
36-
fn validate(call: &<T as frame_system::Config>::Call) -> TransactionValidity {
36+
fn validate(call: &<T as frame_system::Config>::RuntimeCall) -> TransactionValidity {
3737
let bundled_block_number = match call.is_sub_type() {
3838
Some(crate::Call::<T, I>::submit_finality_proof { ref finality_target, .. }) =>
3939
*finality_target.number(),
@@ -66,13 +66,13 @@ mod tests {
6666
// darwinia-network
6767
use super::FilterCall;
6868
use crate::{
69-
mock::{run_test, test_header, Call, TestNumber, TestRuntime},
69+
mock::{run_test, test_header, RuntimeCall, TestNumber, TestRuntime},
7070
BestFinalized,
7171
};
7272
use bp_test_utils::make_default_justification;
7373

7474
fn validate_block_submit(num: TestNumber) -> bool {
75-
crate::Pallet::<TestRuntime>::validate(&Call::Grandpa(
75+
crate::Pallet::<TestRuntime>::validate(&RuntimeCall::Grandpa(
7676
crate::Call::<TestRuntime, ()>::submit_finality_proof {
7777
finality_target: Box::new(test_header(num)),
7878
justification: make_default_justification(&test_header(num)),

modules/grandpa/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub mod pallet {
118118
fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
119119
<RequestCount<T, I>>::mutate(|count| *count = count.saturating_sub(1));
120120

121-
(0_u64)
121+
Weight::from_ref_time(0)
122122
.saturating_add(T::DbWeight::get().reads(1))
123123
.saturating_add(T::DbWeight::get().writes(1))
124124
}
@@ -602,25 +602,25 @@ pub fn initialize_for_benchmarks<T: Config<I>, I: 'static>(header: BridgedHeader
602602
#[cfg(test)]
603603
mod tests {
604604
use super::*;
605-
use crate::mock::{run_test, test_header, Origin, TestHeader, TestNumber, TestRuntime};
605+
use crate::mock::{run_test, test_header, RuntimeOrigin, TestHeader, TestNumber, TestRuntime};
606606
use bp_runtime::BasicOperatingMode;
607607
use bp_test_utils::{
608608
authority_list, generate_owned_bridge_module_tests, make_default_justification,
609609
make_justification_for_header, JustificationGeneratorParams, ALICE, BOB,
610610
};
611611
use codec::Encode;
612612
use frame_support::{
613-
assert_err, assert_noop, assert_ok, storage::generator::StorageValue,
614-
weights::PostDispatchInfo,
613+
assert_err, assert_noop, assert_ok, dispatch::PostDispatchInfo,
614+
storage::generator::StorageValue,
615615
};
616616
use sp_runtime::{Digest, DigestItem, DispatchError};
617617

618618
fn initialize_substrate_bridge() {
619-
assert_ok!(init_with_origin(Origin::root()));
619+
assert_ok!(init_with_origin(RuntimeOrigin::root()));
620620
}
621621

622622
fn init_with_origin(
623-
origin: Origin,
623+
origin: RuntimeOrigin,
624624
) -> Result<
625625
InitializationData<TestHeader>,
626626
sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>,
@@ -642,7 +642,7 @@ mod tests {
642642
let justification = make_default_justification(&header);
643643

644644
Pallet::<TestRuntime>::submit_finality_proof(
645-
Origin::signed(1),
645+
RuntimeOrigin::signed(1),
646646
Box::new(header),
647647
justification,
648648
)
@@ -681,13 +681,13 @@ mod tests {
681681
#[test]
682682
fn init_root_or_owner_origin_can_initialize_pallet() {
683683
run_test(|| {
684-
assert_noop!(init_with_origin(Origin::signed(1)), DispatchError::BadOrigin);
685-
assert_ok!(init_with_origin(Origin::root()));
684+
assert_noop!(init_with_origin(RuntimeOrigin::signed(1)), DispatchError::BadOrigin);
685+
assert_ok!(init_with_origin(RuntimeOrigin::root()));
686686

687687
// Reset storage so we can initialize the pallet again
688688
BestFinalized::<TestRuntime>::kill();
689689
PalletOwner::<TestRuntime>::put(2);
690-
assert_ok!(init_with_origin(Origin::signed(2)));
690+
assert_ok!(init_with_origin(RuntimeOrigin::signed(2)));
691691
})
692692
}
693693

@@ -697,7 +697,7 @@ mod tests {
697697
assert_eq!(BestFinalized::<TestRuntime>::get(), None,);
698698
assert_eq!(Pallet::<TestRuntime>::best_finalized(), None);
699699

700-
let init_data = init_with_origin(Origin::root()).unwrap();
700+
let init_data = init_with_origin(RuntimeOrigin::root()).unwrap();
701701

702702
assert!(<ImportedHeaders<TestRuntime>>::contains_key(init_data.header.hash()));
703703
assert_eq!(BestFinalized::<TestRuntime>::get().unwrap().1, init_data.header.hash());
@@ -714,7 +714,7 @@ mod tests {
714714
run_test(|| {
715715
initialize_substrate_bridge();
716716
assert_noop!(
717-
init_with_origin(Origin::root()),
717+
init_with_origin(RuntimeOrigin::root()),
718718
<Error<TestRuntime>>::AlreadyInitialized
719719
);
720720
})
@@ -757,7 +757,7 @@ mod tests {
757757
submit_finality_proof(1),
758758
PostDispatchInfo {
759759
actual_weight: None,
760-
pays_fee: frame_support::weights::Pays::Yes,
760+
pays_fee: frame_support::dispatch::Pays::Yes,
761761
},
762762
);
763763

@@ -822,7 +822,7 @@ mod tests {
822822
operating_mode: BasicOperatingMode::Normal,
823823
};
824824

825-
assert_ok!(Pallet::<TestRuntime>::initialize(Origin::root(), init_data));
825+
assert_ok!(Pallet::<TestRuntime>::initialize(RuntimeOrigin::root(), init_data));
826826

827827
let header = test_header(1);
828828
let justification = make_default_justification(&header);
@@ -874,7 +874,7 @@ mod tests {
874874
),
875875
PostDispatchInfo {
876876
actual_weight: None,
877-
pays_fee: frame_support::weights::Pays::No,
877+
pays_fee: frame_support::dispatch::Pays::No,
878878
},
879879
);
880880

@@ -993,7 +993,7 @@ mod tests {
993993
invalid_justification.round = 42;
994994

995995
Pallet::<TestRuntime>::submit_finality_proof(
996-
Origin::signed(1),
996+
RuntimeOrigin::signed(1),
997997
Box::new(header),
998998
invalid_justification,
999999
)

modules/grandpa/src/mock.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ frame_support::construct_runtime! {
5353

5454
frame_support::parameter_types! {
5555
pub const BlockHashCount: u64 = 250;
56-
pub const MaximumBlockWeight: Weight = 1024;
56+
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
5757
pub const MaximumBlockLength: u32 = 2 * 1024;
5858
pub const AvailableBlockRatio: Perbill = Perbill::one();
5959
}
@@ -65,9 +65,9 @@ impl frame_system::Config for TestRuntime {
6565
type BlockLength = ();
6666
type BlockNumber = u64;
6767
type BlockWeights = ();
68-
type Call = Call;
68+
type RuntimeCall = RuntimeCall;
6969
type DbWeight = ();
70-
type Event = ();
70+
type RuntimeEvent = ();
7171
type Hash = H256;
7272
type Hashing = BlakeTwo256;
7373
type Header = Header;
@@ -77,7 +77,7 @@ impl frame_system::Config for TestRuntime {
7777
type OnKilledAccount = ();
7878
type OnNewAccount = ();
7979
type OnSetCode = ();
80-
type Origin = Origin;
80+
type RuntimeOrigin = RuntimeOrigin;
8181
type PalletInfo = PalletInfo;
8282
type SS58Prefix = ();
8383
type SystemWeightInfo = ();

modules/grandpa/src/weights.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ pub trait WeightInfo {
5757
pub struct MillauWeight<T>(PhantomData<T>);
5858
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
5959
fn submit_finality_proof(p: u32, v: u32) -> Weight {
60-
(55_070_000 as Weight)
61-
.saturating_add((39_678_000 as Weight).saturating_mul(p as Weight))
62-
.saturating_add((1_540_000 as Weight).saturating_mul(v as Weight))
63-
.saturating_add(T::DbWeight::get().reads(7 as Weight))
64-
.saturating_add(T::DbWeight::get().writes(6 as Weight))
60+
Weight::from_ref_time(55_070_000 as u64)
61+
.saturating_add(Weight::from_ref_time(39_678_000 as u64).saturating_mul(p as u64))
62+
.saturating_add(Weight::from_ref_time(1_540_000 as u64).saturating_mul(v as u64))
63+
.saturating_add(T::DbWeight::get().reads(7 as u64))
64+
.saturating_add(T::DbWeight::get().writes(6 as u64))
6565
}
6666
}
6767

6868
// For backwards compatibility and tests
6969
impl WeightInfo for () {
7070
fn submit_finality_proof(p: u32, v: u32) -> Weight {
71-
(55_070_000 as Weight)
72-
.saturating_add((39_678_000 as Weight).saturating_mul(p as Weight))
73-
.saturating_add((1_540_000 as Weight).saturating_mul(v as Weight))
74-
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
75-
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
71+
Weight::from_ref_time(55_070_000 as u64)
72+
.saturating_add(Weight::from_ref_time(39_678_000 as u64).saturating_mul(p as u64))
73+
.saturating_add(Weight::from_ref_time(1_540_000 as u64).saturating_mul(v as u64))
74+
.saturating_add(RocksDbWeight::get().reads(7 as u64))
75+
.saturating_add(RocksDbWeight::get().writes(6 as u64))
7676
}
7777
}

modules/messages/src/inbound_lane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ mod tests {
553553
run_test(|| {
554554
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
555555
let mut payload = REGULAR_PAYLOAD;
556-
payload.dispatch_result.unspent_weight = 1;
556+
*payload.dispatch_result.unspent_weight.ref_time_mut() = 1;
557557
assert_eq!(
558558
lane.receive_message::<TestMessageDispatch, _>(
559559
&TEST_RELAYER_A,

0 commit comments

Comments
 (0)