-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
In the following code, you forgot to emit the event in Cachectx. This causes events in cachectx to be lost, resulting in inconsistency between events and state changes
crescent/x/liquidstaking/keeper/rebalancing.go
Lines 19 to 48 in c9fab38
| func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (completionTime time.Time, err error) { | |
| dstVal := re.DstValidator.GetOperator() | |
| srcVal := re.SrcValidator.GetOperator() | |
| // check the source validator already has receiving transitive redelegation | |
| hasReceiving := k.stakingKeeper.HasReceivingRedelegation(ctx, re.Delegator, srcVal) | |
| if hasReceiving { | |
| return time.Time{}, stakingtypes.ErrTransitiveRedelegation | |
| } | |
| // calculate delShares from tokens with validation | |
| shares, err := k.stakingKeeper.ValidateUnbondAmount( | |
| ctx, re.Delegator, srcVal, re.Amount, | |
| ) | |
| if err != nil { | |
| return time.Time{}, err | |
| } | |
| // when last, full redelegation of shares from delegation | |
| if re.Last { | |
| shares = re.SrcValidator.GetDelShares(ctx, k.stakingKeeper) | |
| } | |
| cachedCtx, writeCache := ctx.CacheContext() | |
| completionTime, err = k.stakingKeeper.BeginRedelegation(cachedCtx, re.Delegator, srcVal, dstVal, shares) | |
| if err != nil { | |
| return time.Time{}, err | |
| } | |
| writeCache() | |
| return completionTime, nil | |
| } |
Metadata
Metadata
Assignees
Labels
No labels