From 4dbc94c05d75c7c5b0e3a638473c8c964686859a Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 28 Jun 2024 14:44:01 +0200 Subject: [PATCH] feat(debug): add node count for new validator roles in Recent epochs view (#11685) Another small improvement to the debug UI: adding the count of new validator roles introduced in stateless validation. "Chunk-only Producers" column is kept for compatibility with current mainnet. --- tools/debug-ui/src/RecentEpochsView.tsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/debug-ui/src/RecentEpochsView.tsx b/tools/debug-ui/src/RecentEpochsView.tsx index b133f48ca30..03b7a3880f8 100644 --- a/tools/debug-ui/src/RecentEpochsView.tsx +++ b/tools/debug-ui/src/RecentEpochsView.tsx @@ -1,5 +1,5 @@ import { useQuery } from '@tanstack/react-query'; -import { fetchEpochInfo, fetchFullStatus } from './api'; +import { EpochInfoView, fetchEpochInfo, fetchFullStatus } from './api'; import { formatDurationInMillis } from './utils'; import './RecentEpochsView.scss'; @@ -40,6 +40,8 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => { First Block Epoch Start Block Producers + Chunk Producers + Chunk Validators Chunk-only Producers @@ -85,6 +87,8 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => { {firstBlockColumn} {epochStartColumn} {epochInfo.block_producers.length} + {getChunkProducersTotal(epochInfo)} + {getChunkValidatorsTotal(epochInfo)} {epochInfo.chunk_only_producers.length} ); @@ -93,3 +97,21 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => { ); }; + +function getChunkProducersTotal(epochInfo: EpochInfoView) { + return epochInfo.validator_info?.current_validators.reduce((acc, it) => { + if (it.num_expected_chunks > 0) { + acc = acc + 1; + } + return acc; + }, 0) ?? "N/A" +} + +function getChunkValidatorsTotal(epochInfo: EpochInfoView) { + return epochInfo.validator_info?.current_validators.reduce((acc, it) => { + if (it.num_expected_endorsements > 0) { + acc = acc + 1; + } + return acc; + }, 0) ?? "N/A"; +} \ No newline at end of file