Skip to content

Commit 193b10a

Browse files
authored
Merge pull request #2943 from w3f/staging
Staging
2 parents 5bd8527 + d6a764f commit 193b10a

File tree

14 files changed

+163
-132
lines changed

14 files changed

+163
-132
lines changed

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

+1-1
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.2
20+
targetRevision: v3.3.0
2121
plugin:
2222
env:
2323
- name: HELM_VALUES

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

+1-1
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.2
20+
targetRevision: v3.3.0
2121
plugin:
2222
env:
2323
- name: HELM_VALUES

charts/otv-backend/Chart.yaml

+2-2
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.2
4-
appVersion: v3.2.2
3+
version: v3.3.0
4+
appVersion: v3.3.0
55
apiVersion: v2

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"@bull-board/koa": "^5.15.0",
105105
"@koa/router": "^12.0.1",
106106
"@octokit/rest": "^20.0.2",
107-
"@polkadot/api": "^11.0.2",
107+
"@polkadot/api": "^11.1.1",
108108
"@polkadot/keyring": "^12.6.2",
109109
"@types/cron": "^2.4.0",
110110
"@types/jest": "^29.5.12",

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/common",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/common/src/chaindata/chaindata.ts

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApiPromise } from "@polkadot/api";
1+
import { ApiPromise, WsProvider } from "@polkadot/api";
22
import ApiHandler, { apiLabel } from "../ApiHandler/ApiHandler";
33
import logger from "../logger";
44
import { NumberResult } from "../types";
@@ -71,12 +71,45 @@ export const chaindataLabel = { label: "Chaindata" };
7171
export class ChainData {
7272
public handler: ApiHandler;
7373
public api: ApiPromise | null;
74+
public apiPeople: ApiPromise | null;
7475

7576
constructor(handler: ApiHandler) {
7677
this.handler = handler;
7778
this.api = handler.getApi();
79+
this.setApiPeople();
7880
}
7981

82+
setApiPeople = async (): Promise<void> => {
83+
if (!(await this.api.rpc.system.chain()).toLowerCase().includes("kusama"))
84+
return;
85+
86+
const provider = new WsProvider("wss://kusama-people-rpc.polkadot.io");
87+
this.apiPeople = await ApiPromise.create({ provider: provider });
88+
if (this.apiPeople) {
89+
this.apiPeople.on("error", (error) => {
90+
if (
91+
error.toString().includes("FATAL") ||
92+
JSON.stringify(error).includes("FATAL")
93+
) {
94+
logger.error("The API had a FATAL error... exiting!");
95+
process.exit(1);
96+
}
97+
});
98+
}
99+
await this.apiPeople.isReadyOrError;
100+
101+
const [chain, nodeName, nodeVersion] = await Promise.all([
102+
this.apiPeople.rpc.system.chain(),
103+
this.apiPeople.rpc.system.name(),
104+
this.apiPeople.rpc.system.version(),
105+
]);
106+
logger.info(
107+
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`,
108+
apiLabel,
109+
);
110+
return;
111+
};
112+
80113
checkApiConnection = async (retries = 0): Promise<boolean> => {
81114
// Check if the API is already connected
82115
if (this.handler.getApi()?.isConnected) {

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

+23-25
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ export const hasIdentity = async (
66
account: string,
77
): Promise<[boolean, boolean]> => {
88
try {
9-
if (!(await chaindata.checkApiConnection())) {
9+
const api = chaindata.apiPeople ? chaindata.apiPeople : chaindata.api;
10+
11+
if (!api?.isConnected) {
1012
return [false, false];
1113
}
12-
let identity = await chaindata.api?.query.identity.identityOf(account);
14+
let identity = await api.query.identity.identityOf(account);
1315
if (!identity || !identity.isSome) {
1416
// check if it's a sub
15-
const superOf = await chaindata.api?.query.identity.superOf(account);
17+
const superOf = await api.query.identity.superOf(account);
1618
if (superOf && superOf.isSome) {
17-
identity = await chaindata.api?.query.identity.identityOf(
18-
superOf.unwrap()[0],
19-
);
19+
identity = await api.query.identity.identityOf(superOf.unwrap()[0]);
2020
}
2121
}
22-
const identityInfo = await chaindata.api?.derive.accounts.identity(account);
22+
const identityInfo = await api.derive.accounts.identity(account);
2323
if (!identityInfo) return null;
2424
let verified = false;
2525
if (identity && identity.isSome) {
@@ -33,7 +33,7 @@ export const hasIdentity = async (
3333

3434
return [identity ? identity.isSome : false, verified];
3535
} catch (e) {
36-
await handleError(chaindata, e, "hasIdentity");
36+
if (!chaindata.apiPeople) await handleError(chaindata, e, "hasIdentity");
3737
return [false, true];
3838
}
3939
};
@@ -43,26 +43,26 @@ export const getFormattedIdentity = async (
4343
addr: string,
4444
): Promise<Identity | null> => {
4545
try {
46-
if (!(await chaindata.checkApiConnection())) {
46+
const api = chaindata.apiPeople ? chaindata.apiPeople : chaindata.api;
47+
if (!api?.isConnected) {
4748
return null;
4849
}
4950
let identity: Identity | null = null;
5051
let verified = false;
5152
const subAccounts: { name: string; address: string }[] = [];
5253

53-
const hasId = await chaindata.api?.derive.accounts.hasIdentity(addr);
54+
const hasId = await api.derive.accounts.hasIdentity(addr);
5455
if (!hasId || !hasId.hasIdentity) return null;
5556

56-
const identityInfo = await chaindata.api?.derive.accounts.identity(addr);
57+
const identityInfo = await api.derive.accounts.identity(addr);
5758
if (!identityInfo) return null;
5859

59-
const hasSubs = await chaindata.api?.query.identity.subsOf(addr);
60+
const hasSubs = await api.query.identity.subsOf(addr);
6061
if (hasSubs && hasSubs[1].length > 0) {
6162
for (const subaccountAddress of hasSubs[1]) {
62-
const subAccountIdentity =
63-
await chaindata.api?.derive.accounts.identity(
64-
subaccountAddress.toString(),
65-
);
63+
const subAccountIdentity = await api.derive.accounts.identity(
64+
subaccountAddress.toString(),
65+
);
6666
if (subAccountIdentity) {
6767
const subAccount: { name: string; address: string } = {
6868
name: subAccountIdentity.display || "",
@@ -97,21 +97,18 @@ export const getFormattedIdentity = async (
9797
}
9898

9999
if (parent) {
100-
const superIdentity =
101-
await chaindata.api?.derive.accounts.identity(parent);
100+
const superIdentity = await api.derive.accounts.identity(parent);
102101
if (superIdentity) {
103102
const superAccount: { name: string; address: string } = {
104103
name: superIdentity.display || "",
105104
address: parent.toString(),
106105
};
107-
const subIdentities =
108-
await chaindata.api?.query.identity.subsOf(parent);
106+
const subIdentities = await api.query.identity.subsOf(parent);
109107
if (subIdentities && subIdentities[1].length > 0) {
110108
for (const subaccountAddress of subIdentities[1]) {
111-
const subAccountIdentity =
112-
await chaindata.api?.derive.accounts.identity(
113-
subaccountAddress.toString(),
114-
);
109+
const subAccountIdentity = await api.derive.accounts.identity(
110+
subaccountAddress.toString(),
111+
);
115112
if (subAccountIdentity) {
116113
const subAccount: { name: string; address: string } = {
117114
name: subAccountIdentity.display || "",
@@ -158,7 +155,8 @@ export const getFormattedIdentity = async (
158155

159156
return identity;
160157
} catch (e) {
161-
await handleError(chaindata, e, "getFormattedIdentity");
158+
if (!chaindata.apiPeople)
159+
await handleError(chaindata, e, "getFormattedIdentity");
162160
return null;
163161
}
164162
};

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const individualEraPointsJob = async (
2727
const data = await chaindata.getTotalEraPoints(eraIndex);
2828
if (
2929
data &&
30-
data.era &&
30+
data.era == eraIndex &&
3131
data.total &&
3232
data.validators &&
3333
data.validators.length > 0

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/core",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "index.js",
66
"scripts": {

packages/gateway/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/gateway",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/scorekeeper-status-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@1kv/scorekeeper-status-ui",
33
"private": true,
4-
"version": "3.2.2",
4+
"version": "3.3.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

packages/telemetry/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/telemetry",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

packages/worker/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@1kv/worker",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "Services for running the Thousand Validator Program.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

0 commit comments

Comments
 (0)