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: PRT - add lava consumer blocked providers metrics #1919

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
95fb038
CNS-1002: collect raw qos data
oren-lava Jul 31, 2024
a6c389b
CNS-1002: fix isHangingApi arg
oren-lava Jul 31, 2024
6302237
CNS-1003: install collections
oren-lava Jul 31, 2024
40f8187
CNS-1003: implemented reputation
oren-lava Aug 1, 2024
9535548
CNS-1003: rename providerQosFs to reputationsFS
oren-lava Aug 1, 2024
47a5a69
CNS-1003: add reputation pairing score functions
oren-lava Aug 1, 2024
365eb89
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 4, 2024
c83351d
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 4, 2024
68b1c3f
CNS-1003: minor changes
oren-lava Aug 4, 2024
c047f2d
CNS-1003: add small comment
oren-lava Aug 4, 2024
618c0ab
CNS-1002: report qos excellence for reputation only if consumer geo =…
oren-lava Aug 4, 2024
0ceea02
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 4, 2024
759bf83
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 4, 2024
9d37f1d
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 4, 2024
f2ac762
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 4, 2024
74bcc55
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 4, 2024
95a365d
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 5, 2024
d381d7b
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 5, 2024
54a0136
CNS-1004: implement qos excellence score aggregation from relay payments
oren-lava Aug 5, 2024
e3f0183
CNS-1004: unit tests
oren-lava Aug 5, 2024
8613a69
CNS-1003: revert change in protoc_grpc_relay.sh
oren-lava Aug 5, 2024
4471779
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 5, 2024
44f6f9b
CNS-1005: implement decay factor
oren-lava Aug 6, 2024
e79b17c
CNS-1003: add stake to reputation and remove ref indices
oren-lava Aug 6, 2024
d1a4117
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 6, 2024
e655ba7
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 6, 2024
883c25c
CNS-1005: update reputation on epoch start and set repuation pairing …
oren-lava Aug 6, 2024
cd3db87
CNS-1003: minor changes
oren-lava Aug 6, 2024
841e0e8
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 6, 2024
32a544c
CNS-1004: add stake to reputation
oren-lava Aug 6, 2024
f478f6c
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 6, 2024
820f179
CNS-1005: fix error comments
oren-lava Aug 6, 2024
1a599a0
CNS-1004: add stake check in unit test
oren-lava Aug 7, 2024
350b1d9
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 7, 2024
82faf7f
CNS-1005: add support for reputation pairing req (currently disabled)
oren-lava Aug 7, 2024
f4eb857
CNS-1005: remove redundant func
oren-lava Aug 7, 2024
351ce37
CNS-1003: make default QoS score zero
oren-lava Aug 7, 2024
5e56157
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 7, 2024
949e80f
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 7, 2024
a8b0b79
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 8, 2024
48757ca
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 8, 2024
2ff09f5
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 8, 2024
539f403
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 8, 2024
36c47b3
CNS-1005: small fixes
oren-lava Aug 11, 2024
ce24252
CNS-1005: make higher pairing score for lower QoS score and make func…
oren-lava Aug 12, 2024
7bf01ba
CNS-1005: partial unit tests
oren-lava Aug 12, 2024
1215c13
CNS-1005: unit tests
oren-lava Aug 12, 2024
994e762
CNS-1004: minor adds
oren-lava Aug 13, 2024
f87d8b7
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 13, 2024
a160860
CNS-1006: impelemnted queries and partial unit test
oren-lava Aug 15, 2024
37cd180
CNS-1006: small adjustments and README update
oren-lava Aug 15, 2024
d452aff
CNS-1006: small fix and added unit test
oren-lava Aug 15, 2024
628f795
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 15, 2024
37471dc
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 15, 2024
13deb57
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 15, 2024
d115877
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 15, 2024
fc75fd0
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Aug 15, 2024
b1de86e
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Aug 29, 2024
eb40078
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Aug 29, 2024
31f5ddd
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Aug 29, 2024
8da9b2f
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Aug 29, 2024
489fb2d
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Aug 29, 2024
9aa311a
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Sep 4, 2024
468e86a
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Sep 4, 2024
21e2819
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Sep 4, 2024
8a34d74
CNS-1004: fix after merge
oren-lava Sep 4, 2024
f540b6e
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Sep 4, 2024
a6d45f2
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Sep 4, 2024
b6d2063
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Dec 5, 2024
760c63c
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Dec 5, 2024
b7c747f
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Dec 5, 2024
e374c8b
small fixes
oren-lava Dec 5, 2024
e5df7d1
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Dec 5, 2024
b47f2e0
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Dec 5, 2024
5ddcf1e
Merge branch 'CNS-1001-qos-params' into CNS-1002-collect-qos-raw-data
oren-lava Jan 5, 2025
26cb521
Merge branch 'CNS-1002-collect-qos-raw-data' into CNS-1003-reputation…
oren-lava Jan 5, 2025
62eb5c0
PR fixes
oren-lava Jan 5, 2025
c7e2a57
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Jan 5, 2025
5ad9aae
pr fix
oren-lava Jan 5, 2025
1828192
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Jan 5, 2025
0b0e719
remove panics from reputation update failure
oren-lava Jan 5, 2025
094ee32
various commnets and small fixes
oren-lava Jan 5, 2025
0989d8d
avoid string parsing
oren-lava Jan 5, 2025
f160ec7
fix bug in which TimeLastUpdated was updated every relay payment and …
oren-lava Jan 6, 2025
83e399b
Merge branch 'main' into CNS-1003-reputation-proto-definitions
Yaroms Jan 6, 2025
a18e894
Merge branch 'main' into CNS-1003-reputation-proto-definitions
Yaroms Jan 6, 2025
ee2cf55
upon update calculate variance first and then the score
oren-lava Jan 6, 2025
0cd75a5
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Jan 6, 2025
e86b10c
fix unit test
oren-lava Jan 6, 2025
2ffb2e1
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Jan 6, 2025
c30845f
fix lint and unit test
oren-lava Jan 7, 2025
0ccad7c
comment fix
oren-lava Jan 7, 2025
2262838
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Jan 7, 2025
600464d
pr fixes
oren-lava Jan 9, 2025
3f0248d
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Jan 9, 2025
5073c38
small PR fixes
oren-lava Jan 9, 2025
2303348
change half life param to be uint64
oren-lava Jan 9, 2025
6219043
delete pairing query cache
oren-lava Jan 12, 2025
e24a5f1
Merge branch 'main' into CNS-1003-reputation-proto-definitions
oren-lava Jan 12, 2025
eb405f0
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Jan 12, 2025
5fe5fac
Merge branch 'CNS-1004-reputation-qos-score-aggregation' into CNS-100…
oren-lava Jan 12, 2025
87fb340
delete pairing query cache
oren-lava Jan 12, 2025
b919b1e
calculate exp without floats
oren-lava Jan 12, 2025
97b42c1
Merge branch 'CNS-1005-reputation-pairing-score' into CNS-1006-reputa…
oren-lava Jan 12, 2025
859642d
change query arg name
oren-lava Jan 12, 2025
c2512e2
Merge pull request #1631 from lavanet/CNS-1006-reputation-queries
Yaroms Jan 12, 2025
e1fb93d
Merge pull request #1626 from lavanet/CNS-1005-reputation-pairing-score
Yaroms Jan 12, 2025
062ae0d
weigh epoch qos score by cu (revert by relay num)
oren-lava Jan 13, 2025
871b55b
Merge branch 'main' into CNS-1003-reputation-proto-definitions
oren-lava Jan 13, 2025
23ee142
Merge branch 'CNS-1003-reputation-proto-definitions' into CNS-1004-re…
oren-lava Jan 13, 2025
03ceff2
Adding endpoints support for auth
ranlavanet Jan 16, 2025
81cc0ab
fixing chain router test
ranlavanet Jan 16, 2025
2d37d0b
adding connector capabilities for ws auth
ranlavanet Jan 16, 2025
14ee3a2
implementing client capabailities to add headers to websocket connection
ranlavanet Jan 16, 2025
7a1988f
adding websocket capability adding websocket headers on connection
ranlavanet Jan 16, 2025
f8bd4a5
implemeting websocket test for auth headers
ranlavanet Jan 16, 2025
543a6f9
Merge pull request #1612 from lavanet/CNS-1004-reputation-qos-score-a…
Yaroms Jan 16, 2025
ec071f0
Merge pull request #1912 from lavanet/PRT-add-auth-headers-to-websock…
ranlavanet Jan 16, 2025
dcc546c
increase minimum version + protocol version to 4.2.8 / 4.2.1
ranlavanet Jan 16, 2025
337bbe1
Update go version to match toolchain rule
shleikes Jan 19, 2025
7e6d535
Merge branch 'main' into CNS-1003-reputation-proto-definitions
Yaroms Jan 19, 2025
882c984
Merge pull request #1913 from lavanet/PRT-v-4-2-8
ranlavanet Jan 19, 2025
9d39b02
fix lint
oren-lava Jan 19, 2025
20b39a1
Merge branch 'main' into CNS-1003-reputation-proto-definitions
oren-lava Jan 19, 2025
79dd551
fix ReputationHalfLifeFactor param validator
oren-lava Jan 19, 2025
b303d87
fix exponent func
oren-lava Jan 19, 2025
349311a
temp fix for invalid qos reports
oren-lava Jan 19, 2025
344ad89
Merge pull request #1915 from lavanet/PRT-update-go-version
ranlavanet Jan 19, 2025
8943739
Merge pull request #1604 from lavanet/CNS-1003-reputation-proto-defin…
Yaroms Jan 19, 2025
453fce8
added lava_consumer_provider_blocked metric
fbjohnny Jan 20, 2025
be3ae1c
fixing config to include archive
ranlavanet Jan 20, 2025
a74e406
config updated
ranlavanet Jan 20, 2025
625759b
Merge branch 'PRT-add-lava-consumer-blocked-providers-metrics' into F…
ranlavanet Jan 20, 2025
3164628
Merge pull request #1918 from fbjohnny/FB-add-lava_consumer_blocked_p…
ranlavanet Jan 20, 2025
bdafe1a
fix a few issues with locks on metrics
ranlavanet Jan 20, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# - archive
# - debug
# - trace
# - trace + archive
# - debug + archive

# ** Replace the urls with your own node urls **

Expand Down Expand Up @@ -29,4 +31,20 @@ endpoints:
- url: ws://my-eth-node.com/eth/archive/ws
addons:
- trace
- url: http://my-eth-node.com/eth/http/archive
addons:
- debug
- archive
- url: ws://my-eth-node.com/eth/archive/ws
addons:
- debug
- archive
- url: http://my-eth-node.com/eth/http/archive
addons:
- trace
- archive
- url: ws://my-eth-node.com/eth/archive/ws
addons:
- trace
- archive

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/lavanet/lava/v4

go 1.23
go 1.23.3

require (
github.com/99designs/keyring v1.2.1 // indirect
Expand Down
15 changes: 11 additions & 4 deletions proto/lavanet/lava/pairing/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "lavanet/lava/pairing/params.proto";
import "lavanet/lava/pairing/epoch_cu.proto";
import "lavanet/lava/fixationstore/fixation.proto";
import "lavanet/lava/timerstore/timer.proto";
import "lavanet/lava/pairing/reputation.proto";

// this line is used by starport scaffolding # genesis/proto/import

Expand All @@ -18,17 +19,16 @@ message BadgeUsedCu {

// GenesisState defines the pairing module's genesis state.
message GenesisState {
reserved 2,3,4,7;
Params params = 1 [(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 ProviderEpochComplainerCuGenesis provider_epoch_complained_cus = 10 [(gogoproto.nullable) = false];
repeated ProviderConsumerEpochCuGenesis provider_consumer_epoch_cus = 11 [(gogoproto.nullable) = false];
repeated ReputationGenesis reputations = 12 [(gogoproto.nullable) = false];
lavanet.lava.fixationstore.GenesisState reputation_scores = 13 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}

Expand Down Expand Up @@ -60,4 +60,11 @@ message ProviderConsumerEpochCuGenesis {
string project = 3;
string chain_id = 4;
ProviderConsumerEpochCu provider_consumer_epoch_cu = 5 [(gogoproto.nullable) = false];
}

message ReputationGenesis {
string chain_id = 1;
string cluster = 2;
string provider = 3;
Reputation reputation = 4 [(gogoproto.nullable) = false];
}
2 changes: 1 addition & 1 deletion proto/lavanet/lava/pairing/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
int64 reputation_half_life_factor = 17 [(gogoproto.moretags) = "yaml:\"reputation_half_life_factor\""];
uint64 reputation_half_life_factor = 17 [(gogoproto.moretags) = "yaml:\"reputation_half_life_factor\""];
uint64 reputation_relay_failure_cost = 18 [(gogoproto.moretags) = "yaml:\"reputation_relay_failure_cost\""];
}
52 changes: 49 additions & 3 deletions proto/lavanet/lava/pairing/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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/reputation.proto";
import "lavanet/lava/spec/spec.proto";


Expand Down Expand Up @@ -80,9 +81,19 @@ service Query {
}

// 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";
}
rpc ProvidersEpochCu(QueryProvidersEpochCuRequest) returns (QueryProvidersEpochCuResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/providers_epoch_cu";
}

// Queries a for a provider reputation.
rpc ProviderReputation(QueryProviderReputationRequest) returns (QueryProviderReputationResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/provider_reputation/{provider}/{chainID}/{cluster}";
}

// Queries a for a provider reputation's details (mainly for developers).
rpc ProviderReputationDetails(QueryProviderReputationDetailsRequest) returns (QueryProviderReputationDetailsResponse) {
option (google.api.http).get = "/lavanet/lava/pairing/provider_reputation_details/{address}/{chainID}/{cluster}";
}

// this line is used by starport scaffolding # 2

Expand Down Expand Up @@ -238,4 +249,39 @@ message QueryProvidersEpochCuResponse {
message ProviderCuInfo {
string provider = 1;
uint64 cu = 2;
}

message QueryProviderReputationRequest {
string provider = 1;
string chainID = 2;
string cluster = 3;
}

message ReputationData {
uint64 rank = 1; // rank compared to other providers
uint64 providers = 2; // amount of providers with the same chainID+cluster
string overall_performance = 3; // overall performance metric which can be "good", "bad", or "low variance"
string chainID = 4;
string cluster = 5;
}

message QueryProviderReputationResponse {
repeated ReputationData data = 1 [(gogoproto.nullable) = false];
}

message QueryProviderReputationDetailsRequest {
string address = 1;
string chainID = 2;
string cluster = 3;
}

message ReputationDevData {
Reputation reputation = 1 [(gogoproto.nullable) = false];
ReputationPairingScore reputation_pairing_score = 2 [(gogoproto.nullable) = false];
string chainID = 4;
string cluster = 5;
}

message QueryProviderReputationDetailsResponse {
repeated ReputationDevData data = 1 [(gogoproto.nullable) = false];
}
7 changes: 7 additions & 0 deletions proto/lavanet/lava/pairing/relay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,23 @@ message RelayReply {
}

message QualityOfServiceReport{
// Latency of provider answers in milliseconds, range 0-inf, lower is better
string latency = 1 [
(gogoproto.moretags) = "yaml:\"Latency\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Percentage of times the provider returned a non-error response, range 0-1, higher is better
string availability = 2 [
(gogoproto.moretags) = "yaml:\"availability\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Amount of time the provider is not synced (have the latest block) in milliseconds, range 0-inf, lower is better.
// Example: in ETH we have 15sec block time. So sync = 15000 means that the provider is one block
// behind the actual latest block.
string sync = 3 [
(gogoproto.moretags) = "yaml:\"sync\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Expand Down
44 changes: 44 additions & 0 deletions proto/lavanet/lava/pairing/reputation.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package lavanet.lava.pairing;

option go_package = "github.com/lavanet/lava/v4/x/pairing/types";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

// Frac is a fracture struct that helps calculating and updating weighted average on the go
message Frac {
string num = 1 [(gogoproto.moretags) = "yaml:\"num\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false]; // weighted average numerator (w1*s1+w2*s2+...)
string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false]; // weighted denominator (w1+w2+...)
}

// QosScore holds the QoS score from a QoS excellence report. The score and its variance are updated over time using a weighted average.
// Currently, the weight is the amount of relays that are associated with the QoS report.
message QosScore {
Frac score = 1 [(gogoproto.nullable) = false];
Frac variance = 2 [(gogoproto.nullable) = false];
}

// Reputation keeps the QosScore of a provider for a specific cluster for in the provider's geolocation.
// The store key is provider+chain+cluster.
// The epoch_score is a QosScore object that is aggregated over an epoch. When an epoch ends, the "score" field is updated
// with the epoch_score and the epoch_score is reset.
// The time_last_updated is used to calculate the appropriate time decay upon update.
// The creation_time is used to determine if the variance stabilization period has passed and score can be truncated.
// The stake is used when converting the reputation QoS scores to repuatation pairing score.
message Reputation {
QosScore score = 1 [(gogoproto.nullable) = false];
QosScore epoch_score = 2 [(gogoproto.nullable) = false];
int64 time_last_updated = 3;
int64 creation_time = 4;
cosmos.base.v1beta1.Coin stake = 5 [(gogoproto.nullable) = false];
}

// ReputationPairingScore holds the reputation pairing score used by the reputation pairing requirement.
// The score is ranged between [0.5-2]. It's kept in the reputations fixation store with a provider+chain+cluster key.
message ReputationPairingScore {
string score = 1 [(gogoproto.moretags) = "yaml:\"score\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
}

4 changes: 2 additions & 2 deletions protocol/chainlib/chain_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,8 @@ func TestMain(m *testing.M) {
listener := createRPCServer()
for {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
_, err := rpcclient.DialContext(ctx, listenerAddressHttp)
_, err2 := rpcclient.DialContext(ctx, listenerAddressWs)
_, err := rpcclient.DialContext(ctx, listenerAddressHttp, nil)
_, err2 := rpcclient.DialContext(ctx, listenerAddressWs, nil)
if err2 != nil {
utils.LavaFormatDebug("waiting for grpc server to launch")
continue
Expand Down
27 changes: 16 additions & 11 deletions protocol/chainlib/chainproxy/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ func (connector *Connector) numberOfUsedClients() int {
return int(atomic.LoadInt64(&connector.usedClients))
}

func (connector *Connector) getRpcClient(ctx context.Context, nodeUrl common.NodeUrl) (*rpcclient.Client, error) {
authPathNodeUrl := nodeUrl.AuthConfig.AddAuthPath(nodeUrl.Url)
// origin used for auth header in the websocket case
authHeaders := nodeUrl.GetAuthHeaders()
rpcClient, err := rpcclient.DialContext(ctx, authPathNodeUrl, authHeaders)
if err != nil {
return nil, err
}
nodeUrl.SetAuthHeaders(ctx, rpcClient.SetHeader)
return rpcClient, nil
}

func (connector *Connector) createConnection(ctx context.Context, nodeUrl common.NodeUrl, currentNumberOfConnections int) (*rpcclient.Client, error) {
var rpcClient *rpcclient.Client
var err error
Expand All @@ -124,21 +136,13 @@ func (connector *Connector) createConnection(ctx context.Context, nodeUrl common
}
timeout := common.AverageWorldLatency * (1 + time.Duration(numberOfConnectionAttempts))
nctx, cancel := nodeUrl.LowerContextTimeoutWithDuration(ctx, timeout)
// add auth path
authPathNodeUrl := nodeUrl.AuthConfig.AddAuthPath(nodeUrl.Url)
rpcClient, err = rpcclient.DialContext(nctx, authPathNodeUrl)
// get rpcClient
rpcClient, err = connector.getRpcClient(nctx, nodeUrl)
if err != nil {
utils.LavaFormatWarning("Could not connect to the node, retrying", err, []utils.Attribute{
{Key: "Current Number Of Connections", Value: currentNumberOfConnections},
{Key: "Network Address", Value: authPathNodeUrl},
{Key: "Number Of Attempts", Value: numberOfConnectionAttempts},
{Key: "timeout", Value: timeout},
}...)
cancel()
continue
}
cancel()
nodeUrl.SetAuthHeaders(ctx, rpcClient.SetHeader)
break
}

Expand Down Expand Up @@ -178,7 +182,8 @@ func (connector *Connector) increaseNumberOfClients(ctx context.Context, numberO
var err error
for connectionAttempt := 0; connectionAttempt < MaximumNumberOfParallelConnectionsAttempts; connectionAttempt++ {
nctx, cancel := connector.nodeUrl.LowerContextTimeoutWithDuration(ctx, common.AverageWorldLatency*2)
rpcClient, err = rpcclient.DialContext(nctx, connector.nodeUrl.Url)
// get rpcClient
rpcClient, err = connector.getRpcClient(nctx, connector.nodeUrl)
if err != nil {
utils.LavaFormatDebug(
"could no increase number of connections to the node jsonrpc connector, retrying",
Expand Down
Loading
Loading