Skip to content

fix(gloas): prevent uint64 underflow in ListFinalizedSlots on short-lived chains#242

Open
barnabasbusa wants to merge 1 commit intorelease/gloasfrom
bbusa/fix-list-finalized-slots-underflow-gloas
Open

fix(gloas): prevent uint64 underflow in ListFinalizedSlots on short-lived chains#242
barnabasbusa wants to merge 1 commit intorelease/gloasfrom
bbusa/fix-list-finalized-slots-underflow-gloas

Conversation

@barnabasbusa
Copy link
Copy Markdown
Contributor

Summary

  • Same fix as fix: prevent uint64 underflow in ListFinalizedSlots on short-lived chains #241, targeted at release/gloas so gloas devnets / kurtosis enclaves can pick it up immediately without waiting for a master merge.
  • ListFinalizedSlots (backing GET /checkpointz/v1/beacon/slots) computed its lower-bound slot as latestSlot - SlotsPerEpoch * HistoricalEpochCount in uint64. When the finalized epoch is smaller than historical_epoch_count — typical for the first ~2 minutes of a kurtosis gloas enclave with SLOTS_PER_EPOCH=8 and the default historical_epoch_count=20 — the subtraction underflows to ~2^64, so the i > val loop condition is immediately false and the endpoint returns an empty slice. UI "historical finalized epoch boundaries" table then stays blank.
  • Clamp the lower bound at 0 so every available finalized epoch-boundary slot is returned, regardless of chain age. No behavior change once finalizedEpoch >= HistoricalEpochCount.

Repro (on release/gloas before this patch)

$ curl .../checkpointz/v1/beacon/slots
{"data":{"slots":[]}}

After: the list returns whatever's available (1 entry after the first finalized epoch, 2 after the second, …).

Test plan

  • go build ./...
  • go vet ./...
  • golangci-lint run --new-from-rev=origin/release/gloas ./pkg/beacon/... → 0 issues
  • Verified in a running kurtosis gloas enclave: rows populate incrementally from epoch 1 onward instead of staying empty until epoch 20

…ains

When the finalized epoch is smaller than historical_epoch_count (e.g. on a
freshly started devnet or kurtosis enclave), the previous expression
`latestSlot - SlotsPerEpoch*HistoricalEpochCount` underflows uint64 and
produces a value near 2^64, so the loop never executes and the
/checkpointz/v1/beacon/slots endpoint returns an empty list — leaving the
UI's historical checkpoints table blank until the chain has produced
HistoricalEpochCount epochs.

Clamp the lower bound at 0 so we return every available finalized
epoch-boundary slot, regardless of chain age.

Same fix as #241 but targeted at release/gloas so gloas devnets can pick
it up without waiting for a master merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant