Skip to content

Commit

Permalink
bump versions to 3.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
will pankiewicz authored and will pankiewicz committed Jan 10, 2024
1 parent 3cd9665 commit 9ebeddf
Show file tree
Hide file tree
Showing 23 changed files with 400 additions and 168 deletions.
2 changes: 1 addition & 1 deletion apps/1kv-backend-staging/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.0.5
targetRevision: ^v3.0.6
plugin:
env:
- name: HELM_VALUES
Expand Down
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.0.5
targetRevision: ^v3.0.6
plugin:
env:
- name: HELM_VALUES
Expand Down
5 changes: 3 additions & 2 deletions 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.0.5
targetRevision: v3.0.6
plugin:
env:
- name: HELM_VALUES
Expand Down Expand Up @@ -62,7 +62,8 @@ spec:
"unclaimedEraThreshold": 4
},
"cron": {
"monitor": "0 */15 * * * *"
"monitor": "0 */15 * * * *",
"blockEnabled": false
},
"db": {
"mongo": {
Expand Down
5 changes: 3 additions & 2 deletions 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.0.5
targetRevision: v3.0.6
plugin:
env:
- name: HELM_VALUES
Expand Down Expand Up @@ -61,7 +61,8 @@ spec:
"unclaimedEraThreshold": 1
},
"cron": {
"monitor": "0 */15 * * * *"
"monitor": "0 */15 * * * *",
"blockEnabled": false
},
"db": {
"mongo": {
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.0.5
appVersion: v3.0.5
version: v3.0.6
appVersion: v3.0.6
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.0.5",
"version": "3.0.6",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/chaindata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,14 @@ export class ChainData {
return keys;
};

getNextKeys = async (stash: string): Promise<string> => {
getNextKeys = async (stash: string): Promise<any> => {
if (!this.api.isConnected) {
logger.warn(`{Chaindata::API::Warn} API is not connected, returning...`);
return;
}

const nextKeys = await this.api.query.session.nextKeys(stash);
return nextKeys.toHex();
return nextKeys;
};

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/common/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,39 @@ export type ConfigSchema = {
monitor: string;
clearOffline: string;
validity: string;
validityEnabled: boolean;
execution: string;
scorekeeper: string;
rewardClaiming: string;
cancel: string;
stale: string;
score: string;
scoreEnabled: boolean;
eraStats: string;
eraStatsEnabled: boolean;
locationStats: string;
locationStatsEnabled: boolean;
democracy: string;
democracyEnabled: boolean;
// chain querying crons
eraPoints: string;
eraPointsEnabled: boolean;
activeValidator: string;
activeValidatorEnabled: boolean;
inclusion: string;
inclusionEnabled: boolean;
sessionKey: string;
sessionKeyEnabled: boolean;
unclaimedEras: string;
unclaimedErasEnabled: boolean;
validatorPref: string;
validatorPrefEnabled: boolean;
nominator: string;
nominatorEnabled: boolean;
delegation: string;
delegationEnabled: boolean;
block: string;
blockEnabled: boolean;
};
db: {
mongo: {
Expand Down
55 changes: 55 additions & 0 deletions packages/common/src/db/queries/Validators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LatestValidatorSetModel, ValidatorModel } from "../models";
import { allCandidates } from "./Candidate";

export const setLatestValidatorSet = async (
session: number,
Expand Down Expand Up @@ -73,3 +74,57 @@ export const getValidator = async (address: string): Promise<any> => {
export const getValidators = async (): Promise<any> => {
return ValidatorModel.find({}).lean().exec();
};

export const getValidatorsBeefyStats = async (): Promise<any> => {
const latestValidatorSet = await getLatestValidatorSet();
const validators = await getValidators();
const beefyValidators = validators.filter((validator: any) => {
return validator?.keys?.beefy?.slice(0, 10) != "0x62656566";
});

const activeBeefyValidators = beefyValidators.filter((validator: any) => {
return latestValidatorSet?.validators?.includes(validator.address);
});

const candidates = await allCandidates();
const activeBeefy1KVValidators = candidates.filter((candidate: any) => {
for (const validator of activeBeefyValidators) {
if (validator.address == candidate.stash) {
return true;
}
}
});

const totalBeefy1KVValidators = candidates.filter((candidate: any) => {
for (const validator of beefyValidators) {
if (validator.address == candidate.stash) {
return true;
}
}
});

return {
beefy1KVCount: totalBeefy1KVValidators.length,
activeBeefy1KVCount: activeBeefy1KVValidators.length,
activeBeefy1KVPercentage:
(activeBeefy1KVValidators.length / latestValidatorSet.validators.length) *
100,
total1KVValidatorCount: candidates.length,
beefyTotalValidatorCount: beefyValidators.length,
activeBeefyValidatorCount: activeBeefyValidators.length,
activeBeefyPercentage:
(activeBeefyValidators.length / latestValidatorSet.validators.length) *
100,
activeValidatorCount: latestValidatorSet.validators.length,
totalValidators: validators.length,
totalBeefyValidators: (beefyValidators.length / validators.length) * 100,
};
};

export const getDummyBeefyValidators = async (): Promise<any> => {
const validators = await getValidators();
const beefyValidators = validators.filter((validator: any) => {
return validator?.keys?.beefy?.slice(0, 10) == "0x62656566";
});
return beefyValidators;
};
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.0.5",
"version": "3.0.6",
"description": "Services for running the Thousand Validator Program.",
"main": "index.js",
"scripts": {
Expand Down
66 changes: 66 additions & 0 deletions packages/core/src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const startValidatityJob = async (
config: Config.ConfigSchema,
constraints: Constraints.OTV
) => {
const enabled = config.cron?.validityEnabled || true;
if (!enabled) {
logger.warn(`Validity Job is disabled`, cronLabel);
return;
}
const validityFrequency = config.cron?.validity
? config.cron?.validity
: Constants.VALIDITY_CRON;
Expand Down Expand Up @@ -105,6 +110,11 @@ export const startScoreJob = async (
config: Config.ConfigSchema,
constraints: Constraints.OTV
) => {
const enabled = config.cron?.scoreEnabled || true;
if (!enabled) {
logger.warn(`Score Job is disabled`, cronLabel);
return;
}
const scoreFrequency = config.cron?.score
? config.cron?.score
: Constants.SCORE_CRON;
Expand All @@ -130,6 +140,11 @@ export const startEraStatsJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.eraStatsEnabled || true;
if (!enabled) {
logger.warn(`Era Stats Job is disabled`, cronLabel);
return;
}
const eraStatsFrequency = config.cron?.eraStats
? config.cron?.eraStats
: Constants.ERA_STATS_CRON;
Expand Down Expand Up @@ -567,6 +582,11 @@ export const startEraPointsJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.eraPointsEnabled || true;
if (!enabled) {
logger.warn(`Era Points Job is disabled`, cronLabel);
return;
}
const eraPointsFrequency = config.cron?.eraPoints
? config.cron?.eraPoints
: Constants.ERA_POINTS_CRON;
Expand Down Expand Up @@ -604,6 +624,11 @@ export const startActiveValidatorJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.activeValidatorEnabled || true;
if (!enabled) {
logger.warn(`Active Validator Job is disabled`, cronLabel);
return;
}
const activeValidatorFrequency = config.cron?.activeValidator
? config?.cron?.activeValidator
: Constants.ACTIVE_VALIDATOR_CRON;
Expand Down Expand Up @@ -638,6 +663,11 @@ export const startInclusionJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.inclusionEnabled || true;
if (!enabled) {
logger.warn(`Inclusion Job is disabled`, cronLabel);
return;
}
const inclusionFrequency = config.cron?.inclusion
? config.cron?.inclusion
: Constants.INCLUSION_CRON;
Expand Down Expand Up @@ -670,6 +700,11 @@ export const startSessionKeyJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.sessionKeyEnabled || true;
if (!enabled) {
logger.warn(`Session Key Job is disabled`, cronLabel);
return;
}
const sessionKeyFrequency = config.cron?.sessionKey
? config.cron?.sessionKey
: Constants.SESSION_KEY_CRON;
Expand Down Expand Up @@ -739,6 +774,11 @@ export const startValidatorPrefJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.validatorPrefEnabled || true;
if (!enabled) {
logger.warn(`Validator Pref Job is disabled`, cronLabel);
return;
}
const validatorPrefFrequency = config.cron?.validatorPref
? config.cron?.validatorPref
: Constants.VALIDATOR_PREF_CRON;
Expand Down Expand Up @@ -771,6 +811,11 @@ export const startLocationStatsJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.locationStatsEnabled || true;
if (!enabled) {
logger.warn(`Location Stats Job is disabled`, cronLabel);
return;
}
const locationStatsFrequency = config.cron?.locationStats
? config.cron?.locationStats
: Constants.LOCATION_STATS_CRON;
Expand Down Expand Up @@ -803,6 +848,12 @@ export const startDemocracyJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.democracyEnabled || true;
if (!enabled) {
logger.warn(`Democracy Job is disabled`, cronLabel);
return;
}

const democracyFrequency = config?.cron?.democracy
? config?.cron?.democracy
: Constants.DEMOCRACY_CRON;
Expand Down Expand Up @@ -835,6 +886,11 @@ export const startNominatorJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.nominatorEnabled || true;
if (!enabled) {
logger.warn(`Nominator Job is disabled`, cronLabel);
return;
}
const nominatorFrequency = config.cron?.nominator
? config.cron?.nominator
: Constants.NOMINATOR_CRON;
Expand Down Expand Up @@ -867,6 +923,11 @@ export const startDelegationJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.delegationEnabled || true;
if (!enabled) {
logger.warn(`Delegation Job is disabled`, cronLabel);
return;
}
const delegationFrequency = config.cron?.delegation
? config.cron?.delegation
: Constants.DELEGATION_CRON;
Expand Down Expand Up @@ -899,6 +960,11 @@ export const startBlockDataJob = async (
config: Config.ConfigSchema,
chaindata: ChainData
) => {
const enabled = config.cron?.blockEnabled || true;
if (!enabled) {
logger.warn(`Block Job is disabled`, cronLabel);
return;
}
const blockFrequency = config.cron?.block
? config.cron?.block
: Constants.BLOCK_CRON;
Expand Down
Loading

0 comments on commit 9ebeddf

Please sign in to comment.