Skip to content

Commit

Permalink
Remove Alliance module
Browse files Browse the repository at this point in the history
  • Loading branch information
RustNinja committed Dec 1, 2023
1 parent aaca310 commit 320b58f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 71 deletions.
27 changes: 7 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ import (

router "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
alliancemodule "github.com/terra-money/alliance/x/alliance"
alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

custombankmodule "github.com/notional-labs/composable/v6/custom/bank"

Expand Down Expand Up @@ -176,9 +173,6 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
alliancemoduleclient.CreateAllianceProposalHandler,
alliancemoduleclient.UpdateAllianceProposalHandler,
alliancemoduleclient.DeleteAllianceProposalHandler,
// this line is used by starport scaffolding # stargate/app/govProposalHandler
)

Expand Down Expand Up @@ -223,7 +217,6 @@ var (
txBoundary.AppModuleBasic{},
ratelimitmodule.AppModuleBasic{},
consensus.AppModuleBasic{},
alliancemodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand All @@ -232,15 +225,13 @@ var (
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
// mint module needs burn access to remove excess validator tokens (it overallocates, then burns)
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
transfermiddlewaretypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.RewardsPoolName: nil,
icatypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
transfermiddlewaretypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -382,7 +373,6 @@ func NewComposableApp(
txBoundaryModule,
icaModule,
ratelimitModule,
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -420,7 +410,6 @@ func NewComposableApp(
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -454,7 +443,6 @@ func NewComposableApp(
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -492,7 +480,6 @@ func NewComposableApp(
wasm08types.ModuleName,
icatypes.ModuleName,
wasm.ModuleName,
alliancemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down
23 changes: 3 additions & 20 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ import (
routerkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"

alliancemodule "github.com/terra-money/alliance/x/alliance"
alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

transfermiddleware "github.com/notional-labs/composable/v6/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types"
Expand Down Expand Up @@ -152,7 +148,6 @@ type AppKeepers struct {
TxBoundaryKeepper txBoundaryKeeper.Keeper
RouterKeeper *routerkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
}

// InitNormalKeepers initializes all 'normal' keepers.
Expand Down Expand Up @@ -221,21 +216,11 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, appKeepers.keys[feegrant.StoreKey], appKeepers.AccountKeeper)
appKeepers.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, appKeepers.keys[upgradetypes.StoreKey], appCodec, homePath, bApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())

appKeepers.AllianceKeeper = alliancemodulekeeper.NewKeeper(
appCodec,
appKeepers.keys[alliancemoduletypes.StoreKey],
appKeepers.GetSubspace(alliancemoduletypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.StakingKeeper,
appKeepers.DistrKeeper,
)

appKeepers.BankKeeper.RegisterKeepers(appKeepers.AllianceKeeper, appKeepers.StakingKeeper)
appKeepers.BankKeeper.RegisterKeepers(appKeepers.StakingKeeper)
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
appKeepers.StakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks(), appKeepers.AllianceKeeper.StakingHooks()),
stakingtypes.NewMultiStakingHooks(appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks()),
)

// ... other modules keepers
Expand Down Expand Up @@ -399,8 +384,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)).
// AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(appKeepers.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)).
AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(appKeepers.AllianceKeeper))
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper))

// The gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
Expand Down Expand Up @@ -475,7 +459,6 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(icqtypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(alliancemoduletypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(transfermiddlewaretypes.ModuleName)

Expand Down
3 changes: 1 addition & 2 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types"
ratelimitmoduletypes "github.com/notional-labs/composable/v6/x/ratelimit/types"
Expand All @@ -52,7 +51,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasm08types.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, alliancemoduletypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
authzkeeper.StoreKey,
)

Expand Down
24 changes: 1 addition & 23 deletions custom/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ import (
banktypes "github.com/notional-labs/composable/v6/custom/bank/types"

transfermiddlewarekeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"

alliancekeeper "github.com/terra-money/alliance/x/alliance/keeper"
alliancetypes "github.com/terra-money/alliance/x/alliance/types"
)

type Keeper struct {
bankkeeper.BaseKeeper

tfmk banktypes.TransferMiddlewareKeeper
ak alliancekeeper.Keeper
sk banktypes.StakingKeeper
acck accountkeeper.AccountKeeper
}
Expand All @@ -42,16 +38,14 @@ func NewBaseKeeper(
) Keeper {
keeper := Keeper{
BaseKeeper: bankkeeper.NewBaseKeeper(cdc, storeKey, ak, blockedAddrs, authority),
ak: alliancekeeper.Keeper{},
sk: stakingkeeper.Keeper{},
tfmk: tfmk,
acck: ak,
}
return keeper
}

func (k *Keeper) RegisterKeepers(ak alliancekeeper.Keeper, sk banktypes.StakingKeeper) {
k.ak = ak
func (k *Keeper) RegisterKeepers(sk banktypes.StakingKeeper) {
k.sk = sk
}

Expand All @@ -68,16 +62,6 @@ func (k Keeper) SupplyOf(c context.Context, req *types.QuerySupplyOfRequest) (*t
ctx := sdk.UnwrapSDKContext(c)
supply := k.GetSupply(ctx, req.Denom)

if req.Denom == k.sk.BondDenom(ctx) {
assets := k.ak.GetAllAssets(ctx)
totalRewardWeights := sdk.ZeroDec()
for _, asset := range assets {
totalRewardWeights = totalRewardWeights.Add(asset.RewardWeight)
}
allianceBonded := k.ak.GetAllianceBondedAmount(ctx, k.acck.GetModuleAddress(alliancetypes.ModuleName))
supply.Amount = supply.Amount.Sub(allianceBonded)
}

return &types.QuerySupplyOfResponse{Amount: sdk.NewCoin(req.Denom, supply.Amount)}, nil
}

Expand All @@ -93,11 +77,5 @@ func (k Keeper) TotalSupply(ctx context.Context, req *types.QueryTotalSupplyRequ
duplicateCoins := k.tfmk.GetTotalEscrowedToken(sdkCtx)
totalSupply = totalSupply.Sub(duplicateCoins...)

allianceBonded := k.ak.GetAllianceBondedAmount(sdkCtx, k.acck.GetModuleAddress(alliancetypes.ModuleName))
bondDenom := k.sk.BondDenom(sdkCtx)
if totalSupply.AmountOf(bondDenom).IsPositive() {
totalSupply = totalSupply.Sub(sdk.NewCoin(bondDenom, allianceBonded))
}

return &types.QueryTotalSupplyResponse{Supply: totalSupply, Pagination: pageRes}, nil
}
4 changes: 1 addition & 3 deletions custom/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (
custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper"
)

// AppModule wraps around the bank module and the bank keeper to return the right total supply ignoring bonded tokens
// that the alliance module minted to rebalance the voting power
// It modifies the TotalSupply and SupplyOf GRPC queries
// AppModule wraps around the bank module and the bank keeper to return the right total supply
type AppModule struct {
bankmodule.AppModule
keeper custombankkeeper.Keeper
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ require (
github.com/spf13/cobra v1.7.0
github.com/strangelove-ventures/async-icq/v7 v7.0.0-20230413165143-a3b65ccdc897
github.com/stretchr/testify v1.8.4
github.com/terra-money/alliance v0.1.1-0.20230419080242-b29b0ec11186
golang.org/x/tools v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529
google.golang.org/grpc v1.56.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,6 @@ github.com/nishanths/exhaustive v0.8.3 h1:pw5O09vwg8ZaditDp/nQRqVnrMczSJDxRDJMow
github.com/nishanths/exhaustive v0.8.3/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg=
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647 h1:vCSokMIO60u0td51l7NB+pikUChJozIwIb4u8UeqTKI=
github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647/go.mod h1:GFQ8TsXDMTpu7kif0Dwddz6rxazy0ZJQHfN38ZmAodI=
github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0-20231027045618-f659894b12d9 h1:4rte3LTbrQnlu0Gnw6gouj2voGwgjweORA1dcgnQxlU=
github.com/notional-labs/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0-20231027045618-f659894b12d9/go.mod h1:3PHOr4UiPNtnZJutT22fm5+pjIefTlDEgtWGoOJg3A0=
github.com/notional-labs/ibc-go/v7 v7.2.1-0.20231010040541-6cf43006971f h1:Uw35VHCdLTsQf8B4UGTjHCR6HqcYFF6dwPW8uJzS0f4=
Expand Down

0 comments on commit 320b58f

Please sign in to comment.