From 23892a085b0ef2a4b442a322ed568c6eb3f8e0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sat, 30 Dec 2023 00:50:56 +0000 Subject: [PATCH 1/4] core-fellowship: allow infinite demotion period --- substrate/frame/core-fellowship/src/lib.rs | 5 +++++ substrate/frame/core-fellowship/src/tests.rs | 22 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/substrate/frame/core-fellowship/src/lib.rs b/substrate/frame/core-fellowship/src/lib.rs index 1aa53cf08d17..2042f68e7149 100644 --- a/substrate/frame/core-fellowship/src/lib.rs +++ b/substrate/frame/core-fellowship/src/lib.rs @@ -298,6 +298,11 @@ pub mod pallet { let rank_index = Self::rank_to_index(rank).ok_or(Error::::InvalidRank)?; params.demotion_period[rank_index] }; + + if demotion_period.is_zero() { + return Err(Error::::NothingDoing.into()) + } + let demotion_block = member.last_proof.saturating_add(demotion_period); // Ensure enough time has passed. diff --git a/substrate/frame/core-fellowship/src/tests.rs b/substrate/frame/core-fellowship/src/tests.rs index 9ac381ab7f5c..c9098f2171f4 100644 --- a/substrate/frame/core-fellowship/src/tests.rs +++ b/substrate/frame/core-fellowship/src/tests.rs @@ -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::::NothingDoing); + assert_noop!(CoreFellowship::bump(signed(0), 1), Error::::NothingDoing); + }); +} + #[test] fn proof_postpones_auto_demote() { new_test_ext().execute_with(|| { From 96ce807d6ed4a9c5f3c27bb535a0b515cee1354d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sat, 30 Dec 2023 21:30:59 +0000 Subject: [PATCH 2/4] core-fellowship: fix bump benchmarks --- .../frame/core-fellowship/src/benchmarking.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/substrate/frame/core-fellowship/src/benchmarking.rs b/substrate/frame/core-fellowship/src/benchmarking.rs index ea0b5c6d4495..a3c410fac0a1 100644 --- a/substrate/frame/core-fellowship/src/benchmarking.rs +++ b/substrate/frame/core-fellowship/src/benchmarking.rs @@ -53,6 +53,19 @@ mod benchmarks { Ok(member) } + fn set_benchmark_params, 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::::set_params(RawOrigin::Root.into(), Box::new(params))?; + Ok(()) + } + #[benchmark] fn set_params() -> Result<(), BenchmarkError> { let params = ParamsType { @@ -72,6 +85,8 @@ mod benchmarks { #[benchmark] fn bump_offboard() -> Result<(), BenchmarkError> { + set_benchmark_params::()?; + let member = make_member::(0)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. @@ -89,6 +104,8 @@ mod benchmarks { #[benchmark] fn bump_demote() -> Result<(), BenchmarkError> { + set_benchmark_params::()?; + let member = make_member::(2)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. From d371836c54ace481b500f913b1050717603aceef Mon Sep 17 00:00:00 2001 From: Oleg Plakida Date: Sun, 31 Dec 2023 14:49:56 +0000 Subject: [PATCH 3/4] Increase git fetch depth to 1000 --- .gitlab/pipeline/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/pipeline/test.yml b/.gitlab/pipeline/test.yml index bbe9b612bc37..ab57465d87f4 100644 --- a/.gitlab/pipeline/test.yml +++ b/.gitlab/pipeline/test.yml @@ -303,8 +303,8 @@ node-bench-regression-guard: artifacts: true variables: 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 + # current git limit is 20, set to 1000 to avoid failures (gitlab removes old artifacts) + GIT_DEPTH: 1000 GIT_STRATEGY: fetch before_script: [""] script: From b37095bca18bc9ba4be08a080bc3e57057f8150a Mon Sep 17 00:00:00 2001 From: Oleg Plakida Date: Sun, 31 Dec 2023 15:37:45 +0000 Subject: [PATCH 4/4] test --- .gitlab/pipeline/test.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitlab/pipeline/test.yml b/.gitlab/pipeline/test.yml index ab57465d87f4..3a1a2dedf68a 100644 --- a/.gitlab/pipeline/test.yml +++ b/.gitlab/pipeline/test.yml @@ -238,6 +238,8 @@ test-deterministic-wasm: cargo-check-benches: stage: test + artifacts: + expire_in: 10 days variables: CI_JOB_NAME: "cargo-check-benches" extends: @@ -304,14 +306,14 @@ node-bench-regression-guard: variables: CI_IMAGE: "paritytech/node-bench-regression-guard:latest" # current git limit is 20, set to 1000 to avoid failures (gitlab removes old artifacts) - GIT_DEPTH: 1000 - GIT_STRATEGY: fetch + # GIT_DEPTH: 1000 + # GIT_STRATEGY: fetch before_script: [""] script: - - if [ $(ls -la artifacts/benches/ | grep master | wc -l) == 0 ]; then - echo "Couldn't find master artifacts, consider increasing GIT_LIMIT variable"; - exit 1; - fi + # - if [ $(ls -la artifacts/benches/ | grep master | wc -l) == 0 ]; then + # echo "Couldn't find master artifacts, consider increasing GIT_LIMIT variable"; + # exit 1; + # fi - echo "------- IMPORTANT -------" - echo "node-bench-regression-guard depends on the results of a cargo-check-benches job" - echo "In case of this job failure, check your pipeline's cargo-check-benches"