mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 20:21:06 +00:00
More tests and checks confirming that ledger.controller is always correct. (#2599)
A bonded ledger fetched with the `StakingLedger` implementation exposes a method `ledger.controller()` that returns the controller of the ledger. However, that controller is computed and stored under the `ledger.controller` field on the fly - i.e when the ledger is fetched from storage using the `StakingLedger::get` method. The controller field is never stored in storage. This PR add a few more tests checks and improves the ledger try-state checks to make sure these invariants hold true. --------- Co-authored-by: command-bot <> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -1853,7 +1853,17 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
fn check_ledgers() -> Result<(), TryRuntimeError> {
|
||||
Bonded::<T>::iter()
|
||||
.map(|(_, ctrl)| Self::ensure_ledger_consistent(ctrl))
|
||||
.map(|(stash, ctrl)| {
|
||||
// `ledger.controller` is never stored in raw storage.
|
||||
let raw = Ledger::<T>::get(stash).unwrap_or_else(|| {
|
||||
Ledger::<T>::get(ctrl.clone())
|
||||
.expect("try_check: bonded stash/ctrl does not have an associated ledger")
|
||||
});
|
||||
ensure!(raw.controller.is_none(), "raw storage controller should be None");
|
||||
|
||||
// ensure ledger consistency.
|
||||
Self::ensure_ledger_consistent(ctrl)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user