Skip to content

Commit

Permalink
Revert "feat: export community pool (#123)"
Browse files Browse the repository at this point in the history
This reverts commit 8641019.
  • Loading branch information
zakir-code committed Nov 7, 2023
1 parent 8641019 commit 9bd82eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
24 changes: 2 additions & 22 deletions app/upgrades/v6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/ethereum/go-ethereum/common"

"github.com/functionx/fx-core/v6/app/keepers"
crosschainkeeper "github.com/functionx/fx-core/v6/x/crosschain/keeper"
fxgovtypes "github.com/functionx/fx-core/v6/x/gov/types"
govtypes "github.com/functionx/fx-core/v6/x/gov/types"
layer2types "github.com/functionx/fx-core/v6/x/layer2/types"
migratekeeper "github.com/functionx/fx-core/v6/x/migrate/keeper"
fxstakingkeeper "github.com/functionx/fx-core/v6/x/staking/keeper"
Expand All @@ -36,7 +33,6 @@ func CreateUpgradeHandler(

MigrateMetadata(cacheCtx, app.BankKeeper)
MigrateLayer2Module(cacheCtx, app.Layer2Keeper)
ExportCommunityPool(cacheCtx, app.DistrKeeper, app.BankKeeper)

ctx.Logger().Info("start to run v6 migrations...", "module", "upgrade")
toVM, err := mm.RunMigrations(cacheCtx, configurator, fromVM)
Expand Down Expand Up @@ -81,7 +77,7 @@ func UpdateParams(cacheCtx sdk.Context, app *keepers.AppKeepers) error {
govTallyParams.VetoThreshold = sdk.OneDec().String() // 100%
app.GovKeeper.SetTallyParams(cacheCtx, govTallyParams)

app.GovKeeper.IterateParams(cacheCtx, func(param *fxgovtypes.Params) (stop bool) {
app.GovKeeper.IterateParams(cacheCtx, func(param *govtypes.Params) (stop bool) {
param.Quorum = sdk.OneDec().String() // 100%
param.Threshold = sdk.OneDec().String() // 100%
param.VetoThreshold = sdk.OneDec().String() // 100%
Expand All @@ -96,22 +92,6 @@ func UpdateParams(cacheCtx sdk.Context, app *keepers.AppKeepers) error {
return nil
}

func ExportCommunityPool(ctx sdk.Context, distrKeeper distrkeeper.Keeper, bankKeeper bankkeeper.Keeper) sdk.Coins {
feePool := distrKeeper.GetFeePool(ctx)
truncatedCoins, changeCoins := feePool.CommunityPool.TruncateDecimal()
feePool.CommunityPool = changeCoins
distrKeeper.SetFeePool(ctx, feePool)

if err := bankKeeper.SendCoinsFromModuleToModule(ctx, distrtypes.ModuleName, govtypes.ModuleName, truncatedCoins); err != nil {
panic(err)
}
if err := bankKeeper.BurnCoins(ctx, govtypes.ModuleName, truncatedCoins); err != nil {
panic(err)
}
ctx.Logger().Info("export community pool", "coins", truncatedCoins.String())
return truncatedCoins
}

func MigrateMetadata(ctx sdk.Context, bankKeeper bankkeeper.Keeper) {
bankKeeper.IterateAllDenomMetaData(ctx, func(metadata banktypes.Metadata) bool {
address, ok := Layer2GenesisTokenAddress[metadata.Symbol]
Expand Down
6 changes: 0 additions & 6 deletions app/upgrades/v6/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ func (s *UpgradeTestSuite) TestUpdateParams() {
s.CommitBlock(10)
}

func (s *UpgradeTestSuite) TestExportCommunityPool() {
s.CommitBlock(10)
communityPool := v6.ExportCommunityPool(s.ctx, s.app.DistrKeeper, s.app.BankKeeper)
s.True(communityPool.IsAllPositive())
}

func (s *UpgradeTestSuite) TestMigrateMetadata() {
for symbol := range v6.Layer2GenesisTokenAddress {
hasDenomMetaData := s.app.BankKeeper.HasDenomMetaData(s.ctx, strings.ToLower(symbol))
Expand Down

0 comments on commit 9bd82eb

Please sign in to comment.