Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: CNS 930: new epoch payments objects #1335

Merged
merged 39 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eedddfe
CNS-930: define proto of new epoch cu structs
oren-lava Mar 20, 2024
209b607
CNS-930: create epoch CU objects + basic unit tests
oren-lava Mar 24, 2024
2223677
CNS-930: updated epoch CU objects implementation
oren-lava Mar 25, 2024
d9f7a54
CNS-930: added check for valid key when decoding
oren-lava Mar 25, 2024
7f3d3dd
CNS-930: updated genesis with new epoch cu objects
oren-lava Mar 25, 2024
cec2043
CNS-930: added chain ID to epoch CU objects
oren-lava Mar 25, 2024
47eb662
CNS-930: change the epoch payments mechanism to the new one
oren-lava Mar 26, 2024
5a8b1f1
CNS-930: add fixed time work around for time dependent unit tests
oren-lava Mar 26, 2024
46c69de
CNS-930: added provider epoch CU query and updated E2E
oren-lava Mar 26, 2024
7a65221
CNS-930: migrator
oren-lava Mar 26, 2024
bc04778
Merge branch 'main' into CNS-930-begin-block-may-take-too-long
oren-lava Mar 26, 2024
e820d36
CNS-930: lint fixes
oren-lava Mar 26, 2024
3e4937a
CNS-930: changed query name ProviderEpochCu to ProvidersEpochCu
oren-lava Mar 27, 2024
35e283c
CNS-930: changed UniqueEpochSessionGenesis to hold the decoded key
oren-lava Mar 27, 2024
e861f77
CNS-930: change functions names
oren-lava Mar 27, 2024
ebb7dc0
CNS-930: change get all store return types
oren-lava Mar 27, 2024
355a78f
CNS-930: fix TODO
oren-lava Mar 27, 2024
f25f922
CNS-930: change unique session key order
oren-lava Mar 27, 2024
c4f20a3
CNS-930: improve unresponsive CU count efficiency
oren-lava Mar 27, 2024
1b4d203
CNS-930: insert the epoch to the key
oren-lava Mar 27, 2024
82daa93
CNS-930: add cache to epoch CU
oren-lava Mar 27, 2024
778c749
CNS-930: small fix
oren-lava Mar 28, 2024
817e18b
CNS-930: lint
oren-lava Mar 28, 2024
d190137
Merge branch 'main' into CNS-930-begin-block-may-take-too-long
oren-lava Mar 28, 2024
aa3c7b9
CNS-930: fix protocol proto script
oren-lava Mar 28, 2024
ec2852e
updated
oren-lava Mar 28, 2024
d5cd7b8
Revert "updated"
oren-lava Mar 28, 2024
a04a6b5
CNS-930: change GetAllProviderConsumerEpochCu return type
oren-lava Mar 28, 2024
04683ca
CNS-930: update unresponsive count to be efficient
oren-lava Mar 28, 2024
faea0af
CNS-930: small PR fix
oren-lava Apr 1, 2024
51c70a2
CNS-930: another small PR fix
oren-lava Apr 1, 2024
60bdeb0
CNS-930: sort complainedProviders keys
oren-lava Apr 1, 2024
23ed82a
CNS-930: small PR fix
oren-lava Apr 2, 2024
8a92426
make a object just for complainer cu
Apr 3, 2024
d8a16e9
encode uint instead of convert to string
Apr 3, 2024
62bd971
fix iterators
Apr 3, 2024
817f645
Merge branch 'main' into CNS-930-begin-block-may-take-too-long
Yaroms Apr 3, 2024
c5127a4
validate genesis
Apr 3, 2024
2895ff6
Merge branch 'CNS-930-begin-block-may-take-too-long' of github.com:la…
Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ecosystem/lava-sdk/scripts/protoc_grpc_relay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ protoc \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/badges.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/params.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/query.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/provider_payment_storage.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/unique_payment_storage_client_provider.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/subscription/subscription.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/projects/project.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/plans/policy.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/epoch_payments.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/pairing/epoch_cu.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/spec/spec.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/spec/api_collection.proto" \
"$LAVA_PROTO_DIR/lavanet/lava/epochstorage/stake_entry.proto" \
Expand Down
24 changes: 24 additions & 0 deletions proto/lavanet/lava/pairing/epoch_cu.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";
package lavanet.lava.pairing;

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

// UniqueEpochSession is used to detect double spend attacks
// It's kept in a epoch-prefixed store with a unique index: provider, project ID, chain ID and session ID
message UniqueEpochSession {
}

// ProviderEpochCu is used to track the CU of a specific provider in a specific epoch
// It's kept in a epoch-prefixed store with a unique index: provider address
message ProviderEpochCu {
uint64 serviced_cu = 1;
uint64 complainers_cu = 2;
}

// ProviderConsumerEpochCu is used to track the CU between a specific provider and
// consumer in a specific epoch
// It's kept in a epoch-prefixed store with a unique index: provider and project ID
message ProviderConsumerEpochCu {
uint64 cu = 1;
}

11 changes: 0 additions & 11 deletions proto/lavanet/lava/pairing/epoch_payments.proto

This file was deleted.

36 changes: 30 additions & 6 deletions proto/lavanet/lava/pairing/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package lavanet.lava.pairing;

import "gogoproto/gogo.proto";
import "lavanet/lava/pairing/params.proto";
import "lavanet/lava/pairing/unique_payment_storage_client_provider.proto";
import "lavanet/lava/pairing/provider_payment_storage.proto";
import "lavanet/lava/pairing/epoch_payments.proto";
import "lavanet/lava/pairing/epoch_cu.proto";
import "lavanet/lava/fixationstore/fixation.proto";
import "lavanet/lava/timerstore/timer.proto";

Expand All @@ -21,11 +19,37 @@ message BadgeUsedCu {
// GenesisState defines the pairing module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated UniquePaymentStorageClientProvider uniquePaymentStorageClientProviderList = 2 [(gogoproto.nullable) = false];
repeated ProviderPaymentStorage providerPaymentStorageList = 3 [(gogoproto.nullable) = false];
repeated EpochPayments epochPaymentsList = 4 [(gogoproto.nullable) = false];
reserved 2;
reserved 3;
reserved 4;
repeated BadgeUsedCu badgeUsedCuList = 5 [(gogoproto.nullable) = false];
lavanet.lava.timerstore.GenesisState badgesTS = 6 [(gogoproto.nullable) = false];
lavanet.lava.fixationstore.GenesisState providerQosFS = 7 [(gogoproto.nullable) = false];
repeated UniqueEpochSessionGenesis unique_epoch_sessions = 8 [(gogoproto.nullable) = false];
repeated ProviderEpochCuGenesis provider_epoch_cus = 9 [(gogoproto.nullable) = false];
repeated ProviderConsumerEpochCuGenesis provider_consumer_epoch_cus = 10 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}

message UniqueEpochSessionGenesis {
uint64 epoch = 1;
string provider = 2;
string project = 3;
string chain_id = 4;
uint64 session_id = 5;
}

message ProviderEpochCuGenesis {
uint64 epoch = 1;
string provider = 2;
string chain_id = 3;
ProviderEpochCu provider_epoch_cu = 4 [(gogoproto.nullable) = false];
}

message ProviderConsumerEpochCuGenesis {
uint64 epoch = 1;
string provider = 2;
string project = 3;
string chain_id = 4;
ProviderConsumerEpochCu provider_consumer_epoch_cu = 5 [(gogoproto.nullable) = false];
}
23 changes: 0 additions & 23 deletions proto/lavanet/lava/pairing/provider_payment_storage.proto

This file was deleted.

113 changes: 23 additions & 90 deletions proto/lavanet/lava/pairing/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "lavanet/lava/pairing/params.proto";
import "lavanet/lava/pairing/epoch_payments.proto";
import "lavanet/lava/spec/spec.proto";


// this line is used by starport scaffolding # 1
import "lavanet/lava/plans/policy.proto";
import "lavanet/lava/pairing/provider_payment_storage.proto";
import "lavanet/lava/pairing/unique_payment_storage_client_provider.proto";
import "lavanet/lava/epochstorage/stake_entry.proto";
import "lavanet/lava/subscription/subscription.proto";
import "lavanet/lava/projects/project.proto";
Expand Down Expand Up @@ -42,36 +39,6 @@ service Query {
option (google.api.http).get = "/lavanet/lava/pairing/verify_pairing/{chainID}/{client}/{provider}/{block}";
}

// Queries a UniquePaymentStorageClientProvider by index.
rpc UniquePaymentStorageClientProvider(QueryGetUniquePaymentStorageClientProviderRequest) returns (QueryGetUniquePaymentStorageClientProviderResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/unique_payment_storage_client_provider/{index}";
}

// Queries a list of UniquePaymentStorageClientProvider items.
rpc UniquePaymentStorageClientProviderAll(QueryAllUniquePaymentStorageClientProviderRequest) returns (QueryAllUniquePaymentStorageClientProviderResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/unique_payment_storage_client_provider";
}

// Queries a ProviderPaymentStorage by index.
rpc ProviderPaymentStorage(QueryGetProviderPaymentStorageRequest) returns (QueryGetProviderPaymentStorageResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/provider_payment_storage/{index}";
}

// Queries a list of ProviderPaymentStorage items.
rpc ProviderPaymentStorageAll(QueryAllProviderPaymentStorageRequest) returns (QueryAllProviderPaymentStorageResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/provider_payment_storage";
}

// Queries a EpochPayments by index.
rpc EpochPayments(QueryGetEpochPaymentsRequest) returns (QueryGetEpochPaymentsResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/epoch_payments/{index}";
}

// Queries a list of EpochPayments items.
rpc EpochPaymentsAll(QueryAllEpochPaymentsRequest) returns (QueryAllEpochPaymentsResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/epoch_payments";
}

// Queries a UserEntry items.
rpc UserEntry(QueryUserEntryRequest) returns (QueryUserEntryResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/user_entry/{address}/{chainID}";
Expand All @@ -97,11 +64,18 @@ service Query {
option (google.api.http).get = "/lavanet/lava/pairing/subscription_monthly_payout/{consumer}";
}

// this line is used by starport scaffolding # 2
// Queries a list of SdkPairing items.
rpc SdkPairing (QueryGetPairingRequest) returns (QuerySdkPairingResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/sdk_pairing";
// Queries a list of SdkPairing items.
rpc SdkPairing (QueryGetPairingRequest) returns (QuerySdkPairingResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/sdk_pairing";
}

// Queries a for the aggregated CU of all ProviderEpochCu objects all the providers.
rpc ProvidersEpochCu(QueryProvidersEpochCuRequest) returns (QueryProvidersEpochCuResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/providers_epoch_cu";
}

// this line is used by starport scaffolding # 2

}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down Expand Up @@ -151,59 +125,6 @@ message QueryVerifyPairingResponse {
string project_id = 5;
}

message QueryGetUniquePaymentStorageClientProviderRequest {
string index = 1;
}

message QueryGetUniquePaymentStorageClientProviderResponse {
UniquePaymentStorageClientProvider uniquePaymentStorageClientProvider = 1 [(gogoproto.nullable) = false];
}

message QueryAllUniquePaymentStorageClientProviderRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllUniquePaymentStorageClientProviderResponse {
repeated UniquePaymentStorageClientProvider uniquePaymentStorageClientProvider = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryGetProviderPaymentStorageRequest {
string index = 1;

}

message QueryGetProviderPaymentStorageResponse {
ProviderPaymentStorage providerPaymentStorage = 1 [(gogoproto.nullable) = false];
}

message QueryAllProviderPaymentStorageRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllProviderPaymentStorageResponse {
repeated ProviderPaymentStorage providerPaymentStorage = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryGetEpochPaymentsRequest {
string index = 1;

}

message QueryGetEpochPaymentsResponse {
EpochPayments epochPayments = 1 [(gogoproto.nullable) = false];
}

message QueryAllEpochPaymentsRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllEpochPaymentsResponse {
repeated EpochPayments epochPayments = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryUserEntryRequest {
string address = 1;
string chainID = 2;
Expand Down Expand Up @@ -276,3 +197,15 @@ message QuerySubscriptionMonthlyPayoutResponse {
uint64 total = 1;
repeated ChainIDPayout details = 2;
}

message QueryProvidersEpochCuRequest {
}

message QueryProvidersEpochCuResponse {
repeated ProviderCuInfo info = 1 [(gogoproto.nullable) = false];
}

message ProviderCuInfo {
string provider = 1;
uint64 cu = 2;
}

This file was deleted.

4 changes: 1 addition & 3 deletions scripts/cli_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ trace lavad q pairing params >/dev/null
trace lavad q pairing account-info $(lavad keys show alice -a) >/dev/null
trace lavad q pairing effective-policy ETH1 $(lavad keys show alice -a) >/dev/null
trace lavad q pairing get-pairing STRK $(lavad keys show alice -a) >/dev/null
trace lavad q pairing list-epoch-payments >/dev/null
trace lavad q pairing list-provider-payment-storage >/dev/null
trace lavad q pairing list-unique-payment-storage-client-provider >/dev/null
trace lavad q pairing provider-epoch-cu $(lavad keys show servicer1) >/dev/null
trace lavad q pairing providers STRK >/dev/null
trace lavad q pairing sdk-pairing STRK $(lavad keys show alice -a) >/dev/null
trace lavad q pairing provider-monthly-payout $(lavad keys show servicer1 -a) >/dev/null
Expand Down
12 changes: 6 additions & 6 deletions testutil/common/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,12 +788,6 @@ func (ts *Tester) QueryPairingGetPairing(chainID, client string) (*pairingtypes.
return ts.Keepers.Pairing.GetPairing(ts.GoCtx, msg)
}

// QueryPairingListEpochPayments implements 'q pairing list-epoch-payments'
func (ts *Tester) QueryPairingListEpochPayments() (*pairingtypes.QueryAllEpochPaymentsResponse, error) {
msg := &pairingtypes.QueryAllEpochPaymentsRequest{}
return ts.Keepers.Pairing.EpochPaymentsAll(ts.GoCtx, msg)
}

// QueryPairingProviders: implement 'q pairing providers'
func (ts *Tester) QueryPairingProviders(chainID string, frozen bool) (*pairingtypes.QueryProvidersResponse, error) {
msg := &pairingtypes.QueryProvidersRequest{
Expand Down Expand Up @@ -831,6 +825,12 @@ func (ts *Tester) QueryPairingProviderMonthlyPayout(provider string) (*pairingty
return ts.Keepers.Pairing.ProviderMonthlyPayout(ts.GoCtx, msg)
}

// QueryPairingProviderEpochCu implements 'q pairing provider-epoch-cu'
func (ts *Tester) QueryPairingProviderEpochCu(provider string, project string, chainID string) (*pairingtypes.QueryProvidersEpochCuResponse, error) {
msg := &pairingtypes.QueryProvidersEpochCuRequest{}
return ts.Keepers.Pairing.ProvidersEpochCu(ts.GoCtx, msg)
}

// QueryPairingSubscriptionMonthlyPayout implements 'q pairing subscription-monthly-payout'
func (ts *Tester) QueryPairingSubscriptionMonthlyPayout(consumer string) (*pairingtypes.QuerySubscriptionMonthlyPayoutResponse, error) {
msg := &pairingtypes.QuerySubscriptionMonthlyPayoutRequest{
Expand Down
Loading
Loading