Skip to content

Forget to Emit Event inside CacheCtx #229

Description

@Hellobloc

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

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions