You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current lockup module "assumes" that we have a single lockup in AddToExistingLock(which is when we're trying to add coins to existing locks) and add coins to the first lock out of the given array.
func (k Keeper) AddToExistingLock(ctx sdk.Context, owner sdk.AccAddress, coin sdk.Coin, duration time.Duration) ([]types.PeriodLock, error) {
locks := k.GetAccountLockedDurationNotUnlockingOnly(ctx, owner, coin.Denom, duration)
// if existing lock with same duration and denom exists, just add there
if len(locks) > 0 {
lock := locks[0]
_, err := k.AddTokensToLockByID(ctx, lock.ID, owner, coin)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
}
return locks, nil
}
We want to ensure this is a safe, by changing len(locks) = 1 from the current simple check len(locks) > 0.
In order to make this change, we first need to make sure that only a single lockup exists per owner + duration + denom pair, and then change this logical gate to check that len(locks) = 1
Investigate and make sure that only a single lockup exists per owner + duration + denom pair in the current state, make sure there's no edge cases in being able to make multiple locks per owner + duration + denom pair
Change checks in AddToExistingLock to be len(locks) = 1 from len(locks) > 0
The text was updated successfully, but these errors were encountered:
Background
The current lockup module "assumes" that we have a single lockup in
AddToExistingLock
(which is when we're trying to add coins to existing locks) and add coins to the first lock out of the given array.We want to ensure this is a safe, by changing len(locks) = 1 from the current simple check len(locks) > 0.
In order to make this change, we first need to make sure that only a single lockup exists per owner + duration + denom pair, and then change this logical gate to check that len(locks) = 1
cref: #1979 (comment)
Acceptance Criteria
AddToExistingLock
to belen(locks) = 1
fromlen(locks) > 0
The text was updated successfully, but these errors were encountered: