fix(governance): incorrect penalty information in validators table and page (#5896)
This commit is contained in:
parent
4733bc169c
commit
82df401611
@ -288,7 +288,7 @@ describe('Consensus validators table', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
grid.querySelector('[role="gridcell"][col-id="totalPenalties"]')
|
grid.querySelector('[role="gridcell"][col-id="totalPenalties"]')
|
||||||
).toHaveTextContent('13.16%');
|
).toHaveTextContent('10.07%');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
grid.querySelector('[role="gridcell"][col-id="normalisedVotingPower"]')
|
grid.querySelector('[role="gridcell"][col-id="normalisedVotingPower"]')
|
||||||
|
@ -185,15 +185,19 @@ export const ConsensusValidatorsTable = ({
|
|||||||
const { rawValidatorScore: previousEpochValidatorScore } =
|
const { rawValidatorScore: previousEpochValidatorScore } =
|
||||||
getLastEpochScoreAndPerformance(previousEpochData, id);
|
getLastEpochScoreAndPerformance(previousEpochData, id);
|
||||||
|
|
||||||
const overstakingPenalty = calculateOverallPenalty(
|
const overstakingPenalty = calculateOverstakedPenalty(
|
||||||
id,
|
id,
|
||||||
allNodesInPreviousEpoch
|
allNodesInPreviousEpoch
|
||||||
);
|
);
|
||||||
const totalPenalty = calculateOverstakedPenalty(
|
const totalPenalty = calculateOverallPenalty(
|
||||||
id,
|
id,
|
||||||
allNodesInPreviousEpoch
|
allNodesInPreviousEpoch
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const lastEpochDataForNode = allNodesInPreviousEpoch.find(
|
||||||
|
(node) => node.id === id
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
[ValidatorFields.RANKING_INDEX]: stakedTotalRanking,
|
[ValidatorFields.RANKING_INDEX]: stakedTotalRanking,
|
||||||
@ -239,6 +243,12 @@ export const ConsensusValidatorsTable = ({
|
|||||||
: undefined,
|
: undefined,
|
||||||
[ValidatorFields.MULTISIG_ERROR]:
|
[ValidatorFields.MULTISIG_ERROR]:
|
||||||
multisigStatus?.showMultisigStatusError,
|
multisigStatus?.showMultisigStatusError,
|
||||||
|
[ValidatorFields.MULTISIG_PENALTY]: formatNumberPercentage(
|
||||||
|
new BigNumber(1)
|
||||||
|
.minus(lastEpochDataForNode?.rewardScore?.multisigScore ?? 1)
|
||||||
|
.times(100),
|
||||||
|
2
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -378,7 +388,6 @@ export const ConsensusValidatorsTable = ({
|
|||||||
headerTooltip: t('StakeDescription').toString(),
|
headerTooltip: t('StakeDescription').toString(),
|
||||||
cellRenderer: TotalStakeRenderer,
|
cellRenderer: TotalStakeRenderer,
|
||||||
width: 120,
|
width: 120,
|
||||||
sort: 'desc',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: ValidatorFields.PENDING_STAKE,
|
field: ValidatorFields.PENDING_STAKE,
|
||||||
@ -400,6 +409,7 @@ export const ConsensusValidatorsTable = ({
|
|||||||
headerTooltip: t('NormalisedVotingPowerDescription').toString(),
|
headerTooltip: t('NormalisedVotingPowerDescription').toString(),
|
||||||
cellRenderer: VotingPowerRenderer,
|
cellRenderer: VotingPowerRenderer,
|
||||||
width: 120,
|
width: 120,
|
||||||
|
sort: 'desc',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: ValidatorFields.TOTAL_PENALTIES,
|
field: ValidatorFields.TOTAL_PENALTIES,
|
||||||
|
@ -40,6 +40,7 @@ export enum ValidatorFields {
|
|||||||
PENDING_USER_STAKE = 'pendingUserStake',
|
PENDING_USER_STAKE = 'pendingUserStake',
|
||||||
USER_STAKE_SHARE = 'userStakeShare',
|
USER_STAKE_SHARE = 'userStakeShare',
|
||||||
MULTISIG_ERROR = 'multisigError',
|
MULTISIG_ERROR = 'multisigError',
|
||||||
|
MULTISIG_PENALTY = 'multisigPenalty',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addUserDataToValidator = (
|
export const addUserDataToValidator = (
|
||||||
@ -327,7 +328,7 @@ interface TotalPenaltiesRendererProps {
|
|||||||
overstakedAmount: string;
|
overstakedAmount: string;
|
||||||
overstakingPenalty: string;
|
overstakingPenalty: string;
|
||||||
totalPenalties: string;
|
totalPenalties: string;
|
||||||
multisigError?: boolean;
|
multisigPenalty: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,11 +347,9 @@ export const TotalPenaltiesRenderer = ({
|
|||||||
<div data-testid="overstaked-penalty-tooltip">
|
<div data-testid="overstaked-penalty-tooltip">
|
||||||
{t('overstakedPenalty')}: {data.overstakingPenalty}
|
{t('overstakedPenalty')}: {data.overstakingPenalty}
|
||||||
</div>
|
</div>
|
||||||
{data.multisigError && (
|
|
||||||
<div data-testid="multisig-error-tooltip">
|
<div data-testid="multisig-error-tooltip">
|
||||||
{t('multisigPenalty')}: 100%
|
{t('multisigPenalty')}: {data.multisigPenalty}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -37,7 +37,6 @@ import {
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import type { StakingNodeFieldsFragment } from '../__generated__/Staking';
|
import type { StakingNodeFieldsFragment } from '../__generated__/Staking';
|
||||||
import type { PreviousEpochQuery } from '../__generated__/PreviousEpoch';
|
import type { PreviousEpochQuery } from '../__generated__/PreviousEpoch';
|
||||||
import { getMultisigStatusInfo } from '../../../lib/get-multisig-status-info';
|
|
||||||
|
|
||||||
const statuses = {
|
const statuses = {
|
||||||
[Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ]: 'status-ersatz',
|
[Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ]: 'status-ersatz',
|
||||||
@ -105,9 +104,10 @@ export const ValidatorTable = ({
|
|||||||
};
|
};
|
||||||
}, [node, previousEpochData?.epoch.validatorsConnection?.edges]);
|
}, [node, previousEpochData?.epoch.validatorsConnection?.edges]);
|
||||||
|
|
||||||
const multisigStatus = previousEpochData
|
const previousNodeData =
|
||||||
? getMultisigStatusInfo(previousEpochData)
|
previousEpochData?.epoch.validatorsConnection?.edges?.find(
|
||||||
: undefined;
|
(e) => e?.node.id === node.id
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -293,21 +293,15 @@ export const ValidatorTable = ({
|
|||||||
data-testid="multisig-penalty"
|
data-testid="multisig-penalty"
|
||||||
className="flex gap-2 items-baseline"
|
className="flex gap-2 items-baseline"
|
||||||
>
|
>
|
||||||
{multisigStatus?.zeroScoreNodes.find(
|
|
||||||
(n) => n.id === node.id
|
|
||||||
) ? (
|
|
||||||
<Tooltip
|
|
||||||
description={t('multisigPenaltyThisNodeIndicator')}
|
|
||||||
>
|
|
||||||
<span className="inline-block w-2 h-2 rounded-full bg-vega-red-500"></span>
|
|
||||||
</Tooltip>
|
|
||||||
) : null}
|
|
||||||
<Tooltip description={t('multisigPenaltyDescription')}>
|
<Tooltip description={t('multisigPenaltyDescription')}>
|
||||||
<span>
|
<span>
|
||||||
{formatNumberPercentage(
|
{formatNumberPercentage(
|
||||||
BigNumber(
|
new BigNumber(1)
|
||||||
multisigStatus?.showMultisigStatusError ? 100 : 0
|
.minus(
|
||||||
),
|
previousNodeData?.node.rewardScore?.multisigScore ??
|
||||||
|
1
|
||||||
|
)
|
||||||
|
.times(100),
|
||||||
2
|
2
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user