Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit a75bf5a

Browse files
authored
Merge pull request #2852 from w3f/fix-ip-location-dedup
fix ip location dedup
2 parents dbb51eb + a4da8ee commit a75bf5a

File tree

14 files changed

+55
-27
lines changed

14 files changed

+55
-27
lines changed

apps/1kv-backend-staging/templates/kusama-otv-backend.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,14 @@ spec:
123123
"Contabo GmbH"
124124
],
125125
"host": "wss://telemetry-backend.w3f.community/feed"
126+
},
127+
"logger": {
128+
"level": "info",
129+
"excludedLabels": [
130+
"Telemetry",
131+
"Location",
132+
"Block",
133+
"Gateway",
134+
]
126135
}
127136
}

apps/1kv-backend-staging/templates/polkadot-otv-backend.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,14 @@ spec:
122122
"Contabo GmbH"
123123
],
124124
"host": "wss://telemetry-backend.w3f.community/feed"
125+
},
126+
"logger": {
127+
"level": "info",
128+
"excludedLabels": [
129+
"Telemetry",
130+
"Location",
131+
"Block",
132+
"Gateway",
133+
]
125134
}
126135
}

apps/1kv-backend/templates/kusama-otv-backend.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
source:
1818
repoURL: https://w3f.github.io/helm-charts/
1919
chart: otv-backend
20-
targetRevision: v3.1.12
20+
targetRevision: v3.1.13
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -121,5 +121,14 @@ spec:
121121
],
122122
"host": "wss://telemetry-backend.w3f.community/feed",
123123
"ipinfoToken": "token=<path:vaults/k8s-community-secrets/items/otv-kusama#ipinfo-token>"
124+
},
125+
"logger": {
126+
"level": "info",
127+
"excludedLabels": [
128+
"Telemetry",
129+
"Location",
130+
"Block",
131+
"Gateway",
132+
]
124133
}
125134
}

apps/1kv-backend/templates/polkadot-otv-backend.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
source:
1818
repoURL: https://w3f.github.io/helm-charts/
1919
chart: otv-backend
20-
targetRevision: v3.1.12
20+
targetRevision: v3.1.13
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -120,5 +120,14 @@ spec:
120120
],
121121
"host": "wss://telemetry-backend.w3f.community/feed",
122122
"ipinfoToken": "token=<path:vaults/k8s-community-secrets/items/otv-polkadot#ipinfo-token>"
123+
},
124+
"logger": {
125+
"level": "info",
126+
"excludedLabels": [
127+
"Telemetry",
128+
"Location",
129+
"Block",
130+
"Gateway",
131+
]
123132
}
124133
}

charts/otv-backend/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
description: 1K Validators Backend
22
name: otv-backend
3-
version: v3.1.12
4-
appVersion: v3.1.12
3+
version: v3.1.13
4+
appVersion: v3.1.13
55
apiVersion: v2

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/common",
3-
"version": "3.1.12",
3+
"version": "3.1.13",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/common/src/db/queries/Candidate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export const reportOnline = async (
505505
await mergeTelemetryNodeToCandidate(candidate);
506506

507507
// Try and update or make a new Location record
508-
await fetchAndSetCandidateLocation(telemetryNodeDetails);
508+
await fetchAndSetCandidateLocation(candidate, telemetryNodeDetails);
509509

510510
// Update the candidate online validity
511511
await setCandidateOnlineValid(candidate);

packages/common/src/db/queries/CandidateUtils.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@ export const filterCandidateInvalidityFields = (
99
candidate: Candidate,
1010
filter: InvalidityReasonType,
1111
): InvalidityReason[] => {
12-
if (!candidate || !candidate?.invalidity)
13-
throw new Error(
14-
`NO CANDIDATE DATA FOUND FOR CANDIDATE with slotId ${candidate.slotId}`,
15-
);
16-
17-
const invalidityReasons = candidate?.invalidity?.filter(
18-
(invalidityReason) => {
19-
return invalidityReason.type !== filter;
20-
},
12+
return (
13+
candidate?.invalidity?.filter(
14+
(invalidityReason) => invalidityReason.type !== filter,
15+
) || []
2116
);
22-
23-
return invalidityReasons;
2417
};
2518

2619
export const setCandidateInvalidity = async (

packages/common/src/utils/Location.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
2+
Candidate,
23
getCandidateByName,
4+
getCandidateLocation,
35
getIIT,
4-
getLocation,
56
removeIIT,
67
setIIT,
78
setLocation,
@@ -101,13 +102,11 @@ export const nodeDetailsFromTelemetryMessage = (
101102
};
102103

103104
export const fetchAndSetCandidateLocation = async (
105+
candidate: Candidate,
104106
telemetryNodeDetails: TelemetryNodeDetails,
105107
) => {
106108
// See if there's an existing location for the given telemetry data
107-
const existingLocation = await getLocation(
108-
telemetryNodeDetails.name,
109-
telemetryNodeDetails.ipAddress,
110-
);
109+
const existingLocation = await getCandidateLocation(candidate.slotId);
111110

112111
// Fetch and set a new location if:
113112
// - There's no existing location

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/core",
3-
"version": "3.1.12",
3+
"version": "3.1.13",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)