Skip to content

Commit c9763c3

Browse files
committed
[MOON-2434] remove deprecated leave delegator functionality (#2349)
* remove leave delegator functionality * remove precompile methods * return error for removed call indices
1 parent 1e4cd8a commit c9763c3

13 files changed

Lines changed: 202 additions & 1649 deletions

File tree

pallets/parachain-staking/src/benchmarks.rs

Lines changed: 0 additions & 340 deletions
Original file line numberDiff line numberDiff line change
@@ -795,325 +795,6 @@ benchmarks! {
795795
assert!(Pallet::<T>::is_delegator(&caller));
796796
}
797797

798-
schedule_leave_delegators_worst {
799-
// We assume that all candidates have full delegations with scheduled requests
800-
let x in 1..T::MaxDelegationsPerDelegator::get();
801-
802-
let mut seed = Seed::new();
803-
804-
let delegator = create_account::<T>(
805-
"delegator",
806-
seed.take(),
807-
AccountBalance::Value(
808-
T::MinDelegation::get() * T::MaxDelegationsPerDelegator::get().into() * 3000u32.into()
809-
),
810-
AccountAction::None,
811-
)?;
812-
813-
for c in 0..x {
814-
let collator = create_account::<T>(
815-
"collator",
816-
seed.take(),
817-
AccountBalance::MinCandidateStake,
818-
AccountAction::JoinCandidates{ amount: Amount::All, candidate_count: c + 1 },
819-
)?;
820-
821-
let mut decreasing_balance = <DecreasingBalance<T>>::new(
822-
T::MinDelegation::get() * 2000u32.into(),
823-
1u32.into(),
824-
);
825-
let mut col_del_count = 0u32;
826-
for i in 0..T::MaxTopDelegationsPerCandidate::get() - 1 {
827-
let del = create_account::<T>(
828-
"delegator",
829-
seed.take(),
830-
AccountBalance::Value(decreasing_balance.take()),
831-
AccountAction::Delegate{
832-
collator: collator.clone(),
833-
amount: Amount::All,
834-
auto_compound: Percent::from_percent(100),
835-
collator_delegation_count: col_del_count,
836-
collator_auto_compound_delegation_count: col_del_count,
837-
},
838-
)?;
839-
col_del_count += 1;
840-
841-
Pallet::<T>::schedule_delegator_bond_less(
842-
RawOrigin::Signed(del).into(),
843-
collator.clone(),
844-
5u32.into(),
845-
)?;
846-
}
847-
848-
let last_top_delegator_bond = decreasing_balance.take();
849-
<Pallet<T>>::delegate_with_auto_compound(
850-
RawOrigin::Signed(delegator.clone()).into(),
851-
collator.clone(),
852-
last_top_delegator_bond,
853-
Percent::from_percent(100),
854-
col_del_count,
855-
col_del_count,
856-
c,
857-
)?;
858-
col_del_count += 1;
859-
860-
assert_eq!(
861-
<BottomDelegations<T>>::get(&collator).map(|d| d.delegations.len()).unwrap_or_default(),
862-
0,
863-
);
864-
865-
for i in 0..T::MaxBottomDelegationsPerCandidate::get() {
866-
let del = create_account::<T>(
867-
"delegator",
868-
seed.take(),
869-
AccountBalance::Value(decreasing_balance.take()),
870-
AccountAction::Delegate{
871-
collator: collator.clone(),
872-
amount: Amount::All,
873-
auto_compound: Percent::from_percent(100),
874-
collator_delegation_count: col_del_count,
875-
collator_auto_compound_delegation_count: col_del_count,
876-
},
877-
)?;
878-
col_del_count += 1;
879-
880-
Pallet::<T>::schedule_revoke_delegation(
881-
RawOrigin::Signed(del).into(),
882-
collator.clone(),
883-
)?;
884-
}
885-
886-
assert_eq!(
887-
<BottomDelegations<T>>::get(&collator)
888-
.map(|bd| bd.delegations.len() as u32)
889-
.unwrap_or_default(),
890-
T::MaxBottomDelegationsPerCandidate::get(),
891-
);
892-
}
893-
}: {
894-
<Pallet<T>>::schedule_leave_delegators(RawOrigin::Signed(delegator.clone()).into())?;
895-
} verify {
896-
assert!(Pallet::<T>::delegator_state(&delegator).expect("must exist").is_active());
897-
}
898-
899-
cancel_leave_delegators_worst {
900-
// We assume that all candidates have full delegations with scheduled requests
901-
let x in 1..T::MaxDelegationsPerDelegator::get();
902-
903-
let mut seed = Seed::new();
904-
905-
let delegator = create_account::<T>(
906-
"delegator",
907-
seed.take(),
908-
AccountBalance::Value(
909-
T::MinDelegation::get() * T::MaxDelegationsPerDelegator::get().into() * 3000u32.into()
910-
),
911-
AccountAction::None,
912-
)?;
913-
914-
for c in 0..x {
915-
let collator = create_account::<T>(
916-
"collator",
917-
seed.take(),
918-
AccountBalance::MinCandidateStake,
919-
AccountAction::JoinCandidates{ amount: Amount::All, candidate_count: c + 1 },
920-
)?;
921-
922-
let mut decreasing_balance = <DecreasingBalance<T>>::new(
923-
T::MinDelegation::get() * 2000u32.into(),
924-
1u32.into(),
925-
);
926-
let mut col_del_count = 0u32;
927-
for i in 0..T::MaxTopDelegationsPerCandidate::get() - 1 {
928-
let del = create_account::<T>(
929-
"delegator",
930-
seed.take(),
931-
AccountBalance::Value(decreasing_balance.take()),
932-
AccountAction::Delegate{
933-
collator: collator.clone(),
934-
amount: Amount::All,
935-
auto_compound: Percent::from_percent(100),
936-
collator_delegation_count: col_del_count,
937-
collator_auto_compound_delegation_count: col_del_count,
938-
},
939-
)?;
940-
col_del_count += 1;
941-
942-
Pallet::<T>::schedule_delegator_bond_less(
943-
RawOrigin::Signed(del).into(),
944-
collator.clone(),
945-
5u32.into(),
946-
)?;
947-
}
948-
949-
let last_top_delegator_bond = decreasing_balance.take();
950-
<Pallet<T>>::delegate_with_auto_compound(
951-
RawOrigin::Signed(delegator.clone()).into(),
952-
collator.clone(),
953-
last_top_delegator_bond,
954-
Percent::from_percent(100),
955-
col_del_count,
956-
col_del_count,
957-
c,
958-
)?;
959-
col_del_count += 1;
960-
961-
assert_eq!(
962-
<BottomDelegations<T>>::get(&collator).map(|d| d.delegations.len()).unwrap_or_default(),
963-
0,
964-
);
965-
966-
for i in 0..T::MaxBottomDelegationsPerCandidate::get() {
967-
let del = create_account::<T>(
968-
"delegator",
969-
seed.take(),
970-
AccountBalance::Value(decreasing_balance.take()),
971-
AccountAction::Delegate{
972-
collator: collator.clone(),
973-
amount: Amount::All,
974-
auto_compound: Percent::from_percent(100),
975-
collator_delegation_count: col_del_count,
976-
collator_auto_compound_delegation_count: col_del_count,
977-
},
978-
)?;
979-
col_del_count += 1;
980-
981-
Pallet::<T>::schedule_revoke_delegation(
982-
RawOrigin::Signed(del).into(),
983-
collator.clone(),
984-
)?;
985-
}
986-
987-
assert_eq!(
988-
<BottomDelegations<T>>::get(&collator)
989-
.map(|bd| bd.delegations.len() as u32)
990-
.unwrap_or_default(),
991-
T::MaxBottomDelegationsPerCandidate::get(),
992-
);
993-
}
994-
995-
Pallet::<T>::schedule_leave_delegators(RawOrigin::Signed(delegator.clone()).into())?;
996-
}: {
997-
<Pallet<T>>::cancel_leave_delegators(RawOrigin::Signed(delegator.clone()).into())?;
998-
} verify {
999-
assert!(Pallet::<T>::delegator_state(&delegator).expect("must exist").is_active());
1000-
}
1001-
1002-
execute_leave_delegators_worst {
1003-
// We assume that all candidates have full delegations with scheduled requests
1004-
let x in 1..T::MaxDelegationsPerDelegator::get();
1005-
1006-
let mut seed = Seed::new();
1007-
1008-
let delegator = create_account::<T>(
1009-
"delegator",
1010-
seed.take(),
1011-
AccountBalance::Value(
1012-
T::MinDelegation::get() * T::MaxDelegationsPerDelegator::get().into() * 3000u32.into()
1013-
),
1014-
AccountAction::None,
1015-
)?;
1016-
1017-
let author = create_account::<T>(
1018-
"collator",
1019-
seed.take(),
1020-
AccountBalance::MinCandidateStake,
1021-
AccountAction::JoinCandidates{ amount: Amount::All, candidate_count: 1u32 },
1022-
)?;
1023-
1024-
for c in 0..x {
1025-
let collator = create_account::<T>(
1026-
"collator",
1027-
seed.take(),
1028-
AccountBalance::MinCandidateStake,
1029-
AccountAction::JoinCandidates{ amount: Amount::All, candidate_count: c + 2 },
1030-
)?;
1031-
1032-
let mut decreasing_balance = <DecreasingBalance<T>>::new(
1033-
T::MinDelegation::get() * 2000u32.into(),
1034-
1u32.into(),
1035-
);
1036-
let mut col_del_count = 0u32;
1037-
for i in 0..T::MaxTopDelegationsPerCandidate::get() - 1 {
1038-
let del = create_account::<T>(
1039-
"delegator",
1040-
seed.take(),
1041-
AccountBalance::Value(decreasing_balance.take()),
1042-
AccountAction::Delegate{
1043-
collator: collator.clone(),
1044-
amount: Amount::All,
1045-
auto_compound: Percent::from_percent(100),
1046-
collator_delegation_count: col_del_count,
1047-
collator_auto_compound_delegation_count: col_del_count,
1048-
},
1049-
)?;
1050-
col_del_count += 1;
1051-
1052-
Pallet::<T>::schedule_delegator_bond_less(
1053-
RawOrigin::Signed(del).into(),
1054-
collator.clone(),
1055-
5u32.into(),
1056-
)?;
1057-
}
1058-
1059-
let last_top_delegator_bond = decreasing_balance.take();
1060-
<Pallet<T>>::delegate_with_auto_compound(
1061-
RawOrigin::Signed(delegator.clone()).into(),
1062-
collator.clone(),
1063-
last_top_delegator_bond,
1064-
Percent::from_percent(100),
1065-
col_del_count,
1066-
col_del_count,
1067-
c,
1068-
)?;
1069-
col_del_count += 1;
1070-
1071-
assert_eq!(
1072-
<BottomDelegations<T>>::get(&collator).map(|d| d.delegations.len()).unwrap_or_default(),
1073-
0,
1074-
);
1075-
1076-
for i in 0..T::MaxBottomDelegationsPerCandidate::get() {
1077-
let del = create_account::<T>(
1078-
"delegator",
1079-
seed.take(),
1080-
AccountBalance::Value(decreasing_balance.take()),
1081-
AccountAction::Delegate{
1082-
collator: collator.clone(),
1083-
amount: Amount::All,
1084-
auto_compound: Percent::from_percent(100),
1085-
collator_delegation_count: col_del_count,
1086-
collator_auto_compound_delegation_count: col_del_count,
1087-
},
1088-
)?;
1089-
col_del_count += 1;
1090-
1091-
Pallet::<T>::schedule_revoke_delegation(
1092-
RawOrigin::Signed(del).into(),
1093-
collator.clone(),
1094-
)?;
1095-
}
1096-
1097-
assert_eq!(
1098-
<BottomDelegations<T>>::get(&collator)
1099-
.map(|bd| bd.delegations.len() as u32)
1100-
.unwrap_or_default(),
1101-
T::MaxBottomDelegationsPerCandidate::get(),
1102-
);
1103-
}
1104-
1105-
Pallet::<T>::schedule_leave_delegators(RawOrigin::Signed(delegator.clone()).into())?;
1106-
roll_to_and_author::<T>(2, author.clone());
1107-
}: {
1108-
<Pallet<T>>::execute_leave_delegators(
1109-
RawOrigin::Signed(delegator.clone()).into(),
1110-
delegator.clone(),
1111-
x,
1112-
)?;
1113-
} verify {
1114-
assert!(Pallet::<T>::delegator_state(&delegator).is_none());
1115-
}
1116-
1117798
schedule_revoke_delegation {
1118799
// x controls the number of other scheduled requests
1119800
let x in 0..(
@@ -2543,27 +2224,6 @@ mod tests {
25432224
});
25442225
}
25452226

2546-
#[test]
2547-
fn bench_schedule_leave_delegators() {
2548-
new_test_ext().execute_with(|| {
2549-
assert_ok!(Pallet::<Test>::test_benchmark_schedule_leave_delegators_worst());
2550-
});
2551-
}
2552-
2553-
#[test]
2554-
fn bench_execute_leave_delegators() {
2555-
new_test_ext().execute_with(|| {
2556-
assert_ok!(Pallet::<Test>::test_benchmark_execute_leave_delegators_worst());
2557-
});
2558-
}
2559-
2560-
#[test]
2561-
fn bench_cancel_leave_delegators() {
2562-
new_test_ext().execute_with(|| {
2563-
assert_ok!(Pallet::<Test>::test_benchmark_cancel_leave_delegators_worst());
2564-
});
2565-
}
2566-
25672227
#[test]
25682228
fn bench_schedule_revoke_delegation() {
25692229
new_test_ext().execute_with(|| {

0 commit comments

Comments
 (0)