Non-deterministic queries, unhandled settlement errors, epoch stats underflow #885
Summary
Found several bugs during code review of x/inference/keeper/:
1. Non-deterministic gRPC query responses (consensus risk)
Three query handlers iterate Go maps and return results directly without sorting:
GetParticipantsFullStats—maps.Values(participants)returns unstable orderInferencesAndTokensStatsByModels— iteratesmap[string]StatsSummaryDebugStatsDeveloperStats— iteratesstatByTimeandstatByEpochmaps
Go map iteration order is randomized per-process. This means different nodes return the same data in different order, which can cause issues with deterministic replay and client-side caching.
2. uint64 underflow in GetSummaryLastNEpochs / GetSummaryLastNEpochsByDeveloper
When n > effectiveEpochIndex (e.g. early chain with epoch=1, requesting last 5 epochs), this wraps to MaxUint64, creating an enormous iterator range. This is reproducible on any chain in its first few epochs.
3. Ignored errors in SettleAccounts
Four error return values are silently discarded in the settlement path:
GetBitcoinSettleAmountserror logged but settlement continues with potentially uninitialized dataAddTokenomicsDatareturn value completely ignoredSetSettleAmountWithGovernanceTransferreturn value completely ignoredTransferOldSettleAmountsToGovernanceerror logged butnilreturned to caller
4. Missing error in log call
shareWorkWithValidators logs "Unable to update participant" but omits the actual error value, making debugging impossible.
Files
x/inference/keeper/accountsettle.gox/inference/keeper/developer_stats_aggregation.gox/inference/keeper/msg_server_validation.gox/inference/keeper/query_developer_stats_aggregation.gox/inference/keeper/query_get_participant_current_stats.go
💬 Comments (1)
🔄 Auto-synced from Issue #885 every hour.
Closing — PR #886 was closed as part of refocusing on larger scoped contributions.