mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
core-fellowship: allow infinite demotion period (#2828)
This commit is contained in:
@@ -238,6 +238,8 @@ test-deterministic-wasm:
|
|||||||
|
|
||||||
cargo-check-benches:
|
cargo-check-benches:
|
||||||
stage: test
|
stage: test
|
||||||
|
artifacts:
|
||||||
|
expire_in: 10 days
|
||||||
variables:
|
variables:
|
||||||
CI_JOB_NAME: "cargo-check-benches"
|
CI_JOB_NAME: "cargo-check-benches"
|
||||||
extends:
|
extends:
|
||||||
@@ -303,13 +305,10 @@ node-bench-regression-guard:
|
|||||||
artifacts: true
|
artifacts: true
|
||||||
variables:
|
variables:
|
||||||
CI_IMAGE: "paritytech/node-bench-regression-guard:latest"
|
CI_IMAGE: "paritytech/node-bench-regression-guard:latest"
|
||||||
# current git limit is 20, set to 100 to avoid failures (gitlab removes old artifacts)
|
|
||||||
GIT_DEPTH: 100
|
|
||||||
GIT_STRATEGY: fetch
|
|
||||||
before_script: [""]
|
before_script: [""]
|
||||||
script:
|
script:
|
||||||
- if [ $(ls -la artifacts/benches/ | grep master | wc -l) == 0 ]; then
|
- if [ $(ls -la artifacts/benches/ | grep master | wc -l) == 0 ]; then
|
||||||
echo "Couldn't find master artifacts, consider increasing GIT_LIMIT variable";
|
echo "Couldn't find master artifacts";
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
- echo "------- IMPORTANT -------"
|
- echo "------- IMPORTANT -------"
|
||||||
|
|||||||
@@ -53,6 +53,19 @@ mod benchmarks {
|
|||||||
Ok(member)
|
Ok(member)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_benchmark_params<T: Config<I>, I: 'static>() -> Result<(), BenchmarkError> {
|
||||||
|
let params = ParamsType {
|
||||||
|
active_salary: [100u32.into(); 9],
|
||||||
|
passive_salary: [10u32.into(); 9],
|
||||||
|
demotion_period: [100u32.into(); 9],
|
||||||
|
min_promotion_period: [100u32.into(); 9],
|
||||||
|
offboard_timeout: 1u32.into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
CoreFellowship::<T, I>::set_params(RawOrigin::Root.into(), Box::new(params))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn set_params() -> Result<(), BenchmarkError> {
|
fn set_params() -> Result<(), BenchmarkError> {
|
||||||
let params = ParamsType {
|
let params = ParamsType {
|
||||||
@@ -72,6 +85,8 @@ mod benchmarks {
|
|||||||
|
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn bump_offboard() -> Result<(), BenchmarkError> {
|
fn bump_offboard() -> Result<(), BenchmarkError> {
|
||||||
|
set_benchmark_params::<T, I>()?;
|
||||||
|
|
||||||
let member = make_member::<T, I>(0)?;
|
let member = make_member::<T, I>(0)?;
|
||||||
|
|
||||||
// Set it to the max value to ensure that any possible auto-demotion period has passed.
|
// Set it to the max value to ensure that any possible auto-demotion period has passed.
|
||||||
@@ -89,6 +104,8 @@ mod benchmarks {
|
|||||||
|
|
||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn bump_demote() -> Result<(), BenchmarkError> {
|
fn bump_demote() -> Result<(), BenchmarkError> {
|
||||||
|
set_benchmark_params::<T, I>()?;
|
||||||
|
|
||||||
let member = make_member::<T, I>(2)?;
|
let member = make_member::<T, I>(2)?;
|
||||||
|
|
||||||
// Set it to the max value to ensure that any possible auto-demotion period has passed.
|
// Set it to the max value to ensure that any possible auto-demotion period has passed.
|
||||||
|
|||||||
@@ -298,6 +298,11 @@ pub mod pallet {
|
|||||||
let rank_index = Self::rank_to_index(rank).ok_or(Error::<T, I>::InvalidRank)?;
|
let rank_index = Self::rank_to_index(rank).ok_or(Error::<T, I>::InvalidRank)?;
|
||||||
params.demotion_period[rank_index]
|
params.demotion_period[rank_index]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if demotion_period.is_zero() {
|
||||||
|
return Err(Error::<T, I>::NothingDoing.into())
|
||||||
|
}
|
||||||
|
|
||||||
let demotion_block = member.last_proof.saturating_add(demotion_period);
|
let demotion_block = member.last_proof.saturating_add(demotion_period);
|
||||||
|
|
||||||
// Ensure enough time has passed.
|
// Ensure enough time has passed.
|
||||||
|
|||||||
@@ -306,6 +306,28 @@ fn offboard_works() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn infinite_demotion_period_works() {
|
||||||
|
new_test_ext().execute_with(|| {
|
||||||
|
let params = ParamsType {
|
||||||
|
active_salary: [10; 9],
|
||||||
|
passive_salary: [10; 9],
|
||||||
|
min_promotion_period: [10; 9],
|
||||||
|
demotion_period: [0; 9],
|
||||||
|
offboard_timeout: 0,
|
||||||
|
};
|
||||||
|
assert_ok!(CoreFellowship::set_params(signed(1), Box::new(params)));
|
||||||
|
|
||||||
|
set_rank(0, 0);
|
||||||
|
assert_ok!(CoreFellowship::import(signed(0)));
|
||||||
|
set_rank(1, 1);
|
||||||
|
assert_ok!(CoreFellowship::import(signed(1)));
|
||||||
|
|
||||||
|
assert_noop!(CoreFellowship::bump(signed(0), 0), Error::<Test>::NothingDoing);
|
||||||
|
assert_noop!(CoreFellowship::bump(signed(0), 1), Error::<Test>::NothingDoing);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn proof_postpones_auto_demote() {
|
fn proof_postpones_auto_demote() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
|
|||||||
Reference in New Issue
Block a user