Skip to content

Commit

Permalink
Remove claim module (#1301)
Browse files Browse the repository at this point in the history
* Remove claim module

* Add logic for deleting the claims store

Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2022
1 parent 15f131e commit fe1b5d2
Show file tree
Hide file tree
Showing 48 changed files with 17 additions and 94,232 deletions.
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ func (app *OsmosisApp) setupUpgradeStoreLoaders() {
}

if upgradeInfo.Name == v8.UpgradeName {
// TODO: Add claims module as deleted here
storeUpgrades = store.StoreUpgrades{}
storeUpgrades = store.StoreUpgrades{
Deleted: []string{v8.ClaimsModuleName},
}
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
15 changes: 1 addition & 14 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ import (

owasm "github.com/osmosis-labs/osmosis/v7/app/wasm"
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"
claimkeeper "github.com/osmosis-labs/osmosis/v7/x/claim/keeper"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
epochskeeper "github.com/osmosis-labs/osmosis/v7/x/epochs/keeper"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
gammkeeper "github.com/osmosis-labs/osmosis/v7/x/gamm/keeper"
Expand Down Expand Up @@ -95,7 +93,6 @@ type appKeepers struct {
Bech32IBCKeeper *bech32ibckeeper.Keeper
Bech32ICS20Keeper *bech32ics20keeper.Keeper
EvidenceKeeper *evidencekeeper.Keeper
ClaimKeeper *claimkeeper.Keeper
GAMMKeeper *gammkeeper.Keeper
LockupKeeper *lockupkeeper.Keeper
EpochsKeeper *epochskeeper.Keeper
Expand Down Expand Up @@ -267,12 +264,6 @@ func (app *OsmosisApp) InitNormalKeepers(
app.SlashingKeeper,
)

app.ClaimKeeper = claimkeeper.NewKeeper(
appCodec,
keys[claimtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper, app.StakingKeeper, app.DistrKeeper)

gammKeeper := gammkeeper.NewKeeper(
appCodec, keys[gammtypes.StoreKey],
app.GetSubspace(gammtypes.ModuleName),
Expand Down Expand Up @@ -412,7 +403,6 @@ func (app *OsmosisApp) SetupHooks() {
stakingtypes.NewMultiStakingHooks(
app.DistrKeeper.Hooks(),
app.SlashingKeeper.Hooks(),
app.ClaimKeeper.Hooks(),
app.SuperfluidKeeper.Hooks(),
),
)
Expand All @@ -421,7 +411,6 @@ func (app *OsmosisApp) SetupHooks() {
gammtypes.NewMultiGammHooks(
// insert gamm hooks receivers here
app.PoolIncentivesKeeper.Hooks(),
app.ClaimKeeper.Hooks(),
),
)

Expand Down Expand Up @@ -456,8 +445,7 @@ func (app *OsmosisApp) SetupHooks() {

app.GovKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// insert governance hooks receivers here
app.ClaimKeeper.Hooks(),
// insert governance hooks receivers here
),
)
}
Expand Down Expand Up @@ -502,7 +490,6 @@ func KVStoreKeys() []string {
capabilitytypes.StoreKey,
gammtypes.StoreKey,
lockuptypes.StoreKey,
claimtypes.StoreKey,
incentivestypes.StoreKey,
epochstypes.StoreKey,
poolincentivestypes.StoreKey,
Expand Down
8 changes: 0 additions & 8 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ import (

appparams "github.com/osmosis-labs/osmosis/v7/app/params"
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"
"github.com/osmosis-labs/osmosis/v7/x/claim"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
"github.com/osmosis-labs/osmosis/v7/x/epochs"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
"github.com/osmosis-labs/osmosis/v7/x/gamm"
Expand Down Expand Up @@ -108,7 +106,6 @@ var appModuleBasics = []module.AppModuleBasic{
lockup.AppModuleBasic{},
poolincentives.AppModuleBasic{},
epochs.AppModuleBasic{},
claim.AppModuleBasic{},
superfluid.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
wasm.AppModuleBasic{},
Expand All @@ -124,7 +121,6 @@ var moduleAccountPermissions = map[string][]string{
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
claimtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner},
lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand Down Expand Up @@ -166,7 +162,6 @@ func appModules(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(*app.ParamsKeeper),
app.transferModule,
claim.NewAppModule(appCodec, *app.ClaimKeeper),
gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
txfees.NewAppModule(appCodec, *app.TxFeesKeeper),
incentives.NewAppModule(appCodec, *app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
Expand Down Expand Up @@ -215,7 +210,6 @@ func orderBeginBlockers() []string {
gammtypes.ModuleName,
incentivestypes.ModuleName,
lockuptypes.ModuleName,
claimtypes.ModuleName,
poolincentivestypes.ModuleName,
// superfluid must come after distribution and epochs
superfluidtypes.ModuleName,
Expand All @@ -232,7 +226,6 @@ var orderEndBlockers = []string{
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
claimtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -282,7 +275,6 @@ var modulesOrderInitGenesis = []string{
bech32ibctypes.ModuleName, // comes after ibctransfertypes
poolincentivestypes.ModuleName,
superfluidtypes.ModuleName,
claimtypes.ModuleName,
incentivestypes.ModuleName,
epochstypes.ModuleName,
lockuptypes.ModuleName,
Expand Down
4 changes: 4 additions & 0 deletions app/upgrades/v8/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ package v8

// UpgradeName defines the on-chain upgrade name for the Osmosis v7 upgrade.
const UpgradeName = "v8"

// The historic name of the claims module, which is removed in this release.
// Cross-check against https://github.com/osmosis-labs/osmosis/blob/v7.2.0/x/claim/types/keys.go#L5
const ClaimsModuleName = "claim"
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"io/ioutil"
"os"

"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

appparams "github.com/osmosis-labs/osmosis/v7/app/params"
"github.com/osmosis-labs/osmosis/v7/osmoutils"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types"
lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types"
"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
Expand All @@ -40,18 +40,16 @@ type DerivedAccount struct {
UnbondingStake sdk.Int `json:"unbonding_stake"`
Bonded sdk.Coins `json:"bonded"`
BondedBySelectPools map[uint64]sdk.Coins `json:"bonded_by_select_pools"`
UnclaimedAirdrop sdk.Coins `json:"unclaimed_airdrop"`
TotalBalances sdk.Coins `json:"total_balances"`
}

func newDerivedAccount(address string) DerivedAccount {
return DerivedAccount{
Address: address,
LiquidBalances: sdk.Coins{},
Staked: sdk.ZeroInt(),
UnbondingStake: sdk.ZeroInt(),
Bonded: sdk.Coins{},
UnclaimedAirdrop: sdk.Coins{},
Address: address,
LiquidBalances: sdk.Coins{},
Staked: sdk.ZeroInt(),
UnbondingStake: sdk.ZeroInt(),
Bonded: sdk.Coins{},
}
}

Expand Down Expand Up @@ -257,34 +255,6 @@ Example:
snapshotAccs[address] = acc
}

claimGenesis := claimtypes.GenesisState{}
clientCtx.Codec.MustUnmarshalJSON(genState["claim"], &claimGenesis)
for _, record := range claimGenesis.ClaimRecords {
address := record.Address

acc, ok := snapshotAccs[address]
if !ok {
acc = newDerivedAccount(address)
}

claimablePerAction := sdk.Coins{}
for _, coin := range record.InitialClaimableAmount {
claimablePerAction = claimablePerAction.Add(
sdk.NewCoin(coin.Denom,
coin.Amount.QuoRaw(int64(len(claimtypes.Action_name))),
),
)
}

for action := range claimtypes.Action_name {
if record.ActionCompleted[action] == false {
acc.UnclaimedAirdrop = acc.UnclaimedAirdrop.Add(claimablePerAction...)
}
}

snapshotAccs[address] = acc
}

gammGenesis := gammtypes.GenesisState{}
clientCtx.Codec.MustUnmarshalJSON(genState["gamm"], &gammGenesis)

Expand Down Expand Up @@ -313,8 +283,6 @@ Example:
Add(sdk.NewCoin(appparams.BaseCoinUnit, account.Staked)).
Add(sdk.NewCoin(appparams.BaseCoinUnit, account.UnbondingStake)).
Add(account.Bonded...).
Add(account.UnclaimedAirdrop...)
snapshotAccs[addr] = account
}

snapshot := DeriveSnapshot{
Expand Down
23 changes: 0 additions & 23 deletions cmd/osmosisd/cmd/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

appParams "github.com/osmosis-labs/osmosis/v7/app/params"

claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types"
minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types"
Expand Down Expand Up @@ -193,15 +192,6 @@ func PrepareGenesis(clientCtx client.Context, appState map[string]json.RawMessag
}
appState[epochstypes.ModuleName] = epochsGenStateBz

// claim module genesis
claimGenState := claimtypes.GetGenesisStateFromAppState(depCdc, appState)
claimGenState.Params = genesisParams.ClaimParams
claimGenStateBz, err := cdc.MarshalJSON(claimGenState)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal claim genesis state: %w", err)
}
appState[claimtypes.ModuleName] = claimGenStateBz

// poolincentives module genesis
poolincentivesGenState := &genesisParams.PoolIncentivesGenesis
poolincentivesGenStateBz, err := cdc.MarshalJSON(poolincentivesGenState)
Expand Down Expand Up @@ -237,8 +227,6 @@ type GenesisParams struct {
PoolIncentivesGenesis poolincentivestypes.GenesisState

Epochs []epochstypes.EpochInfo

ClaimParams claimtypes.Params
}

func MainnetGenesisParams() GenesisParams {
Expand Down Expand Up @@ -496,13 +484,6 @@ func MainnetGenesisParams() GenesisParams {
time.Hour * 24 * 14, // 14 days
}

genParams.ClaimParams = claimtypes.Params{
AirdropStartTime: genParams.GenesisTime,
DurationUntilDecay: time.Hour * 24 * 60, // 60 days = ~2 months
DurationOfDecay: time.Hour * 24 * 120, // 120 days = ~4 months
ClaimDenom: genParams.NativeCoinMetadatas[0].Base,
}

genParams.ConsensusParams = tmtypes.DefaultConsensusParams()
genParams.ConsensusParams.Block.MaxBytes = 5 * 1024 * 1024
genParams.ConsensusParams.Block.MaxGas = 6_000_000
Expand Down Expand Up @@ -564,10 +545,6 @@ func TestnetGenesisParams() GenesisParams {
time.Hour * 2, // 2 hours
}

genParams.ClaimParams.AirdropStartTime = genParams.GenesisTime
genParams.ClaimParams.DurationUntilDecay = time.Hour * 48 // 2 days
genParams.ClaimParams.DurationOfDecay = time.Hour * 48 // 2 days

genParams.PoolIncentivesGenesis.LockableDurations = genParams.IncentivesGenesis.LockableDurations

return genParams
Expand Down
1 change: 0 additions & 1 deletion cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
AddGenesisWasmMsgCmd(osmosis.DefaultNodeHome),
genutilcli.GenTxCmd(osmosis.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, osmosis.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(osmosis.ModuleBasics),
ExportDeriveBalancesCmd(),
PrepareGenesisCmd(osmosis.DefaultNodeHome, osmosis.ModuleBasics),
tmcli.NewCompletionCmd(rootCmd, true),
testnetCmd(osmosis.ModuleBasics, banktypes.GenesisBalancesIterator{}),
Expand Down
35 changes: 0 additions & 35 deletions proto/osmosis/claim/v1beta1/claim.proto

This file was deleted.

33 changes: 0 additions & 33 deletions proto/osmosis/claim/v1beta1/genesis.proto

This file was deleted.

31 changes: 0 additions & 31 deletions proto/osmosis/claim/v1beta1/params.proto

This file was deleted.

Loading

0 comments on commit fe1b5d2

Please sign in to comment.