fix(keeper): propagate SetPocValidationV2 storage error in SubmitPocValidationsV2#1012
fix(keeper): propagate SetPocValidationV2 storage error in SubmitPocValidationsV2#1012Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Conversation
…ubmitPocValidationsV2 ## Problem `SubmitPocValidationsV2` used `LogWarn + continue` for all `SetPocValidationV2` errors, treating infrastructure-level storage failures the same as expected validation errors (e.g. invalid bech32 addresses). A transient storage failure would silently drop votes and return success to the caller — leaving consensus state inconsistent with no observable signal. ## Fix Replace `LogWarn + continue` with `LogError + return error` for `SetPocValidationV2` failures. This is safe because `HasPocValidationV2` (called earlier in the same loop iteration) already validates bech32 addresses for both participant and validator. Any error reaching `SetPocValidationV2` is therefore definitively a storage-layer failure, not invalid input. - Storage failure: `LogError` + abort batch via `return nil, fmt.Errorf(...)`. Cosmos SDK rolls back the full transaction, preventing partial writes. - Invalid address: caught by `HasPocValidationV2` → `LogWarn + continue`. Partial-success design preserved. `TestSubmitPocValidationsV2_PartialSuccess` passes. Adds `TestSubmitPocValidationsV2_StorageError_AddressPreValidation` documenting the address pre-validation invariant that makes this distinction possible. ## Impact - Storage failures are now observable (LogError, tx rollback) instead of silent - Partial-success behavior for invalid addresses unchanged (design intent preserved) - Closes gonka-ai#1012
1d883d6 to
5f6b2f2
Compare
Doog-bot534
left a comment
There was a problem hiding this comment.
Review: fix(keeper): propagate SetPocValidationV2 storage error
Approve ✅
The core logic change is sound. The original code silently swallowed storage errors and continued processing the batch, which could leave consensus state partially written. Since Cosmos SDK rolls back the entire transaction on error, aborting is the correct behavior for infrastructure failures.
The invariant argument is well-reasoned: HasPocValidationV2 validates bech32 addresses before SetPocValidationV2 is reached, so input validation errors are unreachable at the Set stage.
Suggestions
-
Test gap: The test only tests the direct
SetPocValidationV2call with an invalid address. It does not test the new error propagation path inSubmitPocValidationsV2itself. A test injecting a mock store failure would be more valuable to verify the batch actually aborts and returns an error. -
The
return nil, fmt.Errorf(...)response returns a nil first value — verify callers/middleware handle nil response + non-nil error correctly. Standard Cosmos SDK convention, so likely fine.
Verdict: Correct directional fix. Ship it.
Payout address: gonka10zaal553duxp05nvfpqtsqrm2g0j6j34r8nan7
Problem
SubmitPocValidationsV2usedLogWarn + continuefor allSetPocValidationV2errors, treating infrastructure-level storage failures identically to expected validation errors (e.g. invalid bech32 addresses).A transient storage failure would:
successto the callerFix
Replace
LogWarn + continuewithLogError + return errorforSetPocValidationV2failures.Why this is safe and does not break partial-success design:
HasPocValidationV2(called earlier in the same loop iteration, line 116) already validates bech32 addresses for bothparticipantAddressandvalidatorAddress. Any error reachingSetPocValidationV2is therefore definitively a storage-layer failure, not an address validation error.Two distinct paths:
HasPocValidationV2→LogWarn + continue. Partial-success preserved.LogError + return nil, fmt.Errorf(...). Cosmos SDK rolls back the full transaction.TestSubmitPocValidationsV2_PartialSuccesspasses without modification —"invalid_address"is caught atHasPocValidationV2, never reachesSetPocValidationV2.Adds
TestSubmitPocValidationsV2_StorageError_AddressPreValidationdocumenting this invariant.Impact
LogErrorsurfaces in node monitoring, transaction rollback prevents partial writesSubmitPocValidationV1(single-item handler)Test