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

Commit f3e30e0

Browse files
authored
Merge pull request #2930 from w3f/staging
Staging
2 parents 4157ccf + a08a17b commit f3e30e0

File tree

19 files changed

+50
-109
lines changed

19 files changed

+50
-109
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.2.1
20+
targetRevision: v3.2.2
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.2.1
20+
targetRevision: v3.2.2
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.2.1
4-
appVersion: v3.2.1
3+
version: v3.2.2
4+
appVersion: v3.2.2
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.2.1",
3+
"version": "3.2.2",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/common/src/chaindata/queries/Era.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export const getTotalEraPoints = async (
4646
if (!chainType) {
4747
return {} as EraPointsInfo;
4848
}
49-
const [blockHash, err] = await chaindata.findEraBlockHash(era, chainType);
49+
const [blockHash, err] = await chaindata.findEraBlockHash(
50+
era + 1,
51+
chainType,
52+
);
5053

5154
if (blockHash) {
5255
const apiAt = await chaindata?.api?.at(blockHash);
@@ -204,12 +207,12 @@ export const findEraBlockHash = async (
204207
return ["", "API at block hash is null"];
205208
}
206209

207-
const testEra = await apiAt.query.staking.currentEra();
210+
const testEra = await apiAt.query.staking.activeEra();
208211
if (testEra && testEra.isEmpty) {
209212
logger.info(`Test era is empty: ${JSON.stringify(testEra)}`);
210213
return ["", "Test era is none"];
211214
}
212-
const testIndex = testEra.unwrap().toNumber();
215+
const testIndex = testEra.unwrap().index.toNumber();
213216
if (era == testIndex) {
214217
return [blockHash.toString(), null];
215218
}

packages/common/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,5 @@ export const USE_PROVIDER = true;
207207
export const USE_NOMINATIONS = true;
208208
export const USE_RPC = true;
209209
export const USE_CLIENT = true;
210+
211+
export const ERAPOINTS_JOB_MAX_ERAS = 84;

packages/common/src/constraints/CheckCandidates.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { logger } from "../index";
1+
import { ChainData, logger } from "../index";
22
import { allCandidates, Candidate, setLastValid, setValid } from "../db";
33
import { constraintsLabel, OTV } from "./constraints";
44
import {
@@ -22,6 +22,7 @@ import { percentage, timeRemaining } from "../utils/util";
2222
export const checkCandidate = async (
2323
constraints: OTV,
2424
candidate: Candidate,
25+
validators: string[],
2526
): Promise<boolean> => {
2627
try {
2728
let valid = false;
@@ -33,8 +34,8 @@ export const checkCandidate = async (
3334

3435
const validateValid = await checkValidateIntention(
3536
constraints.config,
36-
constraints.chaindata,
3737
candidate,
38+
validators,
3839
);
3940
if (!validateValid) {
4041
logger.info(
@@ -62,7 +63,10 @@ export const checkCandidate = async (
6263
);
6364
}
6465

65-
const identityValid = await checkIdentity(constraints.chaindata, candidate);
66+
const identityValid =
67+
constraints.config?.constraints?.skipIdentity == true
68+
? true
69+
: (await checkIdentity(constraints.chaindata, candidate)) || false;
6670
if (!identityValid) {
6771
logger.info(`${candidate.name} identity not valid`, constraintsLabel);
6872
}
@@ -166,14 +170,16 @@ export const checkCandidate = async (
166170

167171
export const checkAllCandidates = async (
168172
constraints: OTV,
173+
chaindata: ChainData,
169174
): Promise<boolean> => {
170175
try {
171176
const candidates = await allCandidates();
177+
const validators = await chaindata.getValidators();
172178
logger.info(`checking ${candidates.length} candidates`, constraintsLabel);
173179
for (const [index, candidate] of candidates.entries()) {
174180
const start = Date.now();
175181

176-
const isValid = await constraints.checkCandidate(candidate);
182+
const isValid = await constraints.checkCandidate(candidate, validators);
177183
const end = Date.now();
178184
const time = `(${end - start}ms)`;
179185
const remaining = timeRemaining(

packages/common/src/constraints/ValidityChecks.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ export const checkOnline = async (candidate: Candidate): Promise<boolean> => {
4444
// Check the validate intention for a single validator
4545
export const checkValidateIntention = async (
4646
config: Config.ConfigSchema,
47-
chaindata: ChainData,
4847
candidate: Candidate,
48+
validators: string[],
4949
): Promise<boolean> => {
5050
try {
51-
const validators = await chaindata.getValidators();
5251
if (
5352
!validators?.length ||
5453
validators.includes(Util.formatAddress(candidate?.stash, config))
@@ -65,28 +64,6 @@ export const checkValidateIntention = async (
6564
}
6665
};
6766

68-
// checks the validate intention for all validators
69-
export const checkAllValidateIntentions = async (
70-
config: Config.ConfigSchema,
71-
chaindata: ChainData,
72-
candidates: Candidate[],
73-
): Promise<boolean> => {
74-
try {
75-
const validators = await chaindata.getValidators();
76-
for (const candidate of candidates) {
77-
if (!validators.includes(Util.formatAddress(candidate.stash, config))) {
78-
await setValidateIntentionValidity(candidate, false);
79-
} else {
80-
await setValidateIntentionValidity(candidate, true);
81-
}
82-
}
83-
return true;
84-
} catch (e) {
85-
logger.error(`Error checking validate intentions: ${e}`, constraintsLabel);
86-
throw new Error("could not make validity check");
87-
}
88-
};
89-
9067
// checks that the validator is on the latest client version
9168
export const checkLatestClientVersion = async (
9269
config: Config.ConfigSchema,

packages/common/src/constraints/constraints.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ export class OTV implements Constraints {
100100

101101
// Checks the validity of all candidates
102102
async checkAllCandidates(): Promise<boolean> {
103-
return await checkAllCandidates(this);
103+
return await checkAllCandidates(this, this.chaindata);
104104
}
105105

106106
// Check the candidate and set any invalidity fields
107-
async checkCandidate(candidate: Candidate): Promise<boolean> {
108-
return await checkCandidate(this, candidate);
107+
async checkCandidate(
108+
candidate: Candidate,
109+
validators: string[],
110+
): Promise<boolean> {
111+
return await checkCandidate(this, candidate, validators);
109112
}
110113

111114
async scoreAllCandidates(): Promise<boolean> {

packages/common/src/constraints/score.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const getStats = (arr: number[]): Stats => {
9999
const arrQ75 = arr.length !== 0 ? q75(arr) : 0;
100100
const arrQ90 = arr.length !== 0 ? q90(arr) : 0;
101101
const arrMean = arr.length !== 0 ? mean(arr) : 0;
102-
const arrStd = arr.length !== 0 ? std(arr) : 0;
102+
const arrStd = arr.length > 1 ? std(arr) : 0;
103103

104104
return {
105105
values: arr,

0 commit comments

Comments
 (0)