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

Commit b886d95

Browse files
will pankiewiczwill pankiewicz
authored andcommitted
adjust version checking + enable telemetry integration tests + bump version to v3.1.8
1 parent da60393 commit b886d95

File tree

21 files changed

+118
-55
lines changed

21 files changed

+118
-55
lines changed

.circleci/config.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ jobs:
137137
export MONGO_URI="mongodb://mongodb:27017/testdb"
138138
yarn workspace @1kv/common test:scorekeeper:int
139139
140+
TelemetryIntegrationTests:
141+
description: "Telemetry Integration Tests"
142+
docker:
143+
- image: node:18-bullseye
144+
- image: mongo:6.0.9
145+
name: mongodb
146+
147+
resource_class: xlarge
148+
steps:
149+
- checkout
150+
- run:
151+
name: Install Dependencies
152+
command: yarn install --immutable
153+
- run:
154+
name: Run Tests
155+
command: |
156+
export MONGO_URI="mongodb://mongodb:27017/testdb"
157+
yarn workspace @1kv/telemetry test:int
158+
140159
helmLint:
141160
docker:
142161
- image: web3f/ci-commons:v3.2.3
@@ -296,26 +315,26 @@ workflows:
296315
filters:
297316
tags:
298317
ignore: /.*/
299-
300318
- ChaindataIntegrationTests:
301319
filters:
302320
tags:
303321
ignore: /.*/
304-
305322
- ApiHandlerIntegrationTests:
306323
filters:
307324
tags:
308325
ignore: /.*/
309-
310326
- NominatorIntegrationTests:
311327
filters:
312328
tags:
313329
ignore: /.*/
314-
315330
- ScorekeeperIntegrationTests:
316331
filters:
317332
tags:
318333
ignore: /.*/
334+
- TelemetryIntegrationTests:
335+
filters:
336+
tags:
337+
ignore: /.*/
319338
- helmLint:
320339
filters:
321340
tags:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ docs/.DS_Store
4141
.turbo
4242
build/**
4343
dist/**
44-
.next/**
44+
.next/**
45+
coverage/**

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ spec:
5757
"skipConnectionTime": true,
5858
"skipIdentity": false,
5959
"skipClientUpgrade": false,
60-
"forceClientVersion": "v0.9.39",
6160
"skipUnclaimed": true,
6261
"minSelfStake": 10000000000000,
6362
"commission": 150000000,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ spec:
5656
"skipConnectionTime": false,
5757
"skipIdentity": false,
5858
"skipClientUpgrade": false,
59-
"forceClientVersion": "v0.9.39",
6059
"skipUnclaimed": true,
6160
"minSelfStake": 50000000000000,
6261
"commission": 50000000,

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

Lines changed: 1 addition & 2 deletions
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.7
20+
targetRevision: v3.1.8
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -55,7 +55,6 @@ spec:
5555
"skipIdentity": false,
5656
"skipStakedDestination": true,
5757
"skipClientUpgrade": false,
58-
"forceClientVersion": "v0.9.39",
5958
"skipUnclaimed": true,
6059
"minSelfStake": 10000000000000,
6160
"commission": 150000000,

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

Lines changed: 1 addition & 2 deletions
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.7
20+
targetRevision: v3.1.8
2121
plugin:
2222
env:
2323
- name: HELM_VALUES
@@ -54,7 +54,6 @@ spec:
5454
"skipIdentity": false,
5555
"skipStakedDestination": true,
5656
"skipClientUpgrade": false,
57-
"forceClientVersion": "v0.9.39",
5857
"skipUnclaimed": true,
5958
"minSelfStake": 50000000000000,
6059
"commission": 50000000,

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.7
4-
appVersion: v3.1.7
3+
version: v3.1.8
4+
appVersion: v3.1.8
55
apiVersion: v2

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
"test:common:int:apihandler:ci": "circleci local execute ApiHandlerIntegrationTests",
6565
"test:common:int:nominator:ci": "circleci local execute NominatorIntegrationTests",
6666
"test:common:int:ci": "yarn test:common:int:scorekeeper:ci && yarn test:common:int:chaindata:ci && yarn test:common:int:apihandler:ci && yarn test:common:int:nominator:ci",
67+
"test:telemetry:int:ci": "circleci local execute TelemetryIntegrationTests",
68+
"test:ci:all": "yarn test:common:int:ci && yarn test:telemetry:int:ci",
6769
"test:all": "yarn workspaces foreach run test",
6870
"test": "LOG_LEVEL=warn yarn build && vitest run --coverage --config vitest.config.mts",
6971
"test:ui": "LOG_LEVEL=warn vitest --ui --config vitest.config.mts --coverage",

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

packages/common/src/constraints/ValidityChecks.ts

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import axios from "axios";
2121
import semver from "semver";
2222
import logger from "../logger";
2323
import { constraintsLabel } from "./constraints";
24+
import { getLatestTaggedRelease } from "../scorekeeper/jobs/specificJobs";
2425

2526
export const checkOnline = async (candidate: any): Promise<boolean> => {
2627
try {
@@ -89,43 +90,66 @@ export const checkLatestClientVersion = async (
8990
): Promise<boolean> => {
9091
try {
9192
const skipClientUpgrade = config.constraints?.skipClientUpgrade || false;
92-
if (!skipClientUpgrade) {
93-
if (candidate?.implementation == "Kagome Node") {
94-
await setLatestClientReleaseValidity(candidate.stash, true);
95-
return true;
93+
if (skipClientUpgrade || candidate?.implementation === "Kagome Node") {
94+
// Skip the check if the node is a Kagome Client or if skipping client upgrade is enabled
95+
await setLatestClientReleaseValidity(candidate.stash, true);
96+
return true;
97+
}
98+
99+
// The latest release that is manually set in the config (set if there's reasons for people to downgrade)
100+
const forceLatestRelease = config.constraints.forceClientVersion;
101+
102+
// Get the latest release from the db or github
103+
let latestRelease = await getLatestRelease();
104+
if (!latestRelease) {
105+
logger.info(
106+
`No latest release found, fetching from GitHub`,
107+
constraintsLabel,
108+
);
109+
latestRelease = await getLatestTaggedRelease();
110+
logger.info(
111+
`Latest release fetched from GitHub: ${latestRelease}`,
112+
constraintsLabel,
113+
);
114+
}
115+
116+
// Check if there is a latest release and if the current time is past the grace window
117+
const isPastGraceWindow =
118+
latestRelease &&
119+
Date.now() > latestRelease.publishedAt + Constants.SIXTEEN_HOURS;
120+
121+
if (latestRelease && isPastGraceWindow) {
122+
const nodeVersion = semver.coerce(candidate.version);
123+
const latestVersion = forceLatestRelease
124+
? semver.clean(forceLatestRelease)
125+
: semver.clean(latestRelease.name);
126+
127+
logger.info(
128+
`Checking latest client version: ${nodeVersion} >= ${latestVersion}`,
129+
constraintsLabel,
130+
);
131+
132+
// If cannot parse the version, set the release as invalid
133+
if (!nodeVersion || !latestVersion) {
134+
await setLatestClientReleaseValidity(candidate.stash, false);
135+
return false;
96136
}
97137

98-
const forceLatestRelease = config.constraints.forceClientVersion;
99-
const latestRelease = await getLatestRelease();
100-
if (
101-
candidate.version &&
102-
latestRelease &&
103-
Date.now() > latestRelease.publishedAt + Constants.SIXTEEN_HOURS
104-
) {
105-
const nodeVersion = semver.coerce(candidate.version);
106-
const latestVersion = forceLatestRelease
107-
? semver.clean(forceLatestRelease)
108-
: semver.clean(latestRelease.name);
109-
if (!nodeVersion || !latestVersion) {
110-
await setLatestClientReleaseValidity(candidate.stash, false);
111-
return false;
112-
}
138+
const isUpgraded = semver.gte(nodeVersion, latestVersion);
113139

114-
const isUpgraded = semver.gte(nodeVersion, latestVersion);
115-
if (!isUpgraded) {
116-
await setLatestClientReleaseValidity(candidate.stash, false);
117-
return false;
118-
} else {
119-
await setLatestClientReleaseValidity(candidate.stash, true);
120-
return true;
121-
}
122-
} else {
140+
// If they are not upgrade, set the validity as invalid
141+
if (!isUpgraded) {
123142
await setLatestClientReleaseValidity(candidate.stash, false);
124143
return false;
125144
}
126-
} else {
145+
146+
// If the current version is the latest release, set the release as valid
127147
await setLatestClientReleaseValidity(candidate.stash, true);
128148
return true;
149+
} else {
150+
// If there is no latest release or if not past the grace window, set the release as invalid
151+
await setLatestClientReleaseValidity(candidate.stash, false);
152+
return false;
129153
}
130154
} catch (e) {
131155
logger.error(

0 commit comments

Comments
 (0)