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

Commit 3d038c0

Browse files
committed
Merge branch 'staging' into michalis-sanctions-validity-check-3
2 parents d071ec5 + 5a205c6 commit 3d038c0

File tree

26 files changed

+405
-754
lines changed

26 files changed

+405
-754
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.14
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.14
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.14
4+
appVersion: v3.1.14
55
apiVersion: v2

charts/otv-backend/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ config: |
9494
"Telemetry",
9595
"Location",
9696
"Block",
97-
"Gateway",
97+
"Gateway"
9898
]
9999
}
100100
}

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.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/CheckCandidates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ export const checkCandidate = async (
152152
beefyValid &&
153153
sanctionedGeoAreaValid;
154154

155-
await setValid(candidate.stash, valid);
155+
await setValid(candidate, valid);
156156

157157
if (valid) {
158-
await setLastValid(candidate.stash);
158+
await setLastValid(candidate);
159159
}
160160
return valid;
161161
} catch (e) {

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: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ export const checkValidateIntention = async (
5353
!validators?.length ||
5454
validators.includes(Util.formatAddress(candidate?.stash, config))
5555
) {
56-
await setValidateIntentionValidity(candidate.stash, true);
56+
await setValidateIntentionValidity(candidate, true);
5757
return true;
5858
}
5959

60-
await setValidateIntentionValidity(candidate.stash, false);
60+
await setValidateIntentionValidity(candidate, false);
6161
return false;
6262
} catch (e) {
6363
logger.error(`Error checking validate intention: ${e}`, constraintsLabel);
@@ -75,9 +75,9 @@ export const checkAllValidateIntentions = async (
7575
const validators = await chaindata.getValidators();
7676
for (const candidate of candidates) {
7777
if (!validators.includes(Util.formatAddress(candidate.stash, config))) {
78-
await setValidateIntentionValidity(candidate.stash, false);
78+
await setValidateIntentionValidity(candidate, false);
7979
} else {
80-
await setValidateIntentionValidity(candidate.stash, true);
80+
await setValidateIntentionValidity(candidate, true);
8181
}
8282
}
8383
return true;
@@ -96,7 +96,7 @@ export const checkLatestClientVersion = async (
9696
const skipClientUpgrade = config.constraints?.skipClientUpgrade || false;
9797
if (skipClientUpgrade || candidate?.implementation === "Kagome Node") {
9898
// Skip the check if the node is a Kagome Client or if skipping client upgrade is enabled
99-
await setLatestClientReleaseValidity(candidate.stash, true);
99+
await setLatestClientReleaseValidity(candidate, true);
100100
return true;
101101
}
102102

@@ -146,34 +146,34 @@ export const checkLatestClientVersion = async (
146146

147147
// If cannot parse the version, set the release as invalid
148148
if (!nodeVersion || !latestVersion) {
149-
await setLatestClientReleaseValidity(candidate.stash, false);
149+
await setLatestClientReleaseValidity(candidate, false);
150150
return false;
151151
}
152152

153153
const isUpgraded = semver.gte(nodeVersion, latestVersion);
154154

155155
// If they are not upgraded, set the validity as invalid
156156
if (!isUpgraded) {
157-
await setLatestClientReleaseValidity(candidate.stash, false);
157+
await setLatestClientReleaseValidity(candidate, false);
158158
return false;
159159
}
160160

161161
// If the current version is the latest release, set the release as valid
162-
await setLatestClientReleaseValidity(candidate.stash, true);
162+
await setLatestClientReleaseValidity(candidate, true);
163163
return true;
164164
} else {
165165
logger.info(`Still in grace window of latest release`, constraintsLabel);
166166

167167
// If not past the grace window, set the release as invalid
168-
await setLatestClientReleaseValidity(candidate.stash, true);
168+
await setLatestClientReleaseValidity(candidate, true);
169169
return true;
170170
}
171171
} catch (e) {
172172
logger.error(
173173
`Error checking latest client version: ${e}`,
174174
constraintsLabel,
175175
);
176-
await setLatestClientReleaseValidity(candidate.stash, false);
176+
await setLatestClientReleaseValidity(candidate, false);
177177
throw new Error("could not make validity check");
178178
}
179179
};
@@ -186,14 +186,14 @@ export const checkConnectionTime = async (
186186
if (!config?.constraints?.skipConnectionTime) {
187187
const now = new Date().getTime();
188188
if (now - candidate.discoveredAt < Constants.WEEK) {
189-
await setConnectionTimeInvalidity(candidate.stash, false);
189+
await setConnectionTimeInvalidity(candidate, false);
190190
return false;
191191
} else {
192-
await setConnectionTimeInvalidity(candidate.stash, true);
192+
await setConnectionTimeInvalidity(candidate, true);
193193
return true;
194194
}
195195
} else {
196-
await setConnectionTimeInvalidity(candidate.stash, true);
196+
await setConnectionTimeInvalidity(candidate, true);
197197
return true;
198198
}
199199
} catch (e) {
@@ -212,15 +212,15 @@ export const checkIdentity = async (
212212
);
213213
if (!hasIdentity) {
214214
const invalidityString = `${candidate.name} does not have an identity set.`;
215-
await setIdentityInvalidity(candidate.stash, false, invalidityString);
215+
await setIdentityInvalidity(candidate, false, invalidityString);
216216
return false;
217217
}
218218
if (!verified) {
219219
const invalidityString = `${candidate.name} has an identity but is not verified by the registrar.`;
220-
await setIdentityInvalidity(candidate.stash, false, invalidityString);
220+
await setIdentityInvalidity(candidate, false, invalidityString);
221221
return false;
222222
}
223-
await setIdentityInvalidity(candidate.stash, true);
223+
await setIdentityInvalidity(candidate, true);
224224
return true;
225225
} catch (e) {
226226
logger.error(`Error checking identity: ${e}`, constraintsLabel);
@@ -232,10 +232,10 @@ export const checkOffline = async (candidate: Candidate): Promise<boolean> => {
232232
try {
233233
const totalOffline = candidate.offlineAccumulated / Constants.WEEK;
234234
if (totalOffline > 0.02) {
235-
await setOfflineAccumulatedInvalidity(candidate.stash, false);
235+
await setOfflineAccumulatedInvalidity(candidate, false);
236236
return false;
237237
} else {
238-
await setOfflineAccumulatedInvalidity(candidate.stash, true);
238+
await setOfflineAccumulatedInvalidity(candidate, true);
239239
return true;
240240
}
241241
return true;
@@ -261,10 +261,10 @@ export const checkCommission = async (
261261
} commission is set higher than the maximum allowed. Set: ${
262262
commission / Math.pow(10, 7)
263263
}% Allowed: ${targetCommission / Math.pow(10, 7)}%`;
264-
await setCommissionInvalidity(candidate.stash, false, invalidityString);
264+
await setCommissionInvalidity(candidate, false, invalidityString);
265265
return false;
266266
} else {
267-
await setCommissionInvalidity(candidate.stash, true);
267+
await setCommissionInvalidity(candidate, true);
268268
return true;
269269
}
270270
} catch (e) {
@@ -286,7 +286,7 @@ export const checkSelfStake = async (
286286
let invalidityString;
287287
if (err2) {
288288
invalidityString = `${candidate.name} ${err2}`;
289-
await setSelfStakeInvalidity(candidate.stash, false, invalidityString);
289+
await setSelfStakeInvalidity(candidate, false, invalidityString);
290290
return false;
291291
}
292292
if (parseInt(bondedAmt.toString()) < targetSelfStake) {
@@ -295,11 +295,11 @@ export const checkSelfStake = async (
295295
} has less than the minimum amount bonded: ${parseInt(
296296
bondedAmt.toString(),
297297
)} is bonded.`;
298-
await setSelfStakeInvalidity(candidate.stash, false, invalidityString);
298+
await setSelfStakeInvalidity(candidate, false, invalidityString);
299299
return false;
300300
}
301301
}
302-
await setSelfStakeInvalidity(candidate.stash, true);
302+
await setSelfStakeInvalidity(candidate, true);
303303
return true;
304304
} catch (e) {
305305
logger.error(`Error checking self stake: ${e}`, constraintsLabel);
@@ -323,10 +323,10 @@ export const checkUnclaimed = async (
323323
const invalidityString = `${candidate.name} has unclaimed eras: ${
324324
candidate.unclaimedEras
325325
} prior to era: ${threshold + 1}`;
326-
await setUnclaimedInvalidity(candidate.stash, false, invalidityString);
326+
await setUnclaimedInvalidity(candidate, false, invalidityString);
327327
return false;
328328
} else {
329-
await setUnclaimedInvalidity(candidate.stash, true);
329+
await setUnclaimedInvalidity(candidate, true);
330330
return true;
331331
}
332332
} catch (e) {
@@ -344,10 +344,10 @@ export const checkBlocked = async (
344344
const isBlocked = await chaindata.getBlocked(candidate.stash);
345345
if (isBlocked) {
346346
const invalidityString = `${candidate.name} blocks external nominations`;
347-
await setBlockedInvalidity(candidate.stash, false, invalidityString);
347+
await setBlockedInvalidity(candidate, false, invalidityString);
348348
return false;
349349
} else {
350-
await setBlockedInvalidity(candidate.stash, true);
350+
await setBlockedInvalidity(candidate, true);
351351
return true;
352352
}
353353
} catch (e) {
@@ -362,11 +362,7 @@ export const checkProvider = async (
362362
candidate: Candidate,
363363
): Promise<boolean> => {
364364
try {
365-
const location = await queries.getCandidateLocation(
366-
candidate.slotId,
367-
candidate.name,
368-
candidate.stash,
369-
);
365+
const location = await queries.getCandidateLocation(candidate.slotId);
370366
if (location && location.provider) {
371367
const bannedProviders = config.telemetry?.blacklistedProviders;
372368
if (bannedProviders?.includes(location.provider)) {
@@ -376,14 +372,14 @@ export const checkProvider = async (
376372
label: "Constraints",
377373
},
378374
);
379-
await setProviderInvalidity(candidate.stash, false);
375+
await setProviderInvalidity(candidate, false);
380376
return false;
381377
} else {
382-
await setProviderInvalidity(candidate.stash, true);
378+
await setProviderInvalidity(candidate, true);
383379
return true;
384380
}
385381
} else {
386-
await setProviderInvalidity(candidate.stash, true);
382+
await setProviderInvalidity(candidate, true);
387383
return true;
388384
}
389385
} catch (e) {
@@ -403,17 +399,17 @@ export const checkKusamaRank = async (
403399

404400
if (!!res.data.invalidityReasons) {
405401
const invalidityReason = `${candidate.name} has a kusama node that is invalid: ${res.data.invalidityReasons}`;
406-
await setKusamaRankInvalidity(candidate.stash, false, invalidityReason);
402+
await setKusamaRankInvalidity(candidate, false, invalidityReason);
407403
return false;
408404
}
409405

410406
if (Number(res.data.rank) < Constants.KUSAMA_RANK_VALID_THRESHOLD) {
411407
const invalidityReason = `${candidate.name} has a Kusama stash with lower than 25 rank in the Kusama OTV programme: ${res.data.rank}.`;
412-
await setKusamaRankInvalidity(candidate.stash, false, invalidityReason);
408+
await setKusamaRankInvalidity(candidate, false, invalidityReason);
413409
return false;
414410
}
415411
}
416-
await setKusamaRankInvalidity(candidate.stash, true);
412+
await setKusamaRankInvalidity(candidate, true);
417413
return true;
418414
} catch (e) {
419415
logger.warn(`Error trying to get kusama data...`);
@@ -428,10 +424,10 @@ export const checkBeefyKeys = async (
428424
const isDummy = await queries.hasBeefyDummy(candidate.stash);
429425
if (isDummy) {
430426
const invalidityString = `${candidate.name} has not set beefy keys`;
431-
await setBeefyKeysInvalidity(candidate.stash, false, invalidityString);
427+
await setBeefyKeysInvalidity(candidate, false, invalidityString);
432428
return false;
433429
} else {
434-
await setBeefyKeysInvalidity(candidate.stash, true);
430+
await setBeefyKeysInvalidity(candidate, true);
435431
return true;
436432
}
437433
} catch (e) {

0 commit comments

Comments
 (0)