Skip to content

Commit

Permalink
[R4R]feat: decommission decentralized exchange on BNB Beacon Chain (#875
Browse files Browse the repository at this point in the history
)

* feat: dex prune

* add config for BEP151

* disable ListMsg as well

* fix config

* fix config

* Revert "fix config"

This reverts commit 8e2da4a.

* revert integration test file

* add testnet hardfork height

* change hardfork height
  • Loading branch information
owen-reorg authored Jul 11, 2022
1 parent 160b936 commit 6e87245
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ func SetUpgradeConfig(upgradeConfig *config.UpgradeConfig) {
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP87, upgradeConfig.BEP87Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.FixFailAckPackage, upgradeConfig.FixFailAckPackageHeight)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP128, upgradeConfig.BEP128Height)
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP151, upgradeConfig.BEP151Height)

// register store keys of upgrade
upgrade.Mgr.RegisterStoreKeys(upgrade.BEP9, common.TimeLockStoreKey.Name())
Expand Down
4 changes: 4 additions & 0 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ FixFailAckPackageHeight = {{ .UpgradeConfig.FixFailAckPackageHeight }}
EnableAccountScriptsForCrossChainTransferHeight = {{ .UpgradeConfig.EnableAccountScriptsForCrossChainTransferHeight }}
# Block height of BEP128 upgrade
BEP128Height = {{ .UpgradeConfig.BEP128Height }}
# Block height of BEP151 upgrade
BEP151Height = {{ .UpgradeConfig.BEP151Height }}
[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down Expand Up @@ -526,6 +528,7 @@ type UpgradeConfig struct {
FixFailAckPackageHeight int64 `mapstructure:"FixFailAckPackageHeight"`
EnableAccountScriptsForCrossChainTransferHeight int64 `mapstructure:"EnableAccountScriptsForCrossChainTransferHeight"`
BEP128Height int64 `mapstructure:"BEP128Height"`
BEP151Height int64 `mapstructure:"BEP151Height"`
}

func defaultUpgradeConfig() *UpgradeConfig {
Expand All @@ -546,6 +549,7 @@ func defaultUpgradeConfig() *UpgradeConfig {
BEP70Height: 1,
LaunchBscUpgradeHeight: 1,
BEP128Height: math.MaxInt64,
BEP151Height: math.MaxInt64,
BEP82Height: math.MaxInt64,
BEP84Height: math.MaxInt64,
BEP87Height: math.MaxInt64,
Expand Down
2 changes: 2 additions & 0 deletions asset/testnet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ FixFailAckPackageHeight = 7841000
EnableAccountScriptsForCrossChainTransferHeight = 7841000
#Block height of BEP128 upgrade
BEP128Height = 23551600
#Block height of BEP151 upgrade
BEP151Height = 28250000

[query]
# ABCI query interface black list, suggested value: ["custom/gov/proposals", "custom/timelock/timelocks", "custom/atomicSwap/swapcreator", "custom/atomicSwap/swaprecipient"]
Expand Down
1 change: 1 addition & 0 deletions common/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
FixFailAckPackage = sdk.FixFailAckPackage

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
)

func UpgradeBEP10(before func(), after func()) {
Expand Down
6 changes: 6 additions & 0 deletions plugins/dex/list/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ func NewHandler(keeper *order.DexKeeper, tokenMapper tokens.Mapper, govKeeper go
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
switch msg := msg.(type) {
case types.ListMsg:
if sdk.IsUpgrade(upgrade.BEP151) {
return sdk.ErrMsgNotSupported("ListMsg disabled in BEP-151").Result()
}
return handleList(ctx, keeper, tokenMapper, govKeeper, msg)
case types.ListMiniMsg:
if sdk.IsUpgrade(upgrade.BEP151) {
return sdk.ErrMsgNotSupported("ListMiniMsg disabled in BEP-151").Result()
}
return handleListMini(ctx, keeper, tokenMapper, msg)
default:
errMsg := fmt.Sprintf("Unrecognized dex msg type: %v", reflect.TypeOf(msg).Name())
Expand Down
3 changes: 3 additions & 0 deletions plugins/dex/order/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func NewHandler(dexKeeper *DexKeeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
switch msg := msg.(type) {
case NewOrderMsg:
if sdk.IsUpgrade(upgrade.BEP151) {
return sdk.ErrMsgNotSupported("NewOrderMsg disabled in BEP-151").Result()
}
return handleNewOrder(ctx, dexKeeper, msg)
case CancelOrderMsg:
return handleCancelOrder(ctx, dexKeeper, msg)
Expand Down

0 comments on commit 6e87245

Please sign in to comment.