Skip to content

Commit

Permalink
Merge branch 'master' into kiz-multi-block-eletion
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma authored Feb 14, 2025
2 parents 2632619 + c1915af commit 979a0f3
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.0 (22. Sep 2023)

- name: Lychee link checker
uses: lycheeverse/lychee-action@f81112d0d2814ded911bd23e3beaa9dda9093915 # for v1.9.1 (10. Jan 2024)
uses: lycheeverse/lychee-action@f613c4a64e50d792e0b31ec34bbcbba12263c6a6 # for v1.9.1 (10. Jan 2024)
with:
args: >-
--config .config/lychee.toml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:

- name: Rust Cache
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-on-failure: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/misc-sync-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:
timeout-minutes: 90
- name: Create PR on failure
if: failure() && steps.check-compilation.outcome == 'failure'
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v5
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v5
with:
path: "${{ env.template-path }}"
token: ${{ steps.app_token.outputs.token }}
Expand All @@ -269,7 +269,7 @@ jobs:
body: "The template has NOT been successfully built and needs to be inspected."
branch: "update-template/${{ github.event.inputs.stable_release_branch }}"
- name: Create PR on success
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v5
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v5
with:
path: "${{ env.template-path }}"
token: ${{ steps.app_token.outputs.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-50_publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ jobs:
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0

- name: Cache Docker layers
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-reusable-promote-to-final.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-reusable-rc-buid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
./.github/scripts/release/build-linux-release.sh ${{ matrix.binaries }} ${{ inputs.package }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
with:
subject-path: /artifacts/${{ matrix.binaries }}/${{ matrix.binaries }}

Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
./.github/scripts/release/build-macos-release.sh ${{ matrix.binaries }} ${{ inputs.package }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
with:
subject-path: ${{ env.ARTIFACTS_PATH }}/${{ matrix.binaries }}

Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
. "${GITHUB_WORKSPACE}"/.github/scripts/release/build-deb.sh ${{ inputs.package }} ${VERSION}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
with:
subject-path: target/production/*.deb

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-reusable-s3-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
path: release-artifacts/${{ inputs.target }}/${{ inputs.package }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-srtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
echo "Compressed Runtime: ${{ steps.srtool_build.outputs.wasm_compressed }}"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
with:
subject-path: ${{ steps.srtool_build.outputs.wasm }}

Expand Down
142 changes: 129 additions & 13 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5774,6 +5774,21 @@ fn chill_other_works() {
//
// If any of these are missing, we do not have enough information to allow the
// `chill_other` to succeed from one user to another.
//
// Out of 8 possible cases, only one will allow the use of `chill_other`, which is
// when all 3 conditions are met.

// 1. No limits whatsoever
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
));

// Can't chill these users
assert_noop!(
Expand All @@ -5785,15 +5800,15 @@ fn chill_other_works() {
Error::<Test>::CannotChillOther
);

// Change the minimum bond... but no limits.
// 2. Change only the minimum bonds.
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Set(1_500),
ConfigOp::Set(2_000),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
));

Expand All @@ -5807,11 +5822,11 @@ fn chill_other_works() {
Error::<Test>::CannotChillOther
);

// Add limits, but no threshold
// 3. Add nominator/validator count limits, but no other threshold.
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Noop,
Expand All @@ -5829,15 +5844,59 @@ fn chill_other_works() {
Error::<Test>::CannotChillOther
);

// Add threshold, but no limits
// 4. Add chil threshold, but no other limits
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Set(Percent::from_percent(75)),
ConfigOp::Noop,
ConfigOp::Noop,
));

// Still can't chill these users
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 0),
Error::<Test>::CannotChillOther
);
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 2),
Error::<Test>::CannotChillOther
);

// 5. Add bond and count limits, but no threshold
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Set(1_500),
ConfigOp::Set(2_000),
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
));

// Still can't chill these users
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 0),
Error::<Test>::CannotChillOther
);
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 2),
Error::<Test>::CannotChillOther
);

// 6. Add bond and threshold limits, but no count limits
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Set(Percent::from_percent(75)),
ConfigOp::Noop,
ConfigOp::Noop,
));

Expand All @@ -5851,11 +5910,33 @@ fn chill_other_works() {
Error::<Test>::CannotChillOther
);

// Add threshold and limits
// 7. Add count limits and a chill threshold, but no bond limits
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Set(Percent::from_percent(75)),
ConfigOp::Noop,
ConfigOp::Noop,
));

// Still can't chill these users
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 0),
Error::<Test>::CannotChillOther
);
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1337), 2),
Error::<Test>::CannotChillOther
);

// 8. Add all limits
assert_ok!(Staking::set_staking_configs(
RuntimeOrigin::root(),
ConfigOp::Set(1_500),
ConfigOp::Set(2_000),
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Set(Percent::from_percent(75)),
Expand All @@ -5873,7 +5954,9 @@ fn chill_other_works() {
let b = 4 * i;
let d = 4 * i + 2;
assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), b));
assert_eq!(*staking_events().last().unwrap(), Event::Chilled { stash: b });
assert_ok!(Staking::chill_other(RuntimeOrigin::signed(1337), d));
assert_eq!(*staking_events().last().unwrap(), Event::Chilled { stash: d });
}

// chill a nominator. Limit is not reached, not chill-able
Expand Down Expand Up @@ -6075,6 +6158,14 @@ fn change_of_absolute_max_nominations() {
);
assert_eq!(Staking::electing_voters(bounds, 0).unwrap().len(), 3 + 3);

// No one can be chilled on account of non-decodable keys.
for k in Nominators::<Test>::iter_keys() {
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1), k),
Error::<Test>::CannotChillOther
);
}

// abrupt change from 4 to 3, everyone should be fine.
AbsoluteMaxNominations::set(3);

Expand All @@ -6086,8 +6177,16 @@ fn change_of_absolute_max_nominations() {
);
assert_eq!(Staking::electing_voters(bounds, 0).unwrap().len(), 3 + 3);

// As before, no one can be chilled on account of non-decodable keys.
for k in Nominators::<Test>::iter_keys() {
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1), k),
Error::<Test>::CannotChillOther
);
}

// abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and
// thus non-existent unless if they update.
// thus non-existent unless they update.
AbsoluteMaxNominations::set(2);

assert_eq!(
Expand All @@ -6096,7 +6195,16 @@ fn change_of_absolute_max_nominations() {
.collect::<Vec<_>>(),
vec![(101, 2), (61, 1)]
);
// 70 is still in storage..

// 101 and 61 still cannot be chilled by someone else.
for k in [101, 61].iter() {
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1), *k),
Error::<Test>::CannotChillOther
);
}

// 71 is still in storage..
assert!(Nominators::<Test>::contains_key(71));
// but its value cannot be decoded and default is returned.
assert!(Nominators::<Test>::get(71).is_none());
Expand All @@ -6105,7 +6213,7 @@ fn change_of_absolute_max_nominations() {
assert!(Nominators::<Test>::contains_key(101));

// abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and
// thus non-existent unless if they update.
// thus non-existent unless they update.
AbsoluteMaxNominations::set(1);

assert_eq!(
Expand All @@ -6114,6 +6222,13 @@ fn change_of_absolute_max_nominations() {
.collect::<Vec<_>>(),
vec![(61, 1)]
);

// 61 *still* cannot be chilled by someone else.
assert_noop!(
Staking::chill_other(RuntimeOrigin::signed(1), 61),
Error::<Test>::CannotChillOther
);

assert!(Nominators::<Test>::contains_key(71));
assert!(Nominators::<Test>::contains_key(61));
assert!(Nominators::<Test>::get(71).is_none());
Expand All @@ -6133,6 +6248,7 @@ fn change_of_absolute_max_nominations() {
assert!(Nominators::<Test>::contains_key(101));
assert!(Nominators::<Test>::get(101).is_none());
assert_ok!(Staking::chill_other(RuntimeOrigin::signed(71), 101));
assert_eq!(*staking_events().last().unwrap(), Event::Chilled { stash: 101 });
assert!(!Nominators::<Test>::contains_key(101));
assert!(Nominators::<Test>::get(101).is_none());
})
Expand Down

0 comments on commit 979a0f3

Please sign in to comment.