Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/features/Overview/ShredsProgression/shredsProgressionPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import { slotsPerLeader } from "../../../consts";
const store = getDefaultStore();
export const shredsXScaleKey = "shredsXScaleKey";

type Coordinates = [x: number, y: number, width?: number];
type EventsByFillStyle = {
[fillStyle: string]: Array<[x: number, y: number, width: number]>;
[fillStyle: string]: Array<Coordinates>;
};
export type Position = [xPos: number, cssWidth: number | undefined];
export type LabelPositions = {
Expand Down Expand Up @@ -125,6 +126,8 @@ export function shredsProgressionPlugin(
const rowPxHeight = clamp(canvasHeight / maxShreds, 1, 10);
const gapPxHeight = 1;

const dotSize = Math.max(rowPxHeight, 3);

// n rows, n-1 gaps
const rowsCount = Math.trunc(
(canvasHeight + gapPxHeight) / (rowPxHeight + gapPxHeight),
Expand All @@ -135,7 +138,7 @@ export function shredsProgressionPlugin(
const eventsByFillStyle: EventsByFillStyle = {};
const addEventPosition = (
fillStyle: string,
position: [x: number, y: number, width: number],
position: Coordinates,
) => {
eventsByFillStyle[fillStyle] ??= [];
eventsByFillStyle[fillStyle].push(position);
Expand Down Expand Up @@ -168,7 +171,6 @@ export function shredsProgressionPlugin(
tsXValueOffset,
y: (rowPxHeight + gapPxHeight) * rowIdx + u.bbox.top,
getYOffset,
dotWidth: rowPxHeight,
scaleX: u.scales[shredsXScaleKey],
getXPos,
});
Expand All @@ -179,7 +181,12 @@ export function shredsProgressionPlugin(
u.ctx.beginPath();
u.ctx.fillStyle = fillStyle;
for (const [x, y, width] of eventsByFillStyle[fillStyle]) {
u.ctx.rect(x, y, width, rowPxHeight);
if (width == null) {
// dot
u.ctx.rect(x, y, dotSize, dotSize);
} else {
u.ctx.rect(x, y, width, rowPxHeight);
}
}
u.ctx.fill();
}
Expand Down Expand Up @@ -256,10 +263,7 @@ const getDrawInfo = (
};

interface AddEventsForRowArgs {
addEventPosition: (
fillStyle: string,
position: [x: number, y: number, width: number],
) => void;
addEventPosition: (fillStyle: string, position: Coordinates) => void;
u: uPlot;
firstShredIdx: number;
lastShredIdx: number;
Expand All @@ -272,7 +276,6 @@ interface AddEventsForRowArgs {
getYOffset?: (
eventType: Exclude<ShredEvent, ShredEvent.slot_complete>,
) => number;
dotWidth: number;
scaleX: uPlot.Scale;
getXPos: (xVal: number) => number;
}
Expand All @@ -292,7 +295,6 @@ function addEventsForRow({
isSlotSkipped,
y,
getYOffset,
dotWidth,
scaleX,
getXPos,
}: AddEventsForRowArgs) {
Expand All @@ -316,7 +318,7 @@ function addEventsForRow({

const eventPositions = new Map<
Exclude<ShredEvent, ShredEvent.slot_complete>,
[x: number, y: number, width: number]
Coordinates
>();

// draw events from highest to lowest priority
Expand All @@ -335,7 +337,7 @@ function addEventsForRow({
eventPositions.set(
eventType,
drawOnlyDots || isSlotSkipped
? [startXPos, y + yOffset, dotWidth]
? [startXPos, y + yOffset]
: [startXPos, y + yOffset, endXPos - startXPos],
);
endXPos = startXPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.card {
flex-grow: 1;
flex-shrink: 0;
display: flex;
flex-direction: column;
gap: 10px;
Expand Down
86 changes: 39 additions & 47 deletions src/features/StartupProgress/Firedancer/Gossip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,55 +46,47 @@ export default function Gossip() {
remainingSeconds={remainingSeconds}
/>

<Flex gapX="162px" mt="52px">
<Flex direction="column" gap="20px" flexGrow="1" flexBasis="1">
<Flex justify="between" gap="20px" align="stretch">
<GossipCard
title="Staked Peers"
value={health.connected_staked_peers.toLocaleString(undefined, {
maximumFractionDigits: 0,
})}
/>
<GossipCard
title="Unstaked Peers"
value={health.connected_unstaked_peers.toLocaleString(undefined, {
maximumFractionDigits: 0,
})}
/>
<GossipCard
title="Connected Stake"
value={formattedConnectedStake}
/>
</Flex>

<Flex direction="column" gap="10px">
<Text className={styles.barTitle}>Ingress</Text>
<Text className={styles.barValue}>
{ingressThroughput
? `${ingressThroughput.value} ${ingressThroughput.unit}/s`
: "-- Mbit/s"}
</Text>
<Bars
value={ingress.total_throughput ?? 0}
max={MAX_THROUGHPUT_BYTES}
/>
</Flex>
<Flex mt="52px" direction="column" gap="20px" flexGrow="1" flexBasis="1">
<Flex justify="between" gap="20px" align="stretch" wrap="wrap">
<GossipCard
title="Staked Peers"
value={health.connected_staked_peers.toLocaleString(undefined, {
maximumFractionDigits: 0,
})}
/>
<GossipCard
title="Unstaked Peers"
value={health.connected_unstaked_peers.toLocaleString(undefined, {
maximumFractionDigits: 0,
})}
/>
<GossipCard title="Connected Stake" value={formattedConnectedStake} />
</Flex>

<Flex direction="column" gap="10px">
<Text className={styles.barTitle}>Egress</Text>
<Text className={styles.barValue}>
{egressThroughput
? `${egressThroughput.value} ${egressThroughput.unit}/s`
: "-- Mbit/s"}
</Text>
<Bars
value={egress.total_throughput ?? 0}
max={MAX_THROUGHPUT_BYTES}
/>
</Flex>
<Flex direction="column" gap="10px">
<Text className={styles.barTitle}>Ingress</Text>
<Text className={styles.barValue}>
{ingressThroughput
? `${ingressThroughput.value} ${ingressThroughput.unit}ps`
: "-- Mbps"}
</Text>
<Bars
value={ingress.total_throughput ?? 0}
max={MAX_THROUGHPUT_BYTES}
/>
</Flex>
<Flex flexGrow="1" flexBasis="1" justify="center">
<Text>Stake Discovered</Text>

<Flex direction="column" gap="10px">
<Text className={styles.barTitle}>Egress</Text>
<Text className={styles.barValue}>
{egressThroughput
? `${egressThroughput.value} ${egressThroughput.unit}ps`
: "-- Mbps"}
</Text>
<Bars
value={egress.total_throughput ?? 0}
max={MAX_THROUGHPUT_BYTES}
/>
</Flex>
</Flex>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ export function AccountsRate({ cumulativeAccounts }: AccountsRateProps) {
}, [phase, reset]);

const value = useMemo(() => {
// Possible to have no rate due to only having a single point
if (cumulativeAccounts != null && accountsPerSecond == null) return "0";
if (accountsPerSecond == null) return;
return compactSingleDecimalFormatter.format(accountsPerSecond);
}, [accountsPerSecond]);
}, [accountsPerSecond, cumulativeAccounts]);

return (
<div className={styles.accountsRate}>
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export function formatBytes(
if (bytes === 0 && noDecimalForZero) return { value: "0", unit: "B" };
if (bytes < 1_000) return { value: bytes.toFixed(precision), unit: "B" };
if (bytes < 1_000_000)
return { value: (bytes / 1_000).toFixed(precision), unit: "KB" };
return { value: (bytes / 1_000).toFixed(precision), unit: "kB" };
if (bytes < 1_000_000_000) {
return { value: (bytes / 1_000_000).toFixed(precision), unit: "MB" };
}
Expand Down