Skip to content

Commit

Permalink
fix: update handling (changeover completed checks)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Dec 5, 2024
1 parent 9109c78 commit 4e015ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion x/ccv/consumer/keeper/changeover.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// ChangeoverIsComplete returns whether the standalone to consumer changeover process is complete.
func (k Keeper) ChangeoverIsComplete(ctx sdk.Context) bool {
if !k.IsPrevStandaloneChain(ctx) {
panic("ChangeoverIsComplete should only be called on previously standalone consumers")
return true
}
return ctx.BlockHeight() >= k.FirstConsumerHeight(ctx)
}
Expand Down
10 changes: 5 additions & 5 deletions x/ccv/consumer/keeper/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ func (k Keeper) IterateValidators(context.Context, func(index int64, validator s
// Validator - unimplemented on CCV keeper but implemented on standalone keeper
func (k Keeper) Validator(sdkCtx context.Context, addr sdk.ValAddress) (stakingtypes.ValidatorI, error) {
ctx := sdk.UnwrapSDKContext(sdkCtx)
if k.IsPrevStandaloneChain(ctx) && k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
if k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
return k.standaloneStakingKeeper.Validator(ctx, addr)
}

panic("unimplemented on CCV keeper")
return stakingtypes.Validator{}, errors.New("unimplemented on CCV keeper")
}

// IsJailed returns the outstanding slashing flag for the given validator address
Expand Down Expand Up @@ -184,7 +184,7 @@ func (k Keeper) Jail(context.Context, sdk.ConsAddress) error { return nil }
// This method should be a no-op for consumer chains that launched with the CCV module first.
func (k Keeper) Unjail(sdkCtx context.Context, addr sdk.ConsAddress) error {
ctx := sdk.UnwrapSDKContext(sdkCtx)
if k.IsPrevStandaloneChain(ctx) && k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
if k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
return k.standaloneStakingKeeper.Unjail(ctx, addr)
}
return nil
Expand All @@ -193,10 +193,10 @@ func (k Keeper) Unjail(sdkCtx context.Context, addr sdk.ConsAddress) error {
// Delegation - unimplemented on CCV keeper but implemented on standalone keeper
func (k Keeper) Delegation(sdkCtx context.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.DelegationI, error) {
ctx := sdk.UnwrapSDKContext(sdkCtx)
if k.IsPrevStandaloneChain(ctx) && k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
if k.ChangeoverIsComplete(ctx) && k.standaloneStakingKeeper != nil {
return k.standaloneStakingKeeper.Delegation(ctx, addr, valAddr)
}
panic("unimplemented on CCV keeper")
return stakingtypes.Delegation{}, errors.New("unimplemented on CCV keeper")
}

// MaxValidators - unimplemented on CCV keeper
Expand Down

0 comments on commit 4e015ac

Please sign in to comment.