-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #387 from bnb-chain/develop
* fix: fix nil validator when publishing message (#356) * feat: implement BEP-333(BNB Chain Fusion) (#381) * feat: bc fusion hardfork implementation (#358) * fix: panic issue when doing refundStake and closeCorssChainChannel (#362) * fix: handleMsgSideChainUndelegate should not pass prefixCtx * fix: nil pointer when doing ibc method in endblock * fix: add logs to sunset fork events and immediate sidechain undelegation (#364) * fix: revert immediate sidechain undelegation and handle undelegation in endblock (#365) * fix: disable ClaimMsg after FinalSunsetFork (#366) * feat: add `MsgSideChainStakeMigration` and `StakeMigrationApp` (#367) * feat: add `MsgSideChainStakeMigration` and `StakeMigrationApp` * add missing tag * fix `handleMsgSideChainStakeMigration` * fix review comments * rename `MsgTypeSideChainStakeMigration` * add fee param for `MsgSideChainStakeMigration` * fix: add missing register for new msg (#368) * fix: error within `CreateRawIBCPackageByIdWithFee` (#369) * fix: decimal for BCFusionStopGovThreshold (#370) * fix: panic when totally unbound the validator in voting period (#371) * fix: add missing event (#372) * fix: wrong json tag (#373) * fix: add missing tag of relayer fee in `handleMsgSideChainStakeMigration` (#376) * feat: add IsAutoUnDelegate field to CrossStakeDistributeUndelegatedSynPackage and prevent too many failed in auto refund (#377) * feat: add IsAutoUnDelegate field to CrossStakeDistributeUndelegatedSynPackage * fix: disable undelegate after SecondSunsetFork and prevent too many failed in auto refund * chore: add more logs * revert: cross stake changes * fix: error handling in refund * fix: transferPackage * fix: CrossStakeDistributeUndelegatedSynPackageV2 * fix: reset context every time in refund loop (#378) * fix: do not charge relayerFee for auto cross undelegate after SecondSunsetFork (#379) * fix: do not charge relayerFee for auto cross undelegate after SecondSunsetFork * fix: FeeCalculator * chore: add logs for processed refunding count (#380) * fix: close mirror, mirrorSync channel after FinalSunsetFork (#382) * fix: disable MsgEditSideChainValidator after FirstSunsetFork and refine codes (#383) * fix: change StakeMigrationRelayFee to 0.002BNB (#384) * fix: appHash mismatch causes by channelsMap (#385) --------- Co-authored-by: Roshan <[email protected]> * docs: add change logs for release 0.26.7 (#386) --------- Co-authored-by: forcodedancing <[email protected]> Co-authored-by: dylanhuang <[email protected]> Co-authored-by: Roshan <[email protected]>
- Loading branch information
Showing
41 changed files
with
912 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,103 @@ | ||
package ibc | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"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 | ||
} | ||
var attributes []sdk.Attribute | ||
var ( | ||
attributes []sdk.Attribute | ||
events sdk.Events | ||
) | ||
for _, ibcPackageRecord := range keeper.packageCollector.collectedPackages { | ||
attributes = append(attributes, | ||
sdk.NewAttribute(ibcPackageInfoAttributeKey, | ||
buildIBCPackageAttributeValue(ibcPackageRecord.destChainID, ibcPackageRecord.channelID, ibcPackageRecord.sequence))) | ||
} | ||
|
||
keeper.packageCollector.collectedPackages = keeper.packageCollector.collectedPackages[:0] | ||
event := sdk.NewEvent(ibcEventType, attributes...) | ||
ctx.EventManager().EmitEvent(event) | ||
events.AppendEvent(event) | ||
if sdk.IsUpgrade(sdk.FinalSunsetFork) && !keeper.sideKeeper.IsBSCAllChannelClosed(ctx) { | ||
events = events.AppendEvents(closeSideChainChannels(ctx, keeper)) | ||
} | ||
ctx.EventManager().EmitEvents(events) | ||
} | ||
|
||
func closeSideChainChannels(ctx sdk.Context, k Keeper) sdk.Events { | ||
var events sdk.Events | ||
sideChainId := k.sideKeeper.BscSideChainId(ctx) | ||
// disable side chain channels | ||
id := k.sideKeeper.Config().DestChainNameToID(sideChainId) | ||
govChannelId := sdk.ChannelID(gov.ProposalTypeManageChanPermission) | ||
permissions := k.sideKeeper.GetChannelSendPermissions(ctx, id) | ||
channels := k.sideKeeper.Config().ChannelIDs() | ||
|
||
// 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. | ||
if _, exist := permissions[mirrorChannelID]; !exist { | ||
channels = append(channels, mirrorChannelID) | ||
permissions[mirrorChannelID] = sdk.ChannelAllow | ||
} | ||
if _, exist := permissions[mirrorSyncChannelID]; !exist { | ||
channels = append(channels, mirrorSyncChannelID) | ||
permissions[mirrorSyncChannelID] = sdk.ChannelAllow | ||
} | ||
|
||
// close all side chain channels except gov channel | ||
for _, channelId := range channels { | ||
if channelId == govChannelId { | ||
// skip gov channel | ||
continue | ||
} | ||
if permissions[channelId] == sdk.ChannelForbidden { | ||
// skip forbidden channel | ||
continue | ||
} | ||
|
||
events = events.AppendEvents(closeChannelOnSideChanAndKeeper(ctx, k, id, channelId)) | ||
} | ||
|
||
// disable side chain gov channel | ||
if permissions[govChannelId] == sdk.ChannelAllow { | ||
events = events.AppendEvents(closeChannelOnSideChanAndKeeper(ctx, k, id, govChannelId)) | ||
} | ||
k.sideKeeper.SetBSCAllChannelClosed(ctx) | ||
return events | ||
} | ||
|
||
func closeChannelOnSideChanAndKeeper(ctx sdk.Context, k Keeper, | ||
destChainID sdk.ChainID, channelID sdk.ChannelID) sdk.Events { | ||
var events sdk.Events | ||
_, err := k.sideKeeper.SaveChannelSettingChangeToIbc(ctx, destChainID, channelID, sdk.ChannelForbidden) | ||
if err != nil { | ||
ctx.Logger().Error("failed to save ibc channel change after FinalSunsetFork", | ||
"sideChainId", destChainID, "channelId", channelID, "err", err.Error()) | ||
events.AppendEvent(sdk.NewEvent(EventTypeSaveIBCChannelSettingFailed, | ||
sdk.NewAttribute(AttributeKeySideChainId, fmt.Sprint(destChainID)), | ||
sdk.NewAttribute(AttributeKeyChannelId, fmt.Sprint(channelID)), | ||
sdk.NewAttribute(AttributeKeyError, err.Error()), | ||
)) | ||
return events | ||
} | ||
events.AppendEvent(sdk.NewEvent(EventTypeSaveIBCChannelSettingSucceed, | ||
sdk.NewAttribute(AttributeKeySideChainId, fmt.Sprint(destChainID)), | ||
sdk.NewAttribute(AttributeKeyChannelId, fmt.Sprint(channelID)), | ||
)) | ||
// close bc side chain channel | ||
k.sideKeeper.SetChannelSendPermission(ctx, destChainID, channelID, sdk.ChannelForbidden) | ||
|
||
ctx.Logger().Info("close side chain channel after FinalSunsetFork", "sideChainId", destChainID, "channelId", channelID) | ||
return events | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.