Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close mirror, mirrorSync channel after FinalSunsetFork #382

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading