Skip to content

Commit

Permalink
fix: close mirror, mirrorSync channel after FinalSunsetFork (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 authored Jan 23, 2024
1 parent f5678f8 commit db42125
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions x/ibc/endblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
)

const (
mirrorChannelID = 4
mirrorSyncChannelID = 5
)

func EndBlocker(ctx sdk.Context, keeper Keeper) {
if len(keeper.packageCollector.collectedPackages) == 0 {
return
Expand Down Expand Up @@ -37,12 +42,23 @@ func closeSideChainChannels(ctx sdk.Context, k Keeper) sdk.Events {
id := k.sideKeeper.Config().DestChainNameToID(sideChainId)
govChannelId := sdk.ChannelID(gov.ProposalTypeManageChanPermission)
permissions := k.sideKeeper.GetChannelSendPermissions(ctx, id)
for _, channelId := range k.sideKeeper.Config().ChannelIDs() {
channels := k.sideKeeper.Config().ChannelIDs()
channelsMap := make(map[sdk.ChannelID]sdk.ChannelPermission)
for _, channelId := range channels {
channelsMap[channelId] = permissions[channelId]
}
// mirror, mirrorSync channel was enabled by BEP84(https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP84.md)
// Those channels were bsc side channels, so they would not be in the bc store.
channelsMap[mirrorChannelID] = sdk.ChannelAllow
channelsMap[mirrorSyncChannelID] = sdk.ChannelAllow

// close all side chain channels except gov channel
for channelId, permission := range channelsMap {
if channelId == govChannelId {
// skip gov channel
continue
}
if permissions[channelId] == sdk.ChannelForbidden {
if permission == sdk.ChannelForbidden {
// skip forbidden channel
continue
}
Expand Down

0 comments on commit db42125

Please sign in to comment.