Skip to content

Commit f4380b1

Browse files
fix: no labels before last turbine of catching up phase
1 parent 3ab32d5 commit f4380b1

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

src/features/Overview/ShredsProgression/ShredsSlotLabels.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default function ShredsSlotLabels() {
2424

2525
return (
2626
<Flex
27+
flexShrink="0"
2728
overflowX="hidden"
2829
position="relative"
29-
// extra space for borders
3030
height="30px"
3131
style={{ opacity: 0.8 }}
3232
>

src/features/Overview/ShredsProgression/atoms.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { maxShredEvent, ShredEvent } from "../../../api/entities";
44
import { delayMs, xRangeMs } from "./const";
55
import { nsPerMs, slotsPerLeader } from "../../../consts";
66
import { getSlotGroupLeader } from "../../../utils";
7+
import { startupFinalTurbineHeadAtom } from "../../StartupProgress/atoms";
78

89
type ShredEventTsDeltaMs = number | undefined;
910
/**
@@ -40,17 +41,35 @@ export function createLiveShredsAtoms() {
4041
min: number;
4142
max: number;
4243
}>();
44+
const rangeAfterStartupAtom = atom((get) => {
45+
const range = get(_slotRangeAtom);
46+
const startupFinalTurbineHead = get(startupFinalTurbineHeadAtom);
47+
if (!range || startupFinalTurbineHead == null) return;
48+
49+
// no slots after final turbine head
50+
if (startupFinalTurbineHead + 1 > range.max) return;
51+
52+
return {
53+
min: Math.max(startupFinalTurbineHead + 1, range.min),
54+
max: range.max,
55+
};
56+
});
4357
return {
4458
/**
4559
* min completed slot we've seen since we started collecting data
4660
*/
4761
minCompletedSlot: atom((get) => get(_minCompletedSlotAtom)),
4862
range: atom((get) => get(_slotRangeAtom)),
63+
rangeAfterStartup: rangeAfterStartupAtom,
64+
// leader slots after turbine head at the end of startup
4965
groupLeaderSlots: atom((get) => {
50-
const range = get(_slotRangeAtom);
51-
if (!range) return [];
66+
const range = get(rangeAfterStartupAtom);
67+
const startupFinalTurbineHead = get(startupFinalTurbineHeadAtom);
68+
if (!range || startupFinalTurbineHead == null) return [];
5269

53-
const slots = [getSlotGroupLeader(range.min)];
70+
const min = Math.max(startupFinalTurbineHead + 1, range.min);
71+
72+
const slots = [getSlotGroupLeader(min)];
5473
while (slots[slots.length - 1] + slotsPerLeader - 1 < range.max) {
5574
slots.push(
5675
getSlotGroupLeader(slots[slots.length - 1] + slotsPerLeader),

src/features/Overview/ShredsProgression/shredsProgressionPlugin.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function shredsProgressionPlugin(
5353
const slotRange = store.get(atoms.range);
5454
const minCompletedSlot = store.get(atoms.minCompletedSlot);
5555
const skippedSlotsCluster = store.get(skippedClusterSlotsAtom);
56+
const rangeAfterStartup = store.get(atoms.rangeAfterStartup);
5657

5758
const maxX = u.scales[shredsXScaleKey].max;
5859

@@ -67,6 +68,8 @@ export function shredsProgressionPlugin(
6768
// depending on connection time. Ignore those slots, and only draw slots
6869
// from min completed.
6970
if (minCompletedSlot == null) return;
71+
72+
if (!rangeAfterStartup) return;
7073
}
7174

7275
// Offset to convert shred event delta to chart x value
@@ -184,9 +187,9 @@ export function shredsProgressionPlugin(
184187

185188
u.ctx.restore();
186189

187-
if (!isOnStartupScreen) {
190+
if (!isOnStartupScreen && rangeAfterStartup) {
188191
updateLabels(
189-
slotRange,
192+
rangeAfterStartup,
190193
liveShreds.slots,
191194
skippedSlotsCluster,
192195
u,
@@ -581,22 +584,17 @@ function getIncompleteBlockStart(
581584
const firstSlotNumber = blockSlotNumbers[0];
582585
const startFirstSlotNumber = slots.get(firstSlotNumber)?.minEventTsDelta;
583586

584-
const prevBlockEnd =
585-
previousBlock.type === "complete"
586-
? previousBlock.endTsDelta
587-
: previousBlock.endTsDelta;
587+
if (startFirstSlotNumber != null) return startFirstSlotNumber;
588588

589-
// incomplete block started at either start of first
590-
// slot, or end of previous block
591-
const blockStart = startFirstSlotNumber ?? prevBlockEnd;
592-
if (blockStart == null) {
589+
const prevBlockEnd = previousBlock.endTsDelta;
590+
if (prevBlockEnd == null) {
593591
console.error(
594592
`Missing block start ts for incomplete block beginning at ${firstSlotNumber}`,
595593
);
596594
return;
597595
}
598596

599-
return blockStart;
597+
return prevBlockEnd;
600598
}
601599

602600
type TsDeltaRange = [startTsDelta: number, endTsDelta: number | undefined];

0 commit comments

Comments
 (0)