Rename Origin (#6020)

* Rename Origin

* fmt

* fixes

* more fixes

* fix

* more fixing

* small fixes

* last touches

* update lockfile for {"substrate"}

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Sergej Sakac
2022-09-21 00:53:12 +02:00
committed by GitHub
parent 8d8bd99582
commit 937c4e76ae
46 changed files with 1176 additions and 910 deletions
+172 -172
View File
File diff suppressed because it is too large Load Diff
+55 -32
View File
@@ -88,7 +88,7 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Origin for assigning slots. /// Origin for assigning slots.
type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>; type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
/// The type representing the leasing system. /// The type representing the leasing system.
type Leaser: Leaser< type Leaser: Leaser<
@@ -592,7 +592,7 @@ mod tests {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -738,7 +738,10 @@ mod tests {
run_to_block(1); run_to_block(1);
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::root(),
ParaId::from(1_u32),
),
Error::<Test>::ParaDoesntExist Error::<Test>::ParaDoesntExist
); );
}); });
@@ -750,7 +753,10 @@ mod tests {
run_to_block(1); run_to_block(1);
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::signed(1),
ParaId::from(1_u32),
),
BadOrigin BadOrigin
); );
}); });
@@ -770,7 +776,10 @@ mod tests {
assert_ok!(TestRegistrar::<Test>::make_parachain(ParaId::from(1_u32))); assert_ok!(TestRegistrar::<Test>::make_parachain(ParaId::from(1_u32)));
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::root(),
ParaId::from(1_u32),
),
Error::<Test>::NotParathread Error::<Test>::NotParathread
); );
}); });
@@ -792,18 +801,24 @@ mod tests {
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 1, 1)); assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 1, 1));
// Try to assign a perm slot in current period fails // Try to assign a perm slot in current period fails
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::root(),
ParaId::from(1_u32),
),
Error::<Test>::OngoingLeaseExists Error::<Test>::OngoingLeaseExists
); );
// Cleanup // Cleanup
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
// Register lease for next lease period // Register lease for next lease period
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1)); assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1));
// Should be detected and also fail // Should be detected and also fail
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::root(),
ParaId::from(1_u32),
),
Error::<Test>::OngoingLeaseExists Error::<Test>::OngoingLeaseExists
); );
}); });
@@ -836,17 +851,20 @@ mod tests {
)); ));
assert_ok!(AssignedSlots::assign_perm_parachain_slot( assert_ok!(AssignedSlots::assign_perm_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
)); ));
assert_ok!(AssignedSlots::assign_perm_parachain_slot( assert_ok!(AssignedSlots::assign_perm_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(2_u32), ParaId::from(2_u32),
)); ));
assert_eq!(AssignedSlots::permanent_slot_count(), 2); assert_eq!(AssignedSlots::permanent_slot_count(), 2);
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(3_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::root(),
ParaId::from(3_u32),
),
Error::<Test>::MaxPermanentSlotsExceeded Error::<Test>::MaxPermanentSlotsExceeded
); );
}); });
@@ -868,7 +886,7 @@ mod tests {
assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None); assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None);
assert_ok!(AssignedSlots::assign_perm_parachain_slot( assert_ok!(AssignedSlots::assign_perm_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
)); ));
@@ -901,7 +919,7 @@ mod tests {
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -917,7 +935,7 @@ mod tests {
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::signed(1), RuntimeOrigin::signed(1),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -941,7 +959,7 @@ mod tests {
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -967,7 +985,7 @@ mod tests {
// Try to assign a perm slot in current period fails // Try to assign a perm slot in current period fails
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -975,14 +993,14 @@ mod tests {
); );
// Cleanup // Cleanup
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
// Register lease for next lease period // Register lease for next lease period
assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1)); assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1));
// Should be detected and also fail // Should be detected and also fail
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -1006,7 +1024,7 @@ mod tests {
)); ));
assert_ok!(AssignedSlots::assign_temp_parachain_slot( assert_ok!(AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(n as u32), ParaId::from(n as u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
)); ));
@@ -1023,7 +1041,7 @@ mod tests {
)); ));
assert_noop!( assert_noop!(
AssignedSlots::assign_temp_parachain_slot( AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(7_u32), ParaId::from(7_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
), ),
@@ -1047,7 +1065,7 @@ mod tests {
assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None); assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None);
assert_ok!(AssignedSlots::assign_temp_parachain_slot( assert_ok!(AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
)); ));
@@ -1122,7 +1140,7 @@ mod tests {
)); ));
assert_ok!(AssignedSlots::assign_temp_parachain_slot( assert_ok!(AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(n as u32), ParaId::from(n as u32),
if (n % 2).is_zero() { if (n % 2).is_zero() {
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
@@ -1214,7 +1232,7 @@ mod tests {
run_to_block(1); run_to_block(1);
assert_noop!( assert_noop!(
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),), AssignedSlots::unassign_parachain_slot(RuntimeOrigin::root(), ParaId::from(1_u32),),
Error::<Test>::SlotNotAssigned Error::<Test>::SlotNotAssigned
); );
}); });
@@ -1226,7 +1244,10 @@ mod tests {
run_to_block(1); run_to_block(1);
assert_noop!( assert_noop!(
AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),), AssignedSlots::assign_perm_parachain_slot(
RuntimeOrigin::signed(1),
ParaId::from(1_u32),
),
BadOrigin BadOrigin
); );
}); });
@@ -1245,15 +1266,16 @@ mod tests {
)); ));
assert_ok!(AssignedSlots::assign_perm_parachain_slot( assert_ok!(AssignedSlots::assign_perm_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
)); ));
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true); assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
assert_ok!( assert_ok!(AssignedSlots::unassign_parachain_slot(
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),) RuntimeOrigin::root(),
); ParaId::from(1_u32),
));
assert_eq!(AssignedSlots::permanent_slot_count(), 0); assert_eq!(AssignedSlots::permanent_slot_count(), 0);
assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), false); assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), false);
@@ -1276,16 +1298,17 @@ mod tests {
)); ));
assert_ok!(AssignedSlots::assign_temp_parachain_slot( assert_ok!(AssignedSlots::assign_temp_parachain_slot(
Origin::root(), RuntimeOrigin::root(),
ParaId::from(1_u32), ParaId::from(1_u32),
SlotLeasePeriodStart::Current SlotLeasePeriodStart::Current
)); ));
assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true); assert_eq!(TestRegistrar::<Test>::is_parachain(ParaId::from(1_u32)), true);
assert_ok!( assert_ok!(AssignedSlots::unassign_parachain_slot(
AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),) RuntimeOrigin::root(),
); ParaId::from(1_u32),
));
assert_eq!(AssignedSlots::temporary_slot_count(), 0); assert_eq!(AssignedSlots::temporary_slot_count(), 0);
assert_eq!(AssignedSlots::active_temporary_slot_count(), 0); assert_eq!(AssignedSlots::active_temporary_slot_count(), 0);
+69 -69
View File
@@ -117,7 +117,7 @@ pub mod pallet {
type Randomness: Randomness<Self::Hash, Self::BlockNumber>; type Randomness: Randomness<Self::Hash, Self::BlockNumber>;
/// The origin which may initiate auctions. /// The origin which may initiate auctions.
type InitiateOrigin: EnsureOrigin<Self::Origin>; type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet /// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
@@ -709,7 +709,7 @@ mod tests {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -955,8 +955,8 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_noop!(Auctions::new_auction(Origin::signed(1), 5, 1), BadOrigin); assert_noop!(Auctions::new_auction(RuntimeOrigin::signed(1), 5, 1), BadOrigin);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_eq!(AuctionCounter::<Test>::get(), 1); assert_eq!(AuctionCounter::<Test>::get(), 1);
assert_eq!( assert_eq!(
@@ -970,8 +970,8 @@ mod tests {
fn bidding_works() { fn bidding_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_eq!(Balances::reserved_balance(1), 5); assert_eq!(Balances::reserved_balance(1), 5);
assert_eq!(Balances::free_balance(1), 5); assert_eq!(Balances::free_balance(1), 5);
@@ -986,12 +986,12 @@ mod tests {
fn under_bidding_works() { fn under_bidding_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_storage_noop!({ assert_storage_noop!({
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 1));
}); });
}); });
} }
@@ -1000,9 +1000,9 @@ mod tests {
fn over_bidding_works() { fn over_bidding_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 6)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 6));
assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(1), 10);
@@ -1020,7 +1020,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_eq!(AuctionCounter::<Test>::get(), 1); assert_eq!(AuctionCounter::<Test>::get(), 1);
assert_eq!( assert_eq!(
@@ -1082,8 +1082,8 @@ mod tests {
fn can_win_auction() { fn can_win_auction() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9); assert_eq!(Balances::free_balance(1), 9);
run_to_block(9); run_to_block(9);
@@ -1105,8 +1105,8 @@ mod tests {
fn can_win_auction_with_late_randomness() { fn can_win_auction_with_late_randomness() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9); assert_eq!(Balances::free_balance(1), 9);
assert_eq!( assert_eq!(
@@ -1159,8 +1159,8 @@ mod tests {
fn can_win_incomplete_auction() { fn can_win_incomplete_auction() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 5));
run_to_block(9); run_to_block(9);
assert_eq!(leases(), vec![((0.into(), 4), LeaseData { leaser: 1, amount: 5 }),]); assert_eq!(leases(), vec![((0.into(), 4), LeaseData { leaser: 1, amount: 5 }),]);
@@ -1172,11 +1172,11 @@ mod tests {
fn should_choose_best_combination() { fn should_choose_best_combination() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 2, 3, 4)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 2, 3, 4));
assert_ok!(Auctions::bid(Origin::signed(3), 0.into(), 1, 4, 4, 2)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 0.into(), 1, 4, 4, 2));
assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 1, 1, 4, 2)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 1, 1, 4, 2));
run_to_block(9); run_to_block(9);
assert_eq!( assert_eq!(
@@ -1199,15 +1199,15 @@ mod tests {
fn gap_bid_works() { fn gap_bid_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
// User 1 will make a bid for period 1 and 4 for the same Para 0 // User 1 will make a bid for period 1 and 4 for the same Para 0
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 4)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 4));
// User 2 and 3 will make a bid for para 1 on period 2 and 3 respectively // User 2 and 3 will make a bid for para 1 on period 2 and 3 respectively
assert_ok!(Auctions::bid(Origin::signed(2), 1.into(), 1, 2, 2, 2)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 1.into(), 1, 2, 2, 2));
assert_ok!(Auctions::bid(Origin::signed(3), 1.into(), 1, 3, 3, 3)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 1.into(), 1, 3, 3, 3));
// Total reserved should be the max of the two // Total reserved should be the max of the two
assert_eq!(Balances::reserved_balance(1), 4); assert_eq!(Balances::reserved_balance(1), 4);
@@ -1238,16 +1238,16 @@ mod tests {
fn deposit_credit_should_work() { fn deposit_credit_should_work() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
assert_eq!(Balances::reserved_balance(1), 5); assert_eq!(Balances::reserved_balance(1), 5);
run_to_block(10); run_to_block(10);
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]); assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5); assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 2, 2, 6)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 2, 2, 6));
// Only 1 reserved since we have a deposit credit of 5. // Only 1 reserved since we have a deposit credit of 5.
assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 1);
run_to_block(20); run_to_block(20);
@@ -1267,16 +1267,16 @@ mod tests {
fn deposit_credit_on_alt_para_should_not_count() { fn deposit_credit_on_alt_para_should_not_count() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
assert_eq!(Balances::reserved_balance(1), 5); assert_eq!(Balances::reserved_balance(1), 5);
run_to_block(10); run_to_block(10);
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]); assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5); assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 2, 2, 2, 6)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 2, 2, 2, 6));
// 6 reserved since we are bidding on a new para; only works because we don't // 6 reserved since we are bidding on a new para; only works because we don't
assert_eq!(Balances::reserved_balance(1), 6); assert_eq!(Balances::reserved_balance(1), 6);
run_to_block(20); run_to_block(20);
@@ -1298,11 +1298,11 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
for i in 1..6u64 { for i in 1..6u64 {
run_to_block(i as _); run_to_block(i as _);
assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
for j in 1..6 { for j in 1..6 {
assert_eq!(Balances::reserved_balance(j), if j == i { j } else { 0 }); assert_eq!(Balances::reserved_balance(j), if j == i { j } else { 0 });
assert_eq!(Balances::free_balance(j), if j == i { j * 9 } else { j * 10 }); assert_eq!(Balances::free_balance(j), if j == i { j * 9 } else { j * 10 });
@@ -1327,11 +1327,11 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 0, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 0, 1));
for i in 1..6u64 { for i in 1..6u64 {
run_to_block(((i - 1) / 2 + 1) as _); run_to_block(((i - 1) / 2 + 1) as _);
assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
for j in 1..6 { for j in 1..6 {
assert_eq!(Balances::reserved_balance(j), if j <= i { j } else { 0 }); assert_eq!(Balances::reserved_balance(j), if j <= i { j } else { 0 });
assert_eq!(Balances::free_balance(j), if j <= i { j * 9 } else { j * 10 }); assert_eq!(Balances::free_balance(j), if j <= i { j * 9 } else { j * 10 });
@@ -1405,19 +1405,19 @@ mod tests {
fn lower_bids_are_correctly_refunded() { fn lower_bids_are_correctly_refunded() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 1, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 1, 1));
let para_1 = ParaId::from(1_u32); let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32); let para_2 = ParaId::from(2_u32);
// Make a bid and reserve a balance // Make a bid and reserve a balance
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
assert_eq!(Balances::reserved_balance(1), 10); assert_eq!(Balances::reserved_balance(1), 10);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(10)); assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(10));
assert_eq!(Balances::reserved_balance(2), 0); assert_eq!(Balances::reserved_balance(2), 0);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), None); assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), None);
// Bigger bid, reserves new balance and returns funds // Bigger bid, reserves new balance and returns funds
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 1, 4, 20)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 20));
assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), None); assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), None);
assert_eq!(Balances::reserved_balance(2), 20); assert_eq!(Balances::reserved_balance(2), 20);
@@ -1429,14 +1429,14 @@ mod tests {
fn initialize_winners_in_ending_period_works() { fn initialize_winners_in_ending_period_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
let para_1 = ParaId::from(1_u32); let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32); let para_2 = ParaId::from(2_u32);
let para_3 = ParaId::from(3_u32); let para_3 = ParaId::from(3_u32);
// Make bids // Make bids
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 3, 4, 20)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 20));
assert_eq!( assert_eq!(
Auctions::auction_status(System::block_number()), Auctions::auction_status(System::block_number()),
@@ -1466,7 +1466,7 @@ mod tests {
AuctionStatus::<u32>::EndingPeriod(1, 0) AuctionStatus::<u32>::EndingPeriod(1, 0)
); );
assert_eq!(Auctions::winning(1), Some(winning)); assert_eq!(Auctions::winning(1), Some(winning));
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 3, 4, 30)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 30));
run_to_block(12); run_to_block(12);
assert_eq!( assert_eq!(
@@ -1482,9 +1482,9 @@ mod tests {
fn handle_bid_requires_registered_para() { fn handle_bid_requires_registered_para() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_noop!( assert_noop!(
Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1), Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1),
Error::<Test>::ParaNotRegistered Error::<Test>::ParaNotRegistered
); );
assert_ok!(TestRegistrar::<Test>::register( assert_ok!(TestRegistrar::<Test>::register(
@@ -1493,7 +1493,7 @@ mod tests {
dummy_head_data(), dummy_head_data(),
dummy_validation_code() dummy_validation_code()
)); ));
assert_ok!(Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1));
}); });
} }
@@ -1501,8 +1501,8 @@ mod tests {
fn handle_bid_checks_existing_lease_periods() { fn handle_bid_checks_existing_lease_periods() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 2, 3, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 2, 3, 1));
assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9); assert_eq!(Balances::free_balance(1), 9);
run_to_block(9); run_to_block(9);
@@ -1518,21 +1518,21 @@ mod tests {
// Para 1 just won an auction above and won some lease periods. // Para 1 just won an auction above and won some lease periods.
// No bids can work which overlap these periods. // No bids can work which overlap these periods.
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_noop!( assert_noop!(
Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 4, 1), Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 4, 1),
Error::<Test>::AlreadyLeasedOut, Error::<Test>::AlreadyLeasedOut,
); );
assert_noop!( assert_noop!(
Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 2, 1), Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 2, 1),
Error::<Test>::AlreadyLeasedOut, Error::<Test>::AlreadyLeasedOut,
); );
assert_noop!( assert_noop!(
Auctions::bid(Origin::signed(1), 0.into(), 2, 3, 4, 1), Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 3, 4, 1),
Error::<Test>::AlreadyLeasedOut, Error::<Test>::AlreadyLeasedOut,
); );
// This is okay, not an overlapping bid. // This is okay, not an overlapping bid.
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 1, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 1, 1));
}); });
} }
@@ -1544,14 +1544,14 @@ mod tests {
SampleLength::set(10); SampleLength::set(10);
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
let para_1 = ParaId::from(1_u32); let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32); let para_2 = ParaId::from(2_u32);
let para_3 = ParaId::from(3_u32); let para_3 = ParaId::from(3_u32);
// Make bids // Make bids
assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 11, 14, 10)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 10));
assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 13, 14, 20)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 20));
assert_eq!( assert_eq!(
Auctions::auction_status(System::block_number()), Auctions::auction_status(System::block_number()),
@@ -1576,7 +1576,7 @@ mod tests {
assert_eq!(Auctions::winning(0), Some(winning)); assert_eq!(Auctions::winning(0), Some(winning));
// New bids update the current winning // New bids update the current winning
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 14, 14, 30)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 30));
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 30)); winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 30));
assert_eq!(Auctions::winning(0), Some(winning)); assert_eq!(Auctions::winning(0), Some(winning));
@@ -1588,7 +1588,7 @@ mod tests {
assert_eq!(Auctions::winning(1), Some(winning)); assert_eq!(Auctions::winning(1), Some(winning));
run_to_block(25); run_to_block(25);
// Overbid mid sample // Overbid mid sample
assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 13, 14, 30)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 30));
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30)); winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30));
assert_eq!(Auctions::winning(1), Some(winning)); assert_eq!(Auctions::winning(1), Some(winning));
@@ -1629,7 +1629,7 @@ mod tests {
); );
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
run_to_block(9); run_to_block(9);
assert_eq!( assert_eq!(
@@ -1704,13 +1704,13 @@ mod tests {
fn can_cancel_auction() { fn can_cancel_auction() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9); assert_eq!(Balances::free_balance(1), 9);
assert_noop!(Auctions::cancel_auction(Origin::signed(6)), BadOrigin); assert_noop!(Auctions::cancel_auction(RuntimeOrigin::signed(6)), BadOrigin);
assert_ok!(Auctions::cancel_auction(Origin::root())); assert_ok!(Auctions::cancel_auction(RuntimeOrigin::root()));
assert!(AuctionInfo::<Test>::get().is_none()); assert!(AuctionInfo::<Test>::get().is_none());
assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(Balances::reserved_balance(1), 0);
@@ -1784,7 +1784,7 @@ mod benchmarking {
let duration = T::BlockNumber::max_value(); let duration = T::BlockNumber::max_value();
let lease_period_index = LeasePeriodOf::<T>::max_value(); let lease_period_index = LeasePeriodOf::<T>::max_value();
let origin = T::InitiateOrigin::successful_origin(); let origin = T::InitiateOrigin::successful_origin();
}: _<T::Origin>(origin, duration, lease_period_index) }: _<T::RuntimeOrigin>(origin, duration, lease_period_index)
verify { verify {
assert_last_event::<T>(Event::<T>::AuctionStarted { assert_last_event::<T>(Event::<T>::AuctionStarted {
auction_index: AuctionCounter::<T>::get(), auction_index: AuctionCounter::<T>::get(),
+114 -45
View File
@@ -176,7 +176,7 @@ pub mod pallet {
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>; type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>;
#[pallet::constant] #[pallet::constant]
type Prefix: Get<&'static [u8]>; type Prefix: Get<&'static [u8]>;
type MoveClaimOrigin: EnsureOrigin<Self::Origin>; type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
} }
@@ -750,7 +750,7 @@ mod tests {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -885,7 +885,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&alice(), &42u64.encode(), &[][..]) sig::<Test>(&alice(), &42u64.encode(), &[][..])
)); ));
@@ -900,16 +900,25 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None), Claims::move_claim(RuntimeOrigin::signed(1), eth(&alice()), eth(&bob()), None),
BadOrigin BadOrigin
); );
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None)); assert_ok!(Claims::move_claim(
RuntimeOrigin::signed(6),
eth(&alice()),
eth(&bob()),
None
));
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&bob(), &42u64.encode(), &[][..]) sig::<Test>(&bob(), &42u64.encode(), &[][..])
)); ));
@@ -922,10 +931,15 @@ mod tests {
#[test] #[test]
fn claim_attest_moving_works() { fn claim_attest_moving_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None)); assert_ok!(Claims::move_claim(
RuntimeOrigin::signed(6),
eth(&dave()),
eth(&bob()),
None
));
let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest( assert_ok!(Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
42, 42,
s, s,
StatementKind::Regular.to_text().to_vec() StatementKind::Regular.to_text().to_vec()
@@ -937,8 +951,16 @@ mod tests {
#[test] #[test]
fn attest_moving_works() { fn attest_moving_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&eve()), eth(&bob()), Some(42))); assert_ok!(Claims::move_claim(
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); RuntimeOrigin::signed(6),
eth(&eve()),
eth(&bob()),
Some(42)
));
assert_ok!(Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 300); assert_eq!(Balances::free_balance(&42), 300);
}); });
} }
@@ -947,20 +969,28 @@ mod tests {
fn claiming_does_not_bypass_signing() { fn claiming_does_not_bypass_signing() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&alice(), &42u64.encode(), &[][..]) sig::<Test>(&alice(), &42u64.encode(), &[][..])
)); ));
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&dave(), &42u64.encode(), &[][..])
),
Error::<Test>::InvalidStatement, Error::<Test>::InvalidStatement,
); );
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&eve(), &42u64.encode(), &[][..])
),
Error::<Test>::InvalidStatement, Error::<Test>::InvalidStatement,
); );
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&frank(), &42u64.encode(), &[][..]) sig::<Test>(&frank(), &42u64.encode(), &[][..])
)); ));
@@ -973,7 +1003,7 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = Claims::claim_attest( let r = Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
42, 42,
s.clone(), s.clone(),
StatementKind::Saft.to_text().to_vec(), StatementKind::Saft.to_text().to_vec(),
@@ -981,7 +1011,7 @@ mod tests {
assert_noop!(r, Error::<Test>::InvalidStatement); assert_noop!(r, Error::<Test>::InvalidStatement);
let r = Claims::claim_attest( let r = Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
42, 42,
s, s,
StatementKind::Regular.to_text().to_vec(), StatementKind::Regular.to_text().to_vec(),
@@ -992,7 +1022,7 @@ mod tests {
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest( assert_ok!(Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
42, 42,
s, s,
StatementKind::Regular.to_text().to_vec() StatementKind::Regular.to_text().to_vec()
@@ -1002,7 +1032,7 @@ mod tests {
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
let r = Claims::claim_attest( let r = Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
42, 42,
s, s,
StatementKind::Regular.to_text().to_vec(), StatementKind::Regular.to_text().to_vec(),
@@ -1016,14 +1046,20 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::attest(Origin::signed(69), StatementKind::Saft.to_text().to_vec()), Claims::attest(RuntimeOrigin::signed(69), StatementKind::Saft.to_text().to_vec()),
Error::<Test>::SenderHasNoClaim Error::<Test>::SenderHasNoClaim
); );
assert_noop!( assert_noop!(
Claims::attest(Origin::signed(42), StatementKind::Regular.to_text().to_vec()), Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Regular.to_text().to_vec()
),
Error::<Test>::InvalidStatement Error::<Test>::InvalidStatement
); );
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); assert_ok!(Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 300); assert_eq!(Balances::free_balance(&42), 300);
assert_eq!(Claims::total(), total_claims() - 300); assert_eq!(Claims::total(), total_claims() - 300);
}); });
@@ -1035,13 +1071,16 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
// Alice's claim is 100 // Alice's claim is 100
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&alice(), &42u64.encode(), &[][..]) sig::<Test>(&alice(), &42u64.encode(), &[][..])
)); ));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42 // Eve's claim is 300 through Account 42
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); assert_ok!(Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 100 + 300); assert_eq!(Balances::free_balance(&42), 100 + 300);
assert_eq!(Claims::total(), total_claims() - 400); assert_eq!(Claims::total(), total_claims() - 400);
}); });
@@ -1085,7 +1124,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), &[]); let s = sig::<Test>(&dave(), &42u64.encode(), &[]);
let r = Claims::claim(Origin::none(), 42, s.clone()); let r = Claims::claim(RuntimeOrigin::none(), 42, s.clone());
assert_noop!(r, Error::<Test>::InvalidStatement); assert_noop!(r, Error::<Test>::InvalidStatement);
}); });
} }
@@ -1094,18 +1133,22 @@ mod tests {
fn add_claim_works() { fn add_claim_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_noop!( assert_noop!(
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, None, None), Claims::mint_claim(RuntimeOrigin::signed(42), eth(&bob()), 200, None, None),
sp_runtime::traits::BadOrigin, sp_runtime::traits::BadOrigin,
); );
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim, Error::<Test>::SignerHasNoClaim,
); );
assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, None)); assert_ok!(Claims::mint_claim(RuntimeOrigin::root(), eth(&bob()), 200, None, None));
assert_eq!(Claims::total(), total_claims() + 200); assert_eq!(Claims::total(), total_claims() + 200);
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
69, 69,
sig::<Test>(&bob(), &69u64.encode(), &[][..]) sig::<Test>(&bob(), &69u64.encode(), &[][..])
)); ));
@@ -1119,23 +1162,33 @@ mod tests {
fn add_claim_with_vesting_works() { fn add_claim_with_vesting_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_noop!( assert_noop!(
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, Some((50, 10, 1)), None), Claims::mint_claim(
RuntimeOrigin::signed(42),
eth(&bob()),
200,
Some((50, 10, 1)),
None
),
sp_runtime::traits::BadOrigin, sp_runtime::traits::BadOrigin,
); );
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim, Error::<Test>::SignerHasNoClaim,
); );
assert_ok!(Claims::mint_claim( assert_ok!(Claims::mint_claim(
Origin::root(), RuntimeOrigin::root(),
eth(&bob()), eth(&bob()),
200, 200,
Some((50, 10, 1)), Some((50, 10, 1)),
None None
)); ));
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
69, 69,
sig::<Test>(&bob(), &69u64.encode(), &[][..]) sig::<Test>(&bob(), &69u64.encode(), &[][..])
)); ));
@@ -1160,7 +1213,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_noop!( assert_noop!(
Claims::mint_claim( Claims::mint_claim(
Origin::signed(42), RuntimeOrigin::signed(42),
eth(&bob()), eth(&bob()),
200, 200,
None, None,
@@ -1172,7 +1225,7 @@ mod tests {
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text()); let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
assert_noop!( assert_noop!(
Claims::claim_attest( Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
69, 69,
signature.clone(), signature.clone(),
StatementKind::Regular.to_text().to_vec() StatementKind::Regular.to_text().to_vec()
@@ -1180,18 +1233,18 @@ mod tests {
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
assert_ok!(Claims::mint_claim( assert_ok!(Claims::mint_claim(
Origin::root(), RuntimeOrigin::root(),
eth(&bob()), eth(&bob()),
200, 200,
None, None,
Some(StatementKind::Regular) Some(StatementKind::Regular)
)); ));
assert_noop!( assert_noop!(
Claims::claim_attest(Origin::none(), 69, signature.clone(), vec![],), Claims::claim_attest(RuntimeOrigin::none(), 69, signature.clone(), vec![],),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
assert_ok!(Claims::claim_attest( assert_ok!(Claims::claim_attest(
Origin::none(), RuntimeOrigin::none(),
69, 69,
signature.clone(), signature.clone(),
StatementKind::Regular.to_text().to_vec() StatementKind::Regular.to_text().to_vec()
@@ -1206,7 +1259,7 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_err!( assert_err!(
Claims::claim( Claims::claim(
Origin::signed(42), RuntimeOrigin::signed(42),
42, 42,
sig::<Test>(&alice(), &42u64.encode(), &[][..]) sig::<Test>(&alice(), &42u64.encode(), &[][..])
), ),
@@ -1220,12 +1273,16 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim( assert_ok!(Claims::claim(
Origin::none(), RuntimeOrigin::none(),
42, 42,
sig::<Test>(&alice(), &42u64.encode(), &[][..]) sig::<Test>(&alice(), &42u64.encode(), &[][..])
)); ));
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
@@ -1244,7 +1301,7 @@ mod tests {
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims()); CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims()); assert_eq!(Balances::free_balance(69), total_claims());
assert_ok!(Claims::mint_claim( assert_ok!(Claims::mint_claim(
Origin::root(), RuntimeOrigin::root(),
eth(&bob()), eth(&bob()),
200, 200,
Some((50, 10, 1)), Some((50, 10, 1)),
@@ -1255,7 +1312,11 @@ mod tests {
// They should not be able to claim // They should not be able to claim
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::VestedBalanceExists, Error::<Test>::VestedBalanceExists,
); );
}); });
@@ -1266,7 +1327,11 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &69u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
@@ -1277,7 +1342,11 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::none(), 42, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
+126 -96
View File
@@ -892,7 +892,7 @@ mod tests {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -1168,7 +1168,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let para = new_para(); let para = new_para();
// Now try to create a crowdloan campaign // Now try to create a crowdloan campaign
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
// This is what the initial `fund_info` should look like // This is what the initial `fund_info` should look like
let fund_info = FundInfo { let fund_info = FundInfo {
depositor: 1, depositor: 1,
@@ -1201,7 +1201,7 @@ mod tests {
let para = new_para(); let para = new_para();
// Now try to create a crowdloan campaign // Now try to create a crowdloan campaign
assert_ok!(Crowdloan::create( assert_ok!(Crowdloan::create(
Origin::signed(1), RuntimeOrigin::signed(1),
para, para,
1000, 1000,
1, 1,
@@ -1241,12 +1241,15 @@ mod tests {
let para = new_para(); let para = new_para();
let e = Error::<Test>::InvalidParaId; let e = Error::<Test>::InvalidParaId;
assert_noop!(Crowdloan::create(Origin::signed(1), 1.into(), 1000, 1, 4, 9, None), e); assert_noop!(
Crowdloan::create(RuntimeOrigin::signed(1), 1.into(), 1000, 1, 4, 9, None),
e
);
// Cannot create a crowdloan with bad lease periods // Cannot create a crowdloan with bad lease periods
let e = Error::<Test>::LastPeriodBeforeFirstPeriod; let e = Error::<Test>::LastPeriodBeforeFirstPeriod;
assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 4, 1, 9, None), e); assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 4, 1, 9, None), e);
let e = Error::<Test>::LastPeriodTooFarInFuture; let e = Error::<Test>::LastPeriodTooFarInFuture;
assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 9, 9, None), e); assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 9, 9, None), e);
// Cannot create a crowdloan without some deposit funds // Cannot create a crowdloan without some deposit funds
assert_ok!(TestRegistrar::<Test>::register( assert_ok!(TestRegistrar::<Test>::register(
@@ -1257,14 +1260,22 @@ mod tests {
)); ));
let e = BalancesError::<Test, _>::InsufficientBalance; let e = BalancesError::<Test, _>::InsufficientBalance;
assert_noop!( assert_noop!(
Crowdloan::create(Origin::signed(1337), ParaId::from(1234), 1000, 1, 3, 9, None), Crowdloan::create(
RuntimeOrigin::signed(1337),
ParaId::from(1234),
1000,
1,
3,
9,
None
),
e e
); );
// Cannot create a crowdloan with nonsense end date // Cannot create a crowdloan with nonsense end date
// This crowdloan would end in lease period 2, but is bidding for some slot that starts in lease period 1. // This crowdloan would end in lease period 2, but is bidding for some slot that starts in lease period 1.
assert_noop!( assert_noop!(
Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 41, None), Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 41, None),
Error::<Test>::EndTooFarInFuture Error::<Test>::EndTooFarInFuture
); );
}); });
@@ -1277,13 +1288,13 @@ mod tests {
let index = NextFundIndex::<Test>::get(); let index = NextFundIndex::<Test>::get();
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
// No contributions yet // No contributions yet
assert_eq!(Crowdloan::contribution_get(u32::from(para), &1).0, 0); assert_eq!(Crowdloan::contribution_get(u32::from(para), &1).0, 0);
// User 1 contributes to their own crowdloan // User 1 contributes to their own crowdloan
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 49, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None));
// User 1 has spent some funds to do this, transfer fees **are** taken // User 1 has spent some funds to do this, transfer fees **are** taken
assert_eq!(Balances::free_balance(1), 950); assert_eq!(Balances::free_balance(1), 950);
// Contributions are stored in the trie // Contributions are stored in the trie
@@ -1309,7 +1320,7 @@ mod tests {
let pubkey = crypto::create_ed25519_pubkey(b"//verifier".to_vec()); let pubkey = crypto::create_ed25519_pubkey(b"//verifier".to_vec());
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create( assert_ok!(Crowdloan::create(
Origin::signed(1), RuntimeOrigin::signed(1),
para, para,
1000, 1000,
1, 1,
@@ -1323,7 +1334,7 @@ mod tests {
// Missing signature // Missing signature
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 49, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
Error::<Test>::InvalidSignature Error::<Test>::InvalidSignature
); );
@@ -1335,23 +1346,33 @@ mod tests {
// Invalid signature // Invalid signature
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 49, Some(invalid_signature)), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(invalid_signature)),
Error::<Test>::InvalidSignature Error::<Test>::InvalidSignature
); );
// Valid signature wrong parameter // Valid signature wrong parameter
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 50, Some(valid_signature.clone())), Crowdloan::contribute(
RuntimeOrigin::signed(1),
para,
50,
Some(valid_signature.clone())
),
Error::<Test>::InvalidSignature Error::<Test>::InvalidSignature
); );
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(2), para, 49, Some(valid_signature.clone())), Crowdloan::contribute(
RuntimeOrigin::signed(2),
para,
49,
Some(valid_signature.clone())
),
Error::<Test>::InvalidSignature Error::<Test>::InvalidSignature
); );
// Valid signature // Valid signature
assert_ok!(Crowdloan::contribute( assert_ok!(Crowdloan::contribute(
Origin::signed(1), RuntimeOrigin::signed(1),
para, para,
49, 49,
Some(valid_signature.clone()) Some(valid_signature.clone())
@@ -1359,7 +1380,7 @@ mod tests {
// Reuse valid signature // Reuse valid signature
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 49, Some(valid_signature)), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(valid_signature)),
Error::<Test>::InvalidSignature Error::<Test>::InvalidSignature
); );
@@ -1367,7 +1388,12 @@ mod tests {
let valid_signature_2 = crypto::create_ed25519_signature(&payload_2.encode(), pubkey); let valid_signature_2 = crypto::create_ed25519_signature(&payload_2.encode(), pubkey);
// New valid signature // New valid signature
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 10, Some(valid_signature_2))); assert_ok!(Crowdloan::contribute(
RuntimeOrigin::signed(1),
para,
10,
Some(valid_signature_2)
));
// Contributions appear in free balance of crowdloan // Contributions appear in free balance of crowdloan
assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 59); assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 59);
@@ -1385,22 +1411,22 @@ mod tests {
// Cannot contribute to non-existing fund // Cannot contribute to non-existing fund
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 49, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
Error::<Test>::InvalidParaId Error::<Test>::InvalidParaId
); );
// Cannot contribute below minimum contribution // Cannot contribute below minimum contribution
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 9, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 9, None),
Error::<Test>::ContributionTooSmall Error::<Test>::ContributionTooSmall
); );
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 101, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 101, None));
// Cannot contribute past the limit // Cannot contribute past the limit
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(2), para, 900, None), Crowdloan::contribute(RuntimeOrigin::signed(2), para, 900, None),
Error::<Test>::CapExceeded Error::<Test>::CapExceeded
); );
@@ -1409,31 +1435,31 @@ mod tests {
// Cannot contribute to ended fund // Cannot contribute to ended fund
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para, 49, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None),
Error::<Test>::ContributionPeriodOver Error::<Test>::ContributionPeriodOver
); );
// If a crowdloan has already won, it should not allow contributions. // If a crowdloan has already won, it should not allow contributions.
let para_2 = new_para(); let para_2 = new_para();
let index = NextFundIndex::<Test>::get(); let index = NextFundIndex::<Test>::get();
assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 4, 40, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 4, 40, None));
// Emulate a win by leasing out and putting a deposit. Slots pallet would normally do this. // Emulate a win by leasing out and putting a deposit. Slots pallet would normally do this.
let crowdloan_account = Crowdloan::fund_account_id(index); let crowdloan_account = Crowdloan::fund_account_id(index);
set_winner(para_2, crowdloan_account, true); set_winner(para_2, crowdloan_account, true);
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para_2, 49, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para_2, 49, None),
Error::<Test>::BidOrLeaseActive Error::<Test>::BidOrLeaseActive
); );
// Move past lease period 1, should not be allowed to have further contributions with a crowdloan // Move past lease period 1, should not be allowed to have further contributions with a crowdloan
// that has starting period 1. // that has starting period 1.
let para_3 = new_para(); let para_3 = new_para();
assert_ok!(Crowdloan::create(Origin::signed(1), para_3, 1000, 1, 4, 40, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_3, 1000, 1, 4, 40, None));
run_to_block(40); run_to_block(40);
let now = System::block_number(); let now = System::block_number();
assert_eq!(TestAuctioneer::lease_period_index(now).unwrap().0, 2); assert_eq!(TestAuctioneer::lease_period_index(now).unwrap().0, 2);
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(1), para_3, 49, None), Crowdloan::contribute(RuntimeOrigin::signed(1), para_3, 49, None),
Error::<Test>::ContributionPeriodOver Error::<Test>::ContributionPeriodOver
); );
}); });
@@ -1452,7 +1478,7 @@ mod tests {
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create( assert_ok!(Crowdloan::create(
Origin::signed(1), RuntimeOrigin::signed(1),
para, para,
1000, 1000,
first_period, first_period,
@@ -1464,20 +1490,20 @@ mod tests {
run_to_block(8); run_to_block(8);
// Can def contribute when auction is running. // Can def contribute when auction is running.
assert!(TestAuctioneer::auction_status(System::block_number()).is_ending().is_some()); assert!(TestAuctioneer::auction_status(System::block_number()).is_ending().is_some());
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
run_to_block(10); run_to_block(10);
// Can't contribute when auction is in the VRF delay period. // Can't contribute when auction is in the VRF delay period.
assert!(TestAuctioneer::auction_status(System::block_number()).is_vrf()); assert!(TestAuctioneer::auction_status(System::block_number()).is_vrf());
assert_noop!( assert_noop!(
Crowdloan::contribute(Origin::signed(2), para, 250, None), Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None),
Error::<Test>::VrfDelayInProgress Error::<Test>::VrfDelayInProgress
); );
run_to_block(15); run_to_block(15);
// Its fine to contribute when no auction is running. // Its fine to contribute when no auction is running.
assert!(!TestAuctioneer::auction_status(System::block_number()).is_in_progress()); assert!(!TestAuctioneer::auction_status(System::block_number()).is_in_progress());
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
}) })
} }
@@ -1493,7 +1519,7 @@ mod tests {
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create( assert_ok!(Crowdloan::create(
Origin::signed(1), RuntimeOrigin::signed(1),
para, para,
1000, 1000,
first_period, first_period,
@@ -1505,13 +1531,13 @@ mod tests {
// Fund crowdloan // Fund crowdloan
run_to_block(1); run_to_block(1);
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
run_to_block(3); run_to_block(3);
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 150, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 150, None));
run_to_block(5); run_to_block(5);
assert_ok!(Crowdloan::contribute(Origin::signed(4), para, 200, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(4), para, 200, None));
run_to_block(8); run_to_block(8);
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None));
run_to_block(10); run_to_block(10);
assert_eq!( assert_eq!(
@@ -1535,9 +1561,9 @@ mod tests {
let index = NextFundIndex::<Test>::get(); let index = NextFundIndex::<Test>::get();
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
run_to_block(10); run_to_block(10);
let account_id = Crowdloan::fund_account_id(index); let account_id = Crowdloan::fund_account_id(index);
@@ -1548,11 +1574,11 @@ mod tests {
assert_eq!(Balances::free_balance(2), 1900); assert_eq!(Balances::free_balance(2), 1900);
assert_eq!(Balances::free_balance(3), 2950); assert_eq!(Balances::free_balance(3), 2950);
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
assert_eq!(Balances::free_balance(&account_id), 50); assert_eq!(Balances::free_balance(&account_id), 50);
assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(2), 2000);
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para)); assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para));
assert_eq!(Balances::free_balance(&account_id), 0); assert_eq!(Balances::free_balance(&account_id), 0);
assert_eq!(Balances::free_balance(3), 3000); assert_eq!(Balances::free_balance(3), 3000);
}); });
@@ -1565,26 +1591,26 @@ mod tests {
let index = NextFundIndex::<Test>::get(); let index = NextFundIndex::<Test>::get();
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
run_to_block(10); run_to_block(10);
let account_id = Crowdloan::fund_account_id(index); let account_id = Crowdloan::fund_account_id(index);
// user sends the crowdloan funds trying to make an accounting error // user sends the crowdloan funds trying to make an accounting error
assert_ok!(Balances::transfer(Origin::signed(1), account_id, 10)); assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), account_id, 10));
// overfunded now // overfunded now
assert_eq!(Balances::free_balance(&account_id), 110); assert_eq!(Balances::free_balance(&account_id), 110);
assert_eq!(Balances::free_balance(2), 1900); assert_eq!(Balances::free_balance(2), 1900);
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(2), 2000);
// Some funds are left over // Some funds are left over
assert_eq!(Balances::free_balance(&account_id), 10); assert_eq!(Balances::free_balance(&account_id), 10);
// They wil be left in the account at the end // They wil be left in the account at the end
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
assert_eq!(Balances::free_balance(&account_id), 10); assert_eq!(Balances::free_balance(&account_id), 10);
}); });
} }
@@ -1597,23 +1623,23 @@ mod tests {
let account_id = Crowdloan::fund_account_id(index); let account_id = Crowdloan::fund_account_id(index);
// Set up a crowdloan ending on 9 // Set up a crowdloan ending on 9
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
// Make some contributions // Make some contributions
assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 200, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 200, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 300, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 300, None));
assert_eq!(Balances::free_balance(account_id), 600); assert_eq!(Balances::free_balance(account_id), 600);
// Can't refund before the crowdloan it has ended // Can't refund before the crowdloan it has ended
assert_noop!( assert_noop!(
Crowdloan::refund(Origin::signed(1337), para), Crowdloan::refund(RuntimeOrigin::signed(1337), para),
Error::<Test>::FundNotEnded, Error::<Test>::FundNotEnded,
); );
// Move to the end of the crowdloan // Move to the end of the crowdloan
run_to_block(10); run_to_block(10);
assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
// Funds are returned // Funds are returned
assert_eq!(Balances::free_balance(account_id), 0); assert_eq!(Balances::free_balance(account_id), 0);
@@ -1632,12 +1658,12 @@ mod tests {
let account_id = Crowdloan::fund_account_id(index); let account_id = Crowdloan::fund_account_id(index);
// Set up a crowdloan ending on 9 // Set up a crowdloan ending on 9
assert_ok!(Crowdloan::create(Origin::signed(1), para, 100000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 100000, 1, 1, 9, None));
// Make more contributions than our limit // Make more contributions than our limit
for i in 1..=RemoveKeysLimit::get() * 2 { for i in 1..=RemoveKeysLimit::get() * 2 {
Balances::make_free_balance_be(&i.into(), (1000 * i).into()); Balances::make_free_balance_be(&i.into(), (1000 * i).into());
assert_ok!(Crowdloan::contribute( assert_ok!(Crowdloan::contribute(
Origin::signed(i.into()), RuntimeOrigin::signed(i.into()),
para, para,
(i * 100).into(), (i * 100).into(),
None None
@@ -1648,7 +1674,7 @@ mod tests {
// Move to the end of the crowdloan // Move to the end of the crowdloan
run_to_block(10); run_to_block(10);
assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
assert_eq!( assert_eq!(
last_event(), last_event(),
super::Event::<Test>::PartiallyRefunded { para_id: para }.into() super::Event::<Test>::PartiallyRefunded { para_id: para }.into()
@@ -1658,7 +1684,7 @@ mod tests {
assert!(!Balances::free_balance(account_id).is_zero()); assert!(!Balances::free_balance(account_id).is_zero());
// Call again // Call again
assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para));
assert_eq!(last_event(), super::Event::<Test>::AllRefunded { para_id: para }.into()); assert_eq!(last_event(), super::Event::<Test>::AllRefunded { para_id: para }.into());
// Funds are returned // Funds are returned
@@ -1677,16 +1703,16 @@ mod tests {
let issuance = Balances::total_issuance(); let issuance = Balances::total_issuance();
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
run_to_block(10); run_to_block(10);
// All funds are refunded // All funds are refunded
assert_ok!(Crowdloan::refund(Origin::signed(2), para)); assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para));
// Now that `fund.raised` is zero, it can be dissolved. // Now that `fund.raised` is zero, it can be dissolved.
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
assert_eq!(Balances::free_balance(1), 1000); assert_eq!(Balances::free_balance(1), 1000);
assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(2), 2000);
assert_eq!(Balances::free_balance(3), 3000); assert_eq!(Balances::free_balance(3), 3000);
@@ -1701,13 +1727,13 @@ mod tests {
let issuance = Balances::total_issuance(); let issuance = Balances::total_issuance();
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
// Can't dissolve before it ends // Can't dissolve before it ends
assert_noop!( assert_noop!(
Crowdloan::dissolve(Origin::signed(1), para), Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
Error::<Test>::NotReadyToDissolve Error::<Test>::NotReadyToDissolve
); );
@@ -1715,22 +1741,22 @@ mod tests {
set_winner(para, 1, true); set_winner(para, 1, true);
// Can't dissolve when it won. // Can't dissolve when it won.
assert_noop!( assert_noop!(
Crowdloan::dissolve(Origin::signed(1), para), Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
Error::<Test>::NotReadyToDissolve Error::<Test>::NotReadyToDissolve
); );
set_winner(para, 1, false); set_winner(para, 1, false);
// Can't dissolve while it still has user funds // Can't dissolve while it still has user funds
assert_noop!( assert_noop!(
Crowdloan::dissolve(Origin::signed(1), para), Crowdloan::dissolve(RuntimeOrigin::signed(1), para),
Error::<Test>::NotReadyToDissolve Error::<Test>::NotReadyToDissolve
); );
// All funds are refunded // All funds are refunded
assert_ok!(Crowdloan::refund(Origin::signed(2), para)); assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para));
// Now that `fund.raised` is zero, it can be dissolved. // Now that `fund.raised` is zero, it can be dissolved.
assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para));
assert_eq!(Balances::free_balance(1), 1000); assert_eq!(Balances::free_balance(1), 1000);
assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(2), 2000);
assert_eq!(Balances::free_balance(3), 3000); assert_eq!(Balances::free_balance(3), 3000);
@@ -1746,17 +1772,17 @@ mod tests {
let account_id = Crowdloan::fund_account_id(index); let account_id = Crowdloan::fund_account_id(index);
// Set up a crowdloan // Set up a crowdloan
assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None));
// Fund crowdloans. // Fund crowdloans.
assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
// simulate the reserving of para's funds. this actually happens in the Slots pallet. // simulate the reserving of para's funds. this actually happens in the Slots pallet.
assert_ok!(Balances::reserve(&account_id, 150)); assert_ok!(Balances::reserve(&account_id, 150));
run_to_block(19); run_to_block(19);
assert_noop!( assert_noop!(
Crowdloan::withdraw(Origin::signed(2), 2, para), Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para),
Error::<Test>::BidOrLeaseActive Error::<Test>::BidOrLeaseActive
); );
@@ -1772,11 +1798,11 @@ mod tests {
assert_eq!(Balances::free_balance(2), 1900); assert_eq!(Balances::free_balance(2), 1900);
assert_eq!(Balances::free_balance(3), 2950); assert_eq!(Balances::free_balance(3), 2950);
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para));
assert_eq!(Balances::free_balance(&account_id), 50); assert_eq!(Balances::free_balance(&account_id), 50);
assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(2), 2000);
assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para)); assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para));
assert_eq!(Balances::free_balance(&account_id), 0); assert_eq!(Balances::free_balance(&account_id), 0);
assert_eq!(Balances::free_balance(3), 3000); assert_eq!(Balances::free_balance(3), 3000);
}); });
@@ -1789,11 +1815,11 @@ mod tests {
let para_2 = new_para(); let para_2 = new_para();
// Set up crowdloans // Set up crowdloans
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 1, 9, None));
// Different contributions // Different contributions
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
assert_ok!(Crowdloan::contribute(Origin::signed(3), para_2, 50, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para_2, 50, None));
// Original state // Original state
assert_eq!(Funds::<Test>::get(para_1).unwrap().raised, 100); assert_eq!(Funds::<Test>::get(para_1).unwrap().raised, 100);
assert_eq!(Funds::<Test>::get(para_2).unwrap().raised, 50); assert_eq!(Funds::<Test>::get(para_2).unwrap().raised, 50);
@@ -1810,10 +1836,10 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let para_1 = new_para(); let para_1 = new_para();
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
// Cannot create a fund again // Cannot create a fund again
assert_noop!( assert_noop!(
Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None), Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None),
Error::<Test>::FundNotEnded, Error::<Test>::FundNotEnded,
); );
}); });
@@ -1824,11 +1850,11 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let para_1 = new_para(); let para_1 = new_para();
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
let old_crowdloan = Crowdloan::funds(para_1).unwrap(); let old_crowdloan = Crowdloan::funds(para_1).unwrap();
assert_ok!(Crowdloan::edit(Origin::root(), para_1, 1234, 2, 3, 4, None)); assert_ok!(Crowdloan::edit(RuntimeOrigin::root(), para_1, 1234, 2, 3, 4, None));
let new_crowdloan = Crowdloan::funds(para_1).unwrap(); let new_crowdloan = Crowdloan::funds(para_1).unwrap();
// Some things stay the same // Some things stay the same
@@ -1848,25 +1874,29 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let para_1 = new_para(); let para_1 = new_para();
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
// Cant add a memo before you have contributed. // Cant add a memo before you have contributed.
assert_noop!( assert_noop!(
Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec()), Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, b"hello, world".to_vec()),
Error::<Test>::NoContributions, Error::<Test>::NoContributions,
); );
// Make a contribution. Initially no memo. // Make a contribution. Initially no memo.
assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None));
assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, vec![])); assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, vec![]));
// Can't place a memo that is too large. // Can't place a memo that is too large.
assert_noop!( assert_noop!(
Crowdloan::add_memo(Origin::signed(1), para_1, vec![123; 123]), Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, vec![123; 123]),
Error::<Test>::MemoTooLarge, Error::<Test>::MemoTooLarge,
); );
// Adding a memo to an existing contribution works // Adding a memo to an existing contribution works
assert_ok!(Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec())); assert_ok!(Crowdloan::add_memo(
RuntimeOrigin::signed(1),
para_1,
b"hello, world".to_vec()
));
assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, b"hello, world".to_vec())); assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, b"hello, world".to_vec()));
// Can contribute again and data persists // Can contribute again and data persists
assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None));
assert_eq!(Crowdloan::contribution_get(0u32, &1), (200, b"hello, world".to_vec())); assert_eq!(Crowdloan::contribution_get(0u32, &1), (200, b"hello, world".to_vec()));
}); });
} }
@@ -1877,18 +1907,18 @@ mod tests {
let para_1 = new_para(); let para_1 = new_para();
assert_ok!(TestAuctioneer::new_auction(5, 0)); assert_ok!(TestAuctioneer::new_auction(5, 0));
assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None));
// Should fail when no contributions. // Should fail when no contributions.
assert_noop!( assert_noop!(
Crowdloan::poke(Origin::signed(1), para_1), Crowdloan::poke(RuntimeOrigin::signed(1), para_1),
Error::<Test>::NoContributions Error::<Test>::NoContributions
); );
assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None));
run_to_block(6); run_to_block(6);
assert_ok!(Crowdloan::poke(Origin::signed(1), para_1)); assert_ok!(Crowdloan::poke(RuntimeOrigin::signed(1), para_1));
assert_eq!(Crowdloan::new_raise(), vec![para_1]); assert_eq!(Crowdloan::new_raise(), vec![para_1]);
assert_noop!( assert_noop!(
Crowdloan::poke(Origin::signed(1), para_1), Crowdloan::poke(RuntimeOrigin::signed(1), para_1),
Error::<Test>::AlreadyInNewRaise Error::<Test>::AlreadyInNewRaise
); );
}); });
+1 -1
View File
@@ -106,7 +106,7 @@ mod tests {
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
@@ -61,9 +61,9 @@ fn account_id(i: u32) -> AccountId32 {
array.into() array.into()
} }
fn signed(i: u32) -> Origin { fn signed(i: u32) -> RuntimeOrigin {
let account_id = account_id(i); let account_id = account_id(i);
Origin::signed(account_id) RuntimeOrigin::signed(account_id)
} }
frame_support::construct_runtime!( frame_support::construct_runtime!(
@@ -112,7 +112,7 @@ impl frame_system::Config for Test {
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -218,7 +218,7 @@ impl paras_registrar::Config for Test {
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
type DataDepositPerByte = DataDepositPerByte; type DataDepositPerByte = DataDepositPerByte;
type Currency = Balances; type Currency = Balances;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type WeightInfo = crate::paras_registrar::TestWeightInfo; type WeightInfo = crate::paras_registrar::TestWeightInfo;
} }
@@ -389,7 +389,11 @@ fn basic_end_to_end_works() {
// Start a new auction in the future // Start a new auction in the future
let duration = 99u32 + offset; let duration = 99u32 + offset;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// 2 sessions later they are parathreads // 2 sessions later they are parathreads
run_to_session(2); run_to_session(2);
@@ -557,7 +561,11 @@ fn basic_errors_fail() {
// Start an auction // Start an auction
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// Cannot create a crowdloan if you do not own the para // Cannot create a crowdloan if you do not own the para
assert_noop!( assert_noop!(
@@ -600,7 +608,11 @@ fn competing_slots() {
// Start a new auction in the future // Start a new auction in the future
let duration = 149u32; let duration = 149u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// Paras should be onboarded // Paras should be onboarded
run_to_block(20); // session 2 run_to_block(20); // session 2
@@ -697,7 +709,11 @@ fn competing_bids() {
let starting_block = System::block_number(); let starting_block = System::block_number();
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
for n in 1..=3 { for n in 1..=3 {
// Create a crowdloan for each para // Create a crowdloan for each para
@@ -799,7 +815,11 @@ fn basic_swap_works() {
// Start a new auction in the future // Start a new auction in the future
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// 2 sessions later they are parathreads // 2 sessions later they are parathreads
run_to_session(2); run_to_session(2);
@@ -955,7 +975,11 @@ fn parachain_swap_works() {
let unique_id = winner - 1999u32; let unique_id = winner - 1999u32;
let starting_block = System::block_number(); let starting_block = System::block_number();
let duration = 99u32; let duration = 99u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// 2 sessions later they are parathreads // 2 sessions later they are parathreads
run_to_block(starting_block + 20); run_to_block(starting_block + 20);
@@ -1106,7 +1130,11 @@ fn crowdloan_ending_period_bid() {
// Start a new auction in the future // Start a new auction in the future
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// 2 sessions later they are parathreads // 2 sessions later they are parathreads
run_to_session(2); run_to_session(2);
@@ -1182,7 +1210,11 @@ fn auction_bid_requires_registered_para() {
// Start a new auction in the future // Start a new auction in the future
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// Can't bid with non-registered paras // Can't bid with non-registered paras
Balances::make_free_balance_be(&account_id(1), 1_000_000_000); Balances::make_free_balance_be(&account_id(1), 1_000_000_000);
@@ -1244,7 +1276,11 @@ fn gap_bids_work() {
// Start a new auction in the future // Start a new auction in the future
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
Balances::make_free_balance_be(&account_id(1), 1_000_000_000); Balances::make_free_balance_be(&account_id(1), 1_000_000_000);
Balances::make_free_balance_be(&account_id(2), 1_000_000_000); Balances::make_free_balance_be(&account_id(2), 1_000_000_000);
@@ -1432,7 +1468,11 @@ fn cant_bid_on_existing_lease_periods() {
let starting_block = System::block_number(); let starting_block = System::block_number();
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// 2 sessions later they are parathreads // 2 sessions later they are parathreads
run_to_session(2); run_to_session(2);
@@ -1480,7 +1520,11 @@ fn cant_bid_on_existing_lease_periods() {
let starting_block = System::block_number(); let starting_block = System::block_number();
let duration = 99u32; let duration = 99u32;
let lease_period_index_start = 4u32; let lease_period_index_start = 4u32;
assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); assert_ok!(Auctions::new_auction(
RuntimeOrigin::root(),
duration,
lease_period_index_start
));
// Poke the crowdloan into `NewRaise` // Poke the crowdloan into `NewRaise`
assert_ok!(Crowdloan::poke(signed(1), ParaId::from(2000))); assert_ok!(Crowdloan::poke(signed(1), ParaId::from(2000)));
@@ -1492,7 +1536,7 @@ fn cant_bid_on_existing_lease_periods() {
// Bids cannot be made which intersect // Bids cannot be made which intersect
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start + 0, lease_period_index_start + 0,
@@ -1504,7 +1548,7 @@ fn cant_bid_on_existing_lease_periods() {
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start + 1, lease_period_index_start + 1,
@@ -1516,7 +1560,7 @@ fn cant_bid_on_existing_lease_periods() {
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start - 1, lease_period_index_start - 1,
@@ -1528,7 +1572,7 @@ fn cant_bid_on_existing_lease_periods() {
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start + 0, lease_period_index_start + 0,
@@ -1540,7 +1584,7 @@ fn cant_bid_on_existing_lease_periods() {
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start + 1, lease_period_index_start + 1,
@@ -1552,7 +1596,7 @@ fn cant_bid_on_existing_lease_periods() {
assert_noop!( assert_noop!(
Auctions::bid( Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start - 1, lease_period_index_start - 1,
@@ -1564,7 +1608,7 @@ fn cant_bid_on_existing_lease_periods() {
// Will work when not overlapping // Will work when not overlapping
assert_ok!(Auctions::bid( assert_ok!(Auctions::bid(
Origin::signed(crowdloan_account.clone()), RuntimeOrigin::signed(crowdloan_account.clone()),
ParaId::from(2000), ParaId::from(2000),
2, 2,
lease_period_index_start + 2, lease_period_index_start + 2,
+61 -57
View File
@@ -102,8 +102,8 @@ pub mod pallet {
/// infallibly convert between this origin and the system origin, but in reality, they're the /// infallibly convert between this origin and the system origin, but in reality, they're the
/// same type, we just can't express that to the Rust type system without writing a `where` /// same type, we just can't express that to the Rust type system without writing a `where`
/// clause everywhere. /// clause everywhere.
type Origin: From<<Self as frame_system::Config>::Origin> type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<result::Result<Origin, <Self as Config>::Origin>>; + Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
/// The system's currency for parathread payment. /// The system's currency for parathread payment.
type Currency: ReservableCurrency<Self::AccountId>; type Currency: ReservableCurrency<Self::AccountId>;
@@ -456,7 +456,7 @@ impl<T: Config> Pallet<T> {
/// Ensure the origin is one of Root, the `para` owner, or the `para` itself. /// Ensure the origin is one of Root, the `para` owner, or the `para` itself.
/// If the origin is the `para` owner, the `para` must be unlocked. /// If the origin is the `para` owner, the `para` must be unlocked.
fn ensure_root_para_or_owner( fn ensure_root_para_or_owner(
origin: <T as frame_system::Config>::Origin, origin: <T as frame_system::Config>::RuntimeOrigin,
id: ParaId, id: ParaId,
) -> DispatchResult { ) -> DispatchResult {
ensure_signed(origin.clone()) ensure_signed(origin.clone())
@@ -469,7 +469,8 @@ impl<T: Config> Pallet<T> {
}) })
.or_else(|_| -> DispatchResult { .or_else(|_| -> DispatchResult {
// Else check if para origin... // Else check if para origin...
let caller_id = ensure_parachain(<T as Config>::Origin::from(origin.clone()))?; let caller_id =
ensure_parachain(<T as Config>::RuntimeOrigin::from(origin.clone()))?;
ensure!(caller_id == id, Error::<T>::NotOwner); ensure!(caller_id == id, Error::<T>::NotOwner);
Ok(()) Ok(())
}) })
@@ -648,7 +649,7 @@ mod tests {
impl frame_system::Config for Test { impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -715,8 +716,8 @@ mod tests {
} }
impl Config for Test { impl Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type OnSwap = MockSwap; type OnSwap = MockSwap;
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
@@ -800,7 +801,7 @@ mod tests {
ValidationCode(validation_code) ValidationCode(validation_code)
} }
fn para_origin(id: ParaId) -> Origin { fn para_origin(id: ParaId) -> RuntimeOrigin {
runtime_parachains::Origin::Parachain(id).into() runtime_parachains::Origin::Parachain(id).into()
} }
@@ -828,9 +829,9 @@ mod tests {
// first para is not yet registered // first para is not yet registered
assert!(!Parachains::is_parathread(para_id)); assert!(!Parachains::is_parathread(para_id));
// We register the Para ID // We register the Para ID
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
@@ -851,7 +852,7 @@ mod tests {
assert!(Parachains::is_parathread(para_id)); assert!(Parachains::is_parathread(para_id));
assert!(!Parachains::is_parachain(para_id)); assert!(!Parachains::is_parachain(para_id));
// Deregister it // Deregister it
assert_ok!(Registrar::deregister(Origin::root(), para_id,)); assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,));
run_to_session(8); run_to_session(8);
// It is nothing // It is nothing
assert!(!Parachains::is_parathread(para_id)); assert!(!Parachains::is_parathread(para_id));
@@ -865,10 +866,10 @@ mod tests {
run_to_block(1); run_to_block(1);
let para_id = LOWEST_PUBLIC_ID; let para_id = LOWEST_PUBLIC_ID;
assert!(!Parachains::is_parathread(para_id)); assert!(!Parachains::is_parathread(para_id));
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_eq!(Balances::reserved_balance(&1), <Test as Config>::ParaDeposit::get()); assert_eq!(Balances::reserved_balance(&1), <Test as Config>::ParaDeposit::get());
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
@@ -890,7 +891,7 @@ mod tests {
assert_noop!( assert_noop!(
Registrar::register( Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -899,11 +900,11 @@ mod tests {
); );
// Successfully register para // Successfully register para
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_noop!( assert_noop!(
Registrar::register( Registrar::register(
Origin::signed(2), RuntimeOrigin::signed(2),
para_id, para_id,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -912,7 +913,7 @@ mod tests {
); );
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -920,12 +921,12 @@ mod tests {
run_to_session(2); run_to_session(2);
assert_ok!(Registrar::deregister(Origin::root(), para_id)); assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id));
// Can't do it again // Can't do it again
assert_noop!( assert_noop!(
Registrar::register( Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -934,10 +935,10 @@ mod tests {
); );
// Head Size Check // Head Size Check
assert_ok!(Registrar::reserve(Origin::signed(2))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
assert_noop!( assert_noop!(
Registrar::register( Registrar::register(
Origin::signed(2), RuntimeOrigin::signed(2),
para_id + 1, para_id + 1,
test_genesis_head((max_head_size() + 1) as usize), test_genesis_head((max_head_size() + 1) as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -948,7 +949,7 @@ mod tests {
// Code Size Check // Code Size Check
assert_noop!( assert_noop!(
Registrar::register( Registrar::register(
Origin::signed(2), RuntimeOrigin::signed(2),
para_id + 1, para_id + 1,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code((max_code_size() + 1) as usize), test_validation_code((max_code_size() + 1) as usize),
@@ -958,7 +959,7 @@ mod tests {
// Needs enough funds for deposit // Needs enough funds for deposit
assert_noop!( assert_noop!(
Registrar::reserve(Origin::signed(1337)), Registrar::reserve(RuntimeOrigin::signed(1337)),
BalancesError::<Test, _>::InsufficientBalance BalancesError::<Test, _>::InsufficientBalance
); );
}); });
@@ -970,16 +971,16 @@ mod tests {
run_to_block(1); run_to_block(1);
let para_id = LOWEST_PUBLIC_ID; let para_id = LOWEST_PUBLIC_ID;
assert!(!Parachains::is_parathread(para_id)); assert!(!Parachains::is_parathread(para_id));
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
)); ));
run_to_session(2); run_to_session(2);
assert!(Parachains::is_parathread(para_id)); assert!(Parachains::is_parathread(para_id));
assert_ok!(Registrar::deregister(Origin::root(), para_id,)); assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,));
run_to_session(4); run_to_session(4);
assert!(paras::Pallet::<Test>::lifecycle(para_id).is_none()); assert!(paras::Pallet::<Test>::lifecycle(para_id).is_none());
assert_eq!(Balances::reserved_balance(&1), 0); assert_eq!(Balances::reserved_balance(&1), 0);
@@ -992,9 +993,9 @@ mod tests {
run_to_block(1); run_to_block(1);
let para_id = LOWEST_PUBLIC_ID; let para_id = LOWEST_PUBLIC_ID;
assert!(!Parachains::is_parathread(para_id)); assert!(!Parachains::is_parathread(para_id));
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
@@ -1002,12 +1003,12 @@ mod tests {
run_to_session(2); run_to_session(2);
assert!(Parachains::is_parathread(para_id)); assert!(Parachains::is_parathread(para_id));
// Owner check // Owner check
assert_noop!(Registrar::deregister(Origin::signed(2), para_id,), BadOrigin); assert_noop!(Registrar::deregister(RuntimeOrigin::signed(2), para_id,), BadOrigin);
assert_ok!(Registrar::make_parachain(para_id)); assert_ok!(Registrar::make_parachain(para_id));
run_to_session(4); run_to_session(4);
// Cant directly deregister parachain // Cant directly deregister parachain
assert_noop!( assert_noop!(
Registrar::deregister(Origin::root(), para_id,), Registrar::deregister(RuntimeOrigin::root(), para_id,),
Error::<Test>::NotParathread Error::<Test>::NotParathread
); );
}); });
@@ -1019,16 +1020,16 @@ mod tests {
// Successfully register first two parachains // Successfully register first two parachains
let para_1 = LOWEST_PUBLIC_ID; let para_1 = LOWEST_PUBLIC_ID;
let para_2 = LOWEST_PUBLIC_ID + 1; let para_2 = LOWEST_PUBLIC_ID + 1;
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_1, para_1,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
)); ));
assert_ok!(Registrar::reserve(Origin::signed(2))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(2), RuntimeOrigin::signed(2),
para_2, para_2,
test_genesis_head(max_head_size() as usize), test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize), test_validation_code(max_code_size() as usize),
@@ -1075,17 +1076,17 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
run_to_block(1); run_to_block(1);
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
let para_id = LOWEST_PUBLIC_ID; let para_id = LOWEST_PUBLIC_ID;
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_id, para_id,
vec![1; 3].into(), vec![1; 3].into(),
vec![1, 2, 3].into(), vec![1, 2, 3].into(),
)); ));
// Owner can call swap // Owner can call swap
assert_ok!(Registrar::swap(Origin::signed(1), para_id, para_id + 1)); assert_ok!(Registrar::swap(RuntimeOrigin::signed(1), para_id, para_id + 1));
// 2 session changes to fully onboard. // 2 session changes to fully onboard.
run_to_session(2); run_to_session(2);
@@ -1095,7 +1096,10 @@ mod tests {
assert_ok!(Registrar::make_parachain(para_id)); assert_ok!(Registrar::make_parachain(para_id));
// Owner cannot call swap anymore // Owner cannot call swap anymore
assert_noop!(Registrar::swap(Origin::signed(1), para_id, para_id + 2), BadOrigin); assert_noop!(
Registrar::swap(RuntimeOrigin::signed(1), para_id, para_id + 2),
BadOrigin
);
}); });
} }
@@ -1111,30 +1115,30 @@ mod tests {
// Cannot even start a swap // Cannot even start a swap
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_1, para_2), Registrar::swap(RuntimeOrigin::root(), para_1, para_2),
Error::<Test>::NotRegistered Error::<Test>::NotRegistered
); );
// We register Paras 1 and 2 // We register Paras 1 and 2
assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(Registrar::reserve(Origin::signed(2))); assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2)));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(1), RuntimeOrigin::signed(1),
para_1, para_1,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
)); ));
assert_ok!(Registrar::register( assert_ok!(Registrar::register(
Origin::signed(2), RuntimeOrigin::signed(2),
para_2, para_2,
test_genesis_head(32), test_genesis_head(32),
test_validation_code(32), test_validation_code(32),
)); ));
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
@@ -1145,9 +1149,9 @@ mod tests {
assert!(Parachains::is_parathread(para_2)); assert!(Parachains::is_parathread(para_2));
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
@@ -1155,18 +1159,18 @@ mod tests {
assert_ok!(Registrar::make_parachain(para_1)); assert_ok!(Registrar::make_parachain(para_1));
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
run_to_session(3); run_to_session(3);
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
@@ -1177,15 +1181,15 @@ mod tests {
assert!(Parachains::is_parathread(para_2)); assert!(Parachains::is_parathread(para_2));
// Swap works here. // Swap works here.
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_ok!(Registrar::swap(Origin::root(), para_2, para_1)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_2, para_1));
run_to_session(5); run_to_session(5);
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
@@ -1201,9 +1205,9 @@ mod tests {
run_to_session(7); run_to_session(7);
// Cannot swap // Cannot swap
assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!( assert_noop!(
Registrar::swap(Origin::root(), para_2, para_1), Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap Error::<Test>::CannotSwap
); );
@@ -1261,7 +1265,7 @@ mod benchmarking {
} }
benchmarks! { benchmarks! {
where_clause { where ParaOrigin: Into<<T as frame_system::Config>::Origin> } where_clause { where ParaOrigin: Into<<T as frame_system::Config>::RuntimeOrigin> }
reserve { reserve {
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
+72 -56
View File
@@ -111,10 +111,10 @@ pub mod pallet {
>; >;
/// The origin allowed to set account status. /// The origin allowed to set account status.
type ValidityOrigin: EnsureOrigin<Self::Origin>; type ValidityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The origin allowed to make configurations to the pallet. /// The origin allowed to make configurations to the pallet.
type ConfigurationOrigin: EnsureOrigin<Self::Origin>; type ConfigurationOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The maximum statement length for the statement users to sign when creating an account. /// The maximum statement length for the statement users to sign when creating an account.
#[pallet::constant] #[pallet::constant]
@@ -510,7 +510,7 @@ mod tests {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -596,10 +596,14 @@ mod tests {
fn setup() { fn setup() {
let statement = b"Hello, World".to_vec(); let statement = b"Hello, World".to_vec();
let unlock_block = 100; let unlock_block = 100;
Purchase::set_statement(Origin::signed(configuration_origin()), statement).unwrap(); Purchase::set_statement(RuntimeOrigin::signed(configuration_origin()), statement).unwrap();
Purchase::set_unlock_block(Origin::signed(configuration_origin()), unlock_block).unwrap(); Purchase::set_unlock_block(RuntimeOrigin::signed(configuration_origin()), unlock_block)
Purchase::set_payment_account(Origin::signed(configuration_origin()), payment_account())
.unwrap(); .unwrap();
Purchase::set_payment_account(
RuntimeOrigin::signed(configuration_origin()),
payment_account(),
)
.unwrap();
Balances::make_free_balance_be(&payment_account(), 100_000); Balances::make_free_balance_be(&payment_account(), 100_000);
} }
@@ -665,18 +669,21 @@ mod tests {
let statement = b"Test Set Statement".to_vec(); let statement = b"Test Set Statement".to_vec();
// Invalid origin // Invalid origin
assert_noop!( assert_noop!(
Purchase::set_statement(Origin::signed(alice()), statement.clone()), Purchase::set_statement(RuntimeOrigin::signed(alice()), statement.clone()),
BadOrigin, BadOrigin,
); );
// Too Long // Too Long
let long_statement = [0u8; 10_000].to_vec(); let long_statement = [0u8; 10_000].to_vec();
assert_noop!( assert_noop!(
Purchase::set_statement(Origin::signed(configuration_origin()), long_statement), Purchase::set_statement(
RuntimeOrigin::signed(configuration_origin()),
long_statement
),
Error::<Test>::InvalidStatement, Error::<Test>::InvalidStatement,
); );
// Just right... // Just right...
assert_ok!(Purchase::set_statement( assert_ok!(Purchase::set_statement(
Origin::signed(configuration_origin()), RuntimeOrigin::signed(configuration_origin()),
statement.clone() statement.clone()
)); ));
assert_eq!(Statement::<Test>::get(), statement); assert_eq!(Statement::<Test>::get(), statement);
@@ -689,7 +696,7 @@ mod tests {
let unlock_block = 69; let unlock_block = 69;
// Invalid origin // Invalid origin
assert_noop!( assert_noop!(
Purchase::set_unlock_block(Origin::signed(alice()), unlock_block), Purchase::set_unlock_block(RuntimeOrigin::signed(alice()), unlock_block),
BadOrigin, BadOrigin,
); );
// Block Number in Past // Block Number in Past
@@ -697,14 +704,14 @@ mod tests {
System::set_block_number(bad_unlock_block); System::set_block_number(bad_unlock_block);
assert_noop!( assert_noop!(
Purchase::set_unlock_block( Purchase::set_unlock_block(
Origin::signed(configuration_origin()), RuntimeOrigin::signed(configuration_origin()),
bad_unlock_block bad_unlock_block
), ),
Error::<Test>::InvalidUnlockBlock, Error::<Test>::InvalidUnlockBlock,
); );
// Just right... // Just right...
assert_ok!(Purchase::set_unlock_block( assert_ok!(Purchase::set_unlock_block(
Origin::signed(configuration_origin()), RuntimeOrigin::signed(configuration_origin()),
unlock_block unlock_block
)); ));
assert_eq!(UnlockBlock::<Test>::get(), unlock_block); assert_eq!(UnlockBlock::<Test>::get(), unlock_block);
@@ -717,12 +724,15 @@ mod tests {
let payment_account: AccountId = [69u8; 32].into(); let payment_account: AccountId = [69u8; 32].into();
// Invalid Origin // Invalid Origin
assert_noop!( assert_noop!(
Purchase::set_payment_account(Origin::signed(alice()), payment_account.clone()), Purchase::set_payment_account(
RuntimeOrigin::signed(alice()),
payment_account.clone()
),
BadOrigin, BadOrigin,
); );
// Just right... // Just right...
assert_ok!(Purchase::set_payment_account( assert_ok!(Purchase::set_payment_account(
Origin::signed(configuration_origin()), RuntimeOrigin::signed(configuration_origin()),
payment_account.clone() payment_account.clone()
)); ));
assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account)); assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account));
@@ -753,7 +763,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert!(!Accounts::<Test>::contains_key(alice())); assert!(!Accounts::<Test>::contains_key(alice()));
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec(), alice_signature().to_vec(),
)); ));
@@ -776,7 +786,7 @@ mod tests {
// Wrong Origin // Wrong Origin
assert_noop!( assert_noop!(
Purchase::create_account( Purchase::create_account(
Origin::signed(alice()), RuntimeOrigin::signed(alice()),
alice(), alice(),
alice_signature().to_vec() alice_signature().to_vec()
), ),
@@ -786,7 +796,7 @@ mod tests {
// Wrong Account/Signature // Wrong Account/Signature
assert_noop!( assert_noop!(
Purchase::create_account( Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
bob_signature().to_vec() bob_signature().to_vec()
), ),
@@ -802,7 +812,7 @@ mod tests {
)); ));
assert_noop!( assert_noop!(
Purchase::create_account( Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec() alice_signature().to_vec()
), ),
@@ -811,13 +821,13 @@ mod tests {
// Duplicate Purchasing Account // Duplicate Purchasing Account
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
bob(), bob(),
bob_signature().to_vec() bob_signature().to_vec()
)); ));
assert_noop!( assert_noop!(
Purchase::create_account( Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
bob(), bob(),
bob_signature().to_vec() bob_signature().to_vec()
), ),
@@ -831,19 +841,19 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Alice account is created. // Alice account is created.
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec(), alice_signature().to_vec(),
)); ));
// She submits KYC, and we update the status to `Pending`. // She submits KYC, and we update the status to `Pending`.
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::Pending, AccountValidity::Pending,
)); ));
// KYC comes back negative, so we mark the account invalid. // KYC comes back negative, so we mark the account invalid.
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::Invalid, AccountValidity::Invalid,
)); ));
@@ -859,7 +869,7 @@ mod tests {
); );
// She fixes it, we mark her account valid. // She fixes it, we mark her account valid.
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::ValidLow, AccountValidity::ValidLow,
)); ));
@@ -882,7 +892,7 @@ mod tests {
// Wrong Origin // Wrong Origin
assert_noop!( assert_noop!(
Purchase::update_validity_status( Purchase::update_validity_status(
Origin::signed(alice()), RuntimeOrigin::signed(alice()),
alice(), alice(),
AccountValidity::Pending, AccountValidity::Pending,
), ),
@@ -891,7 +901,7 @@ mod tests {
// Inactive Account // Inactive Account
assert_noop!( assert_noop!(
Purchase::update_validity_status( Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::Pending, AccountValidity::Pending,
), ),
@@ -899,18 +909,18 @@ mod tests {
); );
// Already Completed // Already Completed
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec(), alice_signature().to_vec(),
)); ));
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::Completed, AccountValidity::Completed,
)); ));
assert_noop!( assert_noop!(
Purchase::update_validity_status( Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::Pending, AccountValidity::Pending,
), ),
@@ -924,19 +934,19 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Alice account is created // Alice account is created
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec() alice_signature().to_vec()
)); ));
// And approved for basic contribution // And approved for basic contribution
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::ValidLow, AccountValidity::ValidLow,
)); ));
// We set a balance on the user based on the payment they made. 50 locked, 50 free. // We set a balance on the user based on the payment they made. 50 locked, 50 free.
assert_ok!(Purchase::update_balance( assert_ok!(Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
50, 50,
50, 50,
@@ -954,7 +964,7 @@ mod tests {
); );
// We can update the balance based on new information. // We can update the balance based on new information.
assert_ok!(Purchase::update_balance( assert_ok!(Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
25, 25,
50, 50,
@@ -978,13 +988,19 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Wrong Origin // Wrong Origin
assert_noop!( assert_noop!(
Purchase::update_balance(Origin::signed(alice()), alice(), 50, 50, Permill::zero(),), Purchase::update_balance(
RuntimeOrigin::signed(alice()),
alice(),
50,
50,
Permill::zero(),
),
BadOrigin BadOrigin
); );
// Inactive Account // Inactive Account
assert_noop!( assert_noop!(
Purchase::update_balance( Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
50, 50,
50, 50,
@@ -995,7 +1011,7 @@ mod tests {
// Overflow // Overflow
assert_noop!( assert_noop!(
Purchase::update_balance( Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
u64::MAX, u64::MAX,
u64::MAX, u64::MAX,
@@ -1011,45 +1027,45 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Alice and Bob accounts are created // Alice and Bob accounts are created
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec() alice_signature().to_vec()
)); ));
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
bob(), bob(),
bob_signature().to_vec() bob_signature().to_vec()
)); ));
// Alice is approved for basic contribution // Alice is approved for basic contribution
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::ValidLow, AccountValidity::ValidLow,
)); ));
// Bob is approved for high contribution // Bob is approved for high contribution
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
bob(), bob(),
AccountValidity::ValidHigh, AccountValidity::ValidHigh,
)); ));
// We set a balance on the users based on the payment they made. 50 locked, 50 free. // We set a balance on the users based on the payment they made. 50 locked, 50 free.
assert_ok!(Purchase::update_balance( assert_ok!(Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
50, 50,
50, 50,
Permill::zero(), Permill::zero(),
)); ));
assert_ok!(Purchase::update_balance( assert_ok!(Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
bob(), bob(),
100, 100,
150, 150,
Permill::zero(), Permill::zero(),
)); ));
// Now we call payout for Alice and Bob. // Now we call payout for Alice and Bob.
assert_ok!(Purchase::payout(Origin::signed(payment_account()), alice(),)); assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),));
assert_ok!(Purchase::payout(Origin::signed(payment_account()), bob(),)); assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),));
// Payment is made. // Payment is made.
assert_eq!(<Test as Config>::Currency::free_balance(&payment_account()), 99_650); assert_eq!(<Test as Config>::Currency::free_balance(&payment_account()), 99_650);
assert_eq!(<Test as Config>::Currency::free_balance(&alice()), 100); assert_eq!(<Test as Config>::Currency::free_balance(&alice()), 100);
@@ -1082,13 +1098,13 @@ mod tests {
// Vesting lock is removed in whole on block 101 (100 blocks after block 1) // Vesting lock is removed in whole on block 101 (100 blocks after block 1)
System::set_block_number(100); System::set_block_number(100);
let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::<Test>::vest {}); let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::<Test>::vest {});
assert_ok!(vest_call.clone().dispatch(Origin::signed(alice()))); assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(Origin::signed(bob()))); assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45)); assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), Some(140)); assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), Some(140));
System::set_block_number(101); System::set_block_number(101);
assert_ok!(vest_call.clone().dispatch(Origin::signed(alice()))); assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(Origin::signed(bob()))); assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), None); assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), None);
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), None); assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), None);
}); });
@@ -1098,45 +1114,45 @@ mod tests {
fn payout_handles_basic_errors() { fn payout_handles_basic_errors() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Wrong Origin // Wrong Origin
assert_noop!(Purchase::payout(Origin::signed(alice()), alice(),), BadOrigin); assert_noop!(Purchase::payout(RuntimeOrigin::signed(alice()), alice(),), BadOrigin);
// Account with Existing Vesting Schedule // Account with Existing Vesting Schedule
assert_ok!( assert_ok!(
<Test as Config>::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,) <Test as Config>::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,)
); );
assert_noop!( assert_noop!(
Purchase::payout(Origin::signed(payment_account()), bob(),), Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),),
Error::<Test>::VestingScheduleExists Error::<Test>::VestingScheduleExists
); );
// Invalid Account (never created) // Invalid Account (never created)
assert_noop!( assert_noop!(
Purchase::payout(Origin::signed(payment_account()), alice(),), Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
Error::<Test>::InvalidAccount Error::<Test>::InvalidAccount
); );
// Invalid Account (created, but not valid) // Invalid Account (created, but not valid)
assert_ok!(Purchase::create_account( assert_ok!(Purchase::create_account(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
alice_signature().to_vec() alice_signature().to_vec()
)); ));
assert_noop!( assert_noop!(
Purchase::payout(Origin::signed(payment_account()), alice(),), Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
Error::<Test>::InvalidAccount Error::<Test>::InvalidAccount
); );
// Not enough funds in payment account // Not enough funds in payment account
assert_ok!(Purchase::update_validity_status( assert_ok!(Purchase::update_validity_status(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
AccountValidity::ValidHigh, AccountValidity::ValidHigh,
)); ));
assert_ok!(Purchase::update_balance( assert_ok!(Purchase::update_balance(
Origin::signed(validity_origin()), RuntimeOrigin::signed(validity_origin()),
alice(), alice(),
100_000, 100_000,
100_000, 100_000,
Permill::zero(), Permill::zero(),
)); ));
assert_noop!( assert_noop!(
Purchase::payout(Origin::signed(payment_account()), alice(),), Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
BalancesError::<Test, _>::InsufficientBalance BalancesError::<Test, _>::InsufficientBalance
); );
}); });
+9 -9
View File
@@ -91,7 +91,7 @@ pub mod pallet {
type LeaseOffset: Get<Self::BlockNumber>; type LeaseOffset: Get<Self::BlockNumber>;
/// The origin which may forcibly create or clear leases. Root can always do this. /// The origin which may forcibly create or clear leases. Root can always do this.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>; type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet /// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
@@ -529,7 +529,7 @@ mod tests {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -847,7 +847,7 @@ mod tests {
assert_eq!(Balances::reserved_balance(j), j * 10); assert_eq!(Balances::reserved_balance(j), j * 10);
} }
assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
// Balances cleaned up correctly // Balances cleaned up correctly
for i in 1u32..=max_num { for i in 1u32..=max_num {
@@ -925,21 +925,21 @@ mod tests {
// Para 1 should fail cause they don't have any leases // Para 1 should fail cause they don't have any leases
assert_noop!( assert_noop!(
Slots::trigger_onboard(Origin::signed(1), 1.into()), Slots::trigger_onboard(RuntimeOrigin::signed(1), 1.into()),
Error::<Test>::ParaNotOnboarding Error::<Test>::ParaNotOnboarding
); );
// Para 2 should succeed // Para 2 should succeed
assert_ok!(Slots::trigger_onboard(Origin::signed(1), 2.into())); assert_ok!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into()));
// Para 3 should fail cause their lease is in the future // Para 3 should fail cause their lease is in the future
assert_noop!( assert_noop!(
Slots::trigger_onboard(Origin::signed(1), 3.into()), Slots::trigger_onboard(RuntimeOrigin::signed(1), 3.into()),
Error::<Test>::ParaNotOnboarding Error::<Test>::ParaNotOnboarding
); );
// Trying Para 2 again should fail cause they are not currently a parathread // Trying Para 2 again should fail cause they are not currently a parathread
assert!(Slots::trigger_onboard(Origin::signed(1), 2.into()).is_err()); assert!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into()).is_err());
assert_eq!(TestRegistrar::<Test>::operations(), vec![(2.into(), 1, true),]); assert_eq!(TestRegistrar::<Test>::operations(), vec![(2.into(), 1, true),]);
}); });
@@ -1025,7 +1025,7 @@ mod benchmarking {
let period_begin = 69u32.into(); let period_begin = 69u32.into();
let period_count = 3u32.into(); let period_count = 3u32.into();
let origin = T::ForceOrigin::successful_origin(); let origin = T::ForceOrigin::successful_origin();
}: _<T::Origin>(origin, para, leaser.clone(), amount, period_begin, period_count) }: _<T::RuntimeOrigin>(origin, para, leaser.clone(), amount, period_begin, period_count)
verify { verify {
assert_last_event::<T>(Event::<T>::Leased { assert_last_event::<T>(Event::<T>::Leased {
para_id: para, para_id: para,
@@ -1119,7 +1119,7 @@ mod benchmarking {
} }
let origin = T::ForceOrigin::successful_origin(); let origin = T::ForceOrigin::successful_origin();
}: _<T::Origin>(origin, para) }: _<T::RuntimeOrigin>(origin, para)
verify { verify {
for i in 0 .. max_people { for i in 0 .. max_people {
let leaser = account("lease_deposit", i, 0); let leaser = account("lease_deposit", i, 0);
@@ -92,7 +92,7 @@ parameter_types! {
pub type CouncilCollective = pallet_collective::Instance1; pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime { impl pallet_collective::Config<CouncilCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration; type MotionDuration = CouncilMotionDuration;
@@ -148,7 +148,7 @@ parameter_types! {
pub type TechnicalCollective = pallet_collective::Instance2; pub type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime { impl pallet_collective::Config<TechnicalCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration; type MotionDuration = TechnicalMotionDuration;
+4 -4
View File
@@ -157,7 +157,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = BlockLength; type BlockLength = BlockLength;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -216,8 +216,8 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
} }
impl pallet_scheduler::Config for Runtime { impl pallet_scheduler::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type PalletsOrigin = OriginCaller; type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight; type MaximumWeight = MaximumSchedulerWeight;
@@ -1152,8 +1152,8 @@ impl parachains_ump::Config for Runtime {
impl parachains_dmp::Config for Runtime {} impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime { impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
} }
@@ -1182,8 +1182,8 @@ parameter_types! {
} }
impl paras_registrar::Config for Runtime { impl paras_registrar::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type OnSwap = (Crowdloan, Slots); type OnSwap = (Crowdloan, Slots);
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
+11 -11
View File
@@ -17,8 +17,8 @@
//! XCM configurations for the Kusama runtime. //! XCM configurations for the Kusama runtime.
use super::{ use super::{
parachains_origin, AccountId, Balances, CouncilCollective, Origin, ParaId, Runtime, parachains_origin, AccountId, Balances, CouncilCollective, ParaId, Runtime, RuntimeCall,
RuntimeCall, RuntimeEvent, WeightToFee, XcmPallet, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet,
}; };
use frame_support::{match_types, parameter_types, traits::Everything}; use frame_support::{match_types, parameter_types, traits::Everything};
use runtime_common::{xcm_sender, ToAuthor}; use runtime_common::{xcm_sender, ToAuthor};
@@ -75,13 +75,13 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
/// The means that we convert an the XCM message origin location into a local dispatch origin. /// The means that we convert an the XCM message origin location into a local dispatch origin.
type LocalOriginConverter = ( type LocalOriginConverter = (
// A `Signed` origin of the sovereign account that the original location controls. // A `Signed` origin of the sovereign account that the original location controls.
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
// A child parachain, natively expressed, has the `Parachain` origin. // A child parachain, natively expressed, has the `Parachain` origin.
ChildParachainAsNative<parachains_origin::Origin, Origin>, ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
// The AccountId32 location type can be expressed natively as a `Signed` origin. // The AccountId32 location type can be expressed natively as a `Signed` origin.
SignedAccountId32AsNative<KusamaNetwork, Origin>, SignedAccountId32AsNative<KusamaNetwork, RuntimeOrigin>,
// A system child parachain, expressed as a Superuser, converts to the `Root` origin. // A system child parachain, expressed as a Superuser, converts to the `Root` origin.
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -158,7 +158,7 @@ parameter_types! {
/// Type to convert the council origin to a Plurality `MultiLocation` value. /// Type to convert the council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality< pub type CouncilToPlurality = BackingToPlurality<
Origin, RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>, pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId, CouncilBodyId,
>; >;
@@ -170,7 +170,7 @@ pub type LocalOriginToLocation = (
// `Unit` body. // `Unit` body.
CouncilToPlurality, CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32 // And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, KusamaNetwork>, SignedToAccountId32<RuntimeOrigin, AccountId, KusamaNetwork>,
); );
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
@@ -178,10 +178,10 @@ impl pallet_xcm::Config for Runtime {
// (safe the possibility of someone spamming the parachain if they're willing to pay the KSM to // (safe the possibility of someone spamming the parachain if they're willing to pay the KSM to
// send from the Relay-chain), but it's useless until we bring in XCM v3 which will make // send from the Relay-chain), but it's useless until we bring in XCM v3 which will make
// `DescendOrigin` a bit more useful. // `DescendOrigin` a bit more useful.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, CouncilToPlurality>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, CouncilToPlurality>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally. // Anyone can execute XCM messages locally.
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
// Anyone is able to use teleportation regardless of who they are and what they want to teleport. // Anyone is able to use teleportation regardless of who they are and what they want to teleport.
@@ -191,7 +191,7 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -15,7 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::*; use super::*;
use crate::mock::{new_test_ext, Configuration, Origin, ParasShared, Test}; use crate::mock::{new_test_ext, Configuration, ParasShared, RuntimeOrigin, Test};
use frame_support::{assert_err, assert_ok}; use frame_support::{assert_err, assert_ok};
fn on_new_session(session_index: SessionIndex) -> (HostConfiguration<u32>, HostConfiguration<u32>) { fn on_new_session(session_index: SessionIndex) -> (HostConfiguration<u32>, HostConfiguration<u32>) {
@@ -48,7 +48,7 @@ fn initializer_on_new_session() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
let (prev_config, new_config) = on_new_session(1); let (prev_config, new_config) = on_new_session(1);
assert_eq!(prev_config, new_config); assert_eq!(prev_config, new_config);
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100));
let (prev_config, new_config) = on_new_session(2); let (prev_config, new_config) = on_new_session(2);
assert_eq!(prev_config, new_config); assert_eq!(prev_config, new_config);
@@ -67,7 +67,7 @@ fn config_changes_after_2_session_boundary() {
config.validation_upgrade_delay = 100; config.validation_upgrade_delay = 100;
assert!(old_config != config); assert!(old_config != config);
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100));
// Verify that the current configuration has not changed and that there is a scheduled // Verify that the current configuration has not changed and that there is a scheduled
// change for the SESSION_DELAY sessions in advance. // change for the SESSION_DELAY sessions in advance.
@@ -96,8 +96,8 @@ fn consecutive_changes_within_one_session() {
config.validation_upgrade_cooldown = 100; config.validation_upgrade_cooldown = 100;
assert!(old_config != config); assert!(old_config != config);
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100));
assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 100));
assert_eq!(Configuration::config(), old_config); assert_eq!(Configuration::config(), old_config);
assert_eq!(<Configuration as Store>::PendingConfigs::get(), vec![(2, config.clone())]); assert_eq!(<Configuration as Store>::PendingConfigs::get(), vec![(2, config.clone())]);
@@ -125,7 +125,7 @@ fn pending_next_session_but_we_upgrade_once_more() {
..initial_config.clone() ..initial_config.clone()
}; };
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100));
assert_eq!(Configuration::config(), initial_config); assert_eq!(Configuration::config(), initial_config);
assert_eq!( assert_eq!(
<Configuration as Store>::PendingConfigs::get(), <Configuration as Store>::PendingConfigs::get(),
@@ -136,7 +136,7 @@ fn pending_next_session_but_we_upgrade_once_more() {
// We are still waiting until the pending configuration is applied and we add another // We are still waiting until the pending configuration is applied and we add another
// update. // update.
assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 99)); assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 99));
// This should result in yet another configiguration change scheduled. // This should result in yet another configiguration change scheduled.
assert_eq!(Configuration::config(), initial_config); assert_eq!(Configuration::config(), initial_config);
@@ -173,7 +173,7 @@ fn scheduled_session_config_update_while_next_session_pending() {
..initial_config.clone() ..initial_config.clone()
}; };
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100));
assert_eq!(Configuration::config(), initial_config); assert_eq!(Configuration::config(), initial_config);
assert_eq!( assert_eq!(
<Configuration as Store>::PendingConfigs::get(), <Configuration as Store>::PendingConfigs::get(),
@@ -184,8 +184,8 @@ fn scheduled_session_config_update_while_next_session_pending() {
// The second call should fall into the case where we already have a pending config // The second call should fall into the case where we already have a pending config
// update for the scheduled_session, but we want to update it once more. // update for the scheduled_session, but we want to update it once more.
assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 99)); assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 99));
assert_ok!(Configuration::set_code_retention_period(Origin::root(), 98)); assert_ok!(Configuration::set_code_retention_period(RuntimeOrigin::root(), 98));
// This should result in yet another configiguration change scheduled. // This should result in yet another configiguration change scheduled.
assert_eq!(Configuration::config(), initial_config); assert_eq!(Configuration::config(), initial_config);
@@ -213,30 +213,30 @@ fn scheduled_session_config_update_while_next_session_pending() {
fn invariants() { fn invariants() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_err!( assert_err!(
Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1), Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_max_pov_size(Origin::root(), MAX_POV_SIZE + 1), Configuration::set_max_pov_size(RuntimeOrigin::root(), MAX_POV_SIZE + 1),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_max_head_data_size(Origin::root(), MAX_HEAD_DATA_SIZE + 1), Configuration::set_max_head_data_size(RuntimeOrigin::root(), MAX_HEAD_DATA_SIZE + 1),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_chain_availability_period(Origin::root(), 0), Configuration::set_chain_availability_period(RuntimeOrigin::root(), 0),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_thread_availability_period(Origin::root(), 0), Configuration::set_thread_availability_period(RuntimeOrigin::root(), 0),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_no_show_slots(Origin::root(), 0), Configuration::set_no_show_slots(RuntimeOrigin::root(), 0),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
@@ -247,20 +247,20 @@ fn invariants() {
..Default::default() ..Default::default()
}); });
assert_err!( assert_err!(
Configuration::set_chain_availability_period(Origin::root(), 12), Configuration::set_chain_availability_period(RuntimeOrigin::root(), 12),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_thread_availability_period(Origin::root(), 12), Configuration::set_thread_availability_period(RuntimeOrigin::root(), 12),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_minimum_validation_upgrade_delay(Origin::root(), 9), Configuration::set_minimum_validation_upgrade_delay(RuntimeOrigin::root(), 9),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_err!( assert_err!(
Configuration::set_validation_upgrade_delay(Origin::root(), 0), Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 0),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
}); });
@@ -270,12 +270,12 @@ fn invariants() {
fn consistency_bypass_works() { fn consistency_bypass_works() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_err!( assert_err!(
Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1), Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1),
Error::<Test>::InvalidNewValue Error::<Test>::InvalidNewValue
); );
assert_ok!(Configuration::set_bypass_consistency_check(Origin::root(), true)); assert_ok!(Configuration::set_bypass_consistency_check(RuntimeOrigin::root(), true));
assert_ok!(Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1)); assert_ok!(Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1));
assert_eq!( assert_eq!(
Configuration::config().max_code_size, Configuration::config().max_code_size,
@@ -339,165 +339,186 @@ fn setting_pending_config_members() {
}; };
Configuration::set_validation_upgrade_cooldown( Configuration::set_validation_upgrade_cooldown(
Origin::root(), RuntimeOrigin::root(),
new_config.validation_upgrade_cooldown, new_config.validation_upgrade_cooldown,
) )
.unwrap(); .unwrap();
Configuration::set_validation_upgrade_delay( Configuration::set_validation_upgrade_delay(
Origin::root(), RuntimeOrigin::root(),
new_config.validation_upgrade_delay, new_config.validation_upgrade_delay,
) )
.unwrap(); .unwrap();
Configuration::set_code_retention_period(Origin::root(), new_config.code_retention_period) Configuration::set_code_retention_period(
RuntimeOrigin::root(),
new_config.code_retention_period,
)
.unwrap();
Configuration::set_max_code_size(RuntimeOrigin::root(), new_config.max_code_size).unwrap();
Configuration::set_max_pov_size(RuntimeOrigin::root(), new_config.max_pov_size).unwrap();
Configuration::set_max_head_data_size(RuntimeOrigin::root(), new_config.max_head_data_size)
.unwrap(); .unwrap();
Configuration::set_max_code_size(Origin::root(), new_config.max_code_size).unwrap(); Configuration::set_parathread_cores(RuntimeOrigin::root(), new_config.parathread_cores)
Configuration::set_max_pov_size(Origin::root(), new_config.max_pov_size).unwrap();
Configuration::set_max_head_data_size(Origin::root(), new_config.max_head_data_size)
.unwrap(); .unwrap();
Configuration::set_parathread_cores(Origin::root(), new_config.parathread_cores).unwrap(); Configuration::set_parathread_retries(RuntimeOrigin::root(), new_config.parathread_retries)
Configuration::set_parathread_retries(Origin::root(), new_config.parathread_retries)
.unwrap(); .unwrap();
Configuration::set_group_rotation_frequency( Configuration::set_group_rotation_frequency(
Origin::root(), RuntimeOrigin::root(),
new_config.group_rotation_frequency, new_config.group_rotation_frequency,
) )
.unwrap(); .unwrap();
// This comes out of order to satisfy the validity criteria for the chain and thread // This comes out of order to satisfy the validity criteria for the chain and thread
// availability periods. // availability periods.
Configuration::set_minimum_validation_upgrade_delay( Configuration::set_minimum_validation_upgrade_delay(
Origin::root(), RuntimeOrigin::root(),
new_config.minimum_validation_upgrade_delay, new_config.minimum_validation_upgrade_delay,
) )
.unwrap(); .unwrap();
Configuration::set_chain_availability_period( Configuration::set_chain_availability_period(
Origin::root(), RuntimeOrigin::root(),
new_config.chain_availability_period, new_config.chain_availability_period,
) )
.unwrap(); .unwrap();
Configuration::set_thread_availability_period( Configuration::set_thread_availability_period(
Origin::root(), RuntimeOrigin::root(),
new_config.thread_availability_period, new_config.thread_availability_period,
) )
.unwrap(); .unwrap();
Configuration::set_scheduling_lookahead(Origin::root(), new_config.scheduling_lookahead) Configuration::set_scheduling_lookahead(
.unwrap(); RuntimeOrigin::root(),
new_config.scheduling_lookahead,
)
.unwrap();
Configuration::set_max_validators_per_core( Configuration::set_max_validators_per_core(
Origin::root(), RuntimeOrigin::root(),
new_config.max_validators_per_core, new_config.max_validators_per_core,
) )
.unwrap(); .unwrap();
Configuration::set_max_validators(Origin::root(), new_config.max_validators).unwrap(); Configuration::set_max_validators(RuntimeOrigin::root(), new_config.max_validators)
Configuration::set_dispute_period(Origin::root(), new_config.dispute_period).unwrap(); .unwrap();
Configuration::set_dispute_period(RuntimeOrigin::root(), new_config.dispute_period)
.unwrap();
Configuration::set_dispute_post_conclusion_acceptance_period( Configuration::set_dispute_post_conclusion_acceptance_period(
Origin::root(), RuntimeOrigin::root(),
new_config.dispute_post_conclusion_acceptance_period, new_config.dispute_post_conclusion_acceptance_period,
) )
.unwrap(); .unwrap();
Configuration::set_dispute_max_spam_slots( Configuration::set_dispute_max_spam_slots(
Origin::root(), RuntimeOrigin::root(),
new_config.dispute_max_spam_slots, new_config.dispute_max_spam_slots,
) )
.unwrap(); .unwrap();
Configuration::set_dispute_conclusion_by_time_out_period( Configuration::set_dispute_conclusion_by_time_out_period(
Origin::root(), RuntimeOrigin::root(),
new_config.dispute_conclusion_by_time_out_period, new_config.dispute_conclusion_by_time_out_period,
) )
.unwrap(); .unwrap();
Configuration::set_no_show_slots(Origin::root(), new_config.no_show_slots).unwrap(); Configuration::set_no_show_slots(RuntimeOrigin::root(), new_config.no_show_slots).unwrap();
Configuration::set_n_delay_tranches(Origin::root(), new_config.n_delay_tranches).unwrap(); Configuration::set_n_delay_tranches(RuntimeOrigin::root(), new_config.n_delay_tranches)
.unwrap();
Configuration::set_zeroth_delay_tranche_width( Configuration::set_zeroth_delay_tranche_width(
Origin::root(), RuntimeOrigin::root(),
new_config.zeroth_delay_tranche_width, new_config.zeroth_delay_tranche_width,
) )
.unwrap(); .unwrap();
Configuration::set_needed_approvals(Origin::root(), new_config.needed_approvals).unwrap(); Configuration::set_needed_approvals(RuntimeOrigin::root(), new_config.needed_approvals)
.unwrap();
Configuration::set_relay_vrf_modulo_samples( Configuration::set_relay_vrf_modulo_samples(
Origin::root(), RuntimeOrigin::root(),
new_config.relay_vrf_modulo_samples, new_config.relay_vrf_modulo_samples,
) )
.unwrap(); .unwrap();
Configuration::set_max_upward_queue_count( Configuration::set_max_upward_queue_count(
Origin::root(), RuntimeOrigin::root(),
new_config.max_upward_queue_count, new_config.max_upward_queue_count,
) )
.unwrap(); .unwrap();
Configuration::set_max_upward_queue_size(Origin::root(), new_config.max_upward_queue_size) Configuration::set_max_upward_queue_size(
.unwrap(); RuntimeOrigin::root(),
new_config.max_upward_queue_size,
)
.unwrap();
Configuration::set_max_downward_message_size( Configuration::set_max_downward_message_size(
Origin::root(), RuntimeOrigin::root(),
new_config.max_downward_message_size, new_config.max_downward_message_size,
) )
.unwrap(); .unwrap();
Configuration::set_ump_service_total_weight( Configuration::set_ump_service_total_weight(
Origin::root(), RuntimeOrigin::root(),
new_config.ump_service_total_weight, new_config.ump_service_total_weight,
) )
.unwrap(); .unwrap();
Configuration::set_max_upward_message_size( Configuration::set_max_upward_message_size(
Origin::root(), RuntimeOrigin::root(),
new_config.max_upward_message_size, new_config.max_upward_message_size,
) )
.unwrap(); .unwrap();
Configuration::set_max_upward_message_num_per_candidate( Configuration::set_max_upward_message_num_per_candidate(
Origin::root(), RuntimeOrigin::root(),
new_config.max_upward_message_num_per_candidate, new_config.max_upward_message_num_per_candidate,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_sender_deposit(Origin::root(), new_config.hrmp_sender_deposit) Configuration::set_hrmp_sender_deposit(
.unwrap(); RuntimeOrigin::root(),
new_config.hrmp_sender_deposit,
)
.unwrap();
Configuration::set_hrmp_recipient_deposit( Configuration::set_hrmp_recipient_deposit(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_recipient_deposit, new_config.hrmp_recipient_deposit,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_channel_max_capacity( Configuration::set_hrmp_channel_max_capacity(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_channel_max_capacity, new_config.hrmp_channel_max_capacity,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_channel_max_total_size( Configuration::set_hrmp_channel_max_total_size(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_channel_max_total_size, new_config.hrmp_channel_max_total_size,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_max_parachain_inbound_channels( Configuration::set_hrmp_max_parachain_inbound_channels(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_max_parachain_inbound_channels, new_config.hrmp_max_parachain_inbound_channels,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_max_parathread_inbound_channels( Configuration::set_hrmp_max_parathread_inbound_channels(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_max_parathread_inbound_channels, new_config.hrmp_max_parathread_inbound_channels,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_channel_max_message_size( Configuration::set_hrmp_channel_max_message_size(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_channel_max_message_size, new_config.hrmp_channel_max_message_size,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_max_parachain_outbound_channels( Configuration::set_hrmp_max_parachain_outbound_channels(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_max_parachain_outbound_channels, new_config.hrmp_max_parachain_outbound_channels,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_max_parathread_outbound_channels( Configuration::set_hrmp_max_parathread_outbound_channels(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_max_parathread_outbound_channels, new_config.hrmp_max_parathread_outbound_channels,
) )
.unwrap(); .unwrap();
Configuration::set_hrmp_max_message_num_per_candidate( Configuration::set_hrmp_max_message_num_per_candidate(
Origin::root(), RuntimeOrigin::root(),
new_config.hrmp_max_message_num_per_candidate, new_config.hrmp_max_message_num_per_candidate,
) )
.unwrap(); .unwrap();
Configuration::set_ump_max_individual_weight( Configuration::set_ump_max_individual_weight(
Origin::root(), RuntimeOrigin::root(),
new_config.ump_max_individual_weight, new_config.ump_max_individual_weight,
) )
.unwrap(); .unwrap();
Configuration::set_pvf_checking_enabled(Origin::root(), new_config.pvf_checking_enabled) Configuration::set_pvf_checking_enabled(
RuntimeOrigin::root(),
new_config.pvf_checking_enabled,
)
.unwrap();
Configuration::set_pvf_voting_ttl(RuntimeOrigin::root(), new_config.pvf_voting_ttl)
.unwrap(); .unwrap();
Configuration::set_pvf_voting_ttl(Origin::root(), new_config.pvf_voting_ttl).unwrap();
assert_eq!( assert_eq!(
<Configuration as Store>::PendingConfigs::get(), <Configuration as Store>::PendingConfigs::get(),
@@ -509,7 +530,7 @@ fn setting_pending_config_members() {
#[test] #[test]
fn non_root_cannot_set_config() { fn non_root_cannot_set_config() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert!(Configuration::set_validation_upgrade_delay(Origin::signed(1), 100).is_err()); assert!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::signed(1), 100).is_err());
}); });
} }
+7 -7
View File
@@ -241,9 +241,9 @@ pub mod pallet {
/// The outer event type. /// The outer event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type Origin: From<crate::Origin> type RuntimeOrigin: From<crate::Origin>
+ From<<Self as frame_system::Config>::Origin> + From<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<Result<crate::Origin, <Self as Config>::Origin>>; + Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;
/// An interface for reserving deposits for opening channels. /// An interface for reserving deposits for opening channels.
/// ///
@@ -465,7 +465,7 @@ pub mod pallet {
proposed_max_capacity: u32, proposed_max_capacity: u32,
proposed_max_message_size: u32, proposed_max_message_size: u32,
) -> DispatchResult { ) -> DispatchResult {
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?; let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
Self::init_open_channel( Self::init_open_channel(
origin, origin,
recipient, recipient,
@@ -486,7 +486,7 @@ pub mod pallet {
/// The channel will be opened only on the next session boundary. /// The channel will be opened only on the next session boundary.
#[pallet::weight(<T as Config>::WeightInfo::hrmp_accept_open_channel())] #[pallet::weight(<T as Config>::WeightInfo::hrmp_accept_open_channel())]
pub fn hrmp_accept_open_channel(origin: OriginFor<T>, sender: ParaId) -> DispatchResult { pub fn hrmp_accept_open_channel(origin: OriginFor<T>, sender: ParaId) -> DispatchResult {
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?; let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
Self::accept_open_channel(origin, sender)?; Self::accept_open_channel(origin, sender)?;
Self::deposit_event(Event::OpenChannelAccepted(sender, origin)); Self::deposit_event(Event::OpenChannelAccepted(sender, origin));
Ok(()) Ok(())
@@ -501,7 +501,7 @@ pub mod pallet {
origin: OriginFor<T>, origin: OriginFor<T>,
channel_id: HrmpChannelId, channel_id: HrmpChannelId,
) -> DispatchResult { ) -> DispatchResult {
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?; let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
Self::close_channel(origin, channel_id.clone())?; Self::close_channel(origin, channel_id.clone())?;
Self::deposit_event(Event::ChannelClosed(origin, channel_id)); Self::deposit_event(Event::ChannelClosed(origin, channel_id));
Ok(()) Ok(())
@@ -567,7 +567,7 @@ pub mod pallet {
channel_id: HrmpChannelId, channel_id: HrmpChannelId,
open_requests: u32, open_requests: u32,
) -> DispatchResult { ) -> DispatchResult {
let origin = ensure_parachain(<T as Config>::Origin::from(origin))?; let origin = ensure_parachain(<T as Config>::RuntimeOrigin::from(origin))?;
ensure!( ensure!(
<Self as Store>::HrmpOpenChannelRequestsList::decode_len().unwrap_or_default() <Self as Store>::HrmpOpenChannelRequestsList::decode_len().unwrap_or_default()
as u32 <= open_requests, as u32 <= open_requests,
@@ -66,7 +66,7 @@ fn establish_para_connection<T: Config>(
until: ParachainSetupStep, until: ParachainSetupStep,
) -> [(ParaId, crate::Origin); 2] ) -> [(ParaId, crate::Origin); 2]
where where
<T as frame_system::Config>::Origin: From<crate::Origin>, <T as frame_system::Config>::RuntimeOrigin: From<crate::Origin>,
{ {
let config = Configuration::<T>::config(); let config = Configuration::<T>::config();
let deposit: BalanceOf<T> = config.hrmp_sender_deposit.unique_saturated_into(); let deposit: BalanceOf<T> = config.hrmp_sender_deposit.unique_saturated_into();
@@ -138,7 +138,7 @@ static_assertions::const_assert!(HRMP_MAX_INBOUND_CHANNELS_BOUND < PREFIX_0);
static_assertions::const_assert!(HRMP_MAX_OUTBOUND_CHANNELS_BOUND < PREFIX_0); static_assertions::const_assert!(HRMP_MAX_OUTBOUND_CHANNELS_BOUND < PREFIX_0);
frame_benchmarking::benchmarks! { frame_benchmarking::benchmarks! {
where_clause { where <T as frame_system::Config>::Origin: From<crate::Origin> } where_clause { where <T as frame_system::Config>::RuntimeOrigin: From<crate::Origin> }
hrmp_init_open_channel { hrmp_init_open_channel {
let sender_id: ParaId = 1u32.into(); let sender_id: ParaId = 1u32.into();
@@ -120,7 +120,7 @@ pub mod pallet {
/// A randomness beacon. /// A randomness beacon.
type Randomness: Randomness<Self::Hash, Self::BlockNumber>; type Randomness: Randomness<Self::Hash, Self::BlockNumber>;
/// An origin which is allowed to force updates to parachains. /// An origin which is allowed to force updates to parachains.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>; type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
/// Weight information for extrinsics in this pallet. /// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
} }
+2 -2
View File
@@ -92,7 +92,7 @@ impl frame_system::Config for Test {
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -234,8 +234,8 @@ impl crate::ump::Config for Test {
} }
impl crate::hrmp::Config for Test { impl crate::hrmp::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = pallet_balances::Pallet<Test>; type Currency = pallet_balances::Pallet<Test>;
type WeightInfo = crate::hrmp::TestWeightInfo; type WeightInfo = crate::hrmp::TestWeightInfo;
} }
+40 -12
View File
@@ -26,7 +26,8 @@ use test_helpers::{dummy_head_data, dummy_validation_code};
use crate::{ use crate::{
configuration::HostConfiguration, configuration::HostConfiguration,
mock::{ mock::{
new_test_ext, Configuration, MockGenesisConfig, Origin, Paras, ParasShared, System, Test, new_test_ext, Configuration, MockGenesisConfig, Paras, ParasShared, RuntimeOrigin, System,
Test,
}, },
}; };
@@ -1449,7 +1450,10 @@ fn add_trusted_validation_code_inserts_with_no_users() {
// with the reference count equal to 0. // with the reference count equal to 0.
let validation_code = ValidationCode(vec![1, 2, 3]); let validation_code = ValidationCode(vec![1, 2, 3]);
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
assert_eq!(<Paras as Store>::CodeByHashRefs::get(&validation_code.hash()), 0,); assert_eq!(<Paras as Store>::CodeByHashRefs::get(&validation_code.hash()), 0,);
}); });
} }
@@ -1460,9 +1464,15 @@ fn add_trusted_validation_code_idempotent() {
// parameters is a no-op. // parameters is a no-op.
let validation_code = ValidationCode(vec![1, 2, 3]); let validation_code = ValidationCode(vec![1, 2, 3]);
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
assert_storage_noop!({ assert_storage_noop!({
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
}); });
}); });
} }
@@ -1473,8 +1483,14 @@ fn poke_unused_validation_code_removes_code_cleanly() {
// in the storage but has no users will remove it cleanly from the storage. // in the storage but has no users will remove it cleanly from the storage.
let validation_code = ValidationCode(vec![1, 2, 3]); let validation_code = ValidationCode(vec![1, 2, 3]);
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
assert_ok!(Paras::poke_unused_validation_code(Origin::root(), validation_code.hash())); RuntimeOrigin::root(),
validation_code.clone()
));
assert_ok!(Paras::poke_unused_validation_code(
RuntimeOrigin::root(),
validation_code.hash()
));
assert_eq!(<Paras as Store>::CodeByHashRefs::get(&validation_code.hash()), 0); assert_eq!(<Paras as Store>::CodeByHashRefs::get(&validation_code.hash()), 0);
assert!(!<Paras as Store>::CodeByHash::contains_key(&validation_code.hash())); assert!(!<Paras as Store>::CodeByHash::contains_key(&validation_code.hash()));
@@ -1487,7 +1503,10 @@ fn poke_unused_validation_code_doesnt_remove_code_with_users() {
let validation_code = ValidationCode(vec![1, 2, 3]); let validation_code = ValidationCode(vec![1, 2, 3]);
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
// First we add the code to the storage. // First we add the code to the storage.
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
// Then we add a user to the code, say by upgrading. // Then we add a user to the code, say by upgrading.
run_to_block(2, None); run_to_block(2, None);
@@ -1496,7 +1515,10 @@ fn poke_unused_validation_code_doesnt_remove_code_with_users() {
// Finally we poke the code, which should not remove it from the storage. // Finally we poke the code, which should not remove it from the storage.
assert_storage_noop!({ assert_storage_noop!({
assert_ok!(Paras::poke_unused_validation_code(Origin::root(), validation_code.hash())); assert_ok!(Paras::poke_unused_validation_code(
RuntimeOrigin::root(),
validation_code.hash()
));
}); });
check_code_is_stored(&validation_code); check_code_is_stored(&validation_code);
}); });
@@ -1511,7 +1533,7 @@ fn increase_code_ref_doesnt_have_allergy_on_add_trusted_validation_code() {
let code = ValidationCode(vec![1, 2, 3]); let code = ValidationCode(vec![1, 2, 3]);
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), code.clone())); assert_ok!(Paras::add_trusted_validation_code(RuntimeOrigin::root(), code.clone()));
Paras::increase_code_ref(&code.hash(), &code); Paras::increase_code_ref(&code.hash(), &code);
Paras::increase_code_ref(&code.hash(), &code); Paras::increase_code_ref(&code.hash(), &code);
assert!(<Paras as Store>::CodeByHash::contains_key(code.hash())); assert!(<Paras as Store>::CodeByHash::contains_key(code.hash()));
@@ -1519,7 +1541,7 @@ fn increase_code_ref_doesnt_have_allergy_on_add_trusted_validation_code() {
}); });
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), code.clone())); assert_ok!(Paras::add_trusted_validation_code(RuntimeOrigin::root(), code.clone()));
Paras::decrease_code_ref(&code.hash()); Paras::decrease_code_ref(&code.hash());
assert!(<Paras as Store>::CodeByHash::contains_key(code.hash())); assert!(<Paras as Store>::CodeByHash::contains_key(code.hash()));
assert_eq!(<Paras as Store>::CodeByHashRefs::get(code.hash()), 0); assert_eq!(<Paras as Store>::CodeByHashRefs::get(code.hash()), 0);
@@ -1547,7 +1569,10 @@ fn add_trusted_validation_code_insta_approval() {
..Default::default() ..Default::default()
}; };
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
// Then some parachain upgrades it's code with the relay-parent 1. // Then some parachain upgrades it's code with the relay-parent 1.
run_to_block(2, None); run_to_block(2, None);
@@ -1602,7 +1627,10 @@ fn add_trusted_validation_code_enacts_existing_pvf_vote() {
assert!(<Paras as Store>::PvfActiveVoteMap::contains_key(&validation_code.hash())); assert!(<Paras as Store>::PvfActiveVoteMap::contains_key(&validation_code.hash()));
// Then we add a trusted validation code. That should conclude the vote. // Then we add a trusted validation code. That should conclude the vote.
assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); assert_ok!(Paras::add_trusted_validation_code(
RuntimeOrigin::root(),
validation_code.clone()
));
assert!(<Paras as Store>::FutureCodeUpgrades::get(&para_id).is_some()); assert!(<Paras as Store>::FutureCodeUpgrades::get(&para_id).is_some());
assert!(!<Paras as Store>::PvfActiveVoteMap::contains_key(&validation_code.hash())); assert!(!<Paras as Store>::PvfActiveVoteMap::contains_key(&validation_code.hash()));
}); });
@@ -19,8 +19,8 @@ use crate::{
configuration::HostConfiguration, configuration::HostConfiguration,
initializer::SessionChangeNotification, initializer::SessionChangeNotification,
mock::{ mock::{
new_test_ext, Configuration, MockGenesisConfig, Origin, ParasShared, SessionInfo, System, new_test_ext, Configuration, MockGenesisConfig, ParasShared, RuntimeOrigin, SessionInfo,
Test, System, Test,
}, },
util::take_active_subset, util::take_active_subset,
}; };
@@ -109,7 +109,7 @@ fn session_pruning_is_based_on_dispute_period() {
// changing `dispute_period` works // changing `dispute_period` works
let dispute_period = 5; let dispute_period = 5;
Configuration::set_dispute_period(Origin::root(), dispute_period).unwrap(); Configuration::set_dispute_period(RuntimeOrigin::root(), dispute_period).unwrap();
// Dispute period does not automatically change // Dispute period does not automatically change
let config = Configuration::config(); let config = Configuration::config();
@@ -124,7 +124,7 @@ fn session_pruning_is_based_on_dispute_period() {
// Increase dispute period even more // Increase dispute period even more
let new_dispute_period = 16; let new_dispute_period = 16;
Configuration::set_dispute_period(Origin::root(), new_dispute_period).unwrap(); Configuration::set_dispute_period(RuntimeOrigin::root(), new_dispute_period).unwrap();
run_to_block(210, session_changes); run_to_block(210, session_changes);
assert_eq!(EarliestStoredSession::<Test>::get(), 21 - dispute_period); assert_eq!(EarliestStoredSession::<Test>::get(), 21 - dispute_period);
@@ -154,7 +154,7 @@ fn session_info_is_based_on_config() {
assert_eq!(session.needed_approvals, 3); assert_eq!(session.needed_approvals, 3);
// change some param // change some param
Configuration::set_needed_approvals(Origin::root(), 42).unwrap(); Configuration::set_needed_approvals(RuntimeOrigin::root(), 42).unwrap();
// 2 sessions later // 2 sessions later
run_to_block(3, new_session_every_block); run_to_block(3, new_session_every_block);
let session = Sessions::<Test>::get(&3).unwrap(); let session = Sessions::<Test>::get(&3).unwrap();
+1 -1
View File
@@ -234,7 +234,7 @@ pub mod pallet {
type FirstMessageFactorPercent: Get<u64>; type FirstMessageFactorPercent: Get<u64>;
/// Origin which is allowed to execute overweight messages. /// Origin which is allowed to execute overweight messages.
type ExecuteOverweightOrigin: EnsureOrigin<Self::Origin>; type ExecuteOverweightOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Weight information for extrinsics in this pallet. /// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
+6 -6
View File
@@ -16,8 +16,8 @@
use super::*; use super::*;
use crate::mock::{ use crate::mock::{
assert_last_event, new_test_ext, take_processed, Configuration, MockGenesisConfig, Origin, assert_last_event, new_test_ext, take_processed, Configuration, MockGenesisConfig,
System, Test, Ump, RuntimeOrigin, System, Test, Ump,
}; };
use frame_support::{assert_noop, assert_ok, weights::Weight}; use frame_support::{assert_noop, assert_ok, weights::Weight};
use std::collections::HashSet; use std::collections::HashSet;
@@ -296,7 +296,7 @@ fn service_overweight_unknown() {
// the next test. // the next test.
new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| { new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| {
assert_noop!( assert_noop!(
Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(1000)), Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)),
Error::<Test>::UnknownMessageIndex Error::<Test>::UnknownMessageIndex
); );
}); });
@@ -346,18 +346,18 @@ fn overweight_queue_works() {
// Now verify that if we wanted to service this overweight message with less than enough // Now verify that if we wanted to service this overweight message with less than enough
// weight it will fail. // weight it will fail.
assert_noop!( assert_noop!(
Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(499)), Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(499)),
Error::<Test>::WeightOverLimit Error::<Test>::WeightOverLimit
); );
// ... and if we try to service it with just enough weight it will succeed as well. // ... and if we try to service it with just enough weight it will succeed as well.
assert_ok!(Ump::service_overweight(Origin::root(), 0, Weight::from_ref_time(500))); assert_ok!(Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(500)));
assert_last_event(Event::OverweightServiced(0, Weight::from_ref_time(500)).into()); assert_last_event(Event::OverweightServiced(0, Weight::from_ref_time(500)).into());
// ... and if we try to service a message with index that doesn't exist it will error // ... and if we try to service a message with index that doesn't exist it will error
// out. // out.
assert_noop!( assert_noop!(
Ump::service_overweight(Origin::root(), 1, Weight::from_ref_time(1000)), Ump::service_overweight(RuntimeOrigin::root(), 1, Weight::from_ref_time(1000)),
Error::<Test>::UnknownMessageIndex Error::<Test>::UnknownMessageIndex
); );
}); });
+6 -6
View File
@@ -147,7 +147,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = BlockLength; type BlockLength = BlockLength;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -206,8 +206,8 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
} }
impl pallet_scheduler::Config for Runtime { impl pallet_scheduler::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type PalletsOrigin = OriginCaller; type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight; type MaximumWeight = MaximumSchedulerWeight;
@@ -673,7 +673,7 @@ parameter_types! {
pub type CouncilCollective = pallet_collective::Instance1; pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime { impl pallet_collective::Config<CouncilCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration; type MotionDuration = CouncilMotionDuration;
@@ -729,7 +729,7 @@ parameter_types! {
pub type TechnicalCollective = pallet_collective::Instance2; pub type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime { impl pallet_collective::Config<TechnicalCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration; type MotionDuration = TechnicalMotionDuration;
@@ -1239,8 +1239,8 @@ impl parachains_ump::Config for Runtime {
impl parachains_dmp::Config for Runtime {} impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime { impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
} }
@@ -1272,8 +1272,8 @@ parameter_types! {
} }
impl paras_registrar::Config for Runtime { impl paras_registrar::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type OnSwap = (Crowdloan, Slots); type OnSwap = (Crowdloan, Slots);
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
+10 -10
View File
@@ -17,8 +17,8 @@
//! XCM configuration for Polkadot. //! XCM configuration for Polkadot.
use super::{ use super::{
parachains_origin, AccountId, Balances, CouncilCollective, Origin, ParaId, Runtime, parachains_origin, AccountId, Balances, CouncilCollective, ParaId, Runtime, RuntimeCall,
RuntimeCall, RuntimeEvent, WeightToFee, XcmPallet, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet,
}; };
use frame_support::{ use frame_support::{
match_types, parameter_types, match_types, parameter_types,
@@ -80,13 +80,13 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
type LocalOriginConverter = ( type LocalOriginConverter = (
// If the origin kind is `Sovereign`, then return a `Signed` origin with the account determined // If the origin kind is `Sovereign`, then return a `Signed` origin with the account determined
// by the `SovereignAccountOf` converter. // by the `SovereignAccountOf` converter.
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
// If the origin kind is `Native` and the XCM origin is a child parachain, then we can express // If the origin kind is `Native` and the XCM origin is a child parachain, then we can express
// it with the special `parachains_origin::Origin` origin variant. // it with the special `parachains_origin::Origin` origin variant.
ChildParachainAsNative<parachains_origin::Origin, Origin>, ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
// If the origin kind is `Native` and the XCM origin is the `AccountId32` location, then it can // If the origin kind is `Native` and the XCM origin is the `AccountId32` location, then it can
// be expressed using the `Signed` origin variant. // be expressed using the `Signed` origin variant.
SignedAccountId32AsNative<PolkadotNetwork, Origin>, SignedAccountId32AsNative<PolkadotNetwork, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -158,7 +158,7 @@ parameter_types! {
/// Type to convert a council origin to a Plurality `MultiLocation` value. /// Type to convert a council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality< pub type CouncilToPlurality = BackingToPlurality<
Origin, RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>, pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId, CouncilBodyId,
>; >;
@@ -170,16 +170,16 @@ pub type LocalOriginToLocation = (
// `Unit` body. // `Unit` body.
CouncilToPlurality, CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32 // And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, PolkadotNetwork>, SignedToAccountId32<RuntimeOrigin, AccountId, PolkadotNetwork>,
); );
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
// Only allow the council to send messages. // Only allow the council to send messages.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, CouncilToPlurality>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, CouncilToPlurality>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally... // Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
// ...but they must match our filter, which rejects all. // ...but they must match our filter, which rejects all.
type XcmExecuteFilter = Nothing; // == Deny All type XcmExecuteFilter = Nothing; // == Deny All
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
@@ -187,7 +187,7 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything; // == Allow All type XcmReserveTransferFilter = Everything; // == Allow All
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = AdvertisedXcmVersion; type AdvertisedXcmVersion = AdvertisedXcmVersion;
+6 -6
View File
@@ -149,7 +149,7 @@ impl frame_system::Config for Runtime {
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = BlockLength; type BlockLength = BlockLength;
type DbWeight = RocksDbWeight; type DbWeight = RocksDbWeight;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -207,8 +207,8 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
} }
impl pallet_scheduler::Config for Runtime { impl pallet_scheduler::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type PalletsOrigin = OriginCaller; type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight; type MaximumWeight = MaximumSchedulerWeight;
@@ -459,7 +459,7 @@ parameter_types! {
type CouncilCollective = pallet_collective::Instance1; type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime { impl pallet_collective::Config<CouncilCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration; type MotionDuration = CouncilMotionDuration;
@@ -515,7 +515,7 @@ parameter_types! {
type TechnicalCollective = pallet_collective::Instance2; type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime { impl pallet_collective::Config<TechnicalCollective> for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall; type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration; type MotionDuration = TechnicalMotionDuration;
@@ -1071,8 +1071,8 @@ impl parachains_ump::Config for Runtime {
impl parachains_dmp::Config for Runtime {} impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime { impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
} }
@@ -1118,8 +1118,8 @@ parameter_types! {
} }
impl paras_registrar::Config for Runtime { impl paras_registrar::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type OnSwap = (Crowdloan, Slots); type OnSwap = (Crowdloan, Slots);
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
@@ -40,7 +40,7 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Privileged origin that can add or remove validators. /// Privileged origin that can add or remove validators.
type PrivilegedOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>; type PrivilegedOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
} }
#[pallet::event] #[pallet::event]
+11 -11
View File
@@ -17,8 +17,8 @@
//! XCM configuration for Rococo. //! XCM configuration for Rococo.
use super::{ use super::{
parachains_origin, AccountId, Balances, CouncilCollective, Origin, ParaId, Runtime, parachains_origin, AccountId, Balances, CouncilCollective, ParaId, Runtime, RuntimeCall,
RuntimeCall, RuntimeEvent, WeightToFee, XcmPallet, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet,
}; };
use frame_support::{match_types, parameter_types, traits::Everything}; use frame_support::{match_types, parameter_types, traits::Everything};
use runtime_common::{xcm_sender, ToAuthor}; use runtime_common::{xcm_sender, ToAuthor};
@@ -76,13 +76,13 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
/// The means that we convert an the XCM message origin location into a local dispatch origin. /// The means that we convert an the XCM message origin location into a local dispatch origin.
type LocalOriginConverter = ( type LocalOriginConverter = (
// A `Signed` origin of the sovereign account that the original location controls. // A `Signed` origin of the sovereign account that the original location controls.
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
// A child parachain, natively expressed, has the `Parachain` origin. // A child parachain, natively expressed, has the `Parachain` origin.
ChildParachainAsNative<parachains_origin::Origin, Origin>, ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
// The AccountId32 location type can be expressed natively as a `Signed` origin. // The AccountId32 location type can be expressed natively as a `Signed` origin.
SignedAccountId32AsNative<RococoNetwork, Origin>, SignedAccountId32AsNative<RococoNetwork, RuntimeOrigin>,
// A system child parachain, expressed as a Superuser, converts to the `Root` origin. // A system child parachain, expressed as a Superuser, converts to the `Root` origin.
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -176,7 +176,7 @@ parameter_types! {
/// Type to convert the council origin to a Plurality `MultiLocation` value. /// Type to convert the council origin to a Plurality `MultiLocation` value.
pub type CouncilToPlurality = BackingToPlurality< pub type CouncilToPlurality = BackingToPlurality<
Origin, RuntimeOrigin,
pallet_collective::Origin<Runtime, CouncilCollective>, pallet_collective::Origin<Runtime, CouncilCollective>,
CouncilBodyId, CouncilBodyId,
>; >;
@@ -188,14 +188,14 @@ pub type LocalOriginToLocation = (
// `Unit` body. // `Unit` body.
CouncilToPlurality, CouncilToPlurality,
// And a usual Signed origin to be used in XCM as a corresponding AccountId32 // And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, RococoNetwork>, SignedToAccountId32<RuntimeOrigin, AccountId, RococoNetwork>,
); );
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally. // Anyone can execute XCM messages locally.
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
// Anyone is able to use teleportation regardless of who they are and what they want to teleport. // Anyone is able to use teleportation regardless of who they are and what they want to teleport.
@@ -205,7 +205,7 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
+11 -10
View File
@@ -135,7 +135,7 @@ impl frame_system::Config for Runtime {
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = BlockLength; type BlockLength = BlockLength;
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -534,30 +534,31 @@ parameter_types! {
pub const MaxInstructions: u32 = 100; pub const MaxInstructions: u32 = 100;
} }
pub type LocalOriginToLocation = xcm_builder::SignedToAccountId32<Origin, AccountId, AnyNetwork>; pub type LocalOriginToLocation =
xcm_builder::SignedToAccountId32<RuntimeOrigin, AccountId, AnyNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
// The config types here are entirely configurable, since the only one that is sorely needed // The config types here are entirely configurable, since the only one that is sorely needed
// is `XcmExecutor`, which will be used in unit tests located in xcm-executor. // is `XcmExecutor`, which will be used in unit tests located in xcm-executor.
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type LocationInverter = xcm_config::InvertNothing; type LocationInverter = xcm_config::InvertNothing;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type Weigher = xcm_builder::FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = xcm_builder::FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type XcmRouter = xcm_config::DoNothingRouter; type XcmRouter = xcm_config::DoNothingRouter;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = xcm_executor::XcmExecutor<xcm_config::XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<xcm_config::XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
impl parachains_hrmp::Config for Runtime { impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type WeightInfo = parachains_hrmp::TestWeightInfo; type WeightInfo = parachains_hrmp::TestWeightInfo;
} }
@@ -570,7 +571,7 @@ impl parachains_origin::Config for Runtime {}
impl pallet_test_notifier::Config for Runtime { impl pallet_test_notifier::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
} }
@@ -589,8 +590,8 @@ pub mod pallet_test_notifier {
#[pallet::config] #[pallet::config]
pub trait Config: frame_system::Config + pallet_xcm::Config { pub trait Config: frame_system::Config + pallet_xcm::Config {
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>; type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
type Origin: IsType<<Self as frame_system::Config>::Origin> type RuntimeOrigin: IsType<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<Result<pallet_xcm::Origin, <Self as Config>::Origin>>; + Into<Result<pallet_xcm::Origin, <Self as Config>::RuntimeOrigin>>;
type RuntimeCall: IsType<<Self as pallet_xcm::Config>::RuntimeCall> + From<Call<Self>>; type RuntimeCall: IsType<<Self as pallet_xcm::Config>::RuntimeCall> + From<Call<Self>>;
} }
@@ -647,7 +648,7 @@ pub mod pallet_test_notifier {
query_id: QueryId, query_id: QueryId,
response: Response, response: Response,
) -> DispatchResult { ) -> DispatchResult {
let responder = ensure_response(<T as Config>::Origin::from(origin))?; let responder = ensure_response(<T as Config>::RuntimeOrigin::from(origin))?;
Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response)); Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response));
Ok(()) Ok(())
} }
@@ -31,7 +31,7 @@ parameter_types! {
/// of this chain. /// of this chain.
pub type LocalOriginToLocation = ( pub type LocalOriginToLocation = (
// And a usual Signed origin to be used in XCM as a corresponding AccountId32 // And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<crate::Origin, crate::AccountId, OurNetwork>, SignedToAccountId32<crate::RuntimeOrigin, crate::AccountId, OurNetwork>,
); );
pub struct DoNothingRouter; pub struct DoNothingRouter;
@@ -81,7 +81,7 @@ impl xcm_executor::Config for XcmConfig {
type RuntimeCall = super::RuntimeCall; type RuntimeCall = super::RuntimeCall;
type XcmSender = DoNothingRouter; type XcmSender = DoNothingRouter;
type AssetTransactor = DummyAssetTransactor; type AssetTransactor = DummyAssetTransactor;
type OriginConverter = pallet_xcm::XcmPassthrough<super::Origin>; type OriginConverter = pallet_xcm::XcmPassthrough<super::RuntimeOrigin>;
type IsReserve = (); type IsReserve = ();
type IsTeleporter = (); type IsTeleporter = ();
type LocationInverter = InvertNothing; type LocationInverter = InvertNothing;
+4 -4
View File
@@ -141,7 +141,7 @@ impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights; type BlockWeights = BlockWeights;
type BlockLength = BlockLength; type BlockLength = BlockLength;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
@@ -172,8 +172,8 @@ parameter_types! {
} }
impl pallet_scheduler::Config for Runtime { impl pallet_scheduler::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type PalletsOrigin = OriginCaller; type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight; type MaximumWeight = MaximumSchedulerWeight;
@@ -906,8 +906,8 @@ impl parachains_ump::Config for Runtime {
impl parachains_dmp::Config for Runtime {} impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime { impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
} }
@@ -975,8 +975,8 @@ parameter_types! {
} }
impl paras_registrar::Config for Runtime { impl paras_registrar::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin;
type Currency = Balances; type Currency = Balances;
type OnSwap = (Crowdloan, Slots); type OnSwap = (Crowdloan, Slots);
type ParaDeposit = ParaDeposit; type ParaDeposit = ParaDeposit;
+10 -10
View File
@@ -17,8 +17,8 @@
//! XCM configurations for Westend. //! XCM configurations for Westend.
use super::{ use super::{
parachains_origin, weights, AccountId, Balances, Origin, ParaId, Runtime, RuntimeCall, parachains_origin, weights, AccountId, Balances, ParaId, Runtime, RuntimeCall, RuntimeEvent,
RuntimeEvent, WeightToFee, XcmPallet, RuntimeOrigin, WeightToFee, XcmPallet,
}; };
use frame_support::{ use frame_support::{
parameter_types, parameter_types,
@@ -60,10 +60,10 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
>; >;
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<LocationConverter, Origin>, SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>,
ChildParachainAsNative<parachains_origin::Origin, Origin>, ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<WestendNetwork, Origin>, SignedAccountId32AsNative<WestendNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our /// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
@@ -122,15 +122,15 @@ impl xcm_executor::Config for XcmConfig {
/// of this chain. /// of this chain.
pub type LocalOriginToLocation = ( pub type LocalOriginToLocation = (
// And a usual Signed origin to be used in XCM as a corresponding AccountId32 // And a usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, WestendNetwork>, SignedToAccountId32<RuntimeOrigin, AccountId, WestendNetwork>,
); );
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally... // Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
// ...but they must match our filter, which rejects everything. // ...but they must match our filter, which rejects everything.
type XcmExecuteFilter = Nothing; type XcmExecuteFilter = Nothing;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
@@ -139,7 +139,7 @@ impl pallet_xcm::Config for Runtime {
type Weigher = type Weigher =
WeightInfoBounds<weights::xcm::WestendXcmWeight<RuntimeCall>, RuntimeCall, MaxInstructions>; WeightInfoBounds<weights::xcm::WestendXcmWeight<RuntimeCall>, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -54,7 +54,7 @@ impl frame_system::Config for Test {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
type Hash = H256; type Hash = H256;
@@ -60,7 +60,7 @@ impl frame_system::Config for Test {
type BlockWeights = (); type BlockWeights = ();
type BlockLength = (); type BlockLength = ();
type DbWeight = (); type DbWeight = ();
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
type Hash = H256; type Hash = H256;
@@ -103,7 +103,7 @@ impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type XcmSender = DevNull; type XcmSender = DevNull;
type AssetTransactor = NoAssetTransactor; type AssetTransactor = NoAssetTransactor;
type OriginConverter = AlwaysSignedByDefault<Origin>; type OriginConverter = AlwaysSignedByDefault<RuntimeOrigin>;
type IsReserve = AllAssetLocationsPass; type IsReserve = AllAssetLocationsPass;
type IsTeleporter = (); type IsTeleporter = ();
type LocationInverter = xcm_builder::LocationInverter<Ancestry>; type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
@@ -159,18 +159,18 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
t.into() t.into()
} }
pub struct AlwaysSignedByDefault<Origin>(core::marker::PhantomData<Origin>); pub struct AlwaysSignedByDefault<RuntimeOrigin>(core::marker::PhantomData<RuntimeOrigin>);
impl<Origin> ConvertOrigin<Origin> for AlwaysSignedByDefault<Origin> impl<RuntimeOrigin> ConvertOrigin<RuntimeOrigin> for AlwaysSignedByDefault<RuntimeOrigin>
where where
Origin: OriginTrait, RuntimeOrigin: OriginTrait,
<Origin as OriginTrait>::AccountId: Decode, <RuntimeOrigin as OriginTrait>::AccountId: Decode,
{ {
fn convert_origin( fn convert_origin(
_origin: impl Into<MultiLocation>, _origin: impl Into<MultiLocation>,
_kind: OriginKind, _kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
Ok(Origin::signed( Ok(RuntimeOrigin::signed(
<Origin as OriginTrait>::AccountId::decode(&mut TrailingZeroInput::zeroes()) <RuntimeOrigin as OriginTrait>::AccountId::decode(&mut TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed"), .expect("infinite length input; no invalid inputs for type; qed"),
)) ))
} }
@@ -15,7 +15,7 @@ pub mod pallet {
#[pallet::config] #[pallet::config]
pub trait Config<I: 'static = ()>: frame_system::Config + crate::Config { pub trait Config<I: 'static = ()>: frame_system::Config + crate::Config {
type RuntimeCall: Dispatchable<Origin = Self::Origin> type RuntimeCall: Dispatchable<RuntimeOrigin = Self::RuntimeOrigin>
+ GetDispatchInfo + GetDispatchInfo
+ From<frame_system::Call<Self>> + From<frame_system::Call<Self>>
+ Encode; + Encode;
+18 -7
View File
@@ -75,7 +75,10 @@ pub mod pallet {
/// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation` /// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation`
/// which exists as an interior location within this chain's XCM context. /// which exists as an interior location within this chain's XCM context.
type SendXcmOrigin: EnsureOrigin<<Self as SysConfig>::Origin, Success = MultiLocation>; type SendXcmOrigin: EnsureOrigin<
<Self as SysConfig>::RuntimeOrigin,
Success = MultiLocation,
>;
/// The type used to actually dispatch an XCM to its destination. /// The type used to actually dispatch an XCM to its destination.
type XcmRouter: SendXcm; type XcmRouter: SendXcm;
@@ -83,7 +86,10 @@ pub mod pallet {
/// Required origin for executing XCM messages, including the teleport functionality. If successful, /// Required origin for executing XCM messages, including the teleport functionality. If successful,
/// then it resolves to `MultiLocation` which exists as an interior location within this chain's XCM /// then it resolves to `MultiLocation` which exists as an interior location within this chain's XCM
/// context. /// context.
type ExecuteXcmOrigin: EnsureOrigin<<Self as SysConfig>::Origin, Success = MultiLocation>; type ExecuteXcmOrigin: EnsureOrigin<
<Self as SysConfig>::RuntimeOrigin,
Success = MultiLocation,
>;
/// Our XCM filter which messages to be executed using `XcmExecutor` must pass. /// Our XCM filter which messages to be executed using `XcmExecutor` must pass.
type XcmExecuteFilter: Contains<(MultiLocation, Xcm<<Self as SysConfig>::RuntimeCall>)>; type XcmExecuteFilter: Contains<(MultiLocation, Xcm<<Self as SysConfig>::RuntimeCall>)>;
@@ -104,13 +110,16 @@ pub mod pallet {
type LocationInverter: InvertLocation; type LocationInverter: InvertLocation;
/// The outer `Origin` type. /// The outer `Origin` type.
type Origin: From<Origin> + From<<Self as SysConfig>::Origin>; type RuntimeOrigin: From<Origin> + From<<Self as SysConfig>::RuntimeOrigin>;
/// The outer `Call` type. /// The outer `Call` type.
type RuntimeCall: Parameter type RuntimeCall: Parameter
+ GetDispatchInfo + GetDispatchInfo
+ IsType<<Self as frame_system::Config>::RuntimeCall> + IsType<<Self as frame_system::Config>::RuntimeCall>
+ Dispatchable<Origin = <Self as Config>::Origin, PostInfo = PostDispatchInfo>; + Dispatchable<
RuntimeOrigin = <Self as Config>::RuntimeOrigin,
PostInfo = PostDispatchInfo,
>;
const VERSION_DISCOVERY_QUEUE_SIZE: u32; const VERSION_DISCOVERY_QUEUE_SIZE: u32;
@@ -1555,12 +1564,14 @@ where
/// A simple passthrough where we reuse the `MultiLocation`-typed XCM origin as the inner value of /// A simple passthrough where we reuse the `MultiLocation`-typed XCM origin as the inner value of
/// this crate's `Origin::Xcm` value. /// this crate's `Origin::Xcm` value.
pub struct XcmPassthrough<Origin>(PhantomData<Origin>); pub struct XcmPassthrough<RuntimeOrigin>(PhantomData<RuntimeOrigin>);
impl<Origin: From<crate::Origin>> ConvertOrigin<Origin> for XcmPassthrough<Origin> { impl<RuntimeOrigin: From<crate::Origin>> ConvertOrigin<RuntimeOrigin>
for XcmPassthrough<RuntimeOrigin>
{
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
match kind { match kind {
OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()), OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()),
+13 -13
View File
@@ -52,8 +52,8 @@ pub mod pallet_test_notifier {
#[pallet::config] #[pallet::config]
pub trait Config: frame_system::Config + crate::Config { pub trait Config: frame_system::Config + crate::Config {
type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>; type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;
type Origin: IsType<<Self as frame_system::Config>::Origin> type RuntimeOrigin: IsType<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<Result<crate::Origin, <Self as Config>::Origin>>; + Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;
type RuntimeCall: IsType<<Self as crate::Config>::RuntimeCall> + From<Call<Self>>; type RuntimeCall: IsType<<Self as crate::Config>::RuntimeCall> + From<Call<Self>>;
} }
@@ -110,7 +110,7 @@ pub mod pallet_test_notifier {
query_id: QueryId, query_id: QueryId,
response: Response, response: Response,
) -> DispatchResult { ) -> DispatchResult {
let responder = ensure_response(<T as Config>::Origin::from(origin))?; let responder = ensure_response(<T as Config>::RuntimeOrigin::from(origin))?;
Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response)); Self::deposit_event(Event::<T>::ResponseReceived(responder, query_id, response));
Ok(()) Ok(())
} }
@@ -171,7 +171,7 @@ parameter_types! {
} }
impl frame_system::Config for Test { impl frame_system::Config for Test {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -229,10 +229,10 @@ pub type LocalAssetTransactor =
XcmCurrencyAdapter<Balances, IsConcrete<RelayLocation>, SovereignAccountOf, AccountId, ()>; XcmCurrencyAdapter<Balances, IsConcrete<RelayLocation>, SovereignAccountOf, AccountId, ()>;
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
ChildParachainAsNative<origin::Origin, Origin>, ChildParachainAsNative<origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<AnyNetwork, Origin>, SignedAccountId32AsNative<AnyNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -267,7 +267,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet; type SubscriptionService = XcmPallet;
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, AnyNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, AnyNetwork>;
parameter_types! { parameter_types! {
pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 2; pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 2;
@@ -275,16 +275,16 @@ parameter_types! {
impl pallet_xcm::Config for Test { impl pallet_xcm::Config for Test {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = (TestSendXcmErrX8, TestSendXcm); type XcmRouter = (TestSendXcmErrX8, TestSendXcm);
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = AdvertisedXcmVersion; type AdvertisedXcmVersion = AdvertisedXcmVersion;
@@ -294,7 +294,7 @@ impl origin::Config for Test {}
impl pallet_test_notifier::Config for Test { impl pallet_test_notifier::Config for Test {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
} }
+26 -22
View File
@@ -171,7 +171,11 @@ fn send_works() {
]); ]);
let versioned_dest = Box::new(RelayLocation::get().into()); let versioned_dest = Box::new(RelayLocation::get().into());
let versioned_message = Box::new(VersionedXcm::from(message.clone())); let versioned_message = Box::new(VersionedXcm::from(message.clone()));
assert_ok!(XcmPallet::send(Origin::signed(ALICE), versioned_dest, versioned_message)); assert_ok!(XcmPallet::send(
RuntimeOrigin::signed(ALICE),
versioned_dest,
versioned_message
));
assert_eq!( assert_eq!(
sent_xcm(), sent_xcm(),
vec![( vec![(
@@ -209,7 +213,7 @@ fn send_fails_when_xcm_router_blocks() {
]); ]);
assert_noop!( assert_noop!(
XcmPallet::send( XcmPallet::send(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(MultiLocation::ancestor(8).into()), Box::new(MultiLocation::ancestor(8).into()),
Box::new(VersionedXcm::from(message.clone())), Box::new(VersionedXcm::from(message.clone())),
), ),
@@ -233,7 +237,7 @@ fn teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::teleport_assets( assert_ok!(XcmPallet::teleport_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()), Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -276,7 +280,7 @@ fn limmited_teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets( assert_ok!(XcmPallet::limited_teleport_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()), Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -320,7 +324,7 @@ fn unlimmited_teleport_assets_works() {
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into(); let dest: MultiLocation = AccountId32 { network: Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets( assert_ok!(XcmPallet::limited_teleport_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(RelayLocation::get().into()), Box::new(RelayLocation::get().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -363,7 +367,7 @@ fn reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::reserve_transfer_assets( assert_ok!(XcmPallet::reserve_transfer_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()), Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -411,7 +415,7 @@ fn limited_reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets( assert_ok!(XcmPallet::limited_reserve_transfer_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()), Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -460,7 +464,7 @@ fn unlimited_reserve_transfer_assets_works() {
Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into(); Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets( assert_ok!(XcmPallet::limited_reserve_transfer_assets(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(Parachain(PARA_ID).into().into()), Box::new(Parachain(PARA_ID).into().into()),
Box::new(dest.clone().into()), Box::new(dest.clone().into()),
Box::new((Here, SEND_AMOUNT).into()), Box::new((Here, SEND_AMOUNT).into()),
@@ -507,7 +511,7 @@ fn execute_withdraw_to_deposit_works() {
Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into(); Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::execute( assert_ok!(XcmPallet::execute(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![ Box::new(VersionedXcm::from(Xcm(vec![
WithdrawAsset((Here, SEND_AMOUNT).into()), WithdrawAsset((Here, SEND_AMOUNT).into()),
buy_execution((Here, SEND_AMOUNT)), buy_execution((Here, SEND_AMOUNT)),
@@ -534,7 +538,7 @@ fn trapped_assets_can_be_claimed() {
Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into(); Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into();
assert_ok!(XcmPallet::execute( assert_ok!(XcmPallet::execute(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![ Box::new(VersionedXcm::from(Xcm(vec![
WithdrawAsset((Here, SEND_AMOUNT).into()), WithdrawAsset((Here, SEND_AMOUNT).into()),
buy_execution((Here, SEND_AMOUNT)), buy_execution((Here, SEND_AMOUNT)),
@@ -569,7 +573,7 @@ fn trapped_assets_can_be_claimed() {
let weight = 3 * BaseXcmWeight::get(); let weight = 3 * BaseXcmWeight::get();
assert_ok!(XcmPallet::execute( assert_ok!(XcmPallet::execute(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![ Box::new(VersionedXcm::from(Xcm(vec![
ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() },
buy_execution((Here, SEND_AMOUNT)), buy_execution((Here, SEND_AMOUNT)),
@@ -584,7 +588,7 @@ fn trapped_assets_can_be_claimed() {
let weight = 3 * BaseXcmWeight::get(); let weight = 3 * BaseXcmWeight::get();
assert_ok!(XcmPallet::execute( assert_ok!(XcmPallet::execute(
Origin::signed(ALICE), RuntimeOrigin::signed(ALICE),
Box::new(VersionedXcm::from(Xcm(vec![ Box::new(VersionedXcm::from(Xcm(vec![
ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() },
buy_execution((Here, SEND_AMOUNT)), buy_execution((Here, SEND_AMOUNT)),
@@ -615,7 +619,7 @@ fn basic_subscription_works() {
new_test_ext_with_balances(vec![]).execute_with(|| { new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into(); let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()), Box::new(remote.clone().into()),
)); ));
@@ -658,13 +662,13 @@ fn subscriptions_increment_id() {
new_test_ext_with_balances(vec![]).execute_with(|| { new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into(); let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()), Box::new(remote.clone().into()),
)); ));
let remote2 = Parachain(1001).into(); let remote2 = Parachain(1001).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote2.clone().into()), Box::new(remote2.clone().into()),
)); ));
@@ -689,12 +693,12 @@ fn double_subscription_fails() {
new_test_ext_with_balances(vec![]).execute_with(|| { new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into(); let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()), Box::new(remote.clone().into()),
)); ));
assert_noop!( assert_noop!(
XcmPallet::force_subscribe_version_notify( XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()) Box::new(remote.clone().into())
), ),
Error::<Test>::AlreadySubscribed, Error::<Test>::AlreadySubscribed,
@@ -707,16 +711,16 @@ fn unsubscribe_works() {
new_test_ext_with_balances(vec![]).execute_with(|| { new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into(); let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()), Box::new(remote.clone().into()),
)); ));
assert_ok!(XcmPallet::force_unsubscribe_version_notify( assert_ok!(XcmPallet::force_unsubscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()) Box::new(remote.clone().into())
)); ));
assert_noop!( assert_noop!(
XcmPallet::force_unsubscribe_version_notify( XcmPallet::force_unsubscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()) Box::new(remote.clone().into())
), ),
Error::<Test>::NoSubscription, Error::<Test>::NoSubscription,
@@ -851,7 +855,7 @@ fn subscriber_side_subscription_works() {
new_test_ext_with_balances(vec![]).execute_with(|| { new_test_ext_with_balances(vec![]).execute_with(|| {
let remote = Parachain(1000).into(); let remote = Parachain(1000).into();
assert_ok!(XcmPallet::force_subscribe_version_notify( assert_ok!(XcmPallet::force_subscribe_version_notify(
Origin::root(), RuntimeOrigin::root(),
Box::new(remote.clone().into()), Box::new(remote.clone().into()),
)); ));
take_sent_xcm(); take_sent_xcm();
@@ -893,7 +897,7 @@ fn auto_subscription_works() {
let remote0 = Parachain(1000).into(); let remote0 = Parachain(1000).into();
let remote1 = Parachain(1001).into(); let remote1 = Parachain(1001).into();
assert_ok!(XcmPallet::force_default_xcm_version(Origin::root(), Some(1))); assert_ok!(XcmPallet::force_default_xcm_version(RuntimeOrigin::root(), Some(1)));
// Wrapping a version for a destination we don't know elicits a subscription. // Wrapping a version for a destination we don't know elicits a subscription.
let v1_msg = xcm::v1::Xcm::<()>::QueryResponse { let v1_msg = xcm::v1::Xcm::<()>::QueryResponse {
+2 -2
View File
@@ -60,11 +60,11 @@ pub enum TestCall {
Any(Weight, Option<Weight>), Any(Weight, Option<Weight>),
} }
impl Dispatchable for TestCall { impl Dispatchable for TestCall {
type Origin = TestOrigin; type RuntimeOrigin = TestOrigin;
type Config = (); type Config = ();
type Info = (); type Info = ();
type PostInfo = PostDispatchInfo; type PostInfo = PostDispatchInfo;
fn dispatch(self, origin: Self::Origin) -> DispatchResultWithPostInfo { fn dispatch(self, origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo {
let mut post_info = PostDispatchInfo::default(); let mut post_info = PostDispatchInfo::default();
let maybe_actual = match self { let maybe_actual = match self {
TestCall::OnlyRoot(_, maybe_actual) | TestCall::OnlyRoot(_, maybe_actual) |
@@ -24,18 +24,20 @@ use xcm::latest::{BodyId, BodyPart, Junction, Junctions::*, MultiLocation, Netwo
use xcm_executor::traits::{Convert, ConvertOrigin}; use xcm_executor::traits::{Convert, ConvertOrigin};
/// Sovereign accounts use the system's `Signed` origin with an account ID derived from the `LocationConverter`. /// Sovereign accounts use the system's `Signed` origin with an account ID derived from the `LocationConverter`.
pub struct SovereignSignedViaLocation<LocationConverter, Origin>( pub struct SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>(
PhantomData<(LocationConverter, Origin)>, PhantomData<(LocationConverter, RuntimeOrigin)>,
); );
impl<LocationConverter: Convert<MultiLocation, Origin::AccountId>, Origin: OriginTrait> impl<
ConvertOrigin<Origin> for SovereignSignedViaLocation<LocationConverter, Origin> LocationConverter: Convert<MultiLocation, RuntimeOrigin::AccountId>,
RuntimeOrigin: OriginTrait,
> ConvertOrigin<RuntimeOrigin> for SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>
where where
Origin::AccountId: Clone, RuntimeOrigin::AccountId: Clone,
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!( log::trace!(
target: "xcm::origin_conversion", target: "xcm::origin_conversion",
@@ -44,57 +46,61 @@ where
); );
if let OriginKind::SovereignAccount = kind { if let OriginKind::SovereignAccount = kind {
let location = LocationConverter::convert(origin)?; let location = LocationConverter::convert(origin)?;
Ok(Origin::signed(location).into()) Ok(RuntimeOrigin::signed(location).into())
} else { } else {
Err(origin) Err(origin)
} }
} }
} }
pub struct ParentAsSuperuser<Origin>(PhantomData<Origin>); pub struct ParentAsSuperuser<RuntimeOrigin>(PhantomData<RuntimeOrigin>);
impl<Origin: OriginTrait> ConvertOrigin<Origin> for ParentAsSuperuser<Origin> { impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin> for ParentAsSuperuser<RuntimeOrigin> {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!(target: "xcm::origin_conversion", "ParentAsSuperuser origin: {:?}, kind: {:?}", origin, kind); log::trace!(target: "xcm::origin_conversion", "ParentAsSuperuser origin: {:?}, kind: {:?}", origin, kind);
if kind == OriginKind::Superuser && origin.contains_parents_only(1) { if kind == OriginKind::Superuser && origin.contains_parents_only(1) {
Ok(Origin::root()) Ok(RuntimeOrigin::root())
} else { } else {
Err(origin) Err(origin)
} }
} }
} }
pub struct ChildSystemParachainAsSuperuser<ParaId, Origin>(PhantomData<(ParaId, Origin)>); pub struct ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(
impl<ParaId: IsSystem + From<u32>, Origin: OriginTrait> ConvertOrigin<Origin> PhantomData<(ParaId, RuntimeOrigin)>,
for ChildSystemParachainAsSuperuser<ParaId, Origin> );
impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
for ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!(target: "xcm::origin_conversion", "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}", origin, kind); log::trace!(target: "xcm::origin_conversion", "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}", origin, kind);
match (kind, origin) { match (kind, origin) {
( (
OriginKind::Superuser, OriginKind::Superuser,
MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) }, MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) },
) if ParaId::from(id).is_system() => Ok(Origin::root()), ) if ParaId::from(id).is_system() => Ok(RuntimeOrigin::root()),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
pub struct SiblingSystemParachainAsSuperuser<ParaId, Origin>(PhantomData<(ParaId, Origin)>); pub struct SiblingSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(
impl<ParaId: IsSystem + From<u32>, Origin: OriginTrait> ConvertOrigin<Origin> PhantomData<(ParaId, RuntimeOrigin)>,
for SiblingSystemParachainAsSuperuser<ParaId, Origin> );
impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
for SiblingSystemParachainAsSuperuser<ParaId, RuntimeOrigin>
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!( log::trace!(
target: "xcm::origin_conversion", target: "xcm::origin_conversion",
@@ -105,42 +111,44 @@ impl<ParaId: IsSystem + From<u32>, Origin: OriginTrait> ConvertOrigin<Origin>
( (
OriginKind::Superuser, OriginKind::Superuser,
MultiLocation { parents: 1, interior: X1(Junction::Parachain(id)) }, MultiLocation { parents: 1, interior: X1(Junction::Parachain(id)) },
) if ParaId::from(id).is_system() => Ok(Origin::root()), ) if ParaId::from(id).is_system() => Ok(RuntimeOrigin::root()),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
pub struct ChildParachainAsNative<ParachainOrigin, Origin>(PhantomData<(ParachainOrigin, Origin)>); pub struct ChildParachainAsNative<ParachainOrigin, RuntimeOrigin>(
impl<ParachainOrigin: From<u32>, Origin: From<ParachainOrigin>> ConvertOrigin<Origin> PhantomData<(ParachainOrigin, RuntimeOrigin)>,
for ChildParachainAsNative<ParachainOrigin, Origin> );
impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOrigin<RuntimeOrigin>
for ChildParachainAsNative<ParachainOrigin, RuntimeOrigin>
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!(target: "xcm::origin_conversion", "ChildParachainAsNative origin: {:?}, kind: {:?}", origin, kind); log::trace!(target: "xcm::origin_conversion", "ChildParachainAsNative origin: {:?}, kind: {:?}", origin, kind);
match (kind, origin) { match (kind, origin) {
( (
OriginKind::Native, OriginKind::Native,
MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) }, MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) },
) => Ok(Origin::from(ParachainOrigin::from(id))), ) => Ok(RuntimeOrigin::from(ParachainOrigin::from(id))),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
pub struct SiblingParachainAsNative<ParachainOrigin, Origin>( pub struct SiblingParachainAsNative<ParachainOrigin, RuntimeOrigin>(
PhantomData<(ParachainOrigin, Origin)>, PhantomData<(ParachainOrigin, RuntimeOrigin)>,
); );
impl<ParachainOrigin: From<u32>, Origin: From<ParachainOrigin>> ConvertOrigin<Origin> impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOrigin<RuntimeOrigin>
for SiblingParachainAsNative<ParachainOrigin, Origin> for SiblingParachainAsNative<ParachainOrigin, RuntimeOrigin>
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!( log::trace!(
target: "xcm::origin_conversion", target: "xcm::origin_conversion",
@@ -151,21 +159,23 @@ impl<ParachainOrigin: From<u32>, Origin: From<ParachainOrigin>> ConvertOrigin<Or
( (
OriginKind::Native, OriginKind::Native,
MultiLocation { parents: 1, interior: X1(Junction::Parachain(id)) }, MultiLocation { parents: 1, interior: X1(Junction::Parachain(id)) },
) => Ok(Origin::from(ParachainOrigin::from(id))), ) => Ok(RuntimeOrigin::from(ParachainOrigin::from(id))),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
// Our Relay-chain has a native origin given by the `Get`ter. // Our Relay-chain has a native origin given by the `Get`ter.
pub struct RelayChainAsNative<RelayOrigin, Origin>(PhantomData<(RelayOrigin, Origin)>); pub struct RelayChainAsNative<RelayOrigin, RuntimeOrigin>(
impl<RelayOrigin: Get<Origin>, Origin> ConvertOrigin<Origin> PhantomData<(RelayOrigin, RuntimeOrigin)>,
for RelayChainAsNative<RelayOrigin, Origin> );
impl<RelayOrigin: Get<RuntimeOrigin>, RuntimeOrigin> ConvertOrigin<RuntimeOrigin>
for RelayChainAsNative<RelayOrigin, RuntimeOrigin>
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!(target: "xcm::origin_conversion", "RelayChainAsNative origin: {:?}, kind: {:?}", origin, kind); log::trace!(target: "xcm::origin_conversion", "RelayChainAsNative origin: {:?}, kind: {:?}", origin, kind);
if kind == OriginKind::Native && origin.contains_parents_only(1) { if kind == OriginKind::Native && origin.contains_parents_only(1) {
@@ -176,16 +186,16 @@ impl<RelayOrigin: Get<Origin>, Origin> ConvertOrigin<Origin>
} }
} }
pub struct SignedAccountId32AsNative<Network, Origin>(PhantomData<(Network, Origin)>); pub struct SignedAccountId32AsNative<Network, RuntimeOrigin>(PhantomData<(Network, RuntimeOrigin)>);
impl<Network: Get<NetworkId>, Origin: OriginTrait> ConvertOrigin<Origin> impl<Network: Get<NetworkId>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
for SignedAccountId32AsNative<Network, Origin> for SignedAccountId32AsNative<Network, RuntimeOrigin>
where where
Origin::AccountId: From<[u8; 32]>, RuntimeOrigin::AccountId: From<[u8; 32]>,
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!( log::trace!(
target: "xcm::origin_conversion", target: "xcm::origin_conversion",
@@ -197,22 +207,24 @@ where
OriginKind::Native, OriginKind::Native,
MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, network }) }, MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, network }) },
) if matches!(network, NetworkId::Any) || network == Network::get() => ) if matches!(network, NetworkId::Any) || network == Network::get() =>
Ok(Origin::signed(id.into())), Ok(RuntimeOrigin::signed(id.into())),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
pub struct SignedAccountKey20AsNative<Network, Origin>(PhantomData<(Network, Origin)>); pub struct SignedAccountKey20AsNative<Network, RuntimeOrigin>(
impl<Network: Get<NetworkId>, Origin: OriginTrait> ConvertOrigin<Origin> PhantomData<(Network, RuntimeOrigin)>,
for SignedAccountKey20AsNative<Network, Origin> );
impl<Network: Get<NetworkId>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
for SignedAccountKey20AsNative<Network, RuntimeOrigin>
where where
Origin::AccountId: From<[u8; 20]>, RuntimeOrigin::AccountId: From<[u8; 20]>,
{ {
fn convert_origin( fn convert_origin(
origin: impl Into<MultiLocation>, origin: impl Into<MultiLocation>,
kind: OriginKind, kind: OriginKind,
) -> Result<Origin, MultiLocation> { ) -> Result<RuntimeOrigin, MultiLocation> {
let origin = origin.into(); let origin = origin.into();
log::trace!( log::trace!(
target: "xcm::origin_conversion", target: "xcm::origin_conversion",
@@ -224,28 +236,28 @@ where
OriginKind::Native, OriginKind::Native,
MultiLocation { parents: 0, interior: X1(Junction::AccountKey20 { key, network }) }, MultiLocation { parents: 0, interior: X1(Junction::AccountKey20 { key, network }) },
) if (matches!(network, NetworkId::Any) || network == Network::get()) => ) if (matches!(network, NetworkId::Any) || network == Network::get()) =>
Ok(Origin::signed(key.into())), Ok(RuntimeOrigin::signed(key.into())),
(_, origin) => Err(origin), (_, origin) => Err(origin),
} }
} }
} }
/// `EnsureOrigin` barrier to convert from dispatch origin to XCM origin, if one exists. /// `EnsureOrigin` barrier to convert from dispatch origin to XCM origin, if one exists.
pub struct EnsureXcmOrigin<Origin, Conversion>(PhantomData<(Origin, Conversion)>); pub struct EnsureXcmOrigin<RuntimeOrigin, Conversion>(PhantomData<(RuntimeOrigin, Conversion)>);
impl<Origin: OriginTrait + Clone, Conversion: Convert<Origin, MultiLocation>> EnsureOrigin<Origin> impl<RuntimeOrigin: OriginTrait + Clone, Conversion: Convert<RuntimeOrigin, MultiLocation>>
for EnsureXcmOrigin<Origin, Conversion> EnsureOrigin<RuntimeOrigin> for EnsureXcmOrigin<RuntimeOrigin, Conversion>
where where
Origin::PalletsOrigin: PartialEq, RuntimeOrigin::PalletsOrigin: PartialEq,
{ {
type Success = MultiLocation; type Success = MultiLocation;
fn try_origin(o: Origin) -> Result<Self::Success, Origin> { fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
let o = match Conversion::convert(o) { let o = match Conversion::convert(o) {
Ok(location) => return Ok(location), Ok(location) => return Ok(location),
Err(o) => o, Err(o) => o,
}; };
// We institute a root fallback so root can always represent the context. This // We institute a root fallback so root can always represent the context. This
// guarantees that `successful_origin` will work. // guarantees that `successful_origin` will work.
if o.caller() == Origin::root().caller() { if o.caller() == RuntimeOrigin::root().caller() {
Ok(Here.into()) Ok(Here.into())
} else { } else {
Err(o) Err(o)
@@ -253,8 +265,8 @@ where
} }
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<Origin, ()> { fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
Ok(Origin::root()) Ok(RuntimeOrigin::root())
} }
} }
@@ -262,16 +274,16 @@ where
/// ///
/// Typically used when configuring `pallet-xcm` for allowing normal accounts to dispatch an XCM from an `AccountId32` /// Typically used when configuring `pallet-xcm` for allowing normal accounts to dispatch an XCM from an `AccountId32`
/// origin. /// origin.
pub struct SignedToAccountId32<Origin, AccountId, Network>( pub struct SignedToAccountId32<RuntimeOrigin, AccountId, Network>(
PhantomData<(Origin, AccountId, Network)>, PhantomData<(RuntimeOrigin, AccountId, Network)>,
); );
impl<Origin: OriginTrait + Clone, AccountId: Into<[u8; 32]>, Network: Get<NetworkId>> impl<RuntimeOrigin: OriginTrait + Clone, AccountId: Into<[u8; 32]>, Network: Get<NetworkId>>
Convert<Origin, MultiLocation> for SignedToAccountId32<Origin, AccountId, Network> Convert<RuntimeOrigin, MultiLocation> for SignedToAccountId32<RuntimeOrigin, AccountId, Network>
where where
Origin::PalletsOrigin: From<SystemRawOrigin<AccountId>> RuntimeOrigin::PalletsOrigin: From<SystemRawOrigin<AccountId>>
+ TryInto<SystemRawOrigin<AccountId>, Error = Origin::PalletsOrigin>, + TryInto<SystemRawOrigin<AccountId>, Error = RuntimeOrigin::PalletsOrigin>,
{ {
fn convert(o: Origin) -> Result<MultiLocation, Origin> { fn convert(o: RuntimeOrigin) -> Result<MultiLocation, RuntimeOrigin> {
o.try_with_caller(|caller| match caller.try_into() { o.try_with_caller(|caller| match caller.try_into() {
Ok(SystemRawOrigin::Signed(who)) => Ok(SystemRawOrigin::Signed(who)) =>
Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into()), Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into()),
@@ -286,13 +298,16 @@ where
/// ///
/// Typically used when configuring `pallet-xcm` for allowing a collective's Origin to dispatch an XCM from a /// Typically used when configuring `pallet-xcm` for allowing a collective's Origin to dispatch an XCM from a
/// `Plurality` origin. /// `Plurality` origin.
pub struct BackingToPlurality<Origin, COrigin, Body>(PhantomData<(Origin, COrigin, Body)>); pub struct BackingToPlurality<RuntimeOrigin, COrigin, Body>(
impl<Origin: OriginTrait + Clone, COrigin: GetBacking, Body: Get<BodyId>> PhantomData<(RuntimeOrigin, COrigin, Body)>,
Convert<Origin, MultiLocation> for BackingToPlurality<Origin, COrigin, Body> );
impl<RuntimeOrigin: OriginTrait + Clone, COrigin: GetBacking, Body: Get<BodyId>>
Convert<RuntimeOrigin, MultiLocation> for BackingToPlurality<RuntimeOrigin, COrigin, Body>
where where
Origin::PalletsOrigin: From<COrigin> + TryInto<COrigin, Error = Origin::PalletsOrigin>, RuntimeOrigin::PalletsOrigin:
From<COrigin> + TryInto<COrigin, Error = RuntimeOrigin::PalletsOrigin>,
{ {
fn convert(o: Origin) -> Result<MultiLocation, Origin> { fn convert(o: RuntimeOrigin) -> Result<MultiLocation, RuntimeOrigin> {
o.try_with_caller(|caller| match caller.try_into() { o.try_with_caller(|caller| match caller.try_into() {
Ok(co) => match co.get_backing() { Ok(co) => match co.get_backing() {
Some(backing) => Ok(Junction::Plurality { Some(backing) => Ok(Junction::Plurality {
+9 -9
View File
@@ -61,7 +61,7 @@ parameter_types! {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -133,10 +133,10 @@ pub type LocalCurrencyAdapter = XcmCurrencyAdapter<
pub type LocalAssetTransactor = (LocalCurrencyAdapter,); pub type LocalAssetTransactor = (LocalCurrencyAdapter,);
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
ChildParachainAsNative<origin::Origin, Origin>, ChildParachainAsNative<origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<KusamaNetwork, Origin>, SignedAccountId32AsNative<KusamaNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -176,22 +176,22 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet; type SubscriptionService = XcmPallet;
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = TestSendXcm; type XcmRouter = TestSendXcm;
// Anyone can execute XCM messages locally... // Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Nothing; type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
} }
+1 -1
View File
@@ -33,7 +33,7 @@ pub trait Config {
type AssetTransactor: TransactAsset; type AssetTransactor: TransactAsset;
/// How to get a call origin from a `OriginKind` value. /// How to get a call origin from a `OriginKind` value.
type OriginConverter: ConvertOrigin<<Self::RuntimeCall as Dispatchable>::Origin>; type OriginConverter: ConvertOrigin<<Self::RuntimeCall as Dispatchable>::RuntimeOrigin>;
/// Combinations of (Location, Asset) pairs which we trust as reserves. /// Combinations of (Location, Asset) pairs which we trust as reserves.
type IsReserve: FilterAssetLocation; type IsReserve: FilterAssetLocation;
@@ -206,7 +206,7 @@ mod tests {
Relay::execute_with(|| { Relay::execute_with(|| {
assert_ok!(RelayChainPalletXcm::reserve_transfer_assets( assert_ok!(RelayChainPalletXcm::reserve_transfer_assets(
relay_chain::Origin::signed(ALICE), relay_chain::RuntimeOrigin::signed(ALICE),
Box::new(X1(Parachain(1)).into().into()), Box::new(X1(Parachain(1)).into().into()),
Box::new(X1(AccountId32 { network: Any, id: ALICE.into() }).into().into()), Box::new(X1(AccountId32 { network: Any, id: ALICE.into() }).into().into()),
Box::new((Here, withdraw_amount).into()), Box::new((Here, withdraw_amount).into()),
@@ -52,7 +52,7 @@ parameter_types! {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -114,9 +114,9 @@ pub type LocationToAccountId = (
); );
pub type XcmOriginToCallOrigin = ( pub type XcmOriginToCallOrigin = (
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
SignedAccountId32AsNative<RelayNetwork, Origin>, SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
XcmPassthrough<Origin>, XcmPassthrough<RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -298,20 +298,20 @@ impl mock_msg_queue::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Nothing; type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -42,7 +42,7 @@ parameter_types! {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -107,10 +107,10 @@ pub type LocalAssetTransactor =
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, SovereignAccountOf, AccountId, ()>; XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, SovereignAccountOf, AccountId, ()>;
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
ChildParachainAsNative<origin::Origin, Origin>, ChildParachainAsNative<origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<KusamaNetwork, Origin>, SignedAccountId32AsNative<KusamaNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -140,21 +140,21 @@ impl Config for XcmConfig {
type SubscriptionService = (); type SubscriptionService = ();
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally... // Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Nothing; type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -52,7 +52,7 @@ parameter_types! {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -114,9 +114,9 @@ pub type LocationToAccountId = (
); );
pub type XcmOriginToCallOrigin = ( pub type XcmOriginToCallOrigin = (
SovereignSignedViaLocation<LocationToAccountId, Origin>, SovereignSignedViaLocation<LocationToAccountId, RuntimeOrigin>,
SignedAccountId32AsNative<RelayNetwork, Origin>, SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
XcmPassthrough<Origin>, XcmPassthrough<RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -298,20 +298,20 @@ impl mock_msg_queue::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Nothing; type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
@@ -42,7 +42,7 @@ parameter_types! {
} }
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64; type BlockNumber = u64;
@@ -107,10 +107,10 @@ pub type LocalAssetTransactor =
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, SovereignAccountOf, AccountId, ()>; XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, SovereignAccountOf, AccountId, ()>;
type LocalOriginConverter = ( type LocalOriginConverter = (
SovereignSignedViaLocation<SovereignAccountOf, Origin>, SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
ChildParachainAsNative<origin::Origin, Origin>, ChildParachainAsNative<origin::Origin, RuntimeOrigin>,
SignedAccountId32AsNative<KusamaNetwork, Origin>, SignedAccountId32AsNative<KusamaNetwork, RuntimeOrigin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>, ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
); );
parameter_types! { parameter_types! {
@@ -140,21 +140,21 @@ impl Config for XcmConfig {
type SubscriptionService = (); type SubscriptionService = ();
} }
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, KusamaNetwork>; pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, KusamaNetwork>;
impl pallet_xcm::Config for Runtime { impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter; type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally... // Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>; type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Nothing; type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Everything; type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>; type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;