fix(service): tolerate light-client lag when reading the round's DKG network - #97
Conversation
… at registration GenerateAndSealKey read the round's DKG network once and hard-failed when the light client had not yet verified up to the round's start block, so a node whose verified head trailed the chain tip at a round boundary could not register and lost the round. Retry the not-found read with a bounded budget the same way the dealing/finalization paths tolerate lag, and surface exhaustion as codes.Unavailable so callers see a transient failure.
|
The retry logic and sentinel-error design are solid, and the test coverage is thorough. One build-breaking issue found: Review iteration 2 · Commit f24a3e2 · 2026-08-04T03:30:30Z |
…ag in dealing/finalization paths fetchRoundContext and waitForFinalizationRegistrations failed fast when the light client had not observed the round's DKG network record at all, even though that read has the same lag shape as threshold==0 or a not-yet-reached stage. Classify the not-found read as ErrLightClientLag so the existing retry machinery covers it; other errors still fail fast.
b34856c to
f24a3e2
Compare
Problem
GenerateAndSealKeyreads the round'sDKGNetworkonce at the light client's verified head and returnscodes.Internalon any error, so a transient not-found read at a round boundary (verified head still below the round's start block) hard-fails registration — and the consensus client's ~6s retry window cannot outlast the ~40s observed lag. The dealing/finalization paths (GetOrLoadRoundContext,waitForFinalizationRegistrations) already tolerate lag-shaped reads (threshold == 0, earlier stage) but fail fast on the same not-found shape.Fix
GetDKGNetworkwraps a new sentinelstory.ErrDKGNetworkNotFoundon an empty read (message text unchanged).GenerateAndSealKeyfetches the network viawaitForDKGNetworkCreation: a bounded retry (30 × 3s, outlasting the ~40s boundary lag with margin) scoped to the sentinel — any other error still fails fast. Exhaustion returns the existingErrLightClientLagsentinel mapped tocodes.Unavailable; the loop honors ctx cancellation so a disconnected caller getscodes.Canceledimmediately instead of the handler burning the budget. Retries log at Debug within the documented normal lag and escalate to Warn beyond it.fetchRoundContextclassifies the not-found read asErrLightClientLagsoGetOrLoadRoundContext's existing retry covers it, andwaitForFinalizationRegistrationsretries it like an earlier-stage read.Test coverage
waitForDKGNetworkCreationwaitForFinalizationRegistrationsGetOrLoadRoundContext/fetchRoundContextissue: #96