Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.

Commit d99f8b6

Browse files
authored
Merge pull request #2879 from w3f/staging
Staging
2 parents 5cbb53c + 8146894 commit d99f8b6

27 files changed

+218
-51
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ spec:
6161
"minSelfStake": 10000000000000,
6262
"commission": 150000000,
6363
"unclaimedEraThreshold": 4,
64+
"sanctionedGeoArea": {
65+
"skip": true,
66+
"sanctionedCountries": ["XXX"],
67+
"sanctionedRegions": ["XXX" ]
68+
},
6469
"forceClientVersion": "v1.10.0"
6570
},
6671
"cron": {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ spec:
6060
"minSelfStake": 50000000000000,
6161
"commission": 50000000,
6262
"unclaimedEraThreshold": 1,
63+
"sanctionedGeoArea": {
64+
"skip": true,
65+
"sanctionedCountries": ["XXX"],
66+
"sanctionedRegions": ["XXX" ]
67+
},
6368
"forceClientVersion": "v1.10.0"
6469
},
6570
"cron": {

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

Lines changed: 6 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.16
20+
targetRevision: v3.2.0
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -59,6 +59,11 @@ spec:
5959
"minSelfStake": 10000000000000,
6060
"commission": 150000000,
6161
"unclaimedEraThreshold": 4,
62+
"sanctionedGeoArea": {
63+
"skip": true,
64+
"sanctionedCountries": ["XXX"],
65+
"sanctionedRegions": ["XXX" ]
66+
},
6267
"forceClientVersion": "v1.10.0"
6368
},
6469
"cron": {

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

Lines changed: 6 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.16
20+
targetRevision: v3.2.0
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -58,6 +58,11 @@ spec:
5858
"minSelfStake": 50000000000000,
5959
"commission": 50000000,
6060
"unclaimedEraThreshold": 1,
61+
"sanctionedGeoArea": {
62+
"skip": true,
63+
"sanctionedCountries": ["XXX"],
64+
"sanctionedRegions": ["XXX" ]
65+
},
6166
"forceClientVersion": "v1.10.0"
6267
},
6368
"cron": {

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.16
4-
appVersion: v3.1.16
3+
version: v3.2.0
4+
appVersion: v3.2.0
55
apiVersion: v2

charts/otv-backend/values.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ config: |
4848
},
4949
"constraints": {
5050
"skipConnectionTime": false,
51-
"skipIdentity": false
51+
"skipIdentity": false,
52+
"sanctionedGeoArea": {
53+
"skip": false,
54+
"sanctionedCountries": ["XXX"],
55+
"sanctionedRegions": ["XXX" ]
56+
}
5257
},
5358
"db": {
5459
"mongo": {

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.16",
3+
"version": "3.2.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/common/src/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export type ConfigSchema = {
3131
minSelfStake: number;
3232
commission: number;
3333
unclaimedEraThreshold: number;
34+
sanctionedGeoArea?: {
35+
skip: boolean;
36+
sanctionedCountries: string[];
37+
sanctionedRegions: string[];
38+
};
3439
};
3540
cron: {
3641
monitor: string;

packages/common/src/constraints/CheckCandidates.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
checkSelfStake,
1616
checkUnclaimed,
1717
checkValidateIntention,
18+
checkSanctionedGeoArea,
1819
} from "./ValidityChecks";
1920
import { percentage, timeRemaining } from "../utils/util";
2021

@@ -129,6 +130,12 @@ export const checkCandidate = async (
129130
logger.info(`${candidate.name} beefy keys not valid`, constraintsLabel);
130131
}
131132

133+
const sanctionedGeoAreaValid =
134+
constraints.config?.constraints?.sanctionedGeoArea?.skip == true
135+
? true
136+
: (await checkSanctionedGeoArea(constraints.config, candidate)) ||
137+
false;
138+
132139
valid =
133140
onlineValid &&
134141
validateValid &&
@@ -142,7 +149,8 @@ export const checkCandidate = async (
142149
blockedValid &&
143150
kusamaValid &&
144151
providerValid &&
145-
beefyValid;
152+
beefyValid &&
153+
sanctionedGeoAreaValid;
146154

147155
await setValid(candidate, valid);
148156

packages/common/src/constraints/ValidityChecks.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
setSelfStakeInvalidity,
1616
setUnclaimedInvalidity,
1717
setValidateIntentionValidity,
18+
setSanctionedGeoAreaValidity,
1819
} from "../db";
1920
import { ChainData, Config, Constants, queries, Util } from "../index";
2021
import axios from "axios";
@@ -434,3 +435,61 @@ export const checkBeefyKeys = async (
434435
throw new Error("could not make validity check");
435436
}
436437
};
438+
439+
// Checks if the candidate is in a sanctioned location
440+
export const checkSanctionedGeoArea = async (
441+
config: Config.ConfigSchema,
442+
candidate: Candidate,
443+
): Promise<boolean> => {
444+
try {
445+
if (
446+
!config.constraints?.sanctionedGeoArea?.sanctionedCountries?.length &&
447+
!config.constraints?.sanctionedGeoArea?.sanctionedRegions?.length
448+
) {
449+
await setSanctionedGeoAreaValidity(candidate, true);
450+
return true;
451+
}
452+
453+
const location = await queries.getCandidateLocation(candidate.slotId);
454+
if (!location?.region || !location?.country) {
455+
await setSanctionedGeoAreaValidity(candidate, true);
456+
return true;
457+
}
458+
459+
const sanctionedCountries = config.constraints?.sanctionedGeoArea
460+
?.sanctionedCountries
461+
? config.constraints.sanctionedGeoArea.sanctionedCountries.map((x) =>
462+
x.trim().toLowerCase(),
463+
)
464+
: [];
465+
const sanctionedRegions = config.constraints?.sanctionedGeoArea
466+
?.sanctionedRegions
467+
? config.constraints.sanctionedGeoArea.sanctionedRegions.map((x) =>
468+
x.trim().toLowerCase(),
469+
)
470+
: [];
471+
472+
if (
473+
sanctionedCountries.includes(location.country.trim().toLowerCase()) ||
474+
sanctionedRegions.includes(location.region.trim().toLowerCase())
475+
) {
476+
logger.info(
477+
`${candidate.name} is in a sanctioned location: Country: ${location.country}, Region: ${location.region}`,
478+
{
479+
label: "Constraints",
480+
},
481+
);
482+
await setSanctionedGeoAreaValidity(candidate, false);
483+
return false;
484+
}
485+
486+
await setSanctionedGeoAreaValidity(candidate, true);
487+
return true;
488+
} catch (e) {
489+
logger.error(
490+
`Error checking location for sanctions: ${e}`,
491+
constraintsLabel,
492+
);
493+
throw new Error("could not make validity check");
494+
}
495+
};

0 commit comments

Comments
 (0)