drop the data instead of rolling it out#93
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts how the frontend retains live event history (swaps, transfers, and block tracking) by switching from a strict rolling window to a “trim in chunks” approach to reduce state growth and update churn.
Changes:
- Trim swaps/transfers lists only when exceeding their thresholds, and when trimming occurs keep only ~1/3 of the threshold.
- Reduce
useBlockStateTracker’sMAX_BLOCKSfrom 15000 to 5000 and apply the same chunk-trim strategy. - Apply the same chunk-trim strategy to
useBlockExecutionTracker’s block list.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| frontend/hooks/use-transfer-events.ts | Changes transfer history retention to chunk-trim when exceeding MAX_TRANSFERS. |
| frontend/hooks/use-swap-events.ts | Changes swap history retention to chunk-trim when exceeding MAX_SWAPS. |
| frontend/hooks/use-block-state-tracker.ts | Lowers block retention threshold and chunk-trims block list on overflow. |
| frontend/hooks/use-block-execution-tracker.ts | Chunk-trims tracked blocks on overflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR replaces the per-item rolling-window strategy (always keep exactly the last N items) with a drop-to-1/3 on overflow strategy across four event-tracking hooks. When an array exceeds its Key changes:
The slice directions are consistent: block hooks append to the tail and truncate with Confidence Score: 5/5Safe to merge — no correctness or data-integrity regressions introduced; all truncation directions are consistent with each array's ordering. No P0 or P1 issues found. The truncation logic is correct and symmetric across all four hooks (block hooks append+slice-tail, event hooks prepend+slice-head). The one previously flagged concern (cumulativeTransferred diverging from visible transfers) is a pre-existing design choice that was already discussed. All remaining observations are P2 style/documentation suggestions. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[New event arrives] --> B[Prepend / Append item to array]
B --> C{length > MAX?}
C -- No --> D[Return full array as-is]
C -- Yes --> E[Drop ~2/3 of data, keep newest Math.ceil(MAX/3) items]
E --> F[Array shrinks to ~1/3 capacity]
F --> D
D --> G[React state update]
subgraph "Block hooks — append newest at end"
H[".slice(-Math.ceil(MAX/3))"]
end
subgraph "Swap & Transfer hooks — prepend newest at front"
I[".slice(0, Math.ceil(MAX/3))"]
end
E --> H
E --> I
Reviews (2): Last reviewed commit: "drop the data instead of rolling it out" | Re-trigger Greptile |
Motivation:
Explain here the context, and why you're making that change. What is the problem you're trying to solve.
Modifications:
Describe the modifications you've done.
Result:
After your change, what will change.