Skip to content

Commit

Permalink
fix: add sunsethardfork config and fix panic issue (#988)
Browse files Browse the repository at this point in the history
* feat: add Sunset hardfork config

* fix: nil pointer when doing ibc method in endblock
  • Loading branch information
j75689 authored Dec 14, 2023
1 parent 09b52c7 commit 5ee5e0f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,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 @@ -947,6 +950,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
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
5 changes: 4 additions & 1 deletion common/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ const (
BEP171 = sdk.BEP171 // https://github.com/bnb-chain/BEPs/pull/171 Security Enhancement for Cross-Chain Module
BEP173 = sdk.BEP173 // https://github.com/bnb-chain/BEPs/pull/173 Text Proposal
FixDoubleSignChainId = sdk.FixDoubleSignChainId
BEP255 = sdk.BEP255 // https://github.com/bnb-chain/BEPs/pull/255 Asset Reconciliation for Security Enhancement
BEP255 = sdk.BEP255 // https://github.com/bnb-chain/BEPs/pull/255 Asset Reconciliation for Security Enhancement
FirstSunset = sdk.FirstSunsetFork // https://github.com/bnb-chain/BEPs/pull/333 BNB Chain Fusion
SecondSunset = sdk.SecondSunsetFork // https://github.com/bnb-chain/BEPs/pull/333 BNB Chain Fusion
FinalSunset = sdk.FinalSunsetFork // https://github.com/bnb-chain/BEPs/pull/333 BNB Chain Fusion
)

func UpgradeBEP10(before func(), after func()) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ require (
replace (
github.com/Shopify/sarama v1.26.1 => github.com/Shopify/sarama v1.21.0
// TODO: bump to official release
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231129092047-065b54761eab
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231214014755-d940f55f667c
github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20210702154020-550e1cd83ec1
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/go-amino => github.com/bnb-chain/bnc-go-amino v0.14.1-binance.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231129092047-065b54761eab h1:Wr52A136l+sjd79w3zv6cRaSz9IYNWgoeE9tW9SGwxU=
github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231129092047-065b54761eab/go.mod h1:OjdXpDHofs6gcPLM9oGD+mm8DPc6Lsevz0Kia53zt3Q=
github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231214014755-d940f55f667c h1:8R2s5MCR8ZYn5ChktnXmuwC1z5l0Ldrfpt8WdMqmOQE=
github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20231214014755-d940f55f667c/go.mod h1:OjdXpDHofs6gcPLM9oGD+mm8DPc6Lsevz0Kia53zt3Q=
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.10 h1:E4iSwEbJCLYchHiHE1gnOM3jjmJXLBxARhy/RCl8CpI=
Expand Down

0 comments on commit 5ee5e0f

Please sign in to comment.