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

[r4r]Implement of BEP126 #935

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- Pull requests need to be based on and opened against the master branch.
23 changes: 21 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ import (

const (
appName = "BNBChain"

bscValidatorSetContractAddr = "0000000000000000000000000000000000001000"
slashIndicatorContractAddr = "0000000000000000000000000000000000001001"
stakeContractAddr = "0000000000000000000000000000000000002001"
)

// default home directories for expected binaries
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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())
}
Expand Down
5 changes: 4 additions & 1 deletion app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -578,7 +582,6 @@ func defaultUpgradeConfig() *UpgradeConfig {
BEP87Height: math.MaxInt64,
BEP171Height: math.MaxInt64,
FixFailAckPackageHeight: math.MaxInt64,

EnableAccountScriptsForCrossChainTransferHeight: math.MaxInt64,
}
}
Expand Down
1 change: 1 addition & 0 deletions common/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down