mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-01 21:47:25 +00:00
bbdbeb7ec6
This PR adds a new extrinsic `Call::restore_ledger ` gated by `StakingAdmin` origin that restores a corrupted staking ledger. This extrinsic will be used to recover ledgers that were affected by the issue discussed in https://github.com/paritytech/polkadot-sdk/issues/3245. The extrinsic will re-write the storage items associated with a stash account provided as input parameter. The data used to reset the ledger can be either i) fetched on-chain or ii) partially/totally set by the input parameters of the call. In order to use on-chain data to restore the staking locks, we need a way to read the current lock in the balances pallet. This PR adds a `InspectLockableCurrency` trait and implements it in the pallet balances. An alternative would be to tightly couple staking with the pallet balances but that's inelegant (an example of how it would look like in [this branch](https://github.com/paritytech/polkadot-sdk/tree/gpestana/ledger-badstate-clean_tightly)). More details on the type of corruptions and corresponding fixes https://hackmd.io/DLb5jEYWSmmvqXC9ae4yRg?view#/ We verified that the `Call::restore_ledger` does fix all current corrupted ledgers in Polkadot and Kusama. You can verify it here https://hackmd.io/v-XNrEoGRpe7APR-EZGhOA. **Changes introduced** - Adds `Call::restore_ledger ` extrinsic to recover a corrupted ledger; - Adds trait `frame_support::traits::currency::InspectLockableCurrency` to allow external pallets to read current locks given an account and lock ID; - Implements the `InspectLockableCurrency` in the pallet-balances. - Adds staking locks try-runtime checks (https://github.com/paritytech/polkadot-sdk/issues/3751) **Todo** - [x] benchmark `Call::restore_ledger` - [x] throughout testing of all ledger recovering cases - [x] consider adding the staking locks try-runtime checks to this PR (https://github.com/paritytech/polkadot-sdk/issues/3751) - [x] simulate restoring all ledgers (https://hackmd.io/Dsa2tvhISNSs7zcqriTaxQ?view) in Polkadot and Kusama using chopsticks -- https://hackmd.io/v-XNrEoGRpe7APR-EZGhOA Related to https://github.com/paritytech/polkadot-sdk/issues/3245 Closes https://github.com/paritytech/polkadot-sdk/issues/3751 --------- Co-authored-by: command-bot <>
140 lines
4.8 KiB
Rust
140 lines
4.8 KiB
Rust
// This file is part of Substrate.
|
|
|
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! Traits and associated utilities for use in the FRAME environment.
|
|
//!
|
|
//! NOTE: If you're looking for `parameter_types`, it has moved in to the top-level module.
|
|
|
|
pub mod tokens;
|
|
pub use tokens::{
|
|
currency::{
|
|
ActiveIssuanceOf, Currency, InspectLockableCurrency, LockIdentifier, LockableCurrency,
|
|
NamedReservableCurrency, ReservableCurrency, TotalIssuanceOf, VestingSchedule,
|
|
},
|
|
fungible, fungibles,
|
|
imbalance::{Imbalance, OnUnbalanced, SignedImbalance},
|
|
nonfungible, nonfungible_v2, nonfungibles, nonfungibles_v2, BalanceStatus,
|
|
ExistenceRequirement, Locker, WithdrawReasons,
|
|
};
|
|
|
|
mod members;
|
|
#[allow(deprecated)]
|
|
pub use members::{AllowAll, DenyAll, Filter};
|
|
pub use members::{
|
|
AsContains, ChangeMembers, Contains, ContainsLengthBound, ContainsPair, Equals, Everything,
|
|
EverythingBut, FromContainsPair, InitializeMembers, InsideBoth, IsInVec, Nothing,
|
|
RankedMembers, RankedMembersSwapHandler, SortedMembers, TheseExcept,
|
|
};
|
|
|
|
mod validation;
|
|
pub use validation::{
|
|
DisabledValidators, EstimateNextNewSession, EstimateNextSessionRotation, FindAuthor,
|
|
KeyOwnerProofSystem, Lateness, OneSessionHandler, ValidatorRegistration, ValidatorSet,
|
|
ValidatorSetWithIdentification, VerifySeal,
|
|
};
|
|
|
|
mod error;
|
|
pub use error::PalletError;
|
|
|
|
mod filter;
|
|
pub use filter::{ClearFilterGuard, FilterStack, FilterStackGuard, InstanceFilter};
|
|
|
|
mod misc;
|
|
pub use misc::{
|
|
defensive_prelude::{self, *},
|
|
AccountTouch, Backing, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128,
|
|
ConstU16, ConstU32, ConstU64, ConstU8, DefensiveMax, DefensiveMin, DefensiveSaturating,
|
|
DefensiveTruncateFrom, EnsureInherentsAreFirst, EqualPrivilegeOnly, EstimateCallFee,
|
|
ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, HandleLifetime, IsInherent,
|
|
IsSubType, IsType, Len, OffchainWorker, OnKilledAccount, OnNewAccount, PrivilegeCmp,
|
|
SameOrOther, Time, TryCollect, TryDrop, TypedGet, UnixTime, VariantCount, VariantCountOf,
|
|
WrapperKeepOpaque, WrapperOpaque,
|
|
};
|
|
#[allow(deprecated)]
|
|
pub use misc::{PreimageProvider, PreimageRecipient};
|
|
#[doc(hidden)]
|
|
pub use misc::{DEFENSIVE_OP_INTERNAL_ERROR, DEFENSIVE_OP_PUBLIC_ERROR};
|
|
|
|
mod stored_map;
|
|
pub use stored_map::{StorageMapShim, StoredMap};
|
|
mod randomness;
|
|
pub use randomness::Randomness;
|
|
|
|
mod metadata;
|
|
pub use metadata::{
|
|
CallMetadata, CrateVersion, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion,
|
|
NoStorageVersionSet, PalletInfo, PalletInfoAccess, PalletInfoData, PalletsInfoAccess,
|
|
StorageVersion, STORAGE_VERSION_STORAGE_KEY_POSTFIX,
|
|
};
|
|
|
|
mod hooks;
|
|
#[allow(deprecated)]
|
|
pub use hooks::GenesisBuild;
|
|
pub use hooks::{
|
|
BeforeAllRuntimeMigrations, BuildGenesisConfig, Hooks, IntegrityTest, OnFinalize, OnGenesis,
|
|
OnIdle, OnInitialize, OnPoll, OnRuntimeUpgrade, OnTimestampSet, PostInherents,
|
|
PostTransactions, PreInherents,
|
|
};
|
|
|
|
pub mod schedule;
|
|
mod storage;
|
|
pub use storage::{
|
|
Consideration, Footprint, Incrementable, Instance, LinearStoragePrice, PartialStorageInfoTrait,
|
|
StorageInfo, StorageInfoTrait, StorageInstance, TrackedStorageKey, WhitelistedStorageKeys,
|
|
};
|
|
|
|
mod dispatch;
|
|
#[allow(deprecated)]
|
|
pub use dispatch::EnsureOneOf;
|
|
pub use dispatch::{
|
|
AsEnsureOriginWithArg, CallerTrait, EitherOf, EitherOfDiverse, EnsureOrigin,
|
|
EnsureOriginEqualOrHigherPrivilege, EnsureOriginWithArg, MapSuccess, NeverEnsureOrigin,
|
|
OriginTrait, TryMapSuccess, TryWithMorphedArg, UnfilteredDispatchable,
|
|
};
|
|
|
|
mod voting;
|
|
pub use voting::{ClassCountOf, PollStatus, Polling, VoteTally};
|
|
|
|
mod preimages;
|
|
pub use preimages::{Bounded, BoundedInline, FetchResult, QueryPreimage, StorePreimage};
|
|
|
|
mod messages;
|
|
pub use messages::{
|
|
EnqueueMessage, EnqueueWithOrigin, ExecuteOverweightError, HandleMessage, NoopServiceQueues,
|
|
ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery, ServiceQueues,
|
|
TransformOrigin,
|
|
};
|
|
|
|
mod safe_mode;
|
|
pub use safe_mode::{SafeMode, SafeModeError, SafeModeNotify};
|
|
|
|
mod tx_pause;
|
|
pub use tx_pause::{TransactionPause, TransactionPauseError};
|
|
|
|
pub mod dynamic_params;
|
|
|
|
pub mod tasks;
|
|
pub use tasks::Task;
|
|
|
|
#[cfg(feature = "try-runtime")]
|
|
mod try_runtime;
|
|
#[cfg(feature = "try-runtime")]
|
|
pub use try_runtime::{
|
|
Select as TryStateSelect, TryDecodeEntireStorage, TryDecodeEntireStorageError, TryState,
|
|
UpgradeCheckSelect,
|
|
};
|