Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove claim module #1301

Merged
merged 4 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this should not have been moved to a history file. We need to undo this

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, this was an error that was missed as well :/

Copy link
Contributor

@alexanderbez alexanderbez May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean error? I removed it in the backport branch. Do we need to add it back?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we needed to still run snapshotAccs[addr] = account to update the value in the map, thats what get marshalled

}

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 @@ -150,7 +150,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