From 5ae427e2c0a2d14b4ff1d4f28a7aedc296dde702 Mon Sep 17 00:00:00 2001 From: oren-lava Date: Tue, 20 Jun 2023 17:37:45 +0300 Subject: [PATCH 1/2] CNS-476: moved policy to plan proto --- proto/plans/plan.proto | 27 +- proto/projects/project.proto | 31 +- proto/projects/tx.proto | 5 +- x/plans/types/plan.pb.go | 858 +++++++++++++++++++++++++++++-- x/projects/types/project.pb.go | 898 +++------------------------------ x/projects/types/tx.pb.go | 78 +-- 6 files changed, 950 insertions(+), 947 deletions(-) diff --git a/proto/plans/plan.proto b/proto/plans/plan.proto index 4bc71ae59b..485194c5da 100644 --- a/proto/plans/plan.proto +++ b/proto/plans/plan.proto @@ -5,7 +5,6 @@ option go_package = "github.com/lavanet/lava/x/plans/types"; option (gogoproto.equal_all) = true; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -import "projects/project.proto"; message Plan { reserved 10; @@ -21,5 +20,29 @@ message Plan { string description = 11; // plan description (for humans) string type = 12; // plan type uint64 annual_discount_percentage = 13; // discount for buying the plan for a year - lavanet.lava.projects.Policy plan_policy = 14 [(gogoproto.nullable) = false]; + Policy plan_policy = 14 [(gogoproto.nullable) = false]; } + +// the enum below determines the pairing algorithm's behaviour with the selected providers feature +enum SELECTED_PROVIDERS_MODE { + ALLOWED = 0; // no providers restrictions + MIXED = 1; // use the selected providers mixed with randomly chosen providers + EXCLUSIVE = 2; // use only the selected providers + DISABLED = 3; // selected providers feature is disabled +} + +// protobuf expected in YAML format: used "moretags" to simplify parsing +message Policy { + repeated ChainPolicy chain_policies = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "mapstructure:\"chain_policies\""]; + uint64 geolocation_profile = 2 [(gogoproto.moretags) = "mapstructure:\"geolocation_profile\"", (gogoproto.jsontag) = "geolocation_profile"]; + uint64 total_cu_limit = 3 [(gogoproto.moretags) = "mapstructure:\"total_cu_limit\"", (gogoproto.jsontag) = "total_cu_limit"]; + uint64 epoch_cu_limit = 4 [(gogoproto.moretags) = "mapstructure:\"epoch_cu_limit\"", (gogoproto.jsontag) = "epoch_cu_limit"]; + uint64 max_providers_to_pair = 5 [(gogoproto.jsontag) = "max_providers_to_pair", (gogoproto.moretags) = "mapstructure:\"max_providers_to_pair\""]; + SELECTED_PROVIDERS_MODE selected_providers_mode = 6 [(gogoproto.moretags) = "mapstructure:\"selected_providers_mode\"", (gogoproto.jsontag) = "selected_providers_mode"]; + repeated string selected_providers = 7 [(gogoproto.moretags) = "mapstructure:\"selected_providers\"", (gogoproto.jsontag) = "selected_providers"]; +} + +message ChainPolicy { + string chain_id = 1 [(gogoproto.moretags) = "mapstructure:\"chain_id\""]; + repeated string apis = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "mapstructure:\"apis\""]; +} \ No newline at end of file diff --git a/proto/projects/project.proto b/proto/projects/project.proto index 835da6c081..9af21484fe 100644 --- a/proto/projects/project.proto +++ b/proto/projects/project.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package lavanet.lava.projects; import "gogoproto/gogo.proto"; +import "plans/plan.proto"; option (gogoproto.equal_all) = true; option go_package = "github.com/lavanet/lava/x/projects/types"; @@ -11,9 +12,9 @@ message Project { reserved 3; bool enabled = 4; // enabled flag repeated ProjectKey project_keys = 5 [(gogoproto.nullable) = false]; // list of the projects keys - Policy admin_policy = 6; + lavanet.lava.plans.Policy admin_policy = 6; uint64 used_cu = 7; - Policy subscription_policy = 8; + lavanet.lava.plans.Policy subscription_policy = 8; uint64 snapshot = 9; // snapshot id to uniquely identify snapshots } @@ -32,30 +33,6 @@ message ProjectKey { uint32 kinds = 4; } -// the enum below determines the pairing algorithm's behaviour with the selected providers feature -enum SELECTED_PROVIDERS_MODE { - ALLOWED = 0; // no providers restrictions - MIXED = 1; // use the selected providers mixed with randomly chosen providers - EXCLUSIVE = 2; // use only the selected providers - DISABLED = 3; // selected providers feature is disabled -} - -// protobuf expected in YAML format: used "moretags" to simplify parsing -message Policy { - repeated ChainPolicy chain_policies = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "mapstructure:\"chain_policies\""]; - uint64 geolocation_profile = 2 [(gogoproto.moretags) = "mapstructure:\"geolocation_profile\"", (gogoproto.jsontag) = "geolocation_profile"]; - uint64 total_cu_limit = 3 [(gogoproto.moretags) = "mapstructure:\"total_cu_limit\"", (gogoproto.jsontag) = "total_cu_limit"]; - uint64 epoch_cu_limit = 4 [(gogoproto.moretags) = "mapstructure:\"epoch_cu_limit\"", (gogoproto.jsontag) = "epoch_cu_limit"]; - uint64 max_providers_to_pair = 5 [(gogoproto.jsontag) = "max_providers_to_pair", (gogoproto.moretags) = "mapstructure:\"max_providers_to_pair\""]; - SELECTED_PROVIDERS_MODE selected_providers_mode = 6 [(gogoproto.moretags) = "mapstructure:\"selected_providers_mode\"", (gogoproto.jsontag) = "selected_providers_mode"]; - repeated string selected_providers = 7 [(gogoproto.moretags) = "mapstructure:\"selected_providers\"", (gogoproto.jsontag) = "selected_providers"]; -} - -message ChainPolicy { - string chain_id = 1 [(gogoproto.moretags) = "mapstructure:\"chain_id\""]; - repeated string apis = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "mapstructure:\"apis\""]; -} - message ProtoDeveloperData { string projectID = 1; reserved 2; @@ -67,5 +44,5 @@ message ProjectData { reserved 2; bool enabled = 3; repeated ProjectKey projectKeys = 4 [(gogoproto.nullable) = false]; - Policy policy = 5; + lavanet.lava.plans.Policy policy = 5; } diff --git a/proto/projects/tx.proto b/proto/projects/tx.proto index 8c62bd7403..dda2df0ebf 100644 --- a/proto/projects/tx.proto +++ b/proto/projects/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package lavanet.lava.projects; import "projects/project.proto"; +import "plans/plan.proto"; import "gogoproto/gogo.proto"; // this line is used by starport scaffolding # proto/tx/import @@ -38,7 +39,7 @@ message MsgDelKeysResponse { message MsgSetPolicy { string creator = 1; string project = 2; - Policy policy = 3 [(gogoproto.nullable) = false]; + lavanet.lava.plans.Policy policy = 3 [(gogoproto.nullable) = false]; } message MsgSetPolicyResponse { @@ -47,7 +48,7 @@ message MsgSetPolicyResponse { message MsgSetSubscriptionPolicy { string creator = 1; repeated string projects = 2; - Policy policy = 3 [(gogoproto.nullable) = false]; + lavanet.lava.plans.Policy policy = 3 [(gogoproto.nullable) = false]; } message MsgSetSubscriptionPolicyResponse { diff --git a/x/plans/types/plan.pb.go b/x/plans/types/plan.pb.go index d68fcf2c61..63b3eb3176 100644 --- a/x/plans/types/plan.pb.go +++ b/x/plans/types/plan.pb.go @@ -8,7 +8,6 @@ import ( types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - types1 "github.com/lavanet/lava/x/projects/types" io "io" math "math" math_bits "math/bits" @@ -25,16 +24,48 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// the enum below determines the pairing algorithm's behaviour with the selected providers feature +type SELECTED_PROVIDERS_MODE int32 + +const ( + SELECTED_PROVIDERS_MODE_ALLOWED SELECTED_PROVIDERS_MODE = 0 + SELECTED_PROVIDERS_MODE_MIXED SELECTED_PROVIDERS_MODE = 1 + SELECTED_PROVIDERS_MODE_EXCLUSIVE SELECTED_PROVIDERS_MODE = 2 + SELECTED_PROVIDERS_MODE_DISABLED SELECTED_PROVIDERS_MODE = 3 +) + +var SELECTED_PROVIDERS_MODE_name = map[int32]string{ + 0: "ALLOWED", + 1: "MIXED", + 2: "EXCLUSIVE", + 3: "DISABLED", +} + +var SELECTED_PROVIDERS_MODE_value = map[string]int32{ + "ALLOWED": 0, + "MIXED": 1, + "EXCLUSIVE": 2, + "DISABLED": 3, +} + +func (x SELECTED_PROVIDERS_MODE) String() string { + return proto.EnumName(SELECTED_PROVIDERS_MODE_name, int32(x)) +} + +func (SELECTED_PROVIDERS_MODE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_e5909a10cd0e3497, []int{0} +} + type Plan struct { - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - Block uint64 `protobuf:"varint,3,opt,name=block,proto3" json:"block,omitempty"` - Price types.Coin `protobuf:"bytes,4,opt,name=price,proto3" json:"price"` - AllowOveruse bool `protobuf:"varint,8,opt,name=allow_overuse,json=allowOveruse,proto3" json:"allow_overuse,omitempty"` - OveruseRate uint64 `protobuf:"varint,9,opt,name=overuse_rate,json=overuseRate,proto3" json:"overuse_rate,omitempty"` - Description string `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` - Type string `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` - AnnualDiscountPercentage uint64 `protobuf:"varint,13,opt,name=annual_discount_percentage,json=annualDiscountPercentage,proto3" json:"annual_discount_percentage,omitempty"` - PlanPolicy types1.Policy `protobuf:"bytes,14,opt,name=plan_policy,json=planPolicy,proto3" json:"plan_policy"` + Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + Block uint64 `protobuf:"varint,3,opt,name=block,proto3" json:"block,omitempty"` + Price types.Coin `protobuf:"bytes,4,opt,name=price,proto3" json:"price"` + AllowOveruse bool `protobuf:"varint,8,opt,name=allow_overuse,json=allowOveruse,proto3" json:"allow_overuse,omitempty"` + OveruseRate uint64 `protobuf:"varint,9,opt,name=overuse_rate,json=overuseRate,proto3" json:"overuse_rate,omitempty"` + Description string `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` + Type string `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` + AnnualDiscountPercentage uint64 `protobuf:"varint,13,opt,name=annual_discount_percentage,json=annualDiscountPercentage,proto3" json:"annual_discount_percentage,omitempty"` + PlanPolicy Policy `protobuf:"bytes,14,opt,name=plan_policy,json=planPolicy,proto3" json:"plan_policy"` } func (m *Plan) Reset() { *m = Plan{} } @@ -126,48 +157,221 @@ func (m *Plan) GetAnnualDiscountPercentage() uint64 { return 0 } -func (m *Plan) GetPlanPolicy() types1.Policy { +func (m *Plan) GetPlanPolicy() Policy { if m != nil { return m.PlanPolicy } - return types1.Policy{} + return Policy{} +} + +// protobuf expected in YAML format: used "moretags" to simplify parsing +type Policy struct { + ChainPolicies []ChainPolicy `protobuf:"bytes,1,rep,name=chain_policies,json=chainPolicies,proto3" json:"chain_policies" mapstructure:"chain_policies"` + GeolocationProfile uint64 `protobuf:"varint,2,opt,name=geolocation_profile,json=geolocationProfile,proto3" json:"geolocation_profile" mapstructure:"geolocation_profile"` + TotalCuLimit uint64 `protobuf:"varint,3,opt,name=total_cu_limit,json=totalCuLimit,proto3" json:"total_cu_limit" mapstructure:"total_cu_limit"` + EpochCuLimit uint64 `protobuf:"varint,4,opt,name=epoch_cu_limit,json=epochCuLimit,proto3" json:"epoch_cu_limit" mapstructure:"epoch_cu_limit"` + MaxProvidersToPair uint64 `protobuf:"varint,5,opt,name=max_providers_to_pair,json=maxProvidersToPair,proto3" json:"max_providers_to_pair" mapstructure:"max_providers_to_pair"` + SelectedProvidersMode SELECTED_PROVIDERS_MODE `protobuf:"varint,6,opt,name=selected_providers_mode,json=selectedProvidersMode,proto3,enum=lavanet.lava.plans.SELECTED_PROVIDERS_MODE" json:"selected_providers_mode" mapstructure:"selected_providers_mode"` + SelectedProviders []string `protobuf:"bytes,7,rep,name=selected_providers,json=selectedProviders,proto3" json:"selected_providers" mapstructure:"selected_providers"` +} + +func (m *Policy) Reset() { *m = Policy{} } +func (m *Policy) String() string { return proto.CompactTextString(m) } +func (*Policy) ProtoMessage() {} +func (*Policy) Descriptor() ([]byte, []int) { + return fileDescriptor_e5909a10cd0e3497, []int{1} +} +func (m *Policy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Policy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Policy.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Policy) XXX_Merge(src proto.Message) { + xxx_messageInfo_Policy.Merge(m, src) +} +func (m *Policy) XXX_Size() int { + return m.Size() +} +func (m *Policy) XXX_DiscardUnknown() { + xxx_messageInfo_Policy.DiscardUnknown(m) +} + +var xxx_messageInfo_Policy proto.InternalMessageInfo + +func (m *Policy) GetChainPolicies() []ChainPolicy { + if m != nil { + return m.ChainPolicies + } + return nil +} + +func (m *Policy) GetGeolocationProfile() uint64 { + if m != nil { + return m.GeolocationProfile + } + return 0 +} + +func (m *Policy) GetTotalCuLimit() uint64 { + if m != nil { + return m.TotalCuLimit + } + return 0 +} + +func (m *Policy) GetEpochCuLimit() uint64 { + if m != nil { + return m.EpochCuLimit + } + return 0 +} + +func (m *Policy) GetMaxProvidersToPair() uint64 { + if m != nil { + return m.MaxProvidersToPair + } + return 0 +} + +func (m *Policy) GetSelectedProvidersMode() SELECTED_PROVIDERS_MODE { + if m != nil { + return m.SelectedProvidersMode + } + return SELECTED_PROVIDERS_MODE_ALLOWED +} + +func (m *Policy) GetSelectedProviders() []string { + if m != nil { + return m.SelectedProviders + } + return nil +} + +type ChainPolicy struct { + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" mapstructure:"chain_id"` + Apis []string `protobuf:"bytes,2,rep,name=apis,proto3" json:"apis,omitempty" mapstructure:"apis"` +} + +func (m *ChainPolicy) Reset() { *m = ChainPolicy{} } +func (m *ChainPolicy) String() string { return proto.CompactTextString(m) } +func (*ChainPolicy) ProtoMessage() {} +func (*ChainPolicy) Descriptor() ([]byte, []int) { + return fileDescriptor_e5909a10cd0e3497, []int{2} +} +func (m *ChainPolicy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChainPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChainPolicy.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ChainPolicy) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainPolicy.Merge(m, src) +} +func (m *ChainPolicy) XXX_Size() int { + return m.Size() +} +func (m *ChainPolicy) XXX_DiscardUnknown() { + xxx_messageInfo_ChainPolicy.DiscardUnknown(m) +} + +var xxx_messageInfo_ChainPolicy proto.InternalMessageInfo + +func (m *ChainPolicy) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *ChainPolicy) GetApis() []string { + if m != nil { + return m.Apis + } + return nil } func init() { + proto.RegisterEnum("lavanet.lava.plans.SELECTED_PROVIDERS_MODE", SELECTED_PROVIDERS_MODE_name, SELECTED_PROVIDERS_MODE_value) proto.RegisterType((*Plan)(nil), "lavanet.lava.plans.Plan") + proto.RegisterType((*Policy)(nil), "lavanet.lava.plans.Policy") + proto.RegisterType((*ChainPolicy)(nil), "lavanet.lava.plans.ChainPolicy") } func init() { proto.RegisterFile("plans/plan.proto", fileDescriptor_e5909a10cd0e3497) } var fileDescriptor_e5909a10cd0e3497 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x52, 0xcd, 0x8e, 0xd3, 0x30, - 0x10, 0xae, 0xa9, 0xdb, 0xcd, 0x3a, 0x5d, 0x14, 0x59, 0x2b, 0x64, 0x2a, 0x11, 0x02, 0x08, 0xa9, - 0x27, 0x5b, 0x0b, 0xe2, 0xc6, 0x69, 0x77, 0x4f, 0xb9, 0x50, 0xe5, 0xc8, 0x25, 0x72, 0x5c, 0xab, - 0x18, 0xb2, 0x76, 0x14, 0xbb, 0x65, 0xf7, 0x11, 0xb8, 0xf1, 0x18, 0x3c, 0xca, 0x1e, 0xf7, 0xc8, - 0x09, 0xa1, 0xf6, 0x45, 0x90, 0x7f, 0x84, 0xe0, 0x92, 0x99, 0xf9, 0xbe, 0x2f, 0xfe, 0x3c, 0x33, - 0x46, 0xc5, 0xd0, 0x73, 0x6d, 0x99, 0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e, 0xdf, 0xa3, - 0x25, 0xd7, 0x7a, 0xc7, 0xfb, 0x76, 0xa3, 0xac, 0x30, 0x3b, 0xed, 0xda, 0x41, 0x8e, 0x42, 0x6a, - 0xc7, 0xb7, 0x92, 0x9c, 0x05, 0x1b, 0x12, 0x15, 0xd7, 0x49, 0xb0, 0xfe, 0xcb, 0xe3, 0x6b, 0x94, - 0xfb, 0xf1, 0xb7, 0x83, 0xe9, 0x95, 0xb8, 0x23, 0x8f, 0x43, 0xe3, 0xcf, 0xe8, 0xff, 0xfb, 0x49, - 0x23, 0xa6, 0xeb, 0x20, 0x4a, 0xcd, 0x23, 0xff, 0x5f, 0x44, 0x6a, 0x98, 0xa1, 0x22, 0xaf, 0x61, - 0xf6, 0xa8, 0x98, 0xd6, 0x30, 0x9b, 0x15, 0xf3, 0x1a, 0x66, 0xf3, 0xe2, 0xa4, 0x86, 0xd9, 0x49, - 0x91, 0x5d, 0x5e, 0xfd, 0x38, 0x94, 0xe0, 0xfe, 0x50, 0x82, 0x87, 0x43, 0x09, 0x7e, 0x1f, 0x4a, - 0xf0, 0xfd, 0x58, 0x4e, 0x1e, 0x8e, 0xe5, 0xe4, 0xe7, 0xb1, 0x9c, 0x7c, 0x7c, 0xbd, 0x55, 0xee, - 0xd3, 0xae, 0xa3, 0xc2, 0xdc, 0xb0, 0x64, 0x1b, 0x22, 0xbb, 0x65, 0xf1, 0xdd, 0xf8, 0x2e, 0x6d, - 0x37, 0x0f, 0x7b, 0x7d, 0xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xd3, 0x8a, 0x36, 0x4d, 0x02, - 0x00, 0x00, + // 831 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x4f, 0x6f, 0xdb, 0x36, + 0x1c, 0xb5, 0x62, 0xd9, 0x96, 0x29, 0x27, 0xd0, 0xd8, 0x16, 0xd1, 0x52, 0xcc, 0x72, 0xb5, 0x75, + 0x30, 0x36, 0x40, 0x42, 0x53, 0x6c, 0x87, 0xfd, 0x39, 0xc4, 0xb6, 0x0e, 0x36, 0x9c, 0xc5, 0x50, + 0xba, 0xae, 0xdb, 0x45, 0xa0, 0x29, 0xce, 0xe1, 0x26, 0x8b, 0x82, 0x44, 0x7b, 0xe9, 0x17, 0xd8, + 0x79, 0x1f, 0x63, 0x18, 0xf6, 0x41, 0x7a, 0xec, 0x71, 0x27, 0x61, 0x48, 0x6e, 0x3e, 0xfa, 0x13, + 0x0c, 0xa4, 0x94, 0x34, 0x9e, 0x1d, 0xf4, 0x62, 0x91, 0xef, 0x3d, 0xbe, 0x47, 0xfe, 0xf4, 0x13, + 0x0d, 0x8c, 0x24, 0x42, 0x71, 0xe6, 0x8a, 0x5f, 0x27, 0x49, 0x19, 0x67, 0x10, 0x46, 0x68, 0x89, + 0x62, 0xc2, 0x1d, 0xf1, 0x74, 0x24, 0x7d, 0xf4, 0x70, 0xc6, 0x66, 0x4c, 0xd2, 0xae, 0x18, 0x15, + 0xca, 0xa3, 0x36, 0x66, 0xd9, 0x9c, 0x65, 0xee, 0x14, 0x65, 0xc4, 0x5d, 0x3e, 0x9b, 0x12, 0x8e, + 0x9e, 0xb9, 0x98, 0xd1, 0xd2, 0xc9, 0xfe, 0xbd, 0x0a, 0xd4, 0x49, 0x84, 0x62, 0xf8, 0x10, 0xd4, + 0x68, 0x1c, 0x92, 0x4b, 0x53, 0xe9, 0x28, 0xdd, 0xa6, 0x5f, 0x4c, 0x04, 0x3a, 0x8d, 0x18, 0xfe, + 0xd5, 0xac, 0x76, 0x94, 0xae, 0xea, 0x17, 0x13, 0xf8, 0x05, 0xa8, 0x25, 0x29, 0xc5, 0xc4, 0x54, + 0x3b, 0x4a, 0x57, 0x3f, 0xfe, 0xd0, 0x29, 0x42, 0x1c, 0x11, 0xe2, 0x94, 0x21, 0x4e, 0x9f, 0xd1, + 0xb8, 0xa7, 0xbe, 0xc9, 0xad, 0x8a, 0x5f, 0xa8, 0xe1, 0xc7, 0x60, 0x1f, 0x45, 0x11, 0xfb, 0x2d, + 0x60, 0x4b, 0x92, 0x2e, 0x32, 0x62, 0x6a, 0x1d, 0xa5, 0xab, 0xf9, 0x2d, 0x09, 0x9e, 0x15, 0x18, + 0x7c, 0x02, 0x5a, 0x25, 0x1d, 0xa4, 0x88, 0x13, 0xb3, 0x29, 0x83, 0xf5, 0x12, 0xf3, 0x11, 0x27, + 0xb0, 0x03, 0xf4, 0x90, 0x64, 0x38, 0xa5, 0x09, 0xa7, 0x2c, 0x36, 0x75, 0xb9, 0xe1, 0xbb, 0x10, + 0x84, 0x40, 0xe5, 0xaf, 0x13, 0x62, 0xb6, 0x24, 0x25, 0xc7, 0xf0, 0x1b, 0x70, 0x84, 0xe2, 0x78, + 0x81, 0xa2, 0x20, 0xa4, 0x19, 0x66, 0x8b, 0x98, 0x07, 0x09, 0x49, 0x31, 0x89, 0x39, 0x9a, 0x11, + 0x73, 0x5f, 0xc6, 0x98, 0x85, 0x62, 0x50, 0x0a, 0x26, 0xb7, 0x3c, 0x3c, 0x01, 0xba, 0x28, 0x73, + 0x90, 0xb0, 0x88, 0xe2, 0xd7, 0xe6, 0x81, 0x3c, 0xf8, 0x91, 0xb3, 0xfd, 0x1e, 0x9c, 0x89, 0x54, + 0x94, 0x27, 0x07, 0x02, 0x2b, 0x90, 0x91, 0xaa, 0x01, 0x43, 0x1f, 0xa9, 0xda, 0x9e, 0x51, 0x1d, + 0xa9, 0x5a, 0xcd, 0xa8, 0x8f, 0x54, 0xad, 0x6e, 0x34, 0x46, 0xaa, 0xd6, 0x30, 0x34, 0xfb, 0xef, + 0x3a, 0xa8, 0x17, 0x42, 0x38, 0x07, 0x07, 0xf8, 0x02, 0xd1, 0x32, 0x8c, 0x92, 0xcc, 0x54, 0x3a, + 0xd5, 0xae, 0x7e, 0x6c, 0xed, 0x8a, 0xeb, 0x0b, 0x65, 0x99, 0xf9, 0x54, 0x64, 0xae, 0x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7b, 0xfd, 0x3f, 0xaf, 0xda, 0xca, 0x9b, 0xab, + 0xb6, 0xf2, 0xf6, 0xaa, 0xad, 0xfc, 0x7b, 0xd5, 0x56, 0xfe, 0xb8, 0x6e, 0x57, 0xde, 0x5e, 0xb7, + 0x2b, 0xff, 0x5c, 0xb7, 0x2b, 0x3f, 0x3d, 0x9d, 0x51, 0x7e, 0xb1, 0x98, 0x3a, 0x98, 0xcd, 0xdd, + 0xf2, 0x35, 0xcb, 0xa7, 0x7b, 0xe9, 0x16, 0xff, 0x09, 0xe2, 0x66, 0xcb, 0xa6, 0x75, 0x79, 0x97, + 0x3f, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xea, 0x8a, 0x65, 0x4e, 0x29, 0x06, 0x00, 0x00, } func (this *Plan) Equal(that interface{}) bool { @@ -218,6 +422,90 @@ func (this *Plan) Equal(that interface{}) bool { } return true } +func (this *Policy) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Policy) + if !ok { + that2, ok := that.(Policy) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.ChainPolicies) != len(that1.ChainPolicies) { + return false + } + for i := range this.ChainPolicies { + if !this.ChainPolicies[i].Equal(&that1.ChainPolicies[i]) { + return false + } + } + if this.GeolocationProfile != that1.GeolocationProfile { + return false + } + if this.TotalCuLimit != that1.TotalCuLimit { + return false + } + if this.EpochCuLimit != that1.EpochCuLimit { + return false + } + if this.MaxProvidersToPair != that1.MaxProvidersToPair { + return false + } + if this.SelectedProvidersMode != that1.SelectedProvidersMode { + return false + } + if len(this.SelectedProviders) != len(that1.SelectedProviders) { + return false + } + for i := range this.SelectedProviders { + if this.SelectedProviders[i] != that1.SelectedProviders[i] { + return false + } + } + return true +} +func (this *ChainPolicy) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ChainPolicy) + if !ok { + that2, ok := that.(ChainPolicy) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ChainId != that1.ChainId { + return false + } + if len(this.Apis) != len(that1.Apis) { + return false + } + for i := range this.Apis { + if this.Apis[i] != that1.Apis[i] { + return false + } + } + return true +} func (m *Plan) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -307,6 +595,116 @@ func (m *Plan) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Policy) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Policy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Policy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SelectedProviders) > 0 { + for iNdEx := len(m.SelectedProviders) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SelectedProviders[iNdEx]) + copy(dAtA[i:], m.SelectedProviders[iNdEx]) + i = encodeVarintPlan(dAtA, i, uint64(len(m.SelectedProviders[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + if m.SelectedProvidersMode != 0 { + i = encodeVarintPlan(dAtA, i, uint64(m.SelectedProvidersMode)) + i-- + dAtA[i] = 0x30 + } + if m.MaxProvidersToPair != 0 { + i = encodeVarintPlan(dAtA, i, uint64(m.MaxProvidersToPair)) + i-- + dAtA[i] = 0x28 + } + if m.EpochCuLimit != 0 { + i = encodeVarintPlan(dAtA, i, uint64(m.EpochCuLimit)) + i-- + dAtA[i] = 0x20 + } + if m.TotalCuLimit != 0 { + i = encodeVarintPlan(dAtA, i, uint64(m.TotalCuLimit)) + i-- + dAtA[i] = 0x18 + } + if m.GeolocationProfile != 0 { + i = encodeVarintPlan(dAtA, i, uint64(m.GeolocationProfile)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChainPolicies) > 0 { + for iNdEx := len(m.ChainPolicies) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ChainPolicies[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPlan(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ChainPolicy) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ChainPolicy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChainPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Apis) > 0 { + for iNdEx := len(m.Apis) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Apis[iNdEx]) + copy(dAtA[i:], m.Apis[iNdEx]) + i = encodeVarintPlan(dAtA, i, uint64(len(m.Apis[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintPlan(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintPlan(dAtA []byte, offset int, v uint64) int { offset -= sovPlan(v) base := offset @@ -355,6 +753,61 @@ func (m *Plan) Size() (n int) { return n } +func (m *Policy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChainPolicies) > 0 { + for _, e := range m.ChainPolicies { + l = e.Size() + n += 1 + l + sovPlan(uint64(l)) + } + } + if m.GeolocationProfile != 0 { + n += 1 + sovPlan(uint64(m.GeolocationProfile)) + } + if m.TotalCuLimit != 0 { + n += 1 + sovPlan(uint64(m.TotalCuLimit)) + } + if m.EpochCuLimit != 0 { + n += 1 + sovPlan(uint64(m.EpochCuLimit)) + } + if m.MaxProvidersToPair != 0 { + n += 1 + sovPlan(uint64(m.MaxProvidersToPair)) + } + if m.SelectedProvidersMode != 0 { + n += 1 + sovPlan(uint64(m.SelectedProvidersMode)) + } + if len(m.SelectedProviders) > 0 { + for _, s := range m.SelectedProviders { + l = len(s) + n += 1 + l + sovPlan(uint64(l)) + } + } + return n +} + +func (m *ChainPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovPlan(uint64(l)) + } + if len(m.Apis) > 0 { + for _, s := range m.Apis { + l = len(s) + n += 1 + l + sovPlan(uint64(l)) + } + } + return n +} + func sovPlan(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -650,6 +1103,331 @@ func (m *Plan) Unmarshal(dAtA []byte) error { } return nil } +func (m *Policy) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Policy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Policy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainPolicies", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPlan + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPlan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainPolicies = append(m.ChainPolicies, ChainPolicy{}) + if err := m.ChainPolicies[len(m.ChainPolicies)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GeolocationProfile", wireType) + } + m.GeolocationProfile = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GeolocationProfile |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalCuLimit", wireType) + } + m.TotalCuLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalCuLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochCuLimit", wireType) + } + m.EpochCuLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochCuLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxProvidersToPair", wireType) + } + m.MaxProvidersToPair = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxProvidersToPair |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SelectedProvidersMode", wireType) + } + m.SelectedProvidersMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SelectedProvidersMode |= SELECTED_PROVIDERS_MODE(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SelectedProviders", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPlan + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPlan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SelectedProviders = append(m.SelectedProviders, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlan(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlan + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ChainPolicy) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ChainPolicy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ChainPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPlan + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPlan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Apis", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlan + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPlan + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPlan + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Apis = append(m.Apis, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlan(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlan + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipPlan(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/projects/types/project.pb.go b/x/projects/types/project.pb.go index c66f0e23aa..b42b42efb0 100644 --- a/x/projects/types/project.pb.go +++ b/x/projects/types/project.pb.go @@ -7,6 +7,7 @@ import ( fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/x/plans/types" io "io" math "math" math_bits "math/bits" @@ -23,38 +24,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// the enum below determines the pairing algorithm's behaviour with the selected providers feature -type SELECTED_PROVIDERS_MODE int32 - -const ( - SELECTED_PROVIDERS_MODE_ALLOWED SELECTED_PROVIDERS_MODE = 0 - SELECTED_PROVIDERS_MODE_MIXED SELECTED_PROVIDERS_MODE = 1 - SELECTED_PROVIDERS_MODE_EXCLUSIVE SELECTED_PROVIDERS_MODE = 2 - SELECTED_PROVIDERS_MODE_DISABLED SELECTED_PROVIDERS_MODE = 3 -) - -var SELECTED_PROVIDERS_MODE_name = map[int32]string{ - 0: "ALLOWED", - 1: "MIXED", - 2: "EXCLUSIVE", - 3: "DISABLED", -} - -var SELECTED_PROVIDERS_MODE_value = map[string]int32{ - "ALLOWED": 0, - "MIXED": 1, - "EXCLUSIVE": 2, - "DISABLED": 3, -} - -func (x SELECTED_PROVIDERS_MODE) String() string { - return proto.EnumName(SELECTED_PROVIDERS_MODE_name, int32(x)) -} - -func (SELECTED_PROVIDERS_MODE) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9f89a31663a330ce, []int{0} -} - type ProjectKey_Type int32 const ( @@ -84,14 +53,14 @@ func (ProjectKey_Type) EnumDescriptor() ([]byte, []int) { } type Project struct { - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - Subscription string `protobuf:"bytes,2,opt,name=subscription,proto3" json:"subscription,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` - ProjectKeys []ProjectKey `protobuf:"bytes,5,rep,name=project_keys,json=projectKeys,proto3" json:"project_keys"` - AdminPolicy *Policy `protobuf:"bytes,6,opt,name=admin_policy,json=adminPolicy,proto3" json:"admin_policy,omitempty"` - UsedCu uint64 `protobuf:"varint,7,opt,name=used_cu,json=usedCu,proto3" json:"used_cu,omitempty"` - SubscriptionPolicy *Policy `protobuf:"bytes,8,opt,name=subscription_policy,json=subscriptionPolicy,proto3" json:"subscription_policy,omitempty"` - Snapshot uint64 `protobuf:"varint,9,opt,name=snapshot,proto3" json:"snapshot,omitempty"` + Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + Subscription string `protobuf:"bytes,2,opt,name=subscription,proto3" json:"subscription,omitempty"` + Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` + ProjectKeys []ProjectKey `protobuf:"bytes,5,rep,name=project_keys,json=projectKeys,proto3" json:"project_keys"` + AdminPolicy *types.Policy `protobuf:"bytes,6,opt,name=admin_policy,json=adminPolicy,proto3" json:"admin_policy,omitempty"` + UsedCu uint64 `protobuf:"varint,7,opt,name=used_cu,json=usedCu,proto3" json:"used_cu,omitempty"` + SubscriptionPolicy *types.Policy `protobuf:"bytes,8,opt,name=subscription_policy,json=subscriptionPolicy,proto3" json:"subscription_policy,omitempty"` + Snapshot uint64 `protobuf:"varint,9,opt,name=snapshot,proto3" json:"snapshot,omitempty"` } func (m *Project) Reset() { *m = Project{} } @@ -155,7 +124,7 @@ func (m *Project) GetProjectKeys() []ProjectKey { return nil } -func (m *Project) GetAdminPolicy() *Policy { +func (m *Project) GetAdminPolicy() *types.Policy { if m != nil { return m.AdminPolicy } @@ -169,7 +138,7 @@ func (m *Project) GetUsedCu() uint64 { return 0 } -func (m *Project) GetSubscriptionPolicy() *Policy { +func (m *Project) GetSubscriptionPolicy() *types.Policy { if m != nil { return m.SubscriptionPolicy } @@ -235,151 +204,6 @@ func (m *ProjectKey) GetKinds() uint32 { return 0 } -// protobuf expected in YAML format: used "moretags" to simplify parsing -type Policy struct { - ChainPolicies []ChainPolicy `protobuf:"bytes,1,rep,name=chain_policies,json=chainPolicies,proto3" json:"chain_policies" mapstructure:"chain_policies"` - GeolocationProfile uint64 `protobuf:"varint,2,opt,name=geolocation_profile,json=geolocationProfile,proto3" json:"geolocation_profile" mapstructure:"geolocation_profile"` - TotalCuLimit uint64 `protobuf:"varint,3,opt,name=total_cu_limit,json=totalCuLimit,proto3" json:"total_cu_limit" mapstructure:"total_cu_limit"` - EpochCuLimit uint64 `protobuf:"varint,4,opt,name=epoch_cu_limit,json=epochCuLimit,proto3" json:"epoch_cu_limit" mapstructure:"epoch_cu_limit"` - MaxProvidersToPair uint64 `protobuf:"varint,5,opt,name=max_providers_to_pair,json=maxProvidersToPair,proto3" json:"max_providers_to_pair" mapstructure:"max_providers_to_pair"` - SelectedProvidersMode SELECTED_PROVIDERS_MODE `protobuf:"varint,6,opt,name=selected_providers_mode,json=selectedProvidersMode,proto3,enum=lavanet.lava.projects.SELECTED_PROVIDERS_MODE" json:"selected_providers_mode" mapstructure:"selected_providers_mode"` - SelectedProviders []string `protobuf:"bytes,7,rep,name=selected_providers,json=selectedProviders,proto3" json:"selected_providers" mapstructure:"selected_providers"` -} - -func (m *Policy) Reset() { *m = Policy{} } -func (m *Policy) String() string { return proto.CompactTextString(m) } -func (*Policy) ProtoMessage() {} -func (*Policy) Descriptor() ([]byte, []int) { - return fileDescriptor_9f89a31663a330ce, []int{2} -} -func (m *Policy) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Policy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Policy.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Policy) XXX_Merge(src proto.Message) { - xxx_messageInfo_Policy.Merge(m, src) -} -func (m *Policy) XXX_Size() int { - return m.Size() -} -func (m *Policy) XXX_DiscardUnknown() { - xxx_messageInfo_Policy.DiscardUnknown(m) -} - -var xxx_messageInfo_Policy proto.InternalMessageInfo - -func (m *Policy) GetChainPolicies() []ChainPolicy { - if m != nil { - return m.ChainPolicies - } - return nil -} - -func (m *Policy) GetGeolocationProfile() uint64 { - if m != nil { - return m.GeolocationProfile - } - return 0 -} - -func (m *Policy) GetTotalCuLimit() uint64 { - if m != nil { - return m.TotalCuLimit - } - return 0 -} - -func (m *Policy) GetEpochCuLimit() uint64 { - if m != nil { - return m.EpochCuLimit - } - return 0 -} - -func (m *Policy) GetMaxProvidersToPair() uint64 { - if m != nil { - return m.MaxProvidersToPair - } - return 0 -} - -func (m *Policy) GetSelectedProvidersMode() SELECTED_PROVIDERS_MODE { - if m != nil { - return m.SelectedProvidersMode - } - return SELECTED_PROVIDERS_MODE_ALLOWED -} - -func (m *Policy) GetSelectedProviders() []string { - if m != nil { - return m.SelectedProviders - } - return nil -} - -type ChainPolicy struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" mapstructure:"chain_id"` - Apis []string `protobuf:"bytes,2,rep,name=apis,proto3" json:"apis,omitempty" mapstructure:"apis"` -} - -func (m *ChainPolicy) Reset() { *m = ChainPolicy{} } -func (m *ChainPolicy) String() string { return proto.CompactTextString(m) } -func (*ChainPolicy) ProtoMessage() {} -func (*ChainPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_9f89a31663a330ce, []int{3} -} -func (m *ChainPolicy) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ChainPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ChainPolicy.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ChainPolicy) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChainPolicy.Merge(m, src) -} -func (m *ChainPolicy) XXX_Size() int { - return m.Size() -} -func (m *ChainPolicy) XXX_DiscardUnknown() { - xxx_messageInfo_ChainPolicy.DiscardUnknown(m) -} - -var xxx_messageInfo_ChainPolicy proto.InternalMessageInfo - -func (m *ChainPolicy) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -func (m *ChainPolicy) GetApis() []string { - if m != nil { - return m.Apis - } - return nil -} - type ProtoDeveloperData struct { ProjectID string `protobuf:"bytes,1,opt,name=projectID,proto3" json:"projectID,omitempty"` } @@ -388,7 +212,7 @@ func (m *ProtoDeveloperData) Reset() { *m = ProtoDeveloperData{} } func (m *ProtoDeveloperData) String() string { return proto.CompactTextString(m) } func (*ProtoDeveloperData) ProtoMessage() {} func (*ProtoDeveloperData) Descriptor() ([]byte, []int) { - return fileDescriptor_9f89a31663a330ce, []int{4} + return fileDescriptor_9f89a31663a330ce, []int{2} } func (m *ProtoDeveloperData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -426,17 +250,17 @@ func (m *ProtoDeveloperData) GetProjectID() string { // used as a container struct for the subscription module type ProjectData struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` - ProjectKeys []ProjectKey `protobuf:"bytes,4,rep,name=projectKeys,proto3" json:"projectKeys"` - Policy *Policy `protobuf:"bytes,5,opt,name=policy,proto3" json:"policy,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` + ProjectKeys []ProjectKey `protobuf:"bytes,4,rep,name=projectKeys,proto3" json:"projectKeys"` + Policy *types.Policy `protobuf:"bytes,5,opt,name=policy,proto3" json:"policy,omitempty"` } func (m *ProjectData) Reset() { *m = ProjectData{} } func (m *ProjectData) String() string { return proto.CompactTextString(m) } func (*ProjectData) ProtoMessage() {} func (*ProjectData) Descriptor() ([]byte, []int) { - return fileDescriptor_9f89a31663a330ce, []int{5} + return fileDescriptor_9f89a31663a330ce, []int{3} } func (m *ProjectData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -486,7 +310,7 @@ func (m *ProjectData) GetProjectKeys() []ProjectKey { return nil } -func (m *ProjectData) GetPolicy() *Policy { +func (m *ProjectData) GetPolicy() *types.Policy { if m != nil { return m.Policy } @@ -494,12 +318,9 @@ func (m *ProjectData) GetPolicy() *Policy { } func init() { - proto.RegisterEnum("lavanet.lava.projects.SELECTED_PROVIDERS_MODE", SELECTED_PROVIDERS_MODE_name, SELECTED_PROVIDERS_MODE_value) proto.RegisterEnum("lavanet.lava.projects.ProjectKey_Type", ProjectKey_Type_name, ProjectKey_Type_value) proto.RegisterType((*Project)(nil), "lavanet.lava.projects.Project") proto.RegisterType((*ProjectKey)(nil), "lavanet.lava.projects.ProjectKey") - proto.RegisterType((*Policy)(nil), "lavanet.lava.projects.Policy") - proto.RegisterType((*ChainPolicy)(nil), "lavanet.lava.projects.ChainPolicy") proto.RegisterType((*ProtoDeveloperData)(nil), "lavanet.lava.projects.ProtoDeveloperData") proto.RegisterType((*ProjectData)(nil), "lavanet.lava.projects.ProjectData") } @@ -507,64 +328,39 @@ func init() { func init() { proto.RegisterFile("projects/project.proto", fileDescriptor_9f89a31663a330ce) } var fileDescriptor_9f89a31663a330ce = []byte{ - // 897 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0x8f, 0x13, 0xe7, 0xdf, 0x4b, 0x5a, 0x85, 0xe9, 0x96, 0x5a, 0xbb, 0x6c, 0x9c, 0x1d, 0x01, - 0x8a, 0xf6, 0x90, 0x48, 0x5d, 0x81, 0x10, 0x08, 0x89, 0x26, 0x36, 0x52, 0x4a, 0x9a, 0x44, 0xd3, - 0x52, 0x16, 0x2e, 0x91, 0x6b, 0x0f, 0xed, 0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, 0xce, 0x94, 0x42, 0x43, - 0x6a, 0x56, 0x0e, 0x9f, 0x6f, 0xab, 0x25, 0x40, 0xa4, 0x22, 0x52, 0x62, 0x03, 0x1d, 0x40, 0x31, - 0xf0, 0xa8, 0x35, 0x36, 0x03, 0xa5, 0xd8, 0x90, 0x9a, 0x32, 0x29, 0x44, 0x66, 0x37, 0x40, 0x03, - 0xd8, 0x5b, 0x1f, 0x68, 0xc9, 0x50, 0x7a, 0x1f, 0x06, 0xb4, 0x9e, 0x99, 0x10, 0x3d, 0x85, 0x92, - 0x37, 0x35, 0x1c, 0xef, 0x8a, 0xfb, 0x4a, 0x59, 0x30, 0xad, 0xec, 0x63, 0xb9, 0x94, 0xab, 0xc9, - 0xd8, 0x06, 0x78, 0x98, 0x16, 0xd5, 0x20, 0x77, 0x4d, 0x67, 0xc9, 0xc6, 0x47, 0xcb, 0xe8, 0x30, - 0xae, 0xd9, 0xd4, 0xf2, 0xc4, 0x86, 0xee, 0x90, 0xd8, 0xc0, 0x2f, 0x41, 0x3e, 0x9b, 0x39, 0x14, - 0x95, 0x40, 0x1e, 0x0c, 0x07, 0x7a, 0x2d, 0x83, 0xca, 0x90, 0x3f, 0xd2, 0x4e, 0x7a, 0x83, 0x9a, - 0x84, 0x76, 0xa0, 0xac, 0xe9, 0xe7, 0x7a, 0x7f, 0x38, 0xd2, 0x49, 0x2d, 0x7b, 0x2c, 0x97, 0xb2, - 0xb5, 0x5c, 0xc2, 0xf6, 0x7b, 0x01, 0x0a, 0x49, 0x6b, 0x0e, 0xec, 0x9a, 0x57, 0xc6, 0x72, 0x17, - 0x19, 0xf5, 0x14, 0x49, 0x9c, 0x09, 0xde, 0x32, 0x65, 0x37, 0x02, 0xc7, 0xb9, 0x9d, 0x4f, 0xa2, - 0x43, 0x59, 0x84, 0xea, 0xf3, 0x89, 0xe1, 0x78, 0xbe, 0x1b, 0x98, 0x7e, 0xe0, 0xd2, 0x2f, 0x71, - 0xba, 0x1e, 0x26, 0x3b, 0x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 0x5c, - 0xa8, 0x02, 0xc5, 0xa3, 0x7e, 0x7f, 0xf8, 0x83, 0xae, 0xc5, 0xd2, 0x77, 0xd2, 0x7b, 0xad, 0x6b, - 0xb1, 0xf4, 0xe9, 0xaf, 0xbb, 0xfd, 0xef, 0x4f, 0x7b, 0xe7, 0x7a, 0x2d, 0x8b, 0xaa, 0x50, 0xd2, - 0x7a, 0xa7, 0x47, 0x9d, 0xbe, 0xae, 0xd5, 0x72, 0x9d, 0x6f, 0x7f, 0xbd, 0xab, 0x4b, 0x6f, 0xef, - 0xea, 0xd2, 0xbb, 0xbb, 0xba, 0xf4, 0xd7, 0x5d, 0x5d, 0xfa, 0xe5, 0xbe, 0x9e, 0x79, 0x77, 0x5f, - 0xcf, 0xfc, 0x79, 0x5f, 0xcf, 0xfc, 0xd4, 0xbc, 0x64, 0xfe, 0x55, 0x70, 0xd1, 0x32, 0xf9, 0xa4, - 0x9d, 0x34, 0x29, 0xbe, 0xed, 0xdb, 0xf6, 0xea, 0x07, 0xeb, 0xcf, 0x1c, 0xea, 0x5d, 0x14, 0xc4, - 0x2f, 0xf3, 0xd5, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x0b, 0xfe, 0x8d, 0x79, 0x07, 0x00, - 0x00, + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xbd, 0x8e, 0xd3, 0x4c, + 0x14, 0xcd, 0x24, 0x93, 0xc4, 0xb9, 0xc9, 0x4a, 0xd6, 0x7c, 0xfb, 0x81, 0x15, 0x21, 0x13, 0x5c, + 0x59, 0x14, 0xb6, 0x14, 0x1a, 0x1a, 0x0a, 0x16, 0x07, 0x29, 0x59, 0xc8, 0x46, 0x16, 0xa2, 0xa0, + 0x89, 0x1c, 0x7b, 0x94, 0x35, 0x71, 0x3c, 0xa3, 0x8c, 0xbd, 0x5a, 0xbf, 0x05, 0x8f,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, 0x25, 0x49, 0xf3, 0x41, 0x49, 0x14, 0xb3, + 0x1a, 0xe1, 0xec, 0xed, 0xd7, 0xad, 0x89, 0x6e, 0xb6, 0x26, 0xba, 0xdd, 0x9a, 0xe8, 0xe7, 0xd6, + 0x44, 0x5f, 0x76, 0x66, 0xed, 0x76, 0x67, 0xd6, 0xbe, 0xef, 0xcc, 0xda, 0x27, 0x7b, 0x19, 0x67, + 0x97, 0xf9, 0xc2, 0x09, 0xd9, 0xda, 0x55, 0x19, 0xe5, 0xeb, 0x5e, 0xbb, 0x87, 0x63, 0xcb, 0x0a, + 0x4e, 0xc5, 0xa2, 0x25, 0x8f, 0xe5, 0xc5, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x44, 0x64, + 0x62, 0x85, 0x03, 0x00, 0x00, } func (this *Project) Equal(that interface{}) bool { @@ -644,90 +440,6 @@ func (this *ProjectKey) Equal(that interface{}) bool { } return true } -func (this *Policy) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Policy) - if !ok { - that2, ok := that.(Policy) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if len(this.ChainPolicies) != len(that1.ChainPolicies) { - return false - } - for i := range this.ChainPolicies { - if !this.ChainPolicies[i].Equal(&that1.ChainPolicies[i]) { - return false - } - } - if this.GeolocationProfile != that1.GeolocationProfile { - return false - } - if this.TotalCuLimit != that1.TotalCuLimit { - return false - } - if this.EpochCuLimit != that1.EpochCuLimit { - return false - } - if this.MaxProvidersToPair != that1.MaxProvidersToPair { - return false - } - if this.SelectedProvidersMode != that1.SelectedProvidersMode { - return false - } - if len(this.SelectedProviders) != len(that1.SelectedProviders) { - return false - } - for i := range this.SelectedProviders { - if this.SelectedProviders[i] != that1.SelectedProviders[i] { - return false - } - } - return true -} -func (this *ChainPolicy) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*ChainPolicy) - if !ok { - that2, ok := that.(ChainPolicy) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.ChainId != that1.ChainId { - return false - } - if len(this.Apis) != len(that1.Apis) { - return false - } - for i := range this.Apis { - if this.Apis[i] != that1.Apis[i] { - return false - } - } - return true -} func (this *ProtoDeveloperData) Equal(that interface{}) bool { if that == nil { return this == nil @@ -920,116 +632,6 @@ func (m *ProjectKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Policy) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Policy) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Policy) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SelectedProviders) > 0 { - for iNdEx := len(m.SelectedProviders) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SelectedProviders[iNdEx]) - copy(dAtA[i:], m.SelectedProviders[iNdEx]) - i = encodeVarintProject(dAtA, i, uint64(len(m.SelectedProviders[iNdEx]))) - i-- - dAtA[i] = 0x3a - } - } - if m.SelectedProvidersMode != 0 { - i = encodeVarintProject(dAtA, i, uint64(m.SelectedProvidersMode)) - i-- - dAtA[i] = 0x30 - } - if m.MaxProvidersToPair != 0 { - i = encodeVarintProject(dAtA, i, uint64(m.MaxProvidersToPair)) - i-- - dAtA[i] = 0x28 - } - if m.EpochCuLimit != 0 { - i = encodeVarintProject(dAtA, i, uint64(m.EpochCuLimit)) - i-- - dAtA[i] = 0x20 - } - if m.TotalCuLimit != 0 { - i = encodeVarintProject(dAtA, i, uint64(m.TotalCuLimit)) - i-- - dAtA[i] = 0x18 - } - if m.GeolocationProfile != 0 { - i = encodeVarintProject(dAtA, i, uint64(m.GeolocationProfile)) - i-- - dAtA[i] = 0x10 - } - if len(m.ChainPolicies) > 0 { - for iNdEx := len(m.ChainPolicies) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ChainPolicies[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProject(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ChainPolicy) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ChainPolicy) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ChainPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Apis) > 0 { - for iNdEx := len(m.Apis) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Apis[iNdEx]) - copy(dAtA[i:], m.Apis[iNdEx]) - i = encodeVarintProject(dAtA, i, uint64(len(m.Apis[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintProject(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *ProtoDeveloperData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1193,81 +795,26 @@ func (m *ProjectKey) Size() (n int) { return n } -func (m *Policy) Size() (n int) { +func (m *ProtoDeveloperData) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.ChainPolicies) > 0 { - for _, e := range m.ChainPolicies { - l = e.Size() - n += 1 + l + sovProject(uint64(l)) - } - } - if m.GeolocationProfile != 0 { - n += 1 + sovProject(uint64(m.GeolocationProfile)) - } - if m.TotalCuLimit != 0 { - n += 1 + sovProject(uint64(m.TotalCuLimit)) - } - if m.EpochCuLimit != 0 { - n += 1 + sovProject(uint64(m.EpochCuLimit)) - } - if m.MaxProvidersToPair != 0 { - n += 1 + sovProject(uint64(m.MaxProvidersToPair)) - } - if m.SelectedProvidersMode != 0 { - n += 1 + sovProject(uint64(m.SelectedProvidersMode)) - } - if len(m.SelectedProviders) > 0 { - for _, s := range m.SelectedProviders { - l = len(s) - n += 1 + l + sovProject(uint64(l)) - } + l = len(m.ProjectID) + if l > 0 { + n += 1 + l + sovProject(uint64(l)) } return n } -func (m *ChainPolicy) Size() (n int) { +func (m *ProjectData) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovProject(uint64(l)) - } - if len(m.Apis) > 0 { - for _, s := range m.Apis { - l = len(s) - n += 1 + l + sovProject(uint64(l)) - } - } - return n -} - -func (m *ProtoDeveloperData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProjectID) - if l > 0 { - n += 1 + l + sovProject(uint64(l)) - } - return n -} - -func (m *ProjectData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) + l = len(m.Name) if l > 0 { n += 1 + l + sovProject(uint64(l)) } @@ -1470,7 +1017,7 @@ func (m *Project) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AdminPolicy == nil { - m.AdminPolicy = &Policy{} + m.AdminPolicy = &types.Policy{} } if err := m.AdminPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1525,7 +1072,7 @@ func (m *Project) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.SubscriptionPolicy == nil { - m.SubscriptionPolicy = &Policy{} + m.SubscriptionPolicy = &types.Policy{} } if err := m.SubscriptionPolicy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1672,331 +1219,6 @@ func (m *ProjectKey) Unmarshal(dAtA []byte) error { } return nil } -func (m *Policy) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Policy: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Policy: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainPolicies", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProject - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProject - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainPolicies = append(m.ChainPolicies, ChainPolicy{}) - if err := m.ChainPolicies[len(m.ChainPolicies)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GeolocationProfile", wireType) - } - m.GeolocationProfile = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GeolocationProfile |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalCuLimit", wireType) - } - m.TotalCuLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalCuLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochCuLimit", wireType) - } - m.EpochCuLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EpochCuLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxProvidersToPair", wireType) - } - m.MaxProvidersToPair = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxProvidersToPair |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SelectedProvidersMode", wireType) - } - m.SelectedProvidersMode = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SelectedProvidersMode |= SELECTED_PROVIDERS_MODE(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SelectedProviders", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProject - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProject - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SelectedProviders = append(m.SelectedProviders, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProject(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProject - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ChainPolicy) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ChainPolicy: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ChainPolicy: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProject - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProject - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Apis", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProject - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProject - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProject - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Apis = append(m.Apis, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProject(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProject - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *ProtoDeveloperData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2224,7 +1446,7 @@ func (m *ProjectData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Policy == nil { - m.Policy = &Policy{} + m.Policy = &types.Policy{} } if err := m.Policy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/projects/types/tx.pb.go b/x/projects/types/tx.pb.go index abb7be9e39..189e4d2ba3 100644 --- a/x/projects/types/tx.pb.go +++ b/x/projects/types/tx.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/x/plans/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -221,9 +222,9 @@ func (m *MsgDelKeysResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDelKeysResponse proto.InternalMessageInfo type MsgSetPolicy struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Project string `protobuf:"bytes,2,opt,name=project,proto3" json:"project,omitempty"` - Policy Policy `protobuf:"bytes,3,opt,name=policy,proto3" json:"policy"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Project string `protobuf:"bytes,2,opt,name=project,proto3" json:"project,omitempty"` + Policy types.Policy `protobuf:"bytes,3,opt,name=policy,proto3" json:"policy"` } func (m *MsgSetPolicy) Reset() { *m = MsgSetPolicy{} } @@ -273,11 +274,11 @@ func (m *MsgSetPolicy) GetProject() string { return "" } -func (m *MsgSetPolicy) GetPolicy() Policy { +func (m *MsgSetPolicy) GetPolicy() types.Policy { if m != nil { return m.Policy } - return Policy{} + return types.Policy{} } type MsgSetPolicyResponse struct { @@ -317,9 +318,9 @@ func (m *MsgSetPolicyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetPolicyResponse proto.InternalMessageInfo type MsgSetSubscriptionPolicy struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Projects []string `protobuf:"bytes,2,rep,name=projects,proto3" json:"projects,omitempty"` - Policy Policy `protobuf:"bytes,3,opt,name=policy,proto3" json:"policy"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Projects []string `protobuf:"bytes,2,rep,name=projects,proto3" json:"projects,omitempty"` + Policy types.Policy `protobuf:"bytes,3,opt,name=policy,proto3" json:"policy"` } func (m *MsgSetSubscriptionPolicy) Reset() { *m = MsgSetSubscriptionPolicy{} } @@ -369,11 +370,11 @@ func (m *MsgSetSubscriptionPolicy) GetProjects() []string { return nil } -func (m *MsgSetSubscriptionPolicy) GetPolicy() Policy { +func (m *MsgSetSubscriptionPolicy) GetPolicy() types.Policy { if m != nil { return m.Policy } - return Policy{} + return types.Policy{} } type MsgSetSubscriptionPolicyResponse struct { @@ -426,34 +427,35 @@ func init() { func init() { proto.RegisterFile("projects/tx.proto", fileDescriptor_b5dcbe7dfba713c0) } var fileDescriptor_b5dcbe7dfba713c0 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x28, 0xca, 0xcf, - 0x4a, 0x4d, 0x2e, 0x29, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xcd, - 0x49, 0x2c, 0x4b, 0xcc, 0x4b, 0x2d, 0xd1, 0x03, 0xd1, 0x7a, 0x30, 0x79, 0x29, 0x31, 0xb8, 0x4a, - 0x28, 0x03, 0xa2, 0x5c, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0x20, 0xa2, - 0x4a, 0x3d, 0x8c, 0x5c, 0x5c, 0xbe, 0xc5, 0xe9, 0x8e, 0x29, 0x29, 0xde, 0xa9, 0x95, 0xc5, 0x42, - 0x12, 0x5c, 0xec, 0xc9, 0x45, 0xa9, 0x89, 0x25, 0xf9, 0x45, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, - 0x41, 0x30, 0x2e, 0x48, 0x06, 0x6a, 0x9e, 0x04, 0x13, 0x44, 0x06, 0xca, 0x15, 0xf2, 0xe2, 0xe2, - 0x81, 0x32, 0xe3, 0xb3, 0x53, 0x2b, 0x8b, 0x25, 0x98, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x14, 0xf5, - 0xb0, 0x3a, 0x4f, 0x2f, 0x00, 0xc2, 0xf0, 0x4e, 0xad, 0x74, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, - 0x88, 0xbb, 0x00, 0x2e, 0x52, 0xac, 0x24, 0xc2, 0x25, 0x84, 0x70, 0x4d, 0x50, 0x6a, 0x71, 0x41, - 0x7e, 0x5e, 0x71, 0x2a, 0xcc, 0x91, 0x2e, 0xa9, 0x39, 0x83, 0xc8, 0x91, 0x50, 0xd7, 0xc0, 0x1d, - 0x59, 0xcf, 0xc5, 0xe3, 0x5b, 0x9c, 0x1e, 0x9c, 0x5a, 0x12, 0x90, 0x9f, 0x93, 0x99, 0x5c, 0x49, - 0x96, 0x2b, 0xad, 0xb9, 0xd8, 0x0a, 0xc0, 0xba, 0x25, 0x98, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, - 0x71, 0xb9, 0x0f, 0xac, 0x08, 0xea, 0x36, 0xa8, 0x16, 0x25, 0x31, 0x2e, 0x11, 0x64, 0x07, 0xc0, - 0x1d, 0xd6, 0xcb, 0xc8, 0x25, 0x01, 0x91, 0x08, 0x2e, 0x4d, 0x2a, 0x4e, 0x2e, 0xca, 0x2c, 0x28, - 0xc9, 0xcc, 0xcf, 0x23, 0xe8, 0x4a, 0x29, 0x2e, 0x0e, 0x98, 0x7d, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, - 0x9c, 0x41, 0x70, 0x3e, 0x65, 0xee, 0x54, 0xe2, 0x52, 0xc0, 0xe5, 0x1c, 0x98, 0x9b, 0x8d, 0x66, - 0x31, 0x73, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x85, 0x73, 0xb1, 0xc3, 0x92, 0x26, 0xae, 0xb8, 0x42, - 0xa4, 0x17, 0x29, 0x4d, 0x82, 0x4a, 0x60, 0x16, 0x80, 0x0c, 0x86, 0x25, 0x27, 0x3c, 0x06, 0x43, - 0x95, 0xe0, 0x33, 0x18, 0x2d, 0x19, 0x08, 0xc5, 0x72, 0x71, 0x22, 0xd2, 0x80, 0x32, 0x6e, 0x7d, - 0x70, 0x45, 0x52, 0xda, 0x44, 0x28, 0x82, 0x1b, 0xdf, 0xc8, 0xc8, 0x25, 0x8a, 0x3d, 0x26, 0xf5, - 0xf1, 0x1a, 0x83, 0xa9, 0x41, 0xca, 0x9c, 0x44, 0x0d, 0x30, 0x37, 0x38, 0x39, 0x9d, 0x78, 0x24, - 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, - 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x46, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, - 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x70, 0x30, 0xad, 0x5f, 0xa1, 0x8f, 0x28, 0xbf, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0xc5, 0x8f, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x26, 0xb0, 0x01, 0xc4, - 0xd8, 0x04, 0x00, 0x00, + // 433 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0x3f, 0xeb, 0xd3, 0x40, + 0x18, 0xc7, 0x73, 0xbf, 0x48, 0x6b, 0x9f, 0x76, 0xd0, 0xd0, 0x96, 0x90, 0x21, 0xc6, 0xb8, 0x44, + 0x84, 0x04, 0xea, 0xa0, 0xab, 0xc5, 0xc9, 0x52, 0x28, 0xe9, 0x20, 0x08, 0x22, 0x69, 0x7a, 0xc4, + 0x68, 0xcc, 0x1d, 0xb9, 0xab, 0x34, 0xe0, 0xe2, 0x2a, 0x0e, 0xce, 0xbe, 0xa2, 0x8e, 0x1d, 0x9d, + 0x44, 0xda, 0x37, 0x22, 0x49, 0xee, 0x12, 0xa9, 0xfd, 0xe3, 0x9f, 0xe5, 0xb7, 0xe4, 0x9e, 0xbb, + 0xe7, 0xfb, 0x7c, 0xef, 0x43, 0x9e, 0x87, 0x83, 0xdb, 0x34, 0x23, 0x6f, 0x70, 0xc8, 0x99, 0xc7, + 0xd7, 0x2e, 0xcd, 0x08, 0x27, 0xda, 0x20, 0x09, 0xde, 0x07, 0x29, 0xe6, 0x6e, 0xb1, 0xba, 0x32, + 0x6f, 0x0c, 0x6b, 0xa5, 0x08, 0x2a, 0xb9, 0x71, 0x8b, 0x26, 0x41, 0xca, 0xbc, 0xe2, 0x2b, 0x4e, + 0xfa, 0x11, 0x89, 0x48, 0x19, 0x7a, 0x45, 0x54, 0x9d, 0xda, 0x9f, 0x11, 0xc0, 0x94, 0x45, 0x4f, + 0x96, 0xcb, 0x09, 0xce, 0x99, 0xa6, 0x43, 0x3b, 0xcc, 0x70, 0xc0, 0x49, 0xa6, 0x23, 0x0b, 0x39, + 0x1d, 0x5f, 0x6e, 0x8b, 0x8c, 0xb8, 0x41, 0xbf, 0xaa, 0x32, 0x62, 0xab, 0x3d, 0x83, 0x9e, 0x08, + 0x5f, 0xbd, 0xc5, 0x39, 0xd3, 0x55, 0x4b, 0x75, 0xba, 0xa3, 0xbb, 0xee, 0x51, 0x60, 0x77, 0x56, + 0x05, 0x13, 0x9c, 0x8f, 0x6f, 0x6c, 0xbe, 0xdf, 0x51, 0xfc, 0x2e, 0xad, 0x4f, 0x98, 0xdd, 0x07, + 0xad, 0xa1, 0xf1, 0x31, 0xa3, 0x24, 0x65, 0x58, 0x42, 0x3e, 0xc5, 0xc9, 0x35, 0x82, 0x14, 0x34, + 0x35, 0xe4, 0x07, 0xe8, 0x4d, 0x59, 0x34, 0xc7, 0x7c, 0x46, 0x92, 0x38, 0xcc, 0xff, 0x89, 0xf2, + 0x31, 0xb4, 0x68, 0x59, 0xad, 0xab, 0x16, 0x72, 0xba, 0x23, 0xe3, 0x80, 0xaf, 0xe8, 0xa9, 0x5b, + 0xf9, 0x0b, 0x30, 0xa1, 0xb7, 0x87, 0xd0, 0xff, 0xf5, 0xf6, 0x9a, 0xea, 0x13, 0x02, 0xbd, 0x4a, + 0xcc, 0x57, 0x0b, 0x16, 0x66, 0x31, 0xe5, 0x31, 0x49, 0x2f, 0x22, 0x1a, 0x70, 0x53, 0xfe, 0x0c, + 0xfd, 0xca, 0x52, 0x9d, 0x8e, 0x5f, 0xef, 0xff, 0x03, 0xd2, 0x06, 0xeb, 0x14, 0x8b, 0x04, 0x1e, + 0x7d, 0x55, 0x41, 0x9d, 0xb2, 0x48, 0x7b, 0x0e, 0x6d, 0x39, 0x94, 0xa7, 0xba, 0xd4, 0x4c, 0x8a, + 0x71, 0xff, 0xa2, 0x44, 0x5e, 0x50, 0x18, 0xcb, 0x41, 0x3a, 0x63, 0x2c, 0x24, 0xe7, 0x8c, 0x0f, + 0x06, 0x40, 0x7b, 0x09, 0x9d, 0xa6, 0xfb, 0xf7, 0x4e, 0xd7, 0xd5, 0x22, 0xe3, 0xc1, 0x1f, 0x88, + 0x6a, 0xfb, 0x8f, 0x08, 0x06, 0xc7, 0xdb, 0xe8, 0x9d, 0xb5, 0xf9, 0xbd, 0xc0, 0x78, 0xf4, 0x97, + 0x05, 0x92, 0x61, 0x3c, 0xde, 0xec, 0x4c, 0xb4, 0xdd, 0x99, 0xe8, 0xc7, 0xce, 0x44, 0x5f, 0xf6, + 0xa6, 0xb2, 0xdd, 0x9b, 0xca, 0xb7, 0xbd, 0xa9, 0xbc, 0x70, 0xa2, 0x98, 0xbf, 0x5e, 0x2d, 0xdc, + 0x90, 0xbc, 0xf3, 0x84, 0x79, 0xb9, 0x7a, 0x6b, 0xaf, 0x79, 0xcb, 0x72, 0x8a, 0xd9, 0xa2, 0x55, + 0x3e, 0x3c, 0x0f, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xa9, 0x60, 0x0e, 0xe4, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 71f4cf80bd54d12847b90957986e4aa98802d74b Mon Sep 17 00:00:00 2001 From: oren-lava Date: Tue, 20 Jun 2023 17:38:05 +0300 Subject: [PATCH 2/2] CNS-476: fixed code due to policy move --- testutil/common/common.go | 3 +- x/pairing/keeper/filters/filter.go | 8 ++-- .../keeper/filters/frozen_providers_filter.go | 4 +- .../keeper/filters/geolocation_filter.go | 8 ++-- .../filters/selected_providers_filter.go | 6 +-- x/pairing/keeper/grpc_query_user_entry.go | 6 +-- x/pairing/keeper/limitConsumer.go | 6 +-- .../keeper/msg_server_relay_payment_test.go | 6 +-- x/pairing/keeper/pairing.go | 31 ++++++------- x/pairing/keeper/pairing_subscription_test.go | 15 ++++--- x/pairing/keeper/pairing_test.go | 16 +++---- x/plans/keeper/migrations.go | 3 +- x/plans/keeper/plan_test.go | 3 +- x/plans/types/errors.go | 23 ++++++---- x/{projects => plans}/types/policy.go | 0 x/plans/types/types.go | 25 +++++++++++ x/projects/client/cli/tx_set_admin_policy.go | 3 +- .../client/cli/tx_set_subscription_policy.go | 3 +- x/projects/keeper/project.go | 3 +- x/projects/keeper/project_test.go | 44 +++++++++---------- x/projects/types/errors.go | 7 +-- x/projects/types/message_set_admin_policy.go | 3 +- .../types/message_set_admin_policy_test.go | 5 ++- .../types/message_set_subscription_policy.go | 3 +- .../message_set_subscription_policy_test.go | 5 ++- x/projects/types/types.go | 25 ----------- x/subscription/client/cli/tx_add_project.go | 3 +- x/subscription/keeper/subscription_test.go | 2 +- .../types/message_add_project_test.go | 5 ++- 29 files changed, 141 insertions(+), 133 deletions(-) rename x/{projects => plans}/types/policy.go (100%) diff --git a/testutil/common/common.go b/testutil/common/common.go index 059248950e..edc5498c81 100644 --- a/testutil/common/common.go +++ b/testutil/common/common.go @@ -12,7 +12,6 @@ import ( epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" "github.com/lavanet/lava/x/pairing/types" plantypes "github.com/lavanet/lava/x/plans/types" - projectstypes "github.com/lavanet/lava/x/projects/types" spectypes "github.com/lavanet/lava/x/spec/types" subscriptiontypes "github.com/lavanet/lava/x/subscription/types" "github.com/stretchr/testify/require" @@ -41,7 +40,7 @@ func CreateMockSpec() spectypes.Spec { } func CreateMockPlan() plantypes.Plan { - policy := projectstypes.Policy{ + policy := plantypes.Policy{ TotalCuLimit: 100000, EpochCuLimit: 10000, MaxProvidersToPair: 3, diff --git a/x/pairing/keeper/filters/filter.go b/x/pairing/keeper/filters/filter.go index ad67724db1..223553959d 100644 --- a/x/pairing/keeper/filters/filter.go +++ b/x/pairing/keeper/filters/filter.go @@ -6,12 +6,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lavanet/lava/utils" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" ) type Filter interface { Filter(ctx sdk.Context, providers []epochstoragetypes.StakeEntry, currentEpoch uint64) []bool - InitFilter(strictestPolicy projectstypes.Policy) bool // return if filter is usable (by the policy) + InitFilter(strictestPolicy planstypes.Policy) bool // return if filter is usable (by the policy) } func GetAllFilters() []Filter { @@ -23,7 +23,7 @@ func GetAllFilters() []Filter { return filters } -func initFilters(filters []Filter, strictestPolicy projectstypes.Policy) []Filter { +func initFilters(filters []Filter, strictestPolicy planstypes.Policy) []Filter { activeFilters := []Filter{} for _, filter := range filters { @@ -36,7 +36,7 @@ func initFilters(filters []Filter, strictestPolicy projectstypes.Policy) []Filte return activeFilters } -func FilterProviders(ctx sdk.Context, filters []Filter, providers []epochstoragetypes.StakeEntry, strictestPolicy projectstypes.Policy, currentEpoch uint64) ([]epochstoragetypes.StakeEntry, error) { +func FilterProviders(ctx sdk.Context, filters []Filter, providers []epochstoragetypes.StakeEntry, strictestPolicy planstypes.Policy, currentEpoch uint64) ([]epochstoragetypes.StakeEntry, error) { filters = initFilters(filters, strictestPolicy) var filtersResult [][]bool diff --git a/x/pairing/keeper/filters/frozen_providers_filter.go b/x/pairing/keeper/filters/frozen_providers_filter.go index 1d2686a402..b144800c10 100644 --- a/x/pairing/keeper/filters/frozen_providers_filter.go +++ b/x/pairing/keeper/filters/frozen_providers_filter.go @@ -3,12 +3,12 @@ package filters import ( sdk "github.com/cosmos/cosmos-sdk/types" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" ) type FrozenProvidersFilter struct{} -func (f *FrozenProvidersFilter) InitFilter(strictestPolicy projectstypes.Policy) bool { +func (f *FrozenProvidersFilter) InitFilter(strictestPolicy planstypes.Policy) bool { // frozen providers (or providers that their stake is not applied yet) can't be part of the pairing - this filter is always active return true } diff --git a/x/pairing/keeper/filters/geolocation_filter.go b/x/pairing/keeper/filters/geolocation_filter.go index 9f9e783155..d0d3ae2466 100644 --- a/x/pairing/keeper/filters/geolocation_filter.go +++ b/x/pairing/keeper/filters/geolocation_filter.go @@ -3,7 +3,7 @@ package filters import ( sdk "github.com/cosmos/cosmos-sdk/types" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" ) // TODO: This is a temp filter until the geolocation mechanism changes (this is not optimal) @@ -12,9 +12,9 @@ type GeolocationFilter struct { geolocation uint64 } -func (f *GeolocationFilter) InitFilter(strictestPolicy projectstypes.Policy) bool { - if strictestPolicy.SelectedProvidersMode == projectstypes.SELECTED_PROVIDERS_MODE_DISABLED || - strictestPolicy.SelectedProvidersMode == projectstypes.SELECTED_PROVIDERS_MODE_ALLOWED { +func (f *GeolocationFilter) InitFilter(strictestPolicy planstypes.Policy) bool { + if strictestPolicy.SelectedProvidersMode == planstypes.SELECTED_PROVIDERS_MODE_DISABLED || + strictestPolicy.SelectedProvidersMode == planstypes.SELECTED_PROVIDERS_MODE_ALLOWED { f.geolocation = strictestPolicy.GeolocationProfile return true } diff --git a/x/pairing/keeper/filters/selected_providers_filter.go b/x/pairing/keeper/filters/selected_providers_filter.go index 3cb953d968..7fcee9b8b5 100644 --- a/x/pairing/keeper/filters/selected_providers_filter.go +++ b/x/pairing/keeper/filters/selected_providers_filter.go @@ -3,16 +3,16 @@ package filters import ( sdk "github.com/cosmos/cosmos-sdk/types" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" ) type SelectedProvidersFilter struct { selectedProviders []string } -func (f *SelectedProvidersFilter) InitFilter(strictestPolicy projectstypes.Policy) bool { +func (f *SelectedProvidersFilter) InitFilter(strictestPolicy planstypes.Policy) bool { switch strictestPolicy.SelectedProvidersMode { - case projectstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE, projectstypes.SELECTED_PROVIDERS_MODE_MIXED: + case planstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE, planstypes.SELECTED_PROVIDERS_MODE_MIXED: f.selectedProviders = strictestPolicy.SelectedProviders return true } diff --git a/x/pairing/keeper/grpc_query_user_entry.go b/x/pairing/keeper/grpc_query_user_entry.go index 61da8f2192..b431a09382 100644 --- a/x/pairing/keeper/grpc_query_user_entry.go +++ b/x/pairing/keeper/grpc_query_user_entry.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" "github.com/lavanet/lava/x/pairing/types" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -41,7 +41,7 @@ func (k Keeper) UserEntry(goCtx context.Context, req *types.QueryUserEntryReques } planPolicy := plan.GetPlanPolicy() - policies := []*projectstypes.Policy{&planPolicy, project.AdminPolicy, project.SubscriptionPolicy} + policies := []*planstypes.Policy{&planPolicy, project.AdminPolicy, project.SubscriptionPolicy} // geolocation is a bitmap. common denominator can be calculated with logical AND geolocation := k.CalculateEffectiveGeolocationFromPolicies(policies) @@ -51,7 +51,7 @@ func (k Keeper) UserEntry(goCtx context.Context, req *types.QueryUserEntryReques } allowedCU := k.CalculateEffectiveAllowedCuPerEpochFromPolicies(policies, project.GetUsedCu(), sub.GetMonthCuLeft()) - if !projectstypes.VerifyTotalCuUsage(policies, project.GetUsedCu()) { + if !planstypes.VerifyTotalCuUsage(policies, project.GetUsedCu()) { allowedCU = 0 } diff --git a/x/pairing/keeper/limitConsumer.go b/x/pairing/keeper/limitConsumer.go index f988fe493b..74a719f76f 100644 --- a/x/pairing/keeper/limitConsumer.go +++ b/x/pairing/keeper/limitConsumer.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lavanet/lava/utils" - projectstypes "github.com/lavanet/lava/x/projects/types" + planstypes "github.com/lavanet/lava/x/plans/types" ) func (k Keeper) EnforceClientCUsUsageInEpoch(ctx sdk.Context, allowedCU uint64, totalCUInEpochForUserProvider uint64, clientAddr sdk.AccAddress, chainID string, epoch uint64) error { @@ -19,8 +19,8 @@ func (k Keeper) EnforceClientCUsUsageInEpoch(ctx sdk.Context, allowedCU uint64, } planPolicy := plan.GetPlanPolicy() - policies := []*projectstypes.Policy{&planPolicy, project.AdminPolicy, project.SubscriptionPolicy} - if !projectstypes.VerifyTotalCuUsage(policies, project.GetUsedCu()) { + policies := []*planstypes.Policy{&planPolicy, project.AdminPolicy, project.SubscriptionPolicy} + if !planstypes.VerifyTotalCuUsage(policies, project.GetUsedCu()) { return utils.LavaFormatError("total cu in epoch for consumer exceeded the allowed amount for the project", fmt.Errorf("consumer CU limit exceeded for project"), []utils.Attribute{{Key: "projectUsedCu", Value: project.GetUsedCu()}}...) } diff --git a/x/pairing/keeper/msg_server_relay_payment_test.go b/x/pairing/keeper/msg_server_relay_payment_test.go index d901a08ac1..ad6e6af8a7 100644 --- a/x/pairing/keeper/msg_server_relay_payment_test.go +++ b/x/pairing/keeper/msg_server_relay_payment_test.go @@ -11,7 +11,7 @@ import ( "github.com/lavanet/lava/utils/sigs" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" "github.com/lavanet/lava/x/pairing/types" - plantypes "github.com/lavanet/lava/x/plans/types" + planstypes "github.com/lavanet/lava/x/plans/types" projecttypes "github.com/lavanet/lava/x/projects/types" spectypes "github.com/lavanet/lava/x/spec/types" subscriptionypes "github.com/lavanet/lava/x/subscription/types" @@ -30,7 +30,7 @@ type testStruct struct { providers []*common.Account clients []*common.Account spec spectypes.Spec - plan plantypes.Plan + plan planstypes.Plan } func createStubRequest(relaySession *types.RelaySession) *types.RelayRequest { @@ -726,7 +726,7 @@ func TestCuUsageInProjectsAndSubscription(t *testing.T) { ProjectKeys: []projecttypes.ProjectKey{ projecttypes.ProjectDeveloperKey(projectAdmin1.String()), }, - Policy: &projecttypes.Policy{ + Policy: &planstypes.Policy{ GeolocationProfile: uint64(1), MaxProvidersToPair: 3, TotalCuLimit: 1000, diff --git a/x/pairing/keeper/pairing.go b/x/pairing/keeper/pairing.go index c5c3c1165d..684a5908c2 100644 --- a/x/pairing/keeper/pairing.go +++ b/x/pairing/keeper/pairing.go @@ -10,6 +10,7 @@ import ( "github.com/lavanet/lava/utils" epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" pairingfilters "github.com/lavanet/lava/x/pairing/keeper/filters" + planstypes "github.com/lavanet/lava/x/plans/types" projectstypes "github.com/lavanet/lava/x/projects/types" spectypes "github.com/lavanet/lava/x/spec/types" tendermintcrypto "github.com/tendermint/tendermint/crypto" @@ -107,7 +108,7 @@ func (k Keeper) GetPairingForClient(ctx sdk.Context, chainID string, clientAddre // function used to get a new pairing from provider and client // first argument has all metadata, second argument is only the addresses func (k Keeper) getPairingForClient(ctx sdk.Context, chainID string, clientAddress sdk.AccAddress, block uint64) (providers []epochstoragetypes.StakeEntry, allowedCU uint64, errorRet error) { - var strictestPolicy projectstypes.Policy + var strictestPolicy planstypes.Policy epoch, err := k.VerifyPairingData(ctx, chainID, clientAddress, block) if err != nil { @@ -142,14 +143,14 @@ func (k Keeper) getPairingForClient(ctx sdk.Context, chainID string, clientAddre return providers, allowedCU, err } -func (k Keeper) getProjectStrictestPolicy(ctx sdk.Context, project projectstypes.Project, chainID string) (projectstypes.Policy, uint64, error) { +func (k Keeper) getProjectStrictestPolicy(ctx sdk.Context, project projectstypes.Project, chainID string) (planstypes.Policy, uint64, error) { plan, err := k.subscriptionKeeper.GetPlanFromSubscription(ctx, project.GetSubscription()) if err != nil { - return projectstypes.Policy{}, 0, err + return planstypes.Policy{}, 0, err } planPolicy := plan.GetPlanPolicy() - policies := []*projectstypes.Policy{&planPolicy} + policies := []*planstypes.Policy{&planPolicy} if project.SubscriptionPolicy != nil { policies = append(policies, project.SubscriptionPolicy) } @@ -157,26 +158,26 @@ func (k Keeper) getProjectStrictestPolicy(ctx sdk.Context, project projectstypes policies = append(policies, project.AdminPolicy) } - if !projectstypes.CheckChainIdExistsInPolicies(chainID, policies) { - return projectstypes.Policy{}, 0, fmt.Errorf("chain ID not found in any of the policies") + if !planstypes.CheckChainIdExistsInPolicies(chainID, policies) { + return planstypes.Policy{}, 0, fmt.Errorf("chain ID not found in any of the policies") } geolocation := k.CalculateEffectiveGeolocationFromPolicies(policies) providersToPair, err := k.CalculateEffectiveProvidersToPairFromPolicies(policies) if err != nil { - return projectstypes.Policy{}, 0, err + return planstypes.Policy{}, 0, err } sub, found := k.subscriptionKeeper.GetSubscription(ctx, project.GetSubscription()) if !found { - return projectstypes.Policy{}, 0, fmt.Errorf("could not find subscription with address %s", project.GetSubscription()) + return planstypes.Policy{}, 0, fmt.Errorf("could not find subscription with address %s", project.GetSubscription()) } allowedCU := k.CalculateEffectiveAllowedCuPerEpochFromPolicies(policies, project.GetUsedCu(), sub.GetMonthCuLeft()) selectedProvidersMode, selectedProvidersList := k.CalculateEffectiveSelectedProviders(policies) - strictestPolicy := projectstypes.Policy{ + strictestPolicy := planstypes.Policy{ GeolocationProfile: geolocation, MaxProvidersToPair: providersToPair, SelectedProvidersMode: selectedProvidersMode, @@ -186,12 +187,12 @@ func (k Keeper) getProjectStrictestPolicy(ctx sdk.Context, project projectstypes return strictestPolicy, allowedCU, nil } -func (k Keeper) CalculateEffectiveSelectedProviders(policies []*projectstypes.Policy) (projectstypes.SELECTED_PROVIDERS_MODE, []string) { - selectedProvidersModeList := []projectstypes.SELECTED_PROVIDERS_MODE{} +func (k Keeper) CalculateEffectiveSelectedProviders(policies []*planstypes.Policy) (planstypes.SELECTED_PROVIDERS_MODE, []string) { + selectedProvidersModeList := []planstypes.SELECTED_PROVIDERS_MODE{} selectedProvidersList := [][]string{} for _, p := range policies { selectedProvidersModeList = append(selectedProvidersModeList, p.SelectedProvidersMode) - if p.SelectedProvidersMode == projectstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE || p.SelectedProvidersMode == projectstypes.SELECTED_PROVIDERS_MODE_MIXED { + if p.SelectedProvidersMode == planstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE || p.SelectedProvidersMode == planstypes.SELECTED_PROVIDERS_MODE_MIXED { if len(p.SelectedProviders) != 0 { selectedProvidersList = append(selectedProvidersList, p.SelectedProviders) } @@ -204,7 +205,7 @@ func (k Keeper) CalculateEffectiveSelectedProviders(policies []*projectstypes.Po return effectiveMode, effectiveSelectedProviders } -func (k Keeper) CalculateEffectiveGeolocationFromPolicies(policies []*projectstypes.Policy) uint64 { +func (k Keeper) CalculateEffectiveGeolocationFromPolicies(policies []*planstypes.Policy) uint64 { geolocation := uint64(math.MaxUint64) // geolocation is a bitmap. common denominator can be calculated with logical AND @@ -217,7 +218,7 @@ func (k Keeper) CalculateEffectiveGeolocationFromPolicies(policies []*projectsty return geolocation } -func (k Keeper) CalculateEffectiveProvidersToPairFromPolicies(policies []*projectstypes.Policy) (uint64, error) { +func (k Keeper) CalculateEffectiveProvidersToPairFromPolicies(policies []*planstypes.Policy) (uint64, error) { providersToPair := uint64(math.MaxUint64) for _, policy := range policies { @@ -234,7 +235,7 @@ func (k Keeper) CalculateEffectiveProvidersToPairFromPolicies(policies []*projec return providersToPair, nil } -func (k Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies(policies []*projectstypes.Policy, cuUsedInProject uint64, cuLeftInSubscription uint64) uint64 { +func (k Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies(policies []*planstypes.Policy, cuUsedInProject uint64, cuLeftInSubscription uint64) uint64 { var policyEpochCuLimit []uint64 var policyTotalCuLimit []uint64 for _, policy := range policies { diff --git a/x/pairing/keeper/pairing_subscription_test.go b/x/pairing/keeper/pairing_subscription_test.go index ac6b52a714..2256bb6e90 100644 --- a/x/pairing/keeper/pairing_subscription_test.go +++ b/x/pairing/keeper/pairing_subscription_test.go @@ -8,6 +8,7 @@ import ( testkeeper "github.com/lavanet/lava/testutil/keeper" "github.com/lavanet/lava/utils/sigs" "github.com/lavanet/lava/x/pairing/types" + planstypes "github.com/lavanet/lava/x/plans/types" projectstypes "github.com/lavanet/lava/x/projects/types" subtypes "github.com/lavanet/lava/x/subscription/types" "github.com/stretchr/testify/require" @@ -107,7 +108,7 @@ func TestRelayPaymentSubscription(t *testing.T) { proj, err := ts.keepers.Projects.GetProjectForDeveloper(_ctx, consumer.Addr.String(), uint64(_ctx.BlockHeight())) require.Nil(t, err) - policies := []*projectstypes.Policy{proj.AdminPolicy, proj.SubscriptionPolicy, &ts.plan.PlanPolicy} + policies := []*planstypes.Policy{proj.AdminPolicy, proj.SubscriptionPolicy, &ts.plan.PlanPolicy} sub, found := ts.keepers.Subscription.GetSubscription(_ctx, proj.GetSubscription()) require.True(t, found) allowedCu := ts.keepers.Pairing.CalculateEffectiveAllowedCuPerEpochFromPolicies(policies, proj.GetUsedCu(), sub.GetMonthCuLeft()) @@ -259,11 +260,11 @@ func TestStrictestPolicyGeolocation(t *testing.T) { for _, tt := range geolocationTestTemplates { t.Run(tt.name, func(t *testing.T) { - adminPolicy := &projectstypes.Policy{ + adminPolicy := &planstypes.Policy{ GeolocationProfile: tt.geolocationAdminPolicy, MaxProvidersToPair: 2, } - subscriptionPolicy := &projectstypes.Policy{ + subscriptionPolicy := &planstypes.Policy{ GeolocationProfile: tt.geolocationSubPolicy, MaxProvidersToPair: 2, } @@ -341,11 +342,11 @@ func TestStrictestPolicyProvidersToPair(t *testing.T) { for _, tt := range providersToPairTestTemplates { t.Run(tt.name, func(t *testing.T) { - adminPolicy := &projectstypes.Policy{ + adminPolicy := &planstypes.Policy{ GeolocationProfile: 1, MaxProvidersToPair: tt.providersToPairAdminPolicy, } - subscriptionPolicy := &projectstypes.Policy{ + subscriptionPolicy := &planstypes.Policy{ GeolocationProfile: 1, MaxProvidersToPair: tt.providersToPairSubPolicy, } @@ -460,13 +461,13 @@ func TestStrictestPolicyCuPerEpoch(t *testing.T) { _ctx = sdk.UnwrapSDKContext(ts.ctx) } - adminPolicy := &projectstypes.Policy{ + adminPolicy := &planstypes.Policy{ GeolocationProfile: 1, EpochCuLimit: tt.cuPerEpochAdminPolicy, TotalCuLimit: ts.plan.PlanPolicy.TotalCuLimit, MaxProvidersToPair: ts.plan.PlanPolicy.MaxProvidersToPair, } - subscriptionPolicy := &projectstypes.Policy{ + subscriptionPolicy := &planstypes.Policy{ GeolocationProfile: 1, EpochCuLimit: tt.cuPerEpochSubPolicy, TotalCuLimit: ts.plan.PlanPolicy.TotalCuLimit, diff --git a/x/pairing/keeper/pairing_test.go b/x/pairing/keeper/pairing_test.go index 8f0bf52956..ad18636293 100644 --- a/x/pairing/keeper/pairing_test.go +++ b/x/pairing/keeper/pairing_test.go @@ -310,7 +310,7 @@ func TestSelectedProvidersPairing(t *testing.T) { ts := setupForPaymentTest(t) _ctx := sdk.UnwrapSDKContext(ts.ctx) - projPolicy := &projectstypes.Policy{ + projPolicy := &planstypes.Policy{ GeolocationProfile: math.MaxUint64, MaxProvidersToPair: 3, } @@ -318,12 +318,12 @@ func TestSelectedProvidersPairing(t *testing.T) { err := ts.addProvider(200) require.Nil(t, err) - allowed := projectstypes.SELECTED_PROVIDERS_MODE_ALLOWED - exclusive := projectstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE - disabled := projectstypes.SELECTED_PROVIDERS_MODE_DISABLED + allowed := planstypes.SELECTED_PROVIDERS_MODE_ALLOWED + exclusive := planstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE + disabled := planstypes.SELECTED_PROVIDERS_MODE_DISABLED maxProvidersToPair, err := ts.keepers.Pairing.CalculateEffectiveProvidersToPairFromPolicies( - []*projectstypes.Policy{&ts.plan.PlanPolicy, projPolicy}, + []*planstypes.Policy{&ts.plan.PlanPolicy, projPolicy}, ) require.Nil(t, err) @@ -363,9 +363,9 @@ func TestSelectedProvidersPairing(t *testing.T) { // TODO: add mixed mode test cases (once implemented) templates := []struct { name string - planMode projectstypes.SELECTED_PROVIDERS_MODE - subMode projectstypes.SELECTED_PROVIDERS_MODE - projMode projectstypes.SELECTED_PROVIDERS_MODE + planMode planstypes.SELECTED_PROVIDERS_MODE + subMode planstypes.SELECTED_PROVIDERS_MODE + projMode planstypes.SELECTED_PROVIDERS_MODE providersSet int expectedProviders int }{ diff --git a/x/plans/keeper/migrations.go b/x/plans/keeper/migrations.go index 0af275cac1..13a1779960 100644 --- a/x/plans/keeper/migrations.go +++ b/x/plans/keeper/migrations.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" v2 "github.com/lavanet/lava/x/plans/migrations/v2" "github.com/lavanet/lava/x/plans/types" - projecttypes "github.com/lavanet/lava/x/projects/types" ) type Migrator struct { @@ -34,7 +33,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { m.keeper.plansFS.ReadEntry(ctx, planIndex, block, &plan_v2) // create policy struct - planPolicy := projecttypes.Policy{ + planPolicy := types.Policy{ GeolocationProfile: uint64(1), TotalCuLimit: plan_v2.ComputeUnits, EpochCuLimit: plan_v2.ComputeUnitsPerEpoch, diff --git a/x/plans/keeper/plan_test.go b/x/plans/keeper/plan_test.go index 7744200c45..c0eb875631 100644 --- a/x/plans/keeper/plan_test.go +++ b/x/plans/keeper/plan_test.go @@ -13,7 +13,6 @@ import ( epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" "github.com/lavanet/lava/x/plans/keeper" "github.com/lavanet/lava/x/plans/types" - projectstypes "github.com/lavanet/lava/x/projects/types" "github.com/stretchr/testify/require" ) @@ -55,7 +54,7 @@ func TestPlanEntryGet(t *testing.T) { // createTestPlans returns a slice of plans for testing func createTestPlans(planAmount int, withSameIndex bool, startIndex int) []types.Plan { testPlans := []types.Plan{} - policy := projectstypes.Policy{ + policy := types.Policy{ TotalCuLimit: 1000, EpochCuLimit: 100, MaxProvidersToPair: 3, diff --git a/x/plans/types/errors.go b/x/plans/types/errors.go index 2ca9b7fda9..39fb1592bb 100644 --- a/x/plans/types/errors.go +++ b/x/plans/types/errors.go @@ -8,13 +8,18 @@ import ( // x/plan module sentinel errors var ( - ErrEmptyPlans = sdkerrors.Register(ModuleName, 1, "plans list is empty") - ErrInvalidPlanPrice = sdkerrors.Register(ModuleName, 3, "plan's price field is invalid") - ErrInvalidPlanOveruse = sdkerrors.Register(ModuleName, 4, "plan's CU overuse fields are invalid") - ErrInvalidPlanServicersToPair = sdkerrors.Register(ModuleName, 5, "plan's servicersToPair field is invalid") - ErrInvalidPlanName = sdkerrors.Register(ModuleName, 6, "plan's name field is invalid") - ErrInvalidPlanType = sdkerrors.Register(ModuleName, 7, "plan's type field is invalid") - ErrInvalidPlanDescription = sdkerrors.Register(ModuleName, 8, "plan's description field is invalid") - ErrInvalidPlanComputeUnits = sdkerrors.Register(ModuleName, 9, "plan's compute units fields are invalid") - ErrInvalidPlanAnnualDiscount = sdkerrors.Register(ModuleName, 10, "plan's annual discount field is invalid") + ErrEmptyPlans = sdkerrors.Register(ModuleName, 1, "plans list is empty") + ErrInvalidPlanPrice = sdkerrors.Register(ModuleName, 3, "plan's price field is invalid") + ErrInvalidPlanOveruse = sdkerrors.Register(ModuleName, 4, "plan's CU overuse fields are invalid") + ErrInvalidPlanServicersToPair = sdkerrors.Register(ModuleName, 5, "plan's servicersToPair field is invalid") + ErrInvalidPlanName = sdkerrors.Register(ModuleName, 6, "plan's name field is invalid") + ErrInvalidPlanType = sdkerrors.Register(ModuleName, 7, "plan's type field is invalid") + ErrInvalidPlanDescription = sdkerrors.Register(ModuleName, 8, "plan's description field is invalid") + ErrInvalidPlanComputeUnits = sdkerrors.Register(ModuleName, 9, "plan's compute units fields are invalid") + ErrInvalidPlanAnnualDiscount = sdkerrors.Register(ModuleName, 10, "plan's annual discount field is invalid") + ErrInvalidPolicyCuFields = sdkerrors.Register(ModuleName, 11, "CU per epoch field can't be larger than Total CU field") + ErrInvalidPolicyMaxProvidersToPair = sdkerrors.Register(ModuleName, 12, "MaxProvidersToPair cannot be less than 2") + ErrInvalidPolicy = sdkerrors.Register(ModuleName, 13, "Invalid policy") + ErrPolicyBasicValidation = sdkerrors.Register(ModuleName, 14, "invalid policy") + ErrInvalidSelectedProvidersConfig = sdkerrors.Register(ModuleName, 15, "plan's selected providers config is invalid") ) diff --git a/x/projects/types/policy.go b/x/plans/types/policy.go similarity index 100% rename from x/projects/types/policy.go rename to x/plans/types/policy.go diff --git a/x/plans/types/types.go b/x/plans/types/types.go index 7ce14cd374..4e346553c0 100644 --- a/x/plans/types/types.go +++ b/x/plans/types/types.go @@ -1,7 +1,32 @@ package types +import ( + "bytes" + "encoding/json" +) + const ( MAX_LEN_PLAN_NAME = 50 MAX_LEN_PLAN_DESCRIPTION = 500 MAX_LEN_PLAN_TYPE = 20 ) + +// allows unmarshaling parser func +func (s SELECTED_PROVIDERS_MODE) MarshalJSON() ([]byte, error) { + buffer := bytes.NewBufferString(`"`) + buffer.WriteString(SELECTED_PROVIDERS_MODE_name[int32(s)]) + buffer.WriteString(`"`) + return buffer.Bytes(), nil +} + +// UnmarshalJSON unmashals a quoted json string to the enum value +func (s *SELECTED_PROVIDERS_MODE) UnmarshalJSON(b []byte) error { + var j string + err := json.Unmarshal(b, &j) + if err != nil { + return err + } + // Note that if the string cannot be found then it will be set to the zero value, 'Created' in this case. + *s = SELECTED_PROVIDERS_MODE(SELECTED_PROVIDERS_MODE_value[j]) + return nil +} diff --git a/x/projects/client/cli/tx_set_admin_policy.go b/x/projects/client/cli/tx_set_admin_policy.go index 98762ea13e..a4ccac3ba3 100644 --- a/x/projects/client/cli/tx_set_admin_policy.go +++ b/x/projects/client/cli/tx_set_admin_policy.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" commontypes "github.com/lavanet/lava/common/types" + planstypes "github.com/lavanet/lava/x/plans/types" "github.com/lavanet/lava/x/projects/types" "github.com/spf13/cobra" ) @@ -30,7 +31,7 @@ func CmdSetPolicy() *cobra.Command { projectId := args[0] adminPolicyFilePath := args[1] - var policy types.Policy + var policy planstypes.Policy err = commontypes.ReadYaml(adminPolicyFilePath, "Policy", &policy) if err != nil { return err diff --git a/x/projects/client/cli/tx_set_subscription_policy.go b/x/projects/client/cli/tx_set_subscription_policy.go index 13e977c717..28bf3a807b 100644 --- a/x/projects/client/cli/tx_set_subscription_policy.go +++ b/x/projects/client/cli/tx_set_subscription_policy.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" commontypes "github.com/lavanet/lava/common/types" + planstypes "github.com/lavanet/lava/x/plans/types" "github.com/lavanet/lava/x/projects/types" "github.com/spf13/cobra" ) @@ -32,7 +33,7 @@ func CmdSetSubscriptionPolicy() *cobra.Command { subscriptionPolicyFilePath := args[1] - var policy types.Policy + var policy planstypes.Policy err = commontypes.ReadYaml(subscriptionPolicyFilePath, "Policy", &policy) if err != nil { return err diff --git a/x/projects/keeper/project.go b/x/projects/keeper/project.go index 7494e2f562..7fa01125e7 100644 --- a/x/projects/keeper/project.go +++ b/x/projects/keeper/project.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" commontypes "github.com/lavanet/lava/common/types" "github.com/lavanet/lava/utils" + planstypes "github.com/lavanet/lava/x/plans/types" "github.com/lavanet/lava/x/projects/types" ) @@ -177,7 +178,7 @@ func (k Keeper) ChargeComputeUnitsToProject(ctx sdk.Context, project types.Proje return nil } -func (k Keeper) SetProjectPolicy(ctx sdk.Context, projectIDs []string, policy *types.Policy, key string, setPolicyEnum types.SetPolicyEnum) error { +func (k Keeper) SetProjectPolicy(ctx sdk.Context, projectIDs []string, policy *planstypes.Policy, key string, setPolicyEnum types.SetPolicyEnum) error { ctxBlock := uint64(ctx.BlockHeight()) nextEpoch, err := k.epochstorageKeeper.GetNextEpoch(ctx, ctxBlock) if err != nil { diff --git a/x/projects/keeper/project_test.go b/x/projects/keeper/project_test.go index e829be7173..e6bc67d04a 100644 --- a/x/projects/keeper/project_test.go +++ b/x/projects/keeper/project_test.go @@ -83,7 +83,7 @@ func (ts *testStruct) prepareData(numSub, numAdmin, numDevel int) { types.ProjectDeveloperKey(ts.accounts["pd3_dev"]), } - policy1 := &types.Policy{ + policy1 := &planstypes.Policy{ GeolocationProfile: math.MaxUint64, MaxProvidersToPair: 2, } @@ -93,7 +93,7 @@ func (ts *testStruct) prepareData(numSub, numAdmin, numDevel int) { name string enabled bool keys []types.ProjectKey - policy *types.Policy + policy *planstypes.Policy }{ // project with admin key, enabled, has policy {"pd1", "mock_project_1", true, keys_1_admin, policy1}, @@ -518,7 +518,7 @@ func setPolicyTest(t *testing.T, testAdminPolicy bool) { creator string projectID string geolocation uint64 - chainPolicies []types.ChainPolicy + chainPolicies []planstypes.ChainPolicy totalCuLimit uint64 epochCuLimit uint64 maxProvidersToPair uint64 @@ -527,68 +527,68 @@ func setPolicyTest(t *testing.T, testAdminPolicy bool) { }{ { "valid policy (admin account)", admAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, true, false, }, { "valid policy (subscription account)", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, true, true, }, { "bad creator (developer account -- not admin)", devAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, false, false, }, { "bad projectID (doesn't exist)", devAddr, "fakeProjectId", uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, false, false, }, { "invalid geolocation (0)", devAddr, projectID, uint64(0), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, false, false, }, { // note: currently, we don't verify the chain policies "bad chainID (doesn't exist)", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: "LOL", Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: "LOL", Apis: []string{spec.Apis[0].Name}}}, 100, 10, 3, true, true, }, { // note: currently, we don't verify the chain policies "bad API (doesn't exist)", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{"lol"}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{"lol"}}}, 100, 10, 3, true, true, }, { // note: currently, we don't verify the chain policies "chainID and API not supported (exist in Lava's specs)", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: "ETH1", Apis: []string{"eth_accounts"}}}, + []planstypes.ChainPolicy{{ChainId: "ETH1", Apis: []string{"eth_accounts"}}}, 100, 10, 3, true, true, }, { "epoch CU larger than total CU", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 10, 100, 3, false, false, }, { "bad maxProvidersToPair", subAddr, projectID, uint64(1), - []types.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, + []planstypes.ChainPolicy{{ChainId: spec.Index, Apis: []string{spec.Apis[0].Name}}}, 100, 10, 1, false, false, }, } for _, tt := range templates { t.Run(tt.name, func(t *testing.T) { - newPolicy := types.Policy{ + newPolicy := planstypes.Policy{ ChainPolicies: tt.chainPolicies, GeolocationProfile: tt.geolocation, TotalCuLimit: tt.totalCuLimit, @@ -879,15 +879,15 @@ func TestSetPolicySelectedProviders(t *testing.T) { Name: "name", Enabled: true, ProjectKeys: []types.ProjectKey{{Key: adm1Addr, Kinds: uint32(types.ProjectKey_ADMIN)}}, - Policy: &types.Policy{MaxProvidersToPair: 2, GeolocationProfile: math.MaxUint64}, + Policy: &planstypes.Policy{MaxProvidersToPair: 2, GeolocationProfile: math.MaxUint64}, } subAddr := projectData.ProjectKeys[0].Key projPolicy := projectData.Policy - allowed := types.SELECTED_PROVIDERS_MODE_ALLOWED - mixed := types.SELECTED_PROVIDERS_MODE_MIXED - exclusive := types.SELECTED_PROVIDERS_MODE_EXCLUSIVE - disabled := types.SELECTED_PROVIDERS_MODE_DISABLED + allowed := planstypes.SELECTED_PROVIDERS_MODE_ALLOWED + mixed := planstypes.SELECTED_PROVIDERS_MODE_MIXED + exclusive := planstypes.SELECTED_PROVIDERS_MODE_EXCLUSIVE + disabled := planstypes.SELECTED_PROVIDERS_MODE_DISABLED providersSets := []struct { planProviders []string @@ -904,9 +904,9 @@ func TestSetPolicySelectedProviders(t *testing.T) { templates := []struct { name string - planMode types.SELECTED_PROVIDERS_MODE - subMode types.SELECTED_PROVIDERS_MODE - projMode types.SELECTED_PROVIDERS_MODE + planMode planstypes.SELECTED_PROVIDERS_MODE + subMode planstypes.SELECTED_PROVIDERS_MODE + projMode planstypes.SELECTED_PROVIDERS_MODE providerSet int planPolicyValid bool subPolicyValid bool diff --git a/x/projects/types/errors.go b/x/projects/types/errors.go index 3903b41ae4..bc3c76ae1f 100644 --- a/x/projects/types/errors.go +++ b/x/projects/types/errors.go @@ -8,10 +8,5 @@ import ( // x/projects module sentinel errors var ( - ErrInvalidPolicyCuFields = sdkerrors.Register(ModuleName, 1099, "CU per epoch field can't be larger than Total CU field") - ErrInvalidPolicyMaxProvidersToPair = sdkerrors.Register(ModuleName, 1101, "MaxProvidersToPair cannot be less than 2") - ErrInvalidPolicy = sdkerrors.Register(ModuleName, 1102, "Invalid policy") - ErrPolicyBasicValidation = sdkerrors.Register(ModuleName, 1100, "invalid policy") - ErrInvalidKeyType = sdkerrors.Register(ModuleName, 1103, "invalid project key type") - ErrInvalidSelectedProvidersConfig = sdkerrors.Register(ModuleName, 1104, "plan's selected providers config is invalid") + ErrInvalidKeyType = sdkerrors.Register(ModuleName, 1100, "invalid project key type") ) diff --git a/x/projects/types/message_set_admin_policy.go b/x/projects/types/message_set_admin_policy.go index 14352e7488..b9224cd96d 100644 --- a/x/projects/types/message_set_admin_policy.go +++ b/x/projects/types/message_set_admin_policy.go @@ -3,13 +3,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + planstypes "github.com/lavanet/lava/x/plans/types" ) const TypeMsgSetPolicy = "set_admin_policy" var _ sdk.Msg = &MsgSetPolicy{} -func NewMsgSetPolicy(creator string, project string, policy Policy) *MsgSetPolicy { +func NewMsgSetPolicy(creator string, project string, policy planstypes.Policy) *MsgSetPolicy { return &MsgSetPolicy{ Creator: creator, Project: project, diff --git a/x/projects/types/message_set_admin_policy_test.go b/x/projects/types/message_set_admin_policy_test.go index e090678a79..0d3b5200e9 100644 --- a/x/projects/types/message_set_admin_policy_test.go +++ b/x/projects/types/message_set_admin_policy_test.go @@ -5,6 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/lavanet/lava/testutil/sample" + planstypes "github.com/lavanet/lava/x/plans/types" "github.com/stretchr/testify/require" ) @@ -18,7 +19,7 @@ func TestMsgSetPolicy_ValidateBasic(t *testing.T) { name: "invalid address", msg: MsgSetPolicy{ Creator: "invalid_address", - Policy: Policy{ + Policy: planstypes.Policy{ EpochCuLimit: 100, TotalCuLimit: 1000, MaxProvidersToPair: 3, @@ -29,7 +30,7 @@ func TestMsgSetPolicy_ValidateBasic(t *testing.T) { name: "valid address", msg: MsgSetPolicy{ Creator: sample.AccAddress(), - Policy: Policy{ + Policy: planstypes.Policy{ EpochCuLimit: 100, TotalCuLimit: 1000, MaxProvidersToPair: 3, diff --git a/x/projects/types/message_set_subscription_policy.go b/x/projects/types/message_set_subscription_policy.go index 26986f0773..7abf1c469e 100644 --- a/x/projects/types/message_set_subscription_policy.go +++ b/x/projects/types/message_set_subscription_policy.go @@ -3,13 +3,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + planstypes "github.com/lavanet/lava/x/plans/types" ) const TypeMsgSetSubscriptionPolicy = "set_subscription_policy" var _ sdk.Msg = &MsgSetSubscriptionPolicy{} -func NewMsgSetSubscriptionPolicy(creator string, projects []string, policy Policy) *MsgSetSubscriptionPolicy { +func NewMsgSetSubscriptionPolicy(creator string, projects []string, policy planstypes.Policy) *MsgSetSubscriptionPolicy { return &MsgSetSubscriptionPolicy{ Creator: creator, Projects: projects, diff --git a/x/projects/types/message_set_subscription_policy_test.go b/x/projects/types/message_set_subscription_policy_test.go index 26c60fac7b..6a30393dd9 100644 --- a/x/projects/types/message_set_subscription_policy_test.go +++ b/x/projects/types/message_set_subscription_policy_test.go @@ -5,6 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/lavanet/lava/testutil/sample" + planstypes "github.com/lavanet/lava/x/plans/types" "github.com/stretchr/testify/require" ) @@ -18,7 +19,7 @@ func TestMsgSetSubscriptionPolicy_ValidateBasic(t *testing.T) { name: "invalid address", msg: MsgSetSubscriptionPolicy{ Creator: "invalid_address", - Policy: Policy{ + Policy: planstypes.Policy{ EpochCuLimit: 10, TotalCuLimit: 100, MaxProvidersToPair: 3, @@ -29,7 +30,7 @@ func TestMsgSetSubscriptionPolicy_ValidateBasic(t *testing.T) { name: "valid address", msg: MsgSetSubscriptionPolicy{ Creator: sample.AccAddress(), - Policy: Policy{ + Policy: planstypes.Policy{ EpochCuLimit: 10, TotalCuLimit: 100, MaxProvidersToPair: 3, diff --git a/x/projects/types/types.go b/x/projects/types/types.go index 96580dcff3..05c76964d3 100644 --- a/x/projects/types/types.go +++ b/x/projects/types/types.go @@ -1,10 +1,5 @@ package types -import ( - "bytes" - "encoding/json" -) - const ( MAX_PROJECT_NAME_LEN = 50 ) @@ -21,23 +16,3 @@ const ( AddProjectKeyEventName = "add_key_to_project_event" DelProjectKeyEventName = "del_key_from_project_event" ) - -// allows unmarshaling parser func -func (s SELECTED_PROVIDERS_MODE) MarshalJSON() ([]byte, error) { - buffer := bytes.NewBufferString(`"`) - buffer.WriteString(SELECTED_PROVIDERS_MODE_name[int32(s)]) - buffer.WriteString(`"`) - return buffer.Bytes(), nil -} - -// UnmarshalJSON unmashals a quoted json string to the enum value -func (s *SELECTED_PROVIDERS_MODE) UnmarshalJSON(b []byte) error { - var j string - err := json.Unmarshal(b, &j) - if err != nil { - return err - } - // Note that if the string cannot be found then it will be set to the zero value, 'Created' in this case. - *s = SELECTED_PROVIDERS_MODE(SELECTED_PROVIDERS_MODE_value[j]) - return nil -} diff --git a/x/subscription/client/cli/tx_add_project.go b/x/subscription/client/cli/tx_add_project.go index cc9e10c3ce..591a85329a 100644 --- a/x/subscription/client/cli/tx_add_project.go +++ b/x/subscription/client/cli/tx_add_project.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" commontypes "github.com/lavanet/lava/common/types" "github.com/lavanet/lava/utils" + planstypes "github.com/lavanet/lava/x/plans/types" projectstypes "github.com/lavanet/lava/x/projects/types" "github.com/lavanet/lava/x/subscription/types" "github.com/spf13/cobra" @@ -44,7 +45,7 @@ func CmdAddProject() *cobra.Command { creator := clientCtx.GetFromAddress().String() - var policy *projectstypes.Policy + var policy *planstypes.Policy policyFilePath, err := cmd.Flags().GetString("policy-file") if err != nil { diff --git a/x/subscription/keeper/subscription_test.go b/x/subscription/keeper/subscription_test.go index 5d66dbe133..aefa16c405 100644 --- a/x/subscription/keeper/subscription_test.go +++ b/x/subscription/keeper/subscription_test.go @@ -445,7 +445,7 @@ func TestMonthlyRechargeCU(t *testing.T) { ProjectKeys: []projectstypes.ProjectKey{ projectstypes.ProjectDeveloperKey(anotherAccount.Addr.String()), }, - Policy: &projectstypes.Policy{ + Policy: &planstypes.Policy{ GeolocationProfile: uint64(1), TotalCuLimit: 1000, EpochCuLimit: 100, diff --git a/x/subscription/types/message_add_project_test.go b/x/subscription/types/message_add_project_test.go index 439b99590a..abd775c0c1 100644 --- a/x/subscription/types/message_add_project_test.go +++ b/x/subscription/types/message_add_project_test.go @@ -5,6 +5,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/lavanet/lava/testutil/sample" + planstypes "github.com/lavanet/lava/x/plans/types" projectstypes "github.com/lavanet/lava/x/projects/types" "github.com/stretchr/testify/require" ) @@ -21,7 +22,7 @@ func TestMsgAddProject_ValidateBasic(t *testing.T) { Creator: "invalid_address", ProjectData: projectstypes.ProjectData{ Name: "validName", - Policy: &projectstypes.Policy{MaxProvidersToPair: 3}, + Policy: &planstypes.Policy{MaxProvidersToPair: 3}, ProjectKeys: []projectstypes.ProjectKey{ projectstypes.ProjectAdminKey("invalid address"), }, @@ -34,7 +35,7 @@ func TestMsgAddProject_ValidateBasic(t *testing.T) { Creator: sample.AccAddress(), ProjectData: projectstypes.ProjectData{ Name: "validName", - Policy: &projectstypes.Policy{MaxProvidersToPair: 3}, + Policy: &planstypes.Policy{MaxProvidersToPair: 3}, ProjectKeys: []projectstypes.ProjectKey{ projectstypes.ProjectAdminKey(sample.AccAddress()), },