diff --git a/README.md b/README.md index d010b5c1d..a2f97008e 100644 --- a/README.md +++ b/README.md @@ -171,4 +171,4 @@ It is welcomed to contribute to this repo from everyone. If you'd like to contri - Code must adhere to the official Go formatting guidelines (i.e. please use gofmt tool). - Code must be documented adhering to the official Go commentary guidelines. -- Pull requests need to be based on and opened against the master branch. \ No newline at end of file +- Pull requests need to be based on and opened against the master branch. diff --git a/app/app.go b/app/app.go index 052bd67fe..5004e4de9 100644 --- a/app/app.go +++ b/app/app.go @@ -66,6 +66,10 @@ import ( const ( appName = "BNBChain" + + bscValidatorSetContractAddr = "0000000000000000000000000000000000001000" + slashIndicatorContractAddr = "0000000000000000000000000000000000001001" + stakeContractAddr = "0000000000000000000000000000000000002001" ) // default home directories for expected binaries @@ -340,6 +344,7 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) { upgrade.Mgr.AddUpgradeHeight(upgrade.BEP171, upgradeConfig.BEP171Height) upgrade.Mgr.AddUpgradeHeight(upgrade.BEP173, upgradeConfig.BEP173Height) upgrade.Mgr.AddUpgradeHeight(upgrade.FixDoubleSignChainId, upgradeConfig.FixDoubleSignChainIdHeight) + upgrade.Mgr.AddUpgradeHeight(upgrade.BEP126, upgradeConfig.BEP126Height) // register store keys of upgrade upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name()) @@ -489,6 +494,21 @@ func (app *BinanceChain) initSideChain() { BscSideChainId: ServerContext.BscChainId, }) }) + upgrade.Mgr.RegisterBeginBlocker(sdk.BEP126, func(ctx sdk.Context) { + chainId := sdk.ChainID(ServerContext.BscIbcChainId) + + validatorSetAddr, _ := sdk.NewSmartChainAddress(bscValidatorSetContractAddr) + _, sdkErr := app.scKeeper.AddSystemRewardOperator(ctx, chainId, validatorSetAddr) + if sdkErr != nil { + panic(sdkErr.Error()) + } + + slashIndicatorAddr, _ := sdk.NewSmartChainAddress(slashIndicatorContractAddr) + _, sdkErr = app.scKeeper.AddSystemRewardOperator(ctx, chainId, slashIndicatorAddr) + if sdkErr != nil { + panic(sdkErr.Error()) + } + }) } func (app *BinanceChain) initOracle() { @@ -557,9 +577,8 @@ func (app *BinanceChain) initStaking() { upgrade.Mgr.RegisterBeginBlocker(sdk.BEP153, func(ctx sdk.Context) { chainId := sdk.ChainID(ServerContext.BscIbcChainId) app.scKeeper.SetChannelSendPermission(ctx, chainId, sTypes.CrossStakeChannelID, sdk.ChannelAllow) - stakeContractAddr := "0000000000000000000000000000000000002001" stakeContractBytes, _ := hex.DecodeString(stakeContractAddr) - _, sdkErr := app.scKeeper.CreateNewChannelToIbc(ctx, chainId, sTypes.CrossStakeChannelID, sdk.RewardNotFromSystem, stakeContractBytes) + _, sdkErr := app.scKeeper.CreateNewCrossChainChannel(ctx, chainId, sTypes.CrossStakeChannelID, sdk.RewardNotFromSystem, stakeContractBytes) if sdkErr != nil { panic(sdkErr.Error()) } diff --git a/app/config/config.go b/app/config/config.go index 21f44a091..9c88683ea 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -99,6 +99,8 @@ LimitConsAddrUpdateIntervalHeight = {{ .UpgradeConfig.LimitConsAddrUpdateInterva BEP173Height = {{ .UpgradeConfig.BEP173Height }} # Block height of FixDoubleSignChainIdHeight upgrade FixDoubleSignChainIdHeight = {{ .UpgradeConfig.FixDoubleSignChainIdHeight }} +# Block height of BEP126 upgrade +BEP126Height = {{ .UpgradeConfig.BEP126Height }} [query] # ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"] @@ -546,6 +548,7 @@ type UpgradeConfig struct { BEP171Height int64 `mapstructure:"BEP171Height"` BEP173Height int64 `mapstructure:"BEP173Height"` FixDoubleSignChainIdHeight int64 `mapstructure:"FixDoubleSignChainIdHeight"` + BEP126Height int64 `mapstructure:"BEP126Height"` } func defaultUpgradeConfig() *UpgradeConfig { @@ -566,6 +569,7 @@ func defaultUpgradeConfig() *UpgradeConfig { BEP70Height: 1, LaunchBscUpgradeHeight: 1, LimitConsAddrUpdateIntervalHeight: math.MaxInt64, + BEP126Height: math.MaxInt64, BEP128Height: math.MaxInt64, BEP151Height: math.MaxInt64, BEP153Height: math.MaxInt64, @@ -578,7 +582,6 @@ func defaultUpgradeConfig() *UpgradeConfig { BEP87Height: math.MaxInt64, BEP171Height: math.MaxInt64, FixFailAckPackageHeight: math.MaxInt64, - EnableAccountScriptsForCrossChainTransferHeight: math.MaxInt64, } } diff --git a/common/upgrade/upgrade.go b/common/upgrade/upgrade.go index d3c10d3b5..4683a32e4 100644 --- a/common/upgrade/upgrade.go +++ b/common/upgrade/upgrade.go @@ -39,6 +39,7 @@ const ( BEP87 = "BEP87" // https://github.com/bnb-chain/BEPs/pull/87 FixFailAckPackage = sdk.FixFailAckPackage + BEP126 = sdk.BEP126 // https://github.com/bnb-chain/BEPs/pull/126 Fast finality upgrade BEP128 = sdk.BEP128 // https://github.com/bnb-chain/BEPs/pull/128 Staking reward distribution upgrade BEP151 = "BEP151" // https://github.com/bnb-chain/BEPs/pull/151 Decommission Decentralized Exchange BEP153 = sdk.BEP153 // https://github.com/bnb-chain/BEPs/pull/153 Native Staking diff --git a/go.mod b/go.mod index 1c0088413..35e26ef63 100644 --- a/go.mod +++ b/go.mod @@ -88,7 +88,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.26.1 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.25.8-0.20230407025511-4dc9bc0c5ca9 github.com/tendermint/go-amino => github.com/bnb-chain/bnc-go-amino v0.14.1-binance.2 github.com/tendermint/iavl => github.com/bnb-chain/bnc-tendermint-iavl v0.12.0-binance.5 github.com/tendermint/tendermint => github.com/bnb-chain/bnc-tendermint v0.32.3-bc.9 diff --git a/go.sum b/go.sum index 82a438265..65d57ab5f 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bnb-chain/bnc-cosmos-sdk v0.26.1 h1:OJELJCmBKWBl7FfJpzyIaFzui/SYdWdtljOPBNFznO4= -github.com/bnb-chain/bnc-cosmos-sdk v0.26.1/go.mod h1:RjpdOUIrrkMdk9kWg9BKXkOFaJQjvosBbyr3U//z93c= +github.com/bnb-chain/bnc-cosmos-sdk v0.25.8-0.20230407025511-4dc9bc0c5ca9 h1:CYE2W1CGRP08fDNmmUbofZJ9FKj1UaL9x9Vz2uJuPa0= +github.com/bnb-chain/bnc-cosmos-sdk v0.25.8-0.20230407025511-4dc9bc0c5ca9/go.mod h1:RjpdOUIrrkMdk9kWg9BKXkOFaJQjvosBbyr3U//z93c= github.com/bnb-chain/bnc-go-amino v0.14.1-binance.2 h1:iAlp9gqG0f2LGAauf3ZiijWlT6NI+W2r9y70HH9LI3k= github.com/bnb-chain/bnc-go-amino v0.14.1-binance.2/go.mod h1:LiCO7jev+3HwLGAiN9gpD0z+jTz95RqgSavbse55XOY= github.com/bnb-chain/bnc-tendermint v0.32.3-bc.9 h1:ubmtJkfE9SZfdDTzGBoXkXO8htHCniH8vUL/lLhxd8A=