fix(opencode): stop submitting expired verified protos - #1438
Open
bmc08gt wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugsnag
6aa188d3ce44e305cadc4a0a: a withdrawal failed three times withSubmitIntentError.StaleState: exchange rate is stale. The protos in the request were signed about 23 minutes before submission, and the server rejects anything older than 15.VerifiedProtoManager.getOrEvictalready checks the timestamp against a 15-minute TTL. When it finds an expired entry it evicts it from the map and then returns it anyway.RealVerifiedFiatCalculator.resolveVerifiedStatetreats any non-null result as usable, so the fresh-fetch branch never ran: none of the three attempts logged "Fetching fresh". The live-mint stream re-saved the same old-stamped protos every few seconds, so each retry hit the same path.Three changes in the manager:
getOrEvictreturnsnullfor an expired entry, so the calculator falls through togetLiveMintDataand either gets a fresh proof or fails withStaleRatebefore the request goes out.clientMaxAgeand leaving headroom for the request to land inside the server's window.saveRatesandsaveReserveStatesskip protos that arrive already past the ceiling, the same check iOS makes inVerifiedProtoServiceon arrival.kotlin.time.Clockis injected through an internal primary constructor; the no-arg@Injectconstructor delegates toClock.System, so Hilt and the twoVerifiedProtoManager()factory call sites are unchanged.VerifiedProtoManagerTestdrives the expiry boundary with a fake clock, andRealVerifiedFiatCalculatorTestgains a case showing a null cache hit triggers the fetch.This does not explain why the stream kept sending protos stamped 23 minutes old. If the backend keeps doing that, the refetch will fail with
StaleRateinstead of succeeding, which is still the right outcome for the user's balance but leaves the backend question open.