Skip to content

Commit

Permalink
[AUDIT FIX] decrement total delegations in adjust delegated balance
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Jul 9, 2024
1 parent 25ed61b commit 2a67b7a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x/staketia/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ func (k msgServer) AdjustDelegatedBalance(goCtx context.Context, msg *types.MsgA
}
k.SetHostZone(ctx, hostZone)

// Repeat the same thing on the stakeibc host zone
stakeibcHostZone, found := k.stakeibcKeeper.GetHostZone(ctx, types.CelestiaChainId)
if !found {
return nil, errors.New("celestia host zone not found in stakeibc")
}
stakeibcHostZone.TotalDelegations = hostZone.RemainingDelegatedBalance.Add(msg.DelegationOffset)

if stakeibcHostZone.TotalDelegations.IsNegative() {
return nil, types.ErrNegativeNotAllowed.Wrapf("offset would cause the delegated balance to be negative")
}
k.stakeibcKeeper.SetHostZone(ctx, stakeibcHostZone)

// create a corresponding slash record
latestSlashRecordId := k.IncrementSlashRecordId(ctx)
slashRecord := types.SlashRecord{
Expand Down

0 comments on commit 2a67b7a

Please sign in to comment.