Skip to content

Commit

Permalink
Merge pull request #582 from lavanet/CNS-457-params-for-protocol-vers…
Browse files Browse the repository at this point in the history
…ions

CNS-457 params for protocol versions
  • Loading branch information
Yaroms authored Jul 3, 2023
2 parents 922c053 + e1798c5 commit 59404f2
Show file tree
Hide file tree
Showing 40 changed files with 3,120 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ import (
projectsmodule "github.com/lavanet/lava/x/projects"
projectsmodulekeeper "github.com/lavanet/lava/x/projects/keeper"
projectsmoduletypes "github.com/lavanet/lava/x/projects/types"
protocolmodule "github.com/lavanet/lava/x/protocol"
protocolmodulekeeper "github.com/lavanet/lava/x/protocol/keeper"
protocolmoduletypes "github.com/lavanet/lava/x/protocol/types"
specmodule "github.com/lavanet/lava/x/spec"
specmoduleclient "github.com/lavanet/lava/x/spec/client"
specmodulekeeper "github.com/lavanet/lava/x/spec/keeper"
Expand Down Expand Up @@ -166,6 +169,7 @@ var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_0_14_0,
upgrades.Upgrade_0_15_0,
upgrades.Upgrade_0_15_1,
upgrades.Upgrade_0_16_0,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down Expand Up @@ -221,6 +225,7 @@ var (
pairingmodule.AppModuleBasic{},
conflictmodule.AppModuleBasic{},
projectsmodule.AppModuleBasic{},
protocolmodule.AppModuleBasic{},
plansmodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)
Expand Down Expand Up @@ -517,6 +522,14 @@ func New(
)
conflictModule := conflictmodule.NewAppModule(appCodec, app.ConflictKeeper, app.AccountKeeper, app.BankKeeper)

app.ProtocolKeeper = *protocolmodulekeeper.NewKeeper(
appCodec,
keys[protocolmoduletypes.StoreKey],
keys[protocolmoduletypes.MemStoreKey],
app.GetSubspace(protocolmoduletypes.ModuleName),
)
protocolModule := protocolmodule.NewAppModule(appCodec, app.ProtocolKeeper)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

// Create static IBC router, add transfer route, then set and seal it
Expand Down Expand Up @@ -563,6 +576,7 @@ func New(
conflictModule,
projectsModule,
plansModule,
protocolModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -591,6 +605,7 @@ func New(
pairingmoduletypes.ModuleName,
projectsmoduletypes.ModuleName,
plansmoduletypes.ModuleName,
protocolmoduletypes.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
feegrant.ModuleName,
Expand All @@ -616,6 +631,7 @@ func New(
conflictmoduletypes.ModuleName,
pairingmoduletypes.ModuleName,
projectsmoduletypes.ModuleName,
protocolmoduletypes.ModuleName,
plansmoduletypes.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
Expand Down Expand Up @@ -647,6 +663,7 @@ func New(
pairingmoduletypes.ModuleName,
projectsmoduletypes.ModuleName,
plansmoduletypes.ModuleName,
protocolmoduletypes.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
feegrant.ModuleName,
Expand Down Expand Up @@ -684,6 +701,7 @@ func New(
pairingModule,
conflictModule,
projectsModule,
protocolModule,
plansModule,
// this line is used by starport scaffolding # stargate/app/appModule
)
Expand Down Expand Up @@ -902,6 +920,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(pairingmoduletypes.ModuleName)
paramsKeeper.Subspace(conflictmoduletypes.ModuleName)
paramsKeeper.Subspace(projectsmoduletypes.ModuleName)
paramsKeeper.Subspace(protocolmoduletypes.ModuleName)
paramsKeeper.Subspace(plansmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

Expand Down
2 changes: 2 additions & 0 deletions app/keepers/lavaKeepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
pairingmodulekeeper "github.com/lavanet/lava/x/pairing/keeper"
plansmodulekeeper "github.com/lavanet/lava/x/plans/keeper"
projectsmodulekeeper "github.com/lavanet/lava/x/projects/keeper"
protocolmodulekeeper "github.com/lavanet/lava/x/protocol/keeper"
specmodulekeeper "github.com/lavanet/lava/x/spec/keeper"
subscriptionmodulekeeper "github.com/lavanet/lava/x/subscription/keeper"
// this line is used by starport scaffolding # stargate/app/moduleImport
Expand Down Expand Up @@ -56,4 +57,5 @@ type LavaKeepers struct {
ConflictKeeper conflictmodulekeeper.Keeper
ProjectsKeeper projectsmodulekeeper.Keeper
PlansKeeper plansmodulekeeper.Keeper
ProtocolKeeper protocolmodulekeeper.Keeper
}
12 changes: 12 additions & 0 deletions app/upgrades/empty_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/lavanet/lava/app/keepers"
plansmoduletypes "github.com/lavanet/lava/x/plans/types"
projectsmoduletypes "github.com/lavanet/lava/x/projects/types"
protocolmoduletypes "github.com/lavanet/lava/x/protocol/types"
subscriptionmoduletypes "github.com/lavanet/lava/x/subscription/types"
)

Expand Down Expand Up @@ -207,3 +208,14 @@ var Upgrade_0_15_1 = Upgrade{
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

// Upgrade_0_16_0 adds new modules: protocol
var Upgrade_0_16_0 = Upgrade{
UpgradeName: "v0.16.0",
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
protocolmoduletypes.StoreKey,
},
},
}
168 changes: 168 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31618,6 +31618,55 @@ paths:
additionalProperties: {}
tags:
- Query
/lavanet/lava/protocol/params:
get:
summary: Parameters queries the parameters of the module.
operationId: LavanetLavaProtocolParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
version:
type: object
properties:
provider_target:
type: string
provider_min:
type: string
consumer_target:
type: string
consumer_min:
type: string
description: Params defines the parameters for the module.
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/lavanet/lava/spec/params:
get:
summary: Parameters queries the parameters of the module.
Expand Down Expand Up @@ -56484,6 +56533,53 @@ definitions:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
lavanet.lava.protocol.Params:
type: object
properties:
version:
type: object
properties:
provider_target:
type: string
provider_min:
type: string
consumer_target:
type: string
consumer_min:
type: string
description: Params defines the parameters for the module.
lavanet.lava.protocol.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
version:
type: object
properties:
provider_target:
type: string
provider_min:
type: string
consumer_target:
type: string
consumer_min:
type: string
description: Params defines the parameters for the module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
lavanet.lava.protocol.Version:
type: object
properties:
provider_target:
type: string
provider_min:
type: string
consumer_target:
type: string
consumer_min:
type: string
description: Params defines the parameters for the module.
lavanet.lava.spec.ApiInterface:
type: object
properties:
Expand Down Expand Up @@ -57658,6 +57754,62 @@ definitions:
format: int64
hanging_api:
type: boolean
lavanet.lava.projects.ChainPolicy:
type: object
properties:
chain_id:
type: string
apis:
type: array
items:
type: string
lavanet.lava.projects.Policy:
type: object
properties:
chain_policies:
type: array
items:
type: object
properties:
chain_id:
type: string
apis:
type: array
items:
type: string
geolocation_profile:
type: string
format: uint64
total_cu_limit:
type: string
format: uint64
epoch_cu_limit:
type: string
format: uint64
max_providers_to_pair:
type: string
format: uint64
selected_providers_mode:
type: string
enum:
- ALLOWED
- MIXED
- EXCLUSIVE
- DISABLED
default: ALLOWED
description: |-
- ALLOWED: no providers restrictions
- MIXED: use the selected providers mixed with randomly chosen providers
- EXCLUSIVE: use only the selected providers
- DISABLED: selected providers feature is disabled
title: >-
the enum below determines the pairing algorithm's behaviour with the
selected providers feature
selected_providers:
type: array
items:
type: string
title: 'protobuf expected in YAML format: used "moretags" to simplify parsing'
lavanet.lava.projects.ProjectData:
type: object
properties:
Expand Down Expand Up @@ -57724,6 +57876,22 @@ definitions:
type: string
title: 'protobuf expected in YAML format: used "moretags" to simplify parsing'
title: used as a container struct for the subscription module
lavanet.lava.projects.SELECTED_PROVIDERS_MODE:
type: string
enum:
- ALLOWED
- MIXED
- EXCLUSIVE
- DISABLED
default: ALLOWED
description: |-
- ALLOWED: no providers restrictions
- MIXED: use the selected providers mixed with randomly chosen providers
- EXCLUSIVE: use only the selected providers
- DISABLED: selected providers feature is disabled
title: >-
the enum below determines the pairing algorithm's behaviour with the
selected providers feature
lavanet.lava.subscription.ListInfoStruct:
type: object
properties:
Expand Down
14 changes: 14 additions & 0 deletions proto/protocol/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package lavanet.lava.protocol;

import "gogoproto/gogo.proto";
import "protocol/params.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/lavanet/lava/x/protocol/types";

// GenesisState defines the protocol module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
20 changes: 20 additions & 0 deletions proto/protocol/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package lavanet.lava.protocol;

import "gogoproto/gogo.proto";

option go_package = "github.com/lavanet/lava/x/protocol/types";

// Params defines the parameters for the module.
message Version {
string provider_target = 1 [(gogoproto.moretags) = "yaml:\"provider_target\""];
string provider_min = 2 [(gogoproto.moretags) = "yaml:\"provider_min\""];
string consumer_target = 3 [(gogoproto.moretags) = "yaml:\"consumer_target\""];
string consumer_min = 4 [(gogoproto.moretags) = "yaml:\"consumer_min\""];
}

message Params {
option (gogoproto.goproto_stringer) = false;

Version version = 1 [(gogoproto.nullable) = false];
}
30 changes: 30 additions & 0 deletions proto/protocol/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";
package lavanet.lava.protocol;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "protocol/params.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/lavanet/lava/x/protocol/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/lavanet/lava/protocol/params";
}
// this line is used by starport scaffolding # 2
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

// this line is used by starport scaffolding # 3
Loading

0 comments on commit 59404f2

Please sign in to comment.