Skip to content

Commit

Permalink
fix: panic issue when doing refundStake and closeCorssChainChannel (#362
Browse files Browse the repository at this point in the history
)

* fix: handleMsgSideChainUndelegate should not pass prefixCtx

* fix: nil pointer when doing ibc method in endblock
  • Loading branch information
j75689 authored Dec 14, 2023
1 parent 065b547 commit 2b34b1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions x/ibc/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func NewKeeper(storeKey sdk.StoreKey, paramSpace param.Subspace, codespace sdk.C
}
}

func (k *Keeper) SetSideChainKeeper(sidechainKeeper sidechain.Keeper) {
k.sideKeeper = sidechainKeeper
}

func (k *Keeper) CreateIBCSyncPackage(ctx sdk.Context, destChainName string, channelName string, packageLoad []byte) (uint64, sdk.Error) {
relayerFee, err := k.GetRelayerFeeParam(ctx, destChainName)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions x/stake/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.Valid

if len(storePrefixes) > 0 && sdk.IsUpgrade(sdk.SecondSunsetFork) {
for i := range storePrefixes {
sideChainCtx := ctx.WithSideChainKeyPrefix(storePrefixes[i])
events.AppendEvents(handleRefundStake(sideChainCtx, k))
events.AppendEvents(handleRefundStake(ctx, storePrefixes[i], k))
}
}

Expand Down Expand Up @@ -274,12 +273,13 @@ const (
maxProcessedRefundCount = 10
)

func handleRefundStake(ctx sdk.Context, k keeper.Keeper) sdk.Events {
iterator := k.IteratorAllDelegations(ctx)
func handleRefundStake(ctx sdk.Context, sideChainPrefix []byte, k keeper.Keeper) sdk.Events {
sideChainCtx := ctx.WithSideChainKeyPrefix(sideChainPrefix)
iterator := k.IteratorAllDelegations(sideChainCtx)
defer iterator.Close()
var refundEvents sdk.Events
count := 0
boundDenom := k.BondDenom(ctx)
boundDenom := k.BondDenom(sideChainCtx)

for ; iterator.Valid(); iterator.Next() {
delegation := types.MustUnmarshalDelegation(k.CDC(), iterator.Key(), iterator.Value())
Expand Down

0 comments on commit 2b34b1a

Please sign in to comment.