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

Commit a52fa63

Browse files
authored
Merge pull request #2857 from w3f/fix-ip-location-dedup2
Fix ip location dedup2
2 parents c1812cc + c81587e commit a52fa63

File tree

17 files changed

+22
-57
lines changed

17 files changed

+22
-57
lines changed

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

Lines changed: 1 addition & 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.13
20+
targetRevision: v3.1.14
2121
plugin:
2222
env:
2323
- name: HELM_VALUES

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

Lines changed: 1 addition & 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.13
20+
targetRevision: v3.1.14
2121
plugin:
2222
env:
2323
- name: HELM_VALUES

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.13
4-
appVersion: v3.1.13
3+
version: v3.1.14
4+
appVersion: v3.1.14
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.13",
3+
"version": "3.1.14",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/common/src/constraints/ScoreCandidates.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ export const scoreCandidate = async (
9696

9797
const latestCandidateLocation = await queries.getCandidateLocation(
9898
candidate.slotId,
99-
candidate.name,
100-
candidate.stash,
10199
);
102100

103101
const provider = latestCandidateLocation?.provider || "No Provider";

packages/common/src/constraints/ValidityChecks.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,7 @@ export const checkProvider = async (
361361
candidate: Candidate,
362362
): Promise<boolean> => {
363363
try {
364-
const location = await queries.getCandidateLocation(
365-
candidate.slotId,
366-
candidate.name,
367-
candidate.stash,
368-
);
364+
const location = await queries.getCandidateLocation(candidate.slotId);
369365
if (location && location.provider) {
370366
const bannedProviders = config.telemetry?.blacklistedProviders;
371367
if (bannedProviders?.includes(location.provider)) {

packages/common/src/constraints/Values.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ export const getLocationValues = async (
117117
const locationMap = new Map<string, number>();
118118
const locationArr: { name: string; numberOfNodes: number }[] = [];
119119
for (const candidate of validCandidates) {
120-
const candidateLocation = await getCandidateLocation(
121-
candidate.slotId,
122-
candidate.name,
123-
candidate.stash,
124-
);
120+
const candidateLocation = await getCandidateLocation(candidate.slotId);
125121
const location = candidateLocation?.city || NoLocation.NoLocation;
126122

127123
const locationCount = locationMap.get(location);
@@ -155,11 +151,7 @@ export const getRegionValues = async (
155151
const regionMap = new Map<string, number>();
156152
const regionArr: { name: string; numberOfNodes: number }[] = [];
157153
for (const candidate of validCandidates) {
158-
const candidateLocation = await getCandidateLocation(
159-
candidate.slotId,
160-
candidate.name,
161-
candidate.stash,
162-
);
154+
const candidateLocation = await getCandidateLocation(candidate.slotId);
163155
const region =
164156
candidateLocation && candidateLocation.region
165157
? candidateLocation.region
@@ -196,11 +188,7 @@ export const getCountryValues = async (
196188
const countryMap = new Map<string, number>();
197189
const countryArr: { name: string; numberOfNodes: number }[] = [];
198190
for (const candidate of validCandidates) {
199-
const candidateLocation = await getCandidateLocation(
200-
candidate.slotId,
201-
candidate.name,
202-
candidate.stash,
203-
);
191+
const candidateLocation = await getCandidateLocation(candidate.slotId);
204192
const country =
205193
candidateLocation && candidateLocation.country
206194
? candidateLocation.country
@@ -235,11 +223,7 @@ export const getProviderValues = async (
235223
const providerMap = new Map<string, number>();
236224
const providerArr: { name: string; numberOfNodes: number }[] = [];
237225
for (const candidate of validCandidates) {
238-
const candidateLocation = await getCandidateLocation(
239-
candidate.slotId,
240-
candidate.name,
241-
candidate.stash,
242-
);
226+
const candidateLocation = await getCandidateLocation(candidate.slotId);
243227
const provider =
244228
candidateLocation && candidateLocation.provider
245229
? candidateLocation.provider

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ export const getLocation = async (
3636

3737
export const getCandidateLocation = async (
3838
slotId: number,
39-
stash?: string,
40-
name?: string,
4139
): Promise<Location | null> => {
42-
const query = [{ slotId: slotId }, { stash: stash }, { name: name }];
40+
const query = [{ slotId: slotId }];
4341

4442
return LocationModel.findOne({ $or: query })
4543
.sort({ updated: -1 })
@@ -69,7 +67,7 @@ export const setLocation = async (
6967
}
7068
// Try and find an existing record
7169
const query = {
72-
$or: [{ addr }, { name }, { slotId }],
70+
$or: [{ slotId }],
7371
};
7472
const data = await LocationModel.findOne(query).lean<Location>();
7573

@@ -79,6 +77,7 @@ export const setLocation = async (
7977
}
8078

8179
// Create a new Location record if there is no existing record, or there is a different ip address
80+
// TODO: check if we need multiple addresses to be stored
8281
if (!data || data?.addr != addr) {
8382
const location = new LocationModel({
8483
slotId: slotId,
@@ -103,7 +102,7 @@ export const setLocation = async (
103102
await location.save();
104103
} else {
105104
await LocationModel.findOneAndUpdate(
106-
{ addr, name },
105+
{ slotId },
107106
{
108107
slotId: slotId,
109108
address: stash,

packages/common/src/scorekeeper/jobs/specificJobs/LocationStatsJob.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ export const locationStatsJob = async (metadata: JobRunnerMetadata) => {
4444

4545
// Add all candidate entries to the list of nodes
4646
for (const [index, candidate] of candidates.entries()) {
47-
const location = await queries.getCandidateLocation(
48-
candidate.slotId,
49-
candidate.name,
50-
);
47+
const location = await queries.getCandidateLocation(candidate.slotId);
5148
if (
5249
location?.city != "None" &&
5350
location?.region != "None" &&

packages/common/src/utils/Location.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export const fetchAndSetCandidateLocation = async (
127127
iit && iit.iit ? iit.iit : null,
128128
);
129129
await updateIITRequestCount();
130-
const candidate = await getCandidateByName(telemetryNodeDetails.name);
131130
const slotId = candidate?.slotId;
132131
const stash = candidate?.stash;
133132
if (slotId == undefined || !stash) {

0 commit comments

Comments
 (0)