Skip to content

Commit 6d9daa0

Browse files
fix: no labels before last turbine of catching up phase
1 parent 353d8ed commit 6d9daa0

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/features/Overview/ShredsProgression/atoms.ts

Lines changed: 19 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,32 @@ 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 undefined;
48+
49+
return {
50+
min: Math.max(startupFinalTurbineHead + 1, range.min),
51+
max: Math.max(startupFinalTurbineHead + 1, range.max),
52+
};
53+
});
4354
return {
4455
/**
4556
* min completed slot we've seen since we started collecting data
4657
*/
4758
minCompletedSlot: atom((get) => get(_minCompletedSlotAtom)),
4859
range: atom((get) => get(_slotRangeAtom)),
60+
rangeAfterStartup: rangeAfterStartupAtom,
61+
// leader slots after turbine head at the end of startup
4962
groupLeaderSlots: atom((get) => {
50-
const range = get(_slotRangeAtom);
51-
if (!range) return [];
63+
const range = get(rangeAfterStartupAtom);
64+
const startupFinalTurbineHead = get(startupFinalTurbineHeadAtom);
65+
if (!range || startupFinalTurbineHead == null) return [];
5266

53-
const slots = [getSlotGroupLeader(range.min)];
67+
const min = Math.max(startupFinalTurbineHead + 1, range.min);
68+
69+
const slots = [getSlotGroupLeader(min)];
5470
while (slots[slots.length - 1] + slotsPerLeader - 1 < range.max) {
5571
slots.push(
5672
getSlotGroupLeader(slots[slots.length - 1] + slotsPerLeader),

src/features/Overview/ShredsProgression/shredsProgressionPlugin.ts

Lines changed: 11 additions & 3 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
@@ -183,9 +186,9 @@ export function shredsProgressionPlugin(
183186

184187
u.ctx.restore();
185188

186-
if (!isOnStartupScreen) {
189+
if (!isOnStartupScreen && rangeAfterStartup) {
187190
updateLabels(
188-
slotRange,
191+
rangeAfterStartup,
189192
liveShreds.slots,
190193
skippedSlotsCluster,
191194
u,
@@ -575,8 +578,13 @@ function getSlotBlocks(
575578
function getIncompleteBlockStart(
576579
blockSlotNumbers: number[],
577580
slots: SlotsShreds["slots"],
578-
previousBlock: CompleteBlock | IncompleteBlock,
581+
previousBlock: CompleteBlock | IncompleteBlock | undefined,
579582
) {
583+
if (!previousBlock) {
584+
console.error(`Missing previous block before ${blockSlotNumbers[0]}`);
585+
return;
586+
}
587+
580588
const firstSlotNumber = blockSlotNumbers[0];
581589
const startFirstSlotNumber = slots.get(firstSlotNumber)?.minEventTsDelta;
582590

0 commit comments

Comments
 (0)