Skip to content

Commit

Permalink
feat(debug): add node count for new validator roles in Recent epochs …
Browse files Browse the repository at this point in the history
…view (near#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.
  • Loading branch information
Trisfald authored Jun 28, 2024
1 parent 89fad46 commit 4dbc94c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tools/debug-ui/src/RecentEpochsView.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -40,6 +40,8 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => {
<th>First Block</th>
<th>Epoch Start</th>
<th>Block Producers</th>
<th>Chunk Producers</th>
<th>Chunk Validators</th>
<th>Chunk-only Producers</th>
</tr>
</thead>
Expand Down Expand Up @@ -85,6 +87,8 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => {
<td>{firstBlockColumn}</td>
<td>{epochStartColumn}</td>
<td>{epochInfo.block_producers.length}</td>
<td>{getChunkProducersTotal(epochInfo)}</td>
<td>{getChunkValidatorsTotal(epochInfo)}</td>
<td>{epochInfo.chunk_only_producers.length}</td>
</tr>
);
Expand All @@ -93,3 +97,21 @@ export const RecentEpochsView = ({ addr }: RecentEpochsViewProps) => {
</table>
);
};

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";
}

0 comments on commit 4dbc94c

Please sign in to comment.