ENG-317: price wire float→double (Phase A, client)#333
Closed
islandbitcoin wants to merge 1 commit intomainfrom
Closed
ENG-317: price wire float→double (Phase A, client)#333islandbitcoin wants to merge 1 commit intomainfrom
islandbitcoin wants to merge 1 commit intomainfrom
Conversation
Adds `double price_v2 = 3` alongside the existing `float price = 1` (now deprecated) on PriceResponse and the equivalent on Tick. Servers populate both fields; clients prefer `price_v2` and fall back to `price` so the two repos can roll out independently. Float32 quantises non-USD/non-BTC rates (notably JMD-class rates) by ~6e-8 relative drift, which compounds to ~J$19 of uncertainty on a 1-BTC quote — the wire-level baseline behind ENG-316. Phase B (separate PR, after one prod release cycle on Phase A) removes `float price` entirely.
4 tasks
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.
ENG-317 — float→double on the price wire (Phase A, client side)
Pairs with lnflash/price#7. These two PRs MUST land in
either order but the server PR should hit prod first so this client has
something to read from.
What changes
price.protoandprice_history.proto: adddouble price_v2 = 3alongside the existing
float price(now[deprecated = true]).Wire-compatible: old servers and old clients keep working unchanged.
services/price/index.ts: newpreferDouble({ price, price_v2 })helper used at every read site (real-time get-price, USD-cross
conversion, and the
Tickmapping inlistHistory). Picksprice_v2when populated and non-zero, else falls back toprice.0continues to mean "no price" (existingPriceNotAvailableErrorsemantics).__tests__/wire-precision.test.ts: 10 cases. Demonstrates the float32drift on real-world JMD/USD/JPY intraday rates, and locks in the
fallback semantics for both new-server and pre-ENG-317-server cases.
Why dual-field instead of in-place float→double
Protobuf wire types differ between
float(5) anddouble(1) — anin-place change would silently corrupt all readers. The additive
deprecate-then-remove pattern is the only safe rollout. Phase B (a
follow-up PR after one full release cycle in prod) drops
float priceentirely.Drift baseline
For
9.45 JMD/sat(the ENG-316 rate):price_v2carries the float64 unchanged, so the drift drops to zeroonce both ends are upgraded.
Acceptance
price_v2, falls back toprice, surfacesPriceNotAvailableErroron0fallback path for pre-ENG-317 servers