Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.1.4 #2709

Merged
merged 14 commits into from
Mar 6, 2024
2 changes: 1 addition & 1 deletion apps/1kv-backend/templates/kusama-otv-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.1.3
targetRevision: v3.1.4
plugin:
env:
- name: HELM_VALUES
Expand Down
2 changes: 1 addition & 1 deletion apps/1kv-backend/templates/polkadot-otv-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.1.3
targetRevision: v3.1.4
plugin:
env:
- name: HELM_VALUES
Expand Down
4 changes: 2 additions & 2 deletions charts/otv-backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: 1K Validators Backend
name: otv-backend
version: v3.1.3
appVersion: v3.1.3
version: v3.1.4
appVersion: v3.1.4
apiVersion: v2
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/common",
"version": "3.1.3",
"version": "3.1.4",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
17 changes: 17 additions & 0 deletions packages/common/src/chaindata/queries/Identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ export const getFormattedIdentity = async (
const identityInfo = await chaindata.api?.derive.accounts.identity(addr);
if (!identityInfo) return null;

const hasSubs = await chaindata.api?.query.identity.subsOf(addr);
if (hasSubs && hasSubs[1].length > 0) {
for (const subaccountAddress of hasSubs[1]) {
const subAccountIdentity =
await chaindata.api?.derive.accounts.identity(
subaccountAddress.toString(),
);
if (subAccountIdentity) {
const subAccount: { name: string; address: string } = {
name: subAccountIdentity.display || "",
address: subaccountAddress.toString(),
};
subAccounts.push(subAccount);
}
}
}

const {
display,
email,
Expand Down
17 changes: 12 additions & 5 deletions packages/common/src/nominator/NominatorTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ export const sendProxyTx = async (
}

const namedTargets = await Promise.all(
targets.map(async (val) => {
const name = await queries.getIdentityName(val);
const kyc = await queries.isKYC(val);
const scoreResult = await queries.getLatestValidatorScore(val);
targets.map(async (target) => {
const kyc = await queries.isKYC(target);
let name = await queries.getIdentityName(target);
if (!name) {
name =
(await nominator.chaindata.getFormattedIdentity(target))?.name ||
"";
}

const scoreResult = await queries.getLatestValidatorScore(target);
const score = scoreResult && scoreResult.total ? scoreResult.total : 0;

return {
address: val,
stash: target,
name: name || "",
kyc: kyc || false,
score: score,
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/nominator/nominator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class Nominator extends EventEmitter {
return this._status;
};

public async updateNominatorStatus(newStatus: NominatorStatus) {
public async updateNominatorStatus(newStatus?: NominatorStatus) {
// Always update on-chain data for status
const nominatorInfo = await getNominatorChainInfo(this);
const {
Expand All @@ -113,6 +113,9 @@ export default class Nominator extends EventEmitter {
}

public async shouldNominate(): Promise<boolean> {
// refresh the nominator status with the latest on-chain data
await this.updateNominatorStatus();

const stash = await this.stash();
const isBonded = await this.chaindata.isBonded(stash);
const [bonded, err] = await this.chaindata.getDenomBondedAmount(stash);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/scorekeeper/NumNominations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const autoNumNominations = async (
}

// How many additional validator to nominate above the amount to get in the set
const additional = 1;
const additional = 1.05;

const maxNominations = 24;
// The total amount of validators to nominate
Expand Down
46 changes: 28 additions & 18 deletions packages/common/src/scorekeeper/Round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ export const startRound = async (
);

for (const nom of nominatorGroups) {
const nominatorStatus: NominatorStatus = {
state: NominatorState.Nominating,
status: `Round Started`,
updated: Date.now(),
stale: false,
};
await nom.updateNominatorStatus(nominatorStatus);
const shouldNominate = await nom.shouldNominate();
if (shouldNominate) {
const nominatorStatus: NominatorStatus = {
state: NominatorState.Nominating,
status: `Round Started`,
updated: Date.now(),
stale: false,
};

await nom.updateNominatorStatus(nominatorStatus);
}
}

const proxyTxs = await queries.getAllDelayedTxs();
Expand Down Expand Up @@ -90,26 +94,32 @@ export const startRound = async (
scorekeeperLabel,
);
for (const nom of nominatorGroups) {
const shouldNominate = await nom.shouldNominate();
if (!shouldNominate) {
const nominatorStatus: NominatorStatus = {
state: NominatorState.Nominating,
status: `[${index}/${allCandidates.length}] ${candidate.name} ${isValid ? "✅ " : "❌"}`,
updated: Date.now(),
stale: false,
};
await nom.updateNominatorStatus(nominatorStatus);
}
}
}

for (const nom of nominatorGroups) {
const shouldNominate = await nom.shouldNominate();
if (shouldNominate) {
const nominatorStatus: NominatorStatus = {
state: NominatorState.Nominating,
status: `[${index}/${allCandidates.length}] ${candidate.name} ${isValid ? "✅ " : "❌"}`,
status: `Scoring Candidates...`,
updated: Date.now(),
stale: false,
};
await nom.updateNominatorStatus(nominatorStatus);
}
}

for (const nom of nominatorGroups) {
const nominatorStatus: NominatorStatus = {
state: NominatorState.Nominating,
status: `Scoring Candidates...`,
updated: Date.now(),
stale: false,
};
await nom.updateNominatorStatus(nominatorStatus);
}

// Score all candidates
await constraints.scoreAllCandidates();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { logger, queries } from "../../../index";
import { Job, JobConfig, JobRunnerMetadata, JobStatus } from "../JobsClass";
import { jobStatusEmitter } from "../../../Events";
import { setValidatorRanks, withExecutionTimeLogging } from "../../../utils";
import {
setAllIdentities,
setValidatorRanks,
withExecutionTimeLogging,
} from "../../../utils";
import { JobNames } from "../JobConfigs";

export const erastatsLabel = { label: "EraStatsJob" };
Expand All @@ -18,6 +22,7 @@ export const eraStatsJob = async (
try {
const { chaindata } = metadata;

await setAllIdentities(chaindata, erastatsLabel);
await setValidatorRanks();

const currentSession = await chaindata.getSession();
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/scorekeeper/scorekeeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Job, JobRunnerMetadata, JobStatus } from "./jobs/JobsClass";
import { JobsRunnerFactory } from "./jobs/JobsRunnerFactory";
import { startRound } from "./Round";
import { NominatorStatus } from "../types";
import { setAllIdentities } from "../utils";
// import { monitorJob } from "./jobs";

export type NominatorGroup = Config.NominatorConfig[];
Expand Down Expand Up @@ -244,7 +245,7 @@ export default class ScoreKeeper {
const currentEra = (await this.chaindata.getCurrentEra()) || 0;
this.currentEra = currentEra;

// await setAllIdentities(this.chaindata, scorekeeperLabel);
await setAllIdentities(this.chaindata, scorekeeperLabel);

const nominationPromises = this.nominatorGroups.map((nom) =>
nom.shouldNominate(),
Expand Down
4 changes: 2 additions & 2 deletions packages/common/test/chaindata/chaindata.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe("ChainData Integration Tests", () => {
"should fetch identity",
async () => {
const getIdentity = await chainData.getIdentity(
"J4hAvZoHCviZSoPHoSwLida8cEkZR1NXJcGrcfx9saHTk7D",
"DBfT2GUqHX89afMhTzGCCbAc44zX33d4XySWX2qAPxZ35KE",
);
expect(getIdentity).toBeDefined();
},
Expand All @@ -351,7 +351,7 @@ describe("ChainData Integration Tests", () => {
"should fetch formatted identity",
async () => {
const identity = await chainData.getFormattedIdentity(
"J4hAvZoHCviZSoPHoSwLida8cEkZR1NXJcGrcfx9saHTk7D",
"CbaNLeJQ8e8aCJMTLa9euDKuTDmnT5oPmGFt4AmuvXmYFGN",
);
expect(identity).toBeDefined();
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/core",
"version": "3.1.3",
"version": "3.1.4",
"description": "Services for running the Thousand Validator Program.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/gateway",
"version": "3.1.3",
"version": "3.1.4",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/scorekeeper-status-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@1kv/scorekeeper-status-ui",
"private": true,
"version": "3.1.3",
"version": "3.1.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion packages/scorekeeper-status-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ const App = () => {
theme="polkadot"
/>
{target.name
? `${target.name}`
? `[${target.score?.toFixed(0)}] ${target.name}`
: `${truncateAddress(target.stash)}`}{" "}
{target.kyc && (
<FiCheckCircle
Expand Down
2 changes: 1 addition & 1 deletion packages/telemetry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/telemetry",
"version": "3.1.3",
"version": "3.1.4",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/worker",
"version": "3.1.3",
"version": "3.1.4",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down