From 0248c4576036558e7dd9622abb768b2d96892dd1 Mon Sep 17 00:00:00 2001 From: pablomendezroyo Date: Wed, 2 Oct 2024 10:59:18 +0200 Subject: [PATCH] Add ideal rewards --- .../modules/apiClients/beaconchain/types.ts | 18 ++--- .../src/modules/apiClients/postgres/index.ts | 66 ++----------------- .../src/modules/apiClients/postgres/types.ts | 43 +++++++++--- .../getAttestationsTotalRewards.ts | 27 -------- .../getValidatorAttestationsRewards.ts | 29 ++++++++ ...nsertPerformanceDataAndSendNotification.ts | 32 ++++----- .../sendValidatorsPerformanceNotifications.ts | 23 ++++--- .../trackValidatorsPerformance.ts | 27 ++++---- .../src/modules/validatorsDataIngest/types.ts | 1 + 9 files changed, 115 insertions(+), 151 deletions(-) delete mode 100644 packages/brain/src/modules/cron/trackValidatorsPerformance/getAttestationsTotalRewards.ts create mode 100644 packages/brain/src/modules/cron/trackValidatorsPerformance/getValidatorAttestationsRewards.ts diff --git a/packages/brain/src/modules/apiClients/beaconchain/types.ts b/packages/brain/src/modules/apiClients/beaconchain/types.ts index 074e49f1..b97231ca 100644 --- a/packages/brain/src/modules/apiClients/beaconchain/types.ts +++ b/packages/brain/src/modules/apiClients/beaconchain/types.ts @@ -48,18 +48,20 @@ export interface TotalRewards { inactivity: string; } +export interface IdealRewards { + effective_balance: string; + head: string; + target: string; + source: string; + inclusion_delay: string; + inactivity: string; +} + export interface BeaconchainAttestationRewardsPostResponse { execution_optimistic: boolean; finalized: boolean; data: { - ideal_rewards: { - effective_balance: string; - head: string; - target: string; - source: string; - inclusion_delay: string; - inactivity: string; - }[]; + ideal_rewards: IdealRewards[]; total_rewards: TotalRewards[]; }; } diff --git a/packages/brain/src/modules/apiClients/postgres/index.ts b/packages/brain/src/modules/apiClients/postgres/index.ts index 4402dbe3..459d4769 100644 --- a/packages/brain/src/modules/apiClients/postgres/index.ts +++ b/packages/brain/src/modules/apiClients/postgres/index.ts @@ -1,54 +1,8 @@ import postgres from "postgres"; import logger from "../../logger/index.js"; -import { BlockProposalStatus, ValidatorPerformance } from "./types.js"; +import { BlockProposalStatus, Columns, ValidatorPerformance, ValidatorPerformancePostgres } from "./types.js"; import { ConsensusClient, ExecutionClient } from "@stakingbrain/common"; -// Postgres has a built in class for errors PostgresError. i.e: -// PostgresError: type "block_proposal_status" already exists -// at ErrorResponse (file:///app/node_modules/postgres/src/connection.js:788:26) -// at handle (file:///app/node_modules/postgres/src/connection.js:474:6) -// at Socket.data (file:///app/node_modules/postgres/src/connection.js:315:9) -// at Socket.emit (node:events:519:28) -// at addChunk (node:internal/streams/readable:559:12) -// at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) -// at Readable.push (node:internal/streams/readable:390:5) -// at TCP.onStreamRead (node:internal/stream_base_commons:191:23) { -// severity_local: 'ERROR', -// severity: 'ERROR', -// code: '42710', -// where: `SQL statement "CREATE TYPE BLOCK_PROPOSAL_STATUS AS ENUM('Missed', 'Proposed', 'Unchosen')"\n` + -// 'PL/pgSQL function inline_code_block line 5 at SQL statement', -// file: 'typecmds.c', -// line: '1170', -// routine: 'DefineEnum' -// } - -enum Columns { - validatorIndex = "validator_index", - epoch = "epoch", - executionClient = "execution_client", - consensusClient = "consensus_client", - slot = "slot", - liveness = "liveness", - blockProposalStatus = "block_proposal_status", - syncCommitteeRewards = "sync_comittee_rewards", - attestationsTotalRewards = "attestations_total_rewards", - error = "error" -} - -interface ValidatorPerformancePostgres { - [Columns.validatorIndex]: number; - [Columns.epoch]: number; - [Columns.executionClient]: ExecutionClient; - [Columns.consensusClient]: ConsensusClient; - [Columns.slot]: number; - [Columns.liveness]: boolean; - [Columns.blockProposalStatus]: BlockProposalStatus; - [Columns.syncCommitteeRewards]: number; - [Columns.attestationsTotalRewards]: string; - [Columns.error]: string; -} - export class PostgresClient { private readonly tableName = "validators_performance"; private readonly BLOCK_PROPOSAL_STATUS = "BLOCK_PROPOSAL_STATUS"; @@ -83,17 +37,7 @@ SELECT pg_total_relation_size('${this.tableName}'); } /** - * Initializes the database by creating the required table if it does not exist. - * The table will have the following columns: - * - validator_index: The index of the validator. - * - epoch: The epoch number. - * - slot: The slot number. - * - liveness: The liveness status of the validator. - * - block_proposal_status: The status of the block proposal (missed, proposed, unchosen). - * - sync_comittee_rewards: The rewards received by the validator for participating in the sync committee. - * - attestations_rewards: The rewards received by the validator for participating in the attestations. - * - error: Any error message related to the validator's performance fetch. - * The primary key will be a combination of validator_index and epoch. + * Initializes the database by creating the required table if it does not exist with the required columns. */ public async initialize() { // important: enum create types must be broken into separate conditional checks for each ENUM type before trying to create it. @@ -106,7 +50,6 @@ SELECT pg_total_relation_size('${this.tableName}'); WHEN duplicate_object THEN NULL; END $$; `); - // Check and create EXECUTION_CLIENT ENUM type if not exists await this.sql.unsafe(` DO $$ @@ -139,6 +82,7 @@ CREATE TABLE IF NOT EXISTS ${this.tableName} ( ${Columns.blockProposalStatus} ${this.BLOCK_PROPOSAL_STATUS}, ${Columns.syncCommitteeRewards} BIGINT, ${Columns.attestationsTotalRewards} JSONB, + ${Columns.attestationsIdealRewards} JSONB, ${Columns.error} JSONB NULL, PRIMARY KEY (${Columns.validatorIndex}, ${Columns.epoch}) ); @@ -180,6 +124,7 @@ DO UPDATE SET ${Columns.blockProposalStatus} = EXCLUDED.${Columns.blockProposalStatus}, ${Columns.syncCommitteeRewards} = EXCLUDED.${Columns.syncCommitteeRewards}, ${Columns.attestationsTotalRewards} = EXCLUDED.${Columns.attestationsTotalRewards}, + ${Columns.attestationsIdealRewards} = EXCLUDED.${Columns.attestationsIdealRewards}, ${Columns.error} = EXCLUDED.${Columns.error}; `; @@ -194,6 +139,7 @@ DO UPDATE SET data.blockProposalStatus ?? null, data.syncCommitteeRewards ?? null, data.attestationsTotalRewards ? JSON.stringify(data.attestationsTotalRewards) : null, // JSONB expects a string or null + data.attestationsIdealRewards ? JSON.stringify(data.attestationsIdealRewards) : null, // JSONB expects a string or null data.error ? JSON.stringify(data.error) : null // JSONB expects a string or null ]); } @@ -222,6 +168,7 @@ WHERE ${Columns.validatorIndex} = ANY($1) blockProposalStatus: row.block_proposal_status, syncCommitteeRewards: row.sync_comittee_rewards, attestationsTotalRewards: JSON.parse(row.attestations_total_rewards), + attestationsIdealRewards: JSON.parse(row.attestations_ideal_rewards), error: JSON.parse(row.error) })); } @@ -270,6 +217,7 @@ AND ${Columns.epoch} <= $3 blockProposalStatus: row.block_proposal_status, syncCommitteeRewards: row.sync_comittee_rewards, attestationsTotalRewards: JSON.parse(row.attestations_total_rewards), + attestationsIdealRewards: JSON.parse(row.attestations_ideal_rewards), error: JSON.parse(row.error) }; diff --git a/packages/brain/src/modules/apiClients/postgres/types.ts b/packages/brain/src/modules/apiClients/postgres/types.ts index c8b46721..f8e619b2 100644 --- a/packages/brain/src/modules/apiClients/postgres/types.ts +++ b/packages/brain/src/modules/apiClients/postgres/types.ts @@ -1,4 +1,34 @@ import { ConsensusClient, ExecutionClient } from "@stakingbrain/common"; +import { IdealRewards, TotalRewards } from "../beaconchain/types.js"; + +export enum Columns { + validatorIndex = "validator_index", + epoch = "epoch", + executionClient = "execution_client", + consensusClient = "consensus_client", + slot = "slot", + liveness = "liveness", + blockProposalStatus = "block_proposal_status", + syncCommitteeRewards = "sync_comittee_rewards", + attestationsTotalRewards = "attestations_total_rewards", + attestationsIdealRewards = "attestations_ideal_rewards", + error = "error" +} + +// Interface data write with Postgres client +export interface ValidatorPerformancePostgres { + [Columns.validatorIndex]: number; + [Columns.epoch]: number; + [Columns.executionClient]: ExecutionClient; + [Columns.consensusClient]: ConsensusClient; + [Columns.slot]: number; + [Columns.liveness]: boolean; + [Columns.blockProposalStatus]: BlockProposalStatus; + [Columns.syncCommitteeRewards]: number; + [Columns.attestationsTotalRewards]: string; + [Columns.attestationsIdealRewards]: string; + [Columns.error]: string; +} export enum BlockProposalStatus { Missed = "Missed", @@ -7,22 +37,15 @@ export enum BlockProposalStatus { Error = "Error" } -export interface AttestationsTotalRewards { - validator_index: string; - head: string; - target: string; - source: string; - inclusion_delay: string; - inactivity: string; -} - +// Interface data return from Postgres client export interface ValidatorPerformance { validatorIndex: number; epoch: number; executionClient: ExecutionClient; consensusClient: ConsensusClient; blockProposalStatus?: BlockProposalStatus; - attestationsTotalRewards?: AttestationsTotalRewards; + attestationsTotalRewards?: TotalRewards; + attestationsIdealRewards?: IdealRewards; slot?: number; liveness?: boolean; syncCommitteeRewards?: number; diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/getAttestationsTotalRewards.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/getAttestationsTotalRewards.ts deleted file mode 100644 index 7adb0a1e..00000000 --- a/packages/brain/src/modules/cron/trackValidatorsPerformance/getAttestationsTotalRewards.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BeaconchainApi } from "../../apiClients/index.js"; -import { TotalRewards } from "../../apiClients/types.js"; - -/** - * Get attestations rewards for the validators. - * - * @param {BeaconchainApi} beaconchainApi - Beaconchain API client. - * @param {string} epoch - The epoch to get the rewards. - * @param {string[]} activeValidatorsIndexes - Array of active validator indexes. - * @returns {TotalRewards[]} - Array of total rewards for the validators. - */ -export async function getAttestationsTotalRewards({ - beaconchainApi, - epoch, - activeValidatorsIndexes -}: { - beaconchainApi: BeaconchainApi; - epoch: string; - activeValidatorsIndexes: string[]; -}): Promise { - return ( - await beaconchainApi.getAttestationsRewards({ - epoch, - pubkeysOrIndexes: activeValidatorsIndexes - }) - ).data.total_rewards; -} diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/getValidatorAttestationsRewards.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/getValidatorAttestationsRewards.ts new file mode 100644 index 00000000..d0bdcfe5 --- /dev/null +++ b/packages/brain/src/modules/cron/trackValidatorsPerformance/getValidatorAttestationsRewards.ts @@ -0,0 +1,29 @@ +import { BeaconchainApi } from "../../apiClients/index.js"; +import { IdealRewards, TotalRewards } from "../../apiClients/types.js"; + +/** + * Get attestations rewards for the validators: + * - Total rewards + * - Ideal reward last item from array of IdealRewards -> is the ideal reward maximum that could be achieved by the validator + */ +export async function getValidatorAttestationsRewards({ + beaconchainApi, + epoch, + activeValidatorsIndexes +}: { + beaconchainApi: BeaconchainApi; + epoch: string; + activeValidatorsIndexes: string[]; +}): Promise<{ totalRewards: TotalRewards[]; idealRewards: IdealRewards }> { + const attestationsRewards = ( + await beaconchainApi.getAttestationsRewards({ + epoch, + pubkeysOrIndexes: activeValidatorsIndexes + }) + ).data; + + return { + totalRewards: attestationsRewards.total_rewards, + idealRewards: attestationsRewards.ideal_rewards[attestationsRewards.ideal_rewards.length - 1] + }; +} diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/insertPerformanceDataAndSendNotification.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/insertPerformanceDataAndSendNotification.ts index 510eb67b..5d14ed18 100644 --- a/packages/brain/src/modules/cron/trackValidatorsPerformance/insertPerformanceDataAndSendNotification.ts +++ b/packages/brain/src/modules/cron/trackValidatorsPerformance/insertPerformanceDataAndSendNotification.ts @@ -6,7 +6,7 @@ import { ValidatorPerformanceError, ValidatorPerformanceErrorCode } from "../../apiClients/postgres/types.js"; -import { TotalRewards } from "../../apiClients/types.js"; +import { IdealRewards, TotalRewards } from "../../apiClients/types.js"; import logger from "../../logger/index.js"; import { logPrefix } from "./logPrefix.js"; import { sendValidatorsPerformanceNotifications } from "./sendValidatorsPerformanceNotifications.js"; @@ -15,34 +15,28 @@ import { sendValidatorsPerformanceNotifications } from "./sendValidatorsPerforma * Insert the performance data for the validators in the Postgres DB. On any error * inserting the performance of a validator, the error will be logged and the process will continue * with the next validator. - * - * @param postgresClient - Postgres client to interact with the DB. - * @param activeValidatorIndexes - Array of validator indexes. - * @param currentEpoch - The current epoch. - * @param validatorBlockStatusMap - Map with the block proposal status of each validator. - * @param validatorsAttestationsTotalRewards - Array of total rewards for the validators. */ export async function insertPerformanceDataAndSendNotification({ + executionClient, + consensusClient, sendNotification, dappmanagerApi, postgresClient, - activeValidatorsIndexes, currentEpoch, + activeValidatorsIndexes, validatorBlockStatusMap, - validatorsAttestationsTotalRewards, - executionClient, - consensusClient, + validatorAttestationsRewards, error }: { + executionClient: ExecutionClient; + consensusClient: ConsensusClient; sendNotification: boolean; dappmanagerApi: DappmanagerApi; postgresClient: PostgresClient; - activeValidatorsIndexes: string[]; currentEpoch: number; - validatorBlockStatusMap: Map; - validatorsAttestationsTotalRewards: TotalRewards[]; - executionClient: ExecutionClient; - consensusClient: ConsensusClient; + activeValidatorsIndexes: string[]; + validatorBlockStatusMap?: Map; + validatorAttestationsRewards?: { totalRewards: TotalRewards[]; idealRewards: IdealRewards }; error?: ValidatorPerformanceError; }): Promise { for (const validatorIndex of activeValidatorsIndexes) { @@ -60,7 +54,7 @@ export async function insertPerformanceDataAndSendNotification({ continue; } - const attestationsTotalRewards = validatorsAttestationsTotalRewards.find( + const attestationsTotalRewards = validatorAttestationsRewards?.totalRewards.find( (attestationReward) => attestationReward.validator_index === validatorIndex ); if (!attestationsTotalRewards) { @@ -80,7 +74,7 @@ export async function insertPerformanceDataAndSendNotification({ continue; } - const blockProposalStatus = validatorBlockStatusMap.get(validatorIndex); + const blockProposalStatus = validatorBlockStatusMap?.get(validatorIndex); if (!blockProposalStatus) { await insertDataNotThrow({ postgresClient, @@ -115,7 +109,7 @@ export async function insertPerformanceDataAndSendNotification({ dappmanagerApi, currentEpoch: currentEpoch.toString(), validatorBlockStatusMap, - validatorsAttestationsTotalRewards, + validatorAttestationsRewards, error }); } diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/sendValidatorsPerformanceNotifications.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/sendValidatorsPerformanceNotifications.ts index ddc3aa94..b30ab62f 100644 --- a/packages/brain/src/modules/cron/trackValidatorsPerformance/sendValidatorsPerformanceNotifications.ts +++ b/packages/brain/src/modules/cron/trackValidatorsPerformance/sendValidatorsPerformanceNotifications.ts @@ -3,7 +3,7 @@ import { NotificationType } from "../../apiClients/dappmanager/types.js"; import { BlockProposalStatus, ValidatorPerformanceError } from "../../apiClients/postgres/types.js"; import logger from "../../logger/index.js"; import { logPrefix } from "./logPrefix.js"; -import { TotalRewards } from "../../apiClients/types.js"; +import { IdealRewards, TotalRewards } from "../../apiClients/types.js"; /** * Sends validator performance notification to the dappmanager. The notification will have the following format: @@ -21,14 +21,14 @@ export async function sendValidatorsPerformanceNotifications({ dappmanagerApi, currentEpoch, validatorBlockStatusMap, - validatorsAttestationsTotalRewards, + validatorAttestationsRewards, error }: { sendNotification: boolean; dappmanagerApi: DappmanagerApi; currentEpoch: string; - validatorBlockStatusMap: Map; - validatorsAttestationsTotalRewards: TotalRewards[]; + validatorBlockStatusMap?: Map; + validatorAttestationsRewards?: { totalRewards: TotalRewards[]; idealRewards: IdealRewards }; error?: ValidatorPerformanceError; }): Promise { if (!sendNotification) return; @@ -38,17 +38,16 @@ export async function sendValidatorsPerformanceNotifications({ notificationType: NotificationType.Danger, body: `Failed to fetch performance data for epoch ${currentEpoch}: ${error}` }); - else { + else if (validatorBlockStatusMap && validatorAttestationsRewards) await Promise.all([ sendSuccessNotificationNotThrow({ dappmanagerApi, validatorBlockStatusMap, currentEpoch }), sendWarningNotificationNotThrow({ dappmanagerApi, validatorBlockStatusMap, - validatorsAttestationsTotalRewards, + validatorAttestationsRewards, currentEpoch }) ]); - } } /** @@ -57,8 +56,8 @@ export async function sendValidatorsPerformanceNotifications({ */ async function sendSuccessNotificationNotThrow({ dappmanagerApi, - validatorBlockStatusMap, - currentEpoch + currentEpoch, + validatorBlockStatusMap }: { dappmanagerApi: DappmanagerApi; validatorBlockStatusMap: Map; @@ -86,19 +85,19 @@ async function sendSuccessNotificationNotThrow({ async function sendWarningNotificationNotThrow({ dappmanagerApi, validatorBlockStatusMap, - validatorsAttestationsTotalRewards, + validatorAttestationsRewards, currentEpoch }: { dappmanagerApi: DappmanagerApi; validatorBlockStatusMap: Map; - validatorsAttestationsTotalRewards: TotalRewards[]; + validatorAttestationsRewards: { totalRewards: TotalRewards[]; idealRewards: IdealRewards }; currentEpoch: string; }): Promise { // Send the warning notification together: block missed and att missed const validatorsMissedBlocks = Array.from(validatorBlockStatusMap).filter( ([_, blockStatus]) => blockStatus === "Missed" ); - const validatorsMissedAttestations = validatorsAttestationsTotalRewards + const validatorsMissedAttestations = validatorAttestationsRewards.totalRewards .filter((validator) => parseInt(validator.source) === 0) .map((validator) => validator.validator_index); diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts index 5fd7d8f7..7ff1f54b 100644 --- a/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts +++ b/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts @@ -3,12 +3,12 @@ import { PostgresClient } from "../../apiClients/postgres/index.js"; import logger from "../../logger/index.js"; import { BrainDataBase } from "../../db/index.js"; import { insertPerformanceDataAndSendNotification } from "./insertPerformanceDataAndSendNotification.js"; -import { getAttestationsTotalRewards } from "./getAttestationsTotalRewards.js"; +import { getValidatorAttestationsRewards } from "./getValidatorAttestationsRewards.js"; import { getBlockProposalStatusMap } from "./getBlockProposalStatusMap.js"; import { getActiveValidatorsLoadedInBrain } from "./getActiveValidatorsLoadedInBrain.js"; import { logPrefix } from "./logPrefix.js"; import { ConsensusClient, ExecutionClient } from "@stakingbrain/common"; -import { TotalRewards } from "../../apiClients/types.js"; +import { IdealRewards, TotalRewards } from "../../apiClients/types.js"; import { BlockProposalStatus, ValidatorPerformanceError, @@ -91,20 +91,16 @@ export async function fetchAndInsertPerformanceCron({ }): Promise { let validatorPerformanceError: ValidatorPerformanceError | undefined; let activeValidatorsIndexes: string[] = []; - let validatorBlockStatusMap: Map = new Map(); - let validatorsAttestationsTotalRewards: TotalRewards[] = []; + let validatorBlockStatusMap: Map | undefined; + let validatorAttestationsRewards: { totalRewards: TotalRewards[]; idealRewards: IdealRewards } | undefined; try { logger.debug(`${logPrefix}Starting to track performance for epoch: ${currentEpoch}`); - try { - activeValidatorsIndexes = await getActiveValidatorsLoadedInBrain({ beaconchainApi, brainDb }); - if (activeValidatorsIndexes.length === 0) { - logger.info(`${logPrefix}No active validators found`); - return; // Exit if no active validators are found - } - } catch (e) { - logger.error(`${logPrefix}Error getting active validators: ${e}`); - return; // active validator indexes is crutial for the error handling since each error is indexed by the validator index + + activeValidatorsIndexes = await getActiveValidatorsLoadedInBrain({ beaconchainApi, brainDb }); + if (activeValidatorsIndexes.length === 0) { + logger.info(`${logPrefix}No active validators found`); + return; // Exit if no active validators are found } const { el_offline, is_syncing } = (await beaconchainApi.getSyncingStatus()).data; @@ -117,7 +113,7 @@ export async function fetchAndInsertPerformanceCron({ activeValidatorsIndexes }); - validatorsAttestationsTotalRewards = await getAttestationsTotalRewards({ + validatorAttestationsRewards = await getValidatorAttestationsRewards({ beaconchainApi, epoch: currentEpoch.toString(), activeValidatorsIndexes @@ -128,7 +124,6 @@ export async function fetchAndInsertPerformanceCron({ } catch (e) { logger.error(`${logPrefix}Error tracking validator performance for epoch ${currentEpoch}: ${e}`); validatorPerformanceError = getValidatorPerformanceError(e); - lastEpochProcessedWithError = true; } finally { // Always call storeData in the finally block, regardless of success or failure in try block @@ -139,7 +134,7 @@ export async function fetchAndInsertPerformanceCron({ activeValidatorsIndexes, currentEpoch, validatorBlockStatusMap, - validatorsAttestationsTotalRewards, + validatorAttestationsRewards, error: validatorPerformanceError, executionClient, consensusClient diff --git a/packages/brain/src/modules/validatorsDataIngest/types.ts b/packages/brain/src/modules/validatorsDataIngest/types.ts index 65c1fe6b..1c9e5132 100644 --- a/packages/brain/src/modules/validatorsDataIngest/types.ts +++ b/packages/brain/src/modules/validatorsDataIngest/types.ts @@ -2,6 +2,7 @@ import { ConsensusClient, ExecutionClient } from "@stakingbrain/common"; export type ExecutionConsensusConcatenated = `${ExecutionClient}-${ConsensusClient}`; +// TODO: use ideal rewards to return calculated attestation efficiency export interface ValidatorsDataProcessed { attestationSuccessRate: number; // mean attestationSuccessRate of the validator attestationSuccessRatePerClients: Map;