From bf9b1396421d321dbbfea8530d5636cecee9f2f9 Mon Sep 17 00:00:00 2001 From: Roshan <48975233+Pythonberg1997@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:02:21 +0800 Subject: [PATCH] feat: add `MsgSideChainStakeMigration` and `StakeMigrationApp` (#993) * feat: add `MsgSideChainStakeMigration` and `StakeMigrationApp` * fix review comments * go mod tidy * update fee param for `MsgSideChainStakeMigration` * update go.mod --- app/app.go | 13 +++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index c5e4eeeae..e1d48b483 100644 --- a/app/app.go +++ b/app/app.go @@ -63,6 +63,7 @@ import ( "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 ( @@ -623,6 +624,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()) @@ -633,6 +639,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() { diff --git a/go.mod b/go.mod index 5461520fa..7ee44290f 100644 --- a/go.mod +++ b/go.mod @@ -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.20240105082215-555f52701c56 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20240106034703-7565ea7d1efc 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 diff --git a/go.sum b/go.sum index 209f1456a..e01bd960c 100644 --- a/go.sum +++ b/go.sum @@ -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.20240105082215-555f52701c56 h1:eXJqo4tNqgRsuytJNh67u75+lqz5AoVFGFD2eqiEnDY= -github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20240105082215-555f52701c56/go.mod h1:OjdXpDHofs6gcPLM9oGD+mm8DPc6Lsevz0Kia53zt3Q= +github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20240106034703-7565ea7d1efc h1:cdOIFh4pBX1ImRKpZz/vzZByl+XEGbaKPzCBg8z19TY= +github.com/bnb-chain/bnc-cosmos-sdk v0.26.5-0.20240106034703-7565ea7d1efc/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=