BREAKING: Rename Origin (#12258)

* BREAKING: Rename Origin

* more renaming

* a bit more renaming

* fix

* more fixing

* fix in frame_support

* even more fixes

* fix

* small fix

* ...

* update .stderr

* docs

* update docs

* update docs

* docs
This commit is contained in:
Sergej Sakac
2022-09-21 00:13:09 +02:00
committed by GitHub
parent 986d20b352
commit e4b6f4a66d
221 changed files with 5233 additions and 4200 deletions
@@ -35,11 +35,11 @@ fn pool_lifecycle_e2e() {
assert_eq!(Staking::current_era(), None);
// create the pool, we know this has id 1.
assert_ok!(Pools::create(Origin::signed(10), 50, 10, 10, 10));
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 50, 10, 10, 10));
assert_eq!(LastPoolId::<Runtime>::get(), 1);
// have the pool nominate.
assert_ok!(Pools::nominate(Origin::signed(10), 1, vec![1, 2, 3]));
assert_ok!(Pools::nominate(RuntimeOrigin::signed(10), 1, vec![1, 2, 3]));
assert_eq!(staking_events_since_last_call(), vec![StakingEvent::Bonded(POOL1_BONDED, 50),]);
assert_eq!(
@@ -51,8 +51,8 @@ fn pool_lifecycle_e2e() {
);
// have two members join
assert_ok!(Pools::join(Origin::signed(20), 10, 1));
assert_ok!(Pools::join(Origin::signed(21), 10, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(20), 10, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(21), 10, 1));
assert_eq!(
staking_events_since_last_call(),
@@ -67,17 +67,17 @@ fn pool_lifecycle_e2e() {
);
// pool goes into destroying
assert_ok!(Pools::set_state(Origin::signed(10), 1, PoolState::Destroying));
assert_ok!(Pools::set_state(RuntimeOrigin::signed(10), 1, PoolState::Destroying));
// depositor cannot unbond yet.
assert_noop!(
Pools::unbond(Origin::signed(10), 10, 50),
Pools::unbond(RuntimeOrigin::signed(10), 10, 50),
PoolsError::<Runtime>::MinimumBondNotMet,
);
// now the members want to unbond.
assert_ok!(Pools::unbond(Origin::signed(20), 20, 10));
assert_ok!(Pools::unbond(Origin::signed(21), 21, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(21), 21, 10));
assert_eq!(PoolMembers::<Runtime>::get(20).unwrap().unbonding_eras.len(), 1);
assert_eq!(PoolMembers::<Runtime>::get(20).unwrap().points, 0);
@@ -102,14 +102,14 @@ fn pool_lifecycle_e2e() {
// depositor cannot still unbond
assert_noop!(
Pools::unbond(Origin::signed(10), 10, 50),
Pools::unbond(RuntimeOrigin::signed(10), 10, 50),
PoolsError::<Runtime>::MinimumBondNotMet,
);
for e in 1..BondingDuration::get() {
CurrentEra::<Runtime>::set(Some(e));
assert_noop!(
Pools::withdraw_unbonded(Origin::signed(20), 20, 0),
Pools::withdraw_unbonded(RuntimeOrigin::signed(20), 20, 0),
PoolsError::<Runtime>::CannotWithdrawAny
);
}
@@ -119,13 +119,13 @@ fn pool_lifecycle_e2e() {
// depositor cannot still unbond
assert_noop!(
Pools::unbond(Origin::signed(10), 10, 50),
Pools::unbond(RuntimeOrigin::signed(10), 10, 50),
PoolsError::<Runtime>::MinimumBondNotMet,
);
// but members can now withdraw.
assert_ok!(Pools::withdraw_unbonded(Origin::signed(20), 20, 0));
assert_ok!(Pools::withdraw_unbonded(Origin::signed(21), 21, 0));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(20), 20, 0));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(21), 21, 0));
assert!(PoolMembers::<Runtime>::get(20).is_none());
assert!(PoolMembers::<Runtime>::get(21).is_none());
@@ -146,12 +146,12 @@ fn pool_lifecycle_e2e() {
// as soon as all members have left, the depositor can try to unbond, but since the
// min-nominator intention is set, they must chill first.
assert_noop!(
Pools::unbond(Origin::signed(10), 10, 50),
Pools::unbond(RuntimeOrigin::signed(10), 10, 50),
pallet_staking::Error::<Runtime>::InsufficientBond
);
assert_ok!(Pools::chill(Origin::signed(10), 1));
assert_ok!(Pools::unbond(Origin::signed(10), 10, 50));
assert_ok!(Pools::chill(RuntimeOrigin::signed(10), 1));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(10), 10, 50));
assert_eq!(
staking_events_since_last_call(),
@@ -164,7 +164,7 @@ fn pool_lifecycle_e2e() {
// waiting another bonding duration:
CurrentEra::<Runtime>::set(Some(BondingDuration::get() * 2));
assert_ok!(Pools::withdraw_unbonded(Origin::signed(10), 10, 1));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(10), 10, 1));
// pools is fully destroyed now.
assert_eq!(
@@ -190,7 +190,7 @@ fn pool_slash_e2e() {
assert_eq!(Staking::current_era(), None);
// create the pool, we know this has id 1.
assert_ok!(Pools::create(Origin::signed(10), 40, 10, 10, 10));
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 40, 10, 10, 10));
assert_eq!(LastPoolId::<Runtime>::get(), 1);
assert_eq!(staking_events_since_last_call(), vec![StakingEvent::Bonded(POOL1_BONDED, 40)]);
@@ -205,8 +205,8 @@ fn pool_slash_e2e() {
assert_eq!(Payee::<Runtime>::get(POOL1_BONDED), RewardDestination::Account(POOL1_REWARD));
// have two members join
assert_ok!(Pools::join(Origin::signed(20), 20, 1));
assert_ok!(Pools::join(Origin::signed(21), 20, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(20), 20, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(21), 20, 1));
assert_eq!(
staking_events_since_last_call(),
@@ -224,8 +224,8 @@ fn pool_slash_e2e() {
CurrentEra::<Runtime>::set(Some(1));
// 20 / 80 of the total funds are unlocked, and safe from any further slash.
assert_ok!(Pools::unbond(Origin::signed(10), 10, 10));
assert_ok!(Pools::unbond(Origin::signed(20), 20, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(10), 10, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, 10));
assert_eq!(
staking_events_since_last_call(),
@@ -246,9 +246,9 @@ fn pool_slash_e2e() {
// note: depositor cannot fully unbond at this point.
// these funds will still get slashed.
assert_ok!(Pools::unbond(Origin::signed(10), 10, 10));
assert_ok!(Pools::unbond(Origin::signed(20), 20, 10));
assert_ok!(Pools::unbond(Origin::signed(21), 21, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(10), 10, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(21), 21, 10));
assert_eq!(
staking_events_since_last_call(),
@@ -290,7 +290,7 @@ fn pool_slash_e2e() {
);
CurrentEra::<Runtime>::set(Some(3));
assert_ok!(Pools::unbond(Origin::signed(21), 21, 10));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(21), 21, 10));
assert_eq!(
PoolMembers::<Runtime>::get(21).unwrap(),
@@ -310,8 +310,8 @@ fn pool_slash_e2e() {
// now we start withdrawing. we do it all at once, at era 6 where 20 and 21 are fully free.
CurrentEra::<Runtime>::set(Some(6));
assert_ok!(Pools::withdraw_unbonded(Origin::signed(20), 20, 0));
assert_ok!(Pools::withdraw_unbonded(Origin::signed(21), 21, 0));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(20), 20, 0));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(21), 21, 0));
assert_eq!(
pool_events_since_last_call(),
@@ -331,8 +331,8 @@ fn pool_slash_e2e() {
);
// now, finally, we can unbond the depositor further than their current limit.
assert_ok!(Pools::set_state(Origin::signed(10), 1, PoolState::Destroying));
assert_ok!(Pools::unbond(Origin::signed(10), 10, 20));
assert_ok!(Pools::set_state(RuntimeOrigin::signed(10), 1, PoolState::Destroying));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(10), 10, 20));
assert_eq!(
staking_events_since_last_call(),
@@ -357,7 +357,7 @@ fn pool_slash_e2e() {
}
);
// withdraw the depositor, they should lose 12 balance in total due to slash.
assert_ok!(Pools::withdraw_unbonded(Origin::signed(10), 10, 0));
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(10), 10, 0));
assert_eq!(
staking_events_since_last_call(),
@@ -385,7 +385,7 @@ fn pool_slash_proportional() {
assert_eq!(Staking::current_era(), None);
// create the pool, we know this has id 1.
assert_ok!(Pools::create(Origin::signed(10), 40, 10, 10, 10));
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 40, 10, 10, 10));
assert_eq!(LastPoolId::<T>::get(), 1);
assert_eq!(staking_events_since_last_call(), vec![StakingEvent::Bonded(POOL1_BONDED, 40)]);
@@ -399,9 +399,9 @@ fn pool_slash_proportional() {
// have two members join
let bond = 20;
assert_ok!(Pools::join(Origin::signed(20), bond, 1));
assert_ok!(Pools::join(Origin::signed(21), bond, 1));
assert_ok!(Pools::join(Origin::signed(22), bond, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(20), bond, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(21), bond, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(22), bond, 1));
assert_eq!(
staking_events_since_last_call(),
@@ -424,7 +424,7 @@ fn pool_slash_proportional() {
CurrentEra::<T>::set(Some(99));
// and unbond
assert_ok!(Pools::unbond(Origin::signed(20), 20, bond));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, bond));
assert_eq!(
staking_events_since_last_call(),
@@ -442,7 +442,7 @@ fn pool_slash_proportional() {
);
CurrentEra::<T>::set(Some(100));
assert_ok!(Pools::unbond(Origin::signed(21), 21, bond));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(21), 21, bond));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Unbonded(POOL1_BONDED, bond),]
@@ -459,7 +459,7 @@ fn pool_slash_proportional() {
);
CurrentEra::<T>::set(Some(101));
assert_ok!(Pools::unbond(Origin::signed(22), 22, bond));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(22), 22, bond));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Unbonded(POOL1_BONDED, bond),]
@@ -516,7 +516,7 @@ fn pool_slash_non_proportional_only_bonded_pool() {
assert_eq!(Staking::current_era(), None);
// create the pool, we know this has id 1.
assert_ok!(Pools::create(Origin::signed(10), 40, 10, 10, 10));
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 40, 10, 10, 10));
assert_eq!(staking_events_since_last_call(), vec![StakingEvent::Bonded(POOL1_BONDED, 40)]);
assert_eq!(
pool_events_since_last_call(),
@@ -528,7 +528,7 @@ fn pool_slash_non_proportional_only_bonded_pool() {
// have two members join
let bond = 20;
assert_ok!(Pools::join(Origin::signed(20), bond, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(20), bond, 1));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Bonded(POOL1_BONDED, bond)]
@@ -540,7 +540,7 @@ fn pool_slash_non_proportional_only_bonded_pool() {
// progress and unbond.
CurrentEra::<T>::set(Some(99));
assert_ok!(Pools::unbond(Origin::signed(20), 20, bond));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, bond));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Unbonded(POOL1_BONDED, bond)]
@@ -589,7 +589,7 @@ fn pool_slash_non_proportional_bonded_pool_and_chunks() {
assert_eq!(Staking::current_era(), None);
// create the pool, we know this has id 1.
assert_ok!(Pools::create(Origin::signed(10), 40, 10, 10, 10));
assert_ok!(Pools::create(RuntimeOrigin::signed(10), 40, 10, 10, 10));
assert_eq!(staking_events_since_last_call(), vec![StakingEvent::Bonded(POOL1_BONDED, 40)]);
assert_eq!(
pool_events_since_last_call(),
@@ -601,7 +601,7 @@ fn pool_slash_non_proportional_bonded_pool_and_chunks() {
// have two members join
let bond = 20;
assert_ok!(Pools::join(Origin::signed(20), bond, 1));
assert_ok!(Pools::join(RuntimeOrigin::signed(20), bond, 1));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Bonded(POOL1_BONDED, bond)]
@@ -613,7 +613,7 @@ fn pool_slash_non_proportional_bonded_pool_and_chunks() {
// progress and unbond.
CurrentEra::<T>::set(Some(99));
assert_ok!(Pools::unbond(Origin::signed(20), 20, bond));
assert_ok!(Pools::unbond(RuntimeOrigin::signed(20), 20, bond));
assert_eq!(
staking_events_since_last_call(),
vec![StakingEvent::Unbonded(POOL1_BONDED, bond)]
@@ -43,7 +43,7 @@ impl frame_system::Config for Runtime {
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type Index = AccountIndex;
type BlockNumber = BlockNumber;
type RuntimeCall = RuntimeCall;
@@ -227,7 +227,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
// set some limit for nominations.
assert_ok!(Staking::set_staking_configs(
Origin::root(),
RuntimeOrigin::root(),
pallet_staking::ConfigOp::Set(10), // minimum nominator bond
pallet_staking::ConfigOp::Noop,
pallet_staking::ConfigOp::Noop,