Skip to content

Commit

Permalink
remove reward module, reward protos, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 4, 2024
1 parent d72b319 commit 89ced9c
Show file tree
Hide file tree
Showing 74 changed files with 34 additions and 27,543 deletions.
17 changes: 0 additions & 17 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ import (
oraclekeeper "github.com/provenance-io/provenance/x/oracle/keeper"
oraclemodule "github.com/provenance-io/provenance/x/oracle/module"
oracletypes "github.com/provenance-io/provenance/x/oracle/types"
rewardkeeper "github.com/provenance-io/provenance/x/reward/keeper"
rewardmodule "github.com/provenance-io/provenance/x/reward/module"
rewardtypes "github.com/provenance-io/provenance/x/reward/types"
triggerkeeper "github.com/provenance-io/provenance/x/trigger/keeper"
triggermodule "github.com/provenance-io/provenance/x/trigger/module"
triggertypes "github.com/provenance-io/provenance/x/trigger/types"
Expand Down Expand Up @@ -232,7 +229,6 @@ var (
metadata.AppModuleBasic{},
wasm.AppModuleBasic{},
msgfeesmodule.AppModuleBasic{},
rewardmodule.AppModuleBasic{},
triggermodule.AppModuleBasic{},
oraclemodule.AppModuleBasic{},
holdmodule.AppModuleBasic{},
Expand All @@ -255,7 +251,6 @@ var (
attributetypes.ModuleName: nil,
markertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},
rewardtypes.ModuleName: nil,
triggertypes.ModuleName: nil,
oracletypes.ModuleName: nil,
}
Expand Down Expand Up @@ -311,7 +306,6 @@ type App struct {
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
MsgFeesKeeper msgfeeskeeper.Keeper
RewardKeeper rewardkeeper.Keeper
// QuarantineKeeper quarantinekeeper.Keeper // TODO[1760]: quarantine
// SanctionKeeper sanctionkeeper.Keeper // TODO[1760]: sanction
TriggerKeeper triggerkeeper.Keeper
Expand Down Expand Up @@ -410,7 +404,6 @@ func New(
nametypes.StoreKey,
msgfeestypes.StoreKey,
wasmtypes.StoreKey,
rewardtypes.StoreKey,
// quarantine.StoreKey, // TODO[1760]: quarantine
// sanction.StoreKey, // TODO[1760]: sanction
triggertypes.StoreKey,
Expand Down Expand Up @@ -517,8 +510,6 @@ func New(
stakingtypes.NewMultiStakingHooks(restrictHooks, app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)

app.RewardKeeper = rewardkeeper.NewKeeper(appCodec, keys[rewardtypes.StoreKey], app.StakingKeeper, &app.GovKeeper, app.BankKeeper, app.AccountKeeper)

app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.BaseApp.MsgServiceRouter(), app.AccountKeeper)

app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.BaseApp.MsgServiceRouter(), app.AccountKeeper, group.DefaultConfig())
Expand Down Expand Up @@ -583,7 +574,6 @@ func New(

markerReqAttrBypassAddrs := []sdk.AccAddress{
authtypes.NewModuleAddress(authtypes.FeeCollectorName), // Allow collecting fees in restricted coins.
authtypes.NewModuleAddress(rewardtypes.ModuleName), // Allow rewards to hold onto restricted coins.
// authtypes.NewModuleAddress(quarantine.ModuleName), // Allow quarantine to hold onto restricted coins. // TODO[1760]: quarantine
authtypes.NewModuleAddress(govtypes.ModuleName), // Allow restricted coins in deposits.
authtypes.NewModuleAddress(distrtypes.ModuleName), // Allow fee denoms to be restricted coins.
Expand Down Expand Up @@ -802,7 +792,6 @@ func New(
attribute.NewAppModule(appCodec, app.AttributeKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper),
msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry),
wasm.NewAppModule(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil, app.GetSubspace(wasmtypes.ModuleName)), // TODO[1760]: Need to pass message router instead of nil
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper),
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
oracleModule,
holdmodule.NewAppModule(appCodec, app.HoldKeeper),
Expand Down Expand Up @@ -857,7 +846,6 @@ func New(
markertypes.ModuleName,
icatypes.ModuleName,
attributetypes.ModuleName,
rewardtypes.ModuleName,
triggertypes.ModuleName,

// no-ops
Expand Down Expand Up @@ -894,7 +882,6 @@ func New(
authtypes.ModuleName,
icatypes.ModuleName,
group.ModuleName,
rewardtypes.ModuleName,
triggertypes.ModuleName,

// no-ops
Expand Down Expand Up @@ -968,7 +955,6 @@ func New(
ibchookstypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
rewardtypes.ModuleName,
triggertypes.ModuleName,
oracletypes.ModuleName,

Expand Down Expand Up @@ -1015,7 +1001,6 @@ func New(
msgfeestypes.ModuleName,
metadatatypes.ModuleName,
nametypes.ModuleName,
rewardtypes.ModuleName,
triggertypes.ModuleName,
oracletypes.ModuleName,

Expand Down Expand Up @@ -1049,7 +1034,6 @@ func New(
name.NewAppModule(appCodec, app.NameKeeper, app.AccountKeeper, app.BankKeeper),
attribute.NewAppModule(appCodec, app.AttributeKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper),
msgfeesmodule.NewAppModule(appCodec, app.MsgFeesKeeper, app.interfaceRegistry),
rewardmodule.NewAppModule(appCodec, app.RewardKeeper, app.AccountKeeper, app.BankKeeper),
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper),
holdmodule.NewAppModule(appCodec, app.HoldKeeper),
Expand Down Expand Up @@ -1423,7 +1407,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(attributetypes.ModuleName) // TODO[1760]: params: Migrate attribute params.
paramsKeeper.Subspace(msgfeestypes.ModuleName) // TODO[1760]: params: Migrate msgFees params.
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(rewardtypes.ModuleName) // TODO[1760]: params: Migrate reward params.
paramsKeeper.Subspace(triggertypes.ModuleName) // TODO[1760]: params: Migrate trigger params.

// register the key tables for legacy param subspaces
Expand Down
62 changes: 0 additions & 62 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"github.com/provenance-io/provenance/app/params"
"github.com/provenance-io/provenance/internal"
"github.com/provenance-io/provenance/internal/pioconfig"
rewardtypes "github.com/provenance-io/provenance/x/reward/types"
)

// DefaultConsensusParams defines the default Tendermint consensus params used in
Expand Down Expand Up @@ -516,64 +515,3 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) {
}
return &ed25519.PubKey{Key: pkBytes}
}

// SetupWithGenesisRewardsProgram initializes a new SimApp with the provided
// rewards programs, genesis accounts, validators, and balances.
func SetupWithGenesisRewardsProgram(t *testing.T, nextRewardProgramID uint64, genesisRewards []rewardtypes.RewardProgram, genAccs []authtypes.GenesisAccount, valSet *cmttypes.ValidatorSet, balances ...banktypes.Balance) *App {
t.Helper()

// Make sure there's a validator set with at least one validator in it.
if valSet == nil || len(valSet.Validators) == 0 {
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
require.NoError(t, err)
validator := cmttypes.NewValidator(pubKey, 1)
if valSet == nil {
valSet = cmttypes.NewValidatorSet([]*cmttypes.Validator{validator})
} else {
require.NoError(t, valSet.UpdateWithChangeSet([]*cmttypes.Validator{validator}))
}
}

app, genesisState := setup(t, true, 0, "")
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)
genesisState = genesisStateWithRewards(t, app, genesisState, nextRewardProgramID, genesisRewards)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err, "marshaling genesis state to json")

_, err = app.InitChain(
&abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
require.NoError(t, err, "InitChain")

_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: app.LastBlockHeight() + 1,
Hash: app.LastCommitID().Hash,
NextValidatorsHash: valSet.Hash(),
Time: time.Now().UTC(),
})
require.NoError(t, err, "FinalizeBlock")

return app
}

func genesisStateWithRewards(t *testing.T,
app *App, genesisState GenesisState,
nextRewardProgramID uint64, genesisRewards []rewardtypes.RewardProgram,
) GenesisState {
rewardGenesisState := rewardtypes.NewGenesisState(
nextRewardProgramID,
genesisRewards,
[]rewardtypes.ClaimPeriodRewardDistribution{},
[]rewardtypes.RewardAccountState{},
)
var err error
genesisState[rewardtypes.ModuleName], err = app.AppCodec().MarshalJSON(rewardGenesisState)
require.NoError(t, err, "marshaling reward genesis state JSON")
return genesisState
}
Loading

0 comments on commit 89ced9c

Please sign in to comment.