Skip to content

Commit

Permalink
chore: add safety check when update ledger (#1952)
Browse files Browse the repository at this point in the history
* chore: add safety check when update ledger

* fix ci
  • Loading branch information
mclyk authored Nov 15, 2023
1 parent 615c655 commit 72345d6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pallets/liquid-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,21 +936,19 @@ pub mod pallet {

Self::do_update_ledger(derivative_index, |ledger| {
ensure!(
!Self::is_updated(derivative_index),
!Self::is_updated(derivative_index)
&& XcmRequests::<T>::iter().count().is_zero(),
Error::<T>::StakingLedgerLocked
);
let requests = XcmRequests::<T>::iter().count();
if staking_ledger.total < ledger.total
|| staking_ledger.active < ledger.active
|| staking_ledger.unlocking != ledger.unlocking
|| !requests.is_zero()
{
log::trace!(
target: "liquidStaking::set_staking_ledger::invalidStakingLedger",
"index: {:?}, staking_ledger: {:?}, xcm_request: {:?}",
"index: {:?}, staking_ledger: {:?}",
&derivative_index,
&staking_ledger,
requests,
);
Self::deposit_event(Event::<T>::NonIdealStakingLedger(derivative_index));
}
Expand Down

0 comments on commit 72345d6

Please sign in to comment.