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

[ValSet-Pref] Module Wired up and created MsgSetValidatorSetPreference #2892

Merged
merged 3 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
58 changes: 35 additions & 23 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import (
"github.com/osmosis-labs/osmosis/v12/x/txfees"
txfeeskeeper "github.com/osmosis-labs/osmosis/v12/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types"
valsetpref "github.com/osmosis-labs/osmosis/v12/x/valset-pref"
valsetpreftypes "github.com/osmosis-labs/osmosis/v12/x/valset-pref/types"
)

type AppKeepers struct {
Expand All @@ -92,29 +94,30 @@ type AppKeepers struct {
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// "Normal" keepers
AccountKeeper *authkeeper.AccountKeeper
BankKeeper *bankkeeper.BaseKeeper
AuthzKeeper *authzkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper *distrkeeper.Keeper
SlashingKeeper *slashingkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper *icahostkeeper.Keeper
TransferKeeper *ibctransferkeeper.Keeper
EvidenceKeeper *evidencekeeper.Keeper
GAMMKeeper *gammkeeper.Keeper
TwapKeeper *twap.Keeper
LockupKeeper *lockupkeeper.Keeper
EpochsKeeper *epochskeeper.Keeper
IncentivesKeeper *incentiveskeeper.Keeper
MintKeeper *mintkeeper.Keeper
PoolIncentivesKeeper *poolincentiveskeeper.Keeper
TxFeesKeeper *txfeeskeeper.Keeper
SuperfluidKeeper *superfluidkeeper.Keeper
GovKeeper *govkeeper.Keeper
WasmKeeper *wasm.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper
TokenFactoryKeeper *tokenfactorykeeper.Keeper
AccountKeeper *authkeeper.AccountKeeper
BankKeeper *bankkeeper.BaseKeeper
AuthzKeeper *authzkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper *distrkeeper.Keeper
SlashingKeeper *slashingkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper *icahostkeeper.Keeper
TransferKeeper *ibctransferkeeper.Keeper
EvidenceKeeper *evidencekeeper.Keeper
GAMMKeeper *gammkeeper.Keeper
TwapKeeper *twap.Keeper
LockupKeeper *lockupkeeper.Keeper
EpochsKeeper *epochskeeper.Keeper
IncentivesKeeper *incentiveskeeper.Keeper
MintKeeper *mintkeeper.Keeper
PoolIncentivesKeeper *poolincentiveskeeper.Keeper
TxFeesKeeper *txfeeskeeper.Keeper
SuperfluidKeeper *superfluidkeeper.Keeper
GovKeeper *govkeeper.Keeper
WasmKeeper *wasm.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper
TokenFactoryKeeper *tokenfactorykeeper.Keeper
ValidatorSetPreferenceKeeper *valsetpref.Keeper

// IBC modules
// transfer module
Expand Down Expand Up @@ -338,6 +341,14 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)
appKeepers.TokenFactoryKeeper = &tokenFactoryKeeper

validatorSetPreferenceKeeper := valsetpref.NewKeeper(
appKeepers.keys[valsetpreftypes.StoreKey],
appKeepers.GetSubspace(valsetpreftypes.ModuleName),
appKeepers.StakingKeeper,
)

appKeepers.ValidatorSetPreferenceKeeper = &validatorSetPreferenceKeeper

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate,osmosis"
Expand Down Expand Up @@ -556,5 +567,6 @@ func KVStoreKeys() []string {
superfluidtypes.StoreKey,
wasm.StoreKey,
tokenfactorytypes.StoreKey,
valsetpreftypes.StoreKey,
}
}
2 changes: 2 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/osmosis-labs/osmosis/v12/x/tokenfactory"
"github.com/osmosis-labs/osmosis/v12/x/twap/twapmodule"
"github.com/osmosis-labs/osmosis/v12/x/txfees"
valsetprefmodule "github.com/osmosis-labs/osmosis/v12/x/valset-pref/valpref-module"
)

// AppModuleBasics returns ModuleBasics for the module BasicManager.
Expand Down Expand Up @@ -84,6 +85,7 @@ var AppModuleBasics = []module.AppModuleBasic{
epochs.AppModuleBasic{},
superfluid.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
valsetprefmodule.AppModuleBasic{},
wasm.AppModuleBasic{},
ica.AppModuleBasic{},
}
5 changes: 5 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ import (
twaptypes "github.com/osmosis-labs/osmosis/v12/x/twap/types"
"github.com/osmosis-labs/osmosis/v12/x/txfees"
txfeestypes "github.com/osmosis-labs/osmosis/v12/x/txfees/types"
valsetpreftypes "github.com/osmosis-labs/osmosis/v12/x/valset-pref/types"
valsetprefmodule "github.com/osmosis-labs/osmosis/v12/x/valset-pref/valpref-module"
)

// moduleAccountPermissions defines module account permissions
Expand All @@ -90,6 +92,7 @@ var moduleAccountPermissions = map[string][]string{
txfeestypes.NonNativeFeeCollectorName: nil,
wasm.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
valsetpreftypes.ModuleName: {authtypes.Staking},
}

// appModules return modules to initialize module manager.
Expand Down Expand Up @@ -142,6 +145,7 @@ func appModules(
app.EpochsKeeper,
),
tokenfactory.NewAppModule(*app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
valsetprefmodule.NewAppModule(appCodec, *app.ValidatorSetPreferenceKeeper),
}
}

Expand Down Expand Up @@ -211,6 +215,7 @@ func OrderInitGenesis(allModuleNames []string) []string {
poolincentivestypes.ModuleName,
superfluidtypes.ModuleName,
tokenfactorytypes.ModuleName,
valsetpreftypes.ModuleName,
incentivestypes.ModuleName,
epochstypes.ModuleName,
lockuptypes.ModuleName,
Expand Down
11 changes: 7 additions & 4 deletions app/upgrades/v13/constants.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package v13

import (
"github.com/osmosis-labs/osmosis/v12/app/upgrades"

store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/osmosis-labs/osmosis/v12/app/upgrades"
valsetpreftypes "github.com/osmosis-labs/osmosis/v12/x/valset-pref/types"
)

// UpgradeName defines the on-chain upgrade name for the Osmosis v9 upgrade.
// UpgradeName defines the on-chain upgrade name for the Osmosis v13 upgrade.
const UpgradeName = "v13"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
StoreUpgrades: store.StoreUpgrades{
Added: []string{valsetpreftypes.StoreKey},
Deleted: []string{}, // double check bech32ibc
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this comment for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is following the app/upgrades/v12/constants.go standard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after some digging around i found out that

  • we removed bechibc32 module in v12 and this is for double checking if we need to remove that store but ended up not needing to do anything

stackman27 marked this conversation as resolved.
Show resolved Hide resolved
},
}
14 changes: 14 additions & 0 deletions osmoutils/slice_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@ func ReverseSlice[T any](s []T) []T {
}
return s
}

// ContainsDuplicate checks if there are any duplicate
// elements in the slice.
func ContainsDuplicate[T any](arr []T) bool {
visited := make(map[any]bool, 0)
for i := 0; i < len(arr); i++ {
if visited[arr[i]] {
return true
} else {
visited[arr[i]] = true
}
}
return false
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
syntax = "proto3";
package osmosis.validatorpreference.v1beta1;
package osmosis.valsetpref.v1beta1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "osmosis/validator-preference/v1beta1/state.proto";
import "osmosis/valset-pref/v1beta1/state.proto";

option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/client/queryproto";
option go_package = "github.com/osmosis-labs/osmosis/v12/x/valset-pref/client/queryproto";
option (gogoproto.goproto_getters_all) = false;

// Query defines the gRPC querier service.
service Query {
// Returns the list of ValidatorPreferences for the user.
rpc UserValidatorPreferences(QueryUserValidatorPreferences)
returns (QueryUserValidatorPreferenceResponse) {
option (google.api.http).get =
"/osmosis/validator-preference/v1beta1/{user}";
option (google.api.http).get = "/osmosis/valset-pref/v1beta1/{address}";
}
}

// Request type for UserValidatorPreferences.
message QueryUserValidatorPreferences {
// user account address
string user = 1;
string address = 1;
}

// Response type the QueryUserValidatorPreferences query request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";
package osmosis.validatorpreference.v1beta1;
package osmosis.valsetpref.v1beta1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/types";
option go_package = "github.com/osmosis-labs/osmosis/v12/x/valset-pref/types";
option (gogoproto.goproto_getters_all) = false;

// ValidatorPreference defines the message structure for
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
syntax = "proto3";
package osmosis.validatorpreference.v1beta1;
package osmosis.valsetpref.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/validator-preference/v1beta1/state.proto";
import "osmosis/valset-pref/v1beta1/state.proto";

option go_package = "github.com/osmosis-labs/osmosis/v12/x/validator-preference/types";
option go_package = "github.com/osmosis-labs/osmosis/v12/x/valset-pref/types";

// Msg defines the validator-preference modules's gRPC message service.
// Msg defines the valset-pref modules's gRPC message service.
service Msg {
// SetValidatorSetPreference creates a set of validator preference.
// This message will process both create + update request.
Expand Down
Binary file modified tests/e2e/scripts/rate_limiter.wasm
Binary file not shown.
File renamed without changes.
22 changes: 22 additions & 0 deletions x/valset-pref/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package client

import (
"context"

validatorprefkeeper "github.com/osmosis-labs/osmosis/v12/x/valset-pref"
"github.com/osmosis-labs/osmosis/v12/x/valset-pref/client/queryproto"
)

type Querier struct {
K validatorprefkeeper.Keeper
stackman27 marked this conversation as resolved.
Show resolved Hide resolved
}

var _ queryproto.QueryServer = Querier{}

func NewQuerier(k validatorprefkeeper.Keeper) Querier {
return Querier{K: k}
}

func (q Querier) UserValidatorPreferences(ctx context.Context, req *queryproto.QueryUserValidatorPreferences) (*queryproto.QueryUserValidatorPreferenceResponse, error) {
stackman27 marked this conversation as resolved.
Show resolved Hide resolved
return &queryproto.QueryUserValidatorPreferenceResponse{}, nil
}
Loading