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

feat: implement BEP-333(BNB Chain Fusion) #1003

Merged
merged 28 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f27a818
feat: bc fusion hardfork implementation (#983)
j75689 Nov 30, 2023
09b52c7
update comsmos dep
unclezoro Nov 30, 2023
5ee5e0f
fix: add sunsethardfork config and fix panic issue (#988)
j75689 Dec 14, 2023
dad1e23
fix: only refund opened swap
j75689 Dec 15, 2023
587060a
fix: do not check timelock time if isBCFusionRefund
j75689 Dec 15, 2023
996e8ac
fixup! fix: only refund opened swap
j75689 Dec 15, 2023
0c727fe
fix: log format
j75689 Dec 15, 2023
ca8aa34
Merge pull request #989 from bnb-chain/bc-fusion-fix2
j75689 Dec 15, 2023
aca759f
fix: format refund logs and update cosmos-sdk (#991)
j75689 Jan 5, 2024
49902aa
chore: update cosmos-sdk (#992)
j75689 Jan 5, 2024
bf9b139
feat: add `MsgSideChainStakeMigration` and `StakeMigrationApp` (#993)
pythonberg1997 Jan 6, 2024
67223ed
fix: add missing register for new msg (#994)
pythonberg1997 Jan 6, 2024
9f8ec7e
fix: error within `CreateRawIBCPackageByIdWithFee` (#995)
pythonberg1997 Jan 6, 2024
c3ab169
chore: update cosmos-sdk (#996)
j75689 Jan 10, 2024
4bb18c6
fix: add missing tag of relayer fee in `handleMsgSideChainStakeMigrat…
pythonberg1997 Jan 12, 2024
ea088e2
chore: update cosmos-sdk (#999)
j75689 Jan 12, 2024
43fad4d
chore: update cosmos-sdk to fix refundStake issue (#1000)
j75689 Jan 15, 2024
892b522
chore: add logs to refund tokens (#1001)
j75689 Jan 15, 2024
a35979d
chore: update cosmo-sdk (#1002)
j75689 Jan 15, 2024
fa46382
feat: implement cmd to sign validator ownership (#1004)
j75689 Jan 22, 2024
33c826b
fix: change BreatheBlockInterval to time period (#1005)
j75689 Jan 22, 2024
5975694
chore: update cosmos-sdk (#1006)
j75689 Jan 23, 2024
a3543ab
chore: refine codes (#1007)
j75689 Jan 26, 2024
099412a
chore: update cosmos-sdk (#1008)
j75689 Jan 26, 2024
40707f5
chore: update cosmos-sdk (#1009)
j75689 Jan 29, 2024
7b52da0
chore: update cosmos-sdk (#1010)
j75689 Jan 31, 2024
195d046
dep: update cosmos dep
unclezoro Feb 26, 2024
019f602
doc: add change log and testnet upgrade hight (#1011)
unclezoro Feb 26, 2024
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.10.17
This is the release for the sunset of BNB Beacon Chain.

FEATURES
* [\#977](https://github.com/bnb-chain/node/pull/1003) [BEP] feat: implement BEP-333(BNB Chain Fusion)


## v0.10.16
FEATURES
* [\#977](https://github.com/bnb-chain/node/pull/977) [BEP] asset: add bep255 upgrade height for mainnet
Expand Down
26 changes: 25 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ import (
"github.com/bnb-chain/node/plugins/dex/list"
"github.com/bnb-chain/node/plugins/dex/order"
dextypes "github.com/bnb-chain/node/plugins/dex/types"
migrate "github.com/bnb-chain/node/plugins/migrate"
tokenRecover "github.com/bnb-chain/node/plugins/recover"
"github.com/bnb-chain/node/plugins/tokens"
"github.com/bnb-chain/node/plugins/tokens/issue"
"github.com/bnb-chain/node/plugins/tokens/ownership"
"github.com/bnb-chain/node/plugins/tokens/seturi"
"github.com/bnb-chain/node/plugins/tokens/swap"
"github.com/bnb-chain/node/plugins/tokens/timelock"
"github.com/bnb-chain/node/wire"
stakeMigration "github.com/cosmos/cosmos-sdk/x/stake/stake_migration"
)

const (
Expand Down Expand Up @@ -359,6 +362,9 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
upgrade.Mgr.AddUpgradeHeight(upgrade.FixDoubleSignChainId, upgradeConfig.FixDoubleSignChainIdHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP126, upgradeConfig.BEP126Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP255, upgradeConfig.BEP255Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.FirstSunset, upgradeConfig.FirstSunsetHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.SecondSunset, upgradeConfig.SecondSunsetHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.FinalSunset, upgradeConfig.FinalSunsetHeight)

// register store keys of upgrade
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name())
Expand Down Expand Up @@ -619,6 +625,11 @@ func (app *BNBBeaconChain) initStaking() {
newCtx := ctx.WithSideChainKeyPrefix(storePrefix)
app.stakeKeeper.ClearUpSideVoteAddrs(newCtx)
})
upgrade.Mgr.RegisterBeginBlocker(sdk.FirstSunsetFork, func(ctx sdk.Context) {
chainId := sdk.ChainID(ServerContext.BscIbcChainId)
// enable channel but not send cross chain msg
app.scKeeper.SetChannelSendPermission(ctx, chainId, sTypes.StakeMigrationChannelID, sdk.ChannelAllow)
})
app.stakeKeeper.SubscribeParamChange(app.ParamHub)
app.stakeKeeper.SubscribeBCParamChange(app.ParamHub)
app.stakeKeeper = app.stakeKeeper.WithHooks(app.slashKeeper.Hooks())
Expand All @@ -629,6 +640,13 @@ func (app *BNBBeaconChain) initStaking() {
if err != nil {
panic(err)
}

// register stake migration channel
stakeMigrationApp := stakeMigration.NewStakeMigrationApp(app.stakeKeeper)
err = app.scKeeper.RegisterChannel(sTypes.StakeMigrationChannel, sTypes.StakeMigrationChannelID, stakeMigrationApp)
if err != nil {
panic(err)
}
}

func (app *BNBBeaconChain) initGov() {
Expand Down Expand Up @@ -880,7 +898,7 @@ func (app *BNBBeaconChain) isBreatheBlock(height int64, lastBlockTime time.Time,
// lastBlockTime is zero if this blockTime is for the first block (first block doesn't mean height = 1, because after
// state sync from breathe block, the height is breathe block + 1)
if app.baseConfig.BreatheBlockInterval > 0 {
return height%int64(app.baseConfig.BreatheBlockInterval) == 0
return !lastBlockTime.IsZero() && !utils.SamePeriodInUTC(lastBlockTime, blockTime, int64(app.baseConfig.BreatheBlockInterval))
} else {
return !lastBlockTime.IsZero() && !utils.SameDayInUTC(lastBlockTime, blockTime)
}
Expand Down Expand Up @@ -918,6 +936,7 @@ func (app *BNBBeaconChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock)
tokens.EndBreatheBlock(ctx, app.swapKeeper)
} else {
app.Logger.Debug("normal block", "height", height)
tokens.EndBlocker(ctx, app.timeLockKeeper, app.swapKeeper)
}

app.DexKeeper.StoreTradePrices(ctx)
Expand Down Expand Up @@ -945,6 +964,9 @@ func (app *BNBBeaconChain) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock)
} else if ctx.RouterCallRecord()["stake"] || sdk.IsUpgrade(upgrade.BEP128) {
validatorUpdates, completedUbd = stake.EndBlocker(ctx, app.stakeKeeper)
}

// That is no deep copy when New IBC Keeper. need to set it again.
app.ibcKeeper.SetSideChainKeeper(app.scKeeper)
ibc.EndBlocker(ctx, app.ibcKeeper)
if len(validatorUpdates) != 0 {
app.ValAddrCache.ClearCache()
Expand Down Expand Up @@ -1156,6 +1178,8 @@ func MakeCodec() *wire.Codec {
bridge.RegisterWire(cdc)
oracle.RegisterWire(cdc)
ibc.RegisterWire(cdc)
tokenRecover.RegisterWire(cdc)
migrate.RegisterWire(cdc)
return cdc
}

Expand Down
14 changes: 13 additions & 1 deletion app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ FixDoubleSignChainIdHeight = {{ .UpgradeConfig.FixDoubleSignChainIdHeight }}
BEP126Height = {{ .UpgradeConfig.BEP126Height }}
# Block height of BEP255 upgrade
BEP255Height = {{ .UpgradeConfig.BEP255Height }}
# Block height of FirstSunset upgrade
FirstSunsetHeight = {{ .UpgradeConfig.FirstSunsetHeight }}
# Block height of SecondSunset upgrade
SecondSunsetHeight = {{ .UpgradeConfig.SecondSunsetHeight }}
# Block height of FinalSunset upgrade
FinalSunsetHeight = {{ .UpgradeConfig.FinalSunsetHeight }}

[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down Expand Up @@ -552,6 +558,9 @@ type UpgradeConfig struct {
FixDoubleSignChainIdHeight int64 `mapstructure:"FixDoubleSignChainIdHeight"`
BEP126Height int64 `mapstructure:"BEP126Height"`
BEP255Height int64 `mapstructure:"BEP255Height"`
FirstSunsetHeight int64 `mapstructure:"FirstSunsetHeight"`
SecondSunsetHeight int64 `mapstructure:"SecondSunsetHeight"`
FinalSunsetHeight int64 `mapstructure:"FinalSunsetHeight"`
}

func defaultUpgradeConfig() *UpgradeConfig {
Expand Down Expand Up @@ -586,7 +595,10 @@ func defaultUpgradeConfig() *UpgradeConfig {
BEP171Height: math.MaxInt64,
FixFailAckPackageHeight: math.MaxInt64,
EnableAccountScriptsForCrossChainTransferHeight: math.MaxInt64,
BEP255Height: math.MaxInt64,
BEP255Height: math.MaxInt64,
FirstSunsetHeight: math.MaxInt64,
SecondSunsetHeight: math.MaxInt64,
FinalSunsetHeight: math.MaxInt64,
}
}

Expand Down
Loading
Loading