fix(pair): skip Observe extrapolate on unrepresentable Decimal ratio #1236

Merged
PlasticDigits merged 3 commits from issue/1231 into main 2026-09-12 02:38:43 +00:00

Summary

  • oracle_observe_single forward-extrapolation now uses Decimal::checked_from_ratio (same operand order as oracle_update). Either overflow skips extrapolate and returns last stored cumulatives — same as the zero-reserve branch. No VM panic. No clamp to Decimal::MAX.
  • Execute-path #465 skip is unchanged. Observe price_times_dt / checked_add stay typed Oracle errors. #1224 execute overflow is out of scope.
  • Tests beside oracle_overflow_tests (oracle_observe_overflow_tests). Docs/skill O1231-1–O1231-6. Wasm migrate is ops after merge.

Fixes #1231

Acceptance

  • AC1. Extreme non-zero ratio + Observe extrapolate (seconds_ago == 0 / target after last obs) does not panic; returns last cumulatives.
  • AC2. oracle_update extreme ratio still Ok / skip (#465).
  • AC3. Balanced reserves + dt > 0 still advance cumulatives.
  • AC4. Historical interpolation (two stored obs, no spot ratio) unchanged under extreme live reserves.
  • AC5. extreme_ratio_degrades_gracefully_instead_of_panicking and normal_ratio_still_records_observation stay green.
  • AC6. Observe JSON shape unchanged on the success path (price_a_cumulatives / price_b_cumulatives).

Test plan

  • make verify-issue-1231 (first pass + retest after grep/fmt)
  • cargo test -p cl8y-dex-pair oracle_overflow
  • cargo test -p cl8y-dex-pair oracle_observe
  • cargo test -p cl8y-dex-tests oracle -- --test-threads=1
  • cargo clippy -- -D warnings in smartcontracts
  • make test-contracts: cl8y-dex-tests 504 passed; one pre-existing factory cw2 version pin (1.10.0 vs 1.9.0) unrelated to this change.
  • Reviewer: confirm Observe skip returns last cumulatives, not clamp / not execute rewrite
  • Ops follow-up (not this PR): pair wasm store + migrate
## Summary - `oracle_observe_single` forward-extrapolation now uses `Decimal::checked_from_ratio` (same operand order as `oracle_update`). Either overflow **skips extrapolate** and returns last stored cumulatives — same as the zero-reserve branch. No VM panic. No clamp to `Decimal::MAX`. - Execute-path `#465` skip is unchanged. Observe `price_times_dt` / `checked_add` stay typed `Oracle` errors. `#1224` execute overflow is out of scope. - Tests beside `oracle_overflow_tests` (`oracle_observe_overflow_tests`). Docs/skill **O1231-1–O1231-6**. Wasm migrate is ops after merge. Fixes #1231 ## Acceptance - [x] AC1. Extreme non-zero ratio + Observe extrapolate (`seconds_ago == 0` / target after last obs) does not panic; returns last cumulatives. - [x] AC2. `oracle_update` extreme ratio still `Ok` / skip (#465). - [x] AC3. Balanced reserves + `dt > 0` still advance cumulatives. - [x] AC4. Historical interpolation (two stored obs, no spot ratio) unchanged under extreme live reserves. - [x] AC5. `extreme_ratio_degrades_gracefully_instead_of_panicking` and `normal_ratio_still_records_observation` stay green. - [x] AC6. Observe JSON shape unchanged on the success path (`price_a_cumulatives` / `price_b_cumulatives`). ## Test plan - [x] `make verify-issue-1231` (first pass + retest after grep/fmt) - [x] `cargo test -p cl8y-dex-pair oracle_overflow` - [x] `cargo test -p cl8y-dex-pair oracle_observe` - [x] `cargo test -p cl8y-dex-tests oracle -- --test-threads=1` - [x] `cargo clippy -- -D warnings` in `smartcontracts` - [x] `make test-contracts`: cl8y-dex-tests 504 passed; one pre-existing factory cw2 version pin (`1.10.0` vs `1.9.0`) unrelated to this change. - [ ] Reviewer: confirm Observe skip returns last cumulatives, not clamp / not execute rewrite - [ ] Ops follow-up (not this PR): pair wasm store + migrate
QueryMsg::Observe still used panicking from_ratio after #465 skipped
the execute sample. Use checked_from_ratio and return last cumulatives.
Author
Owner

drain skip: hard-blocked (needs-human / high-risk / human topic); remaining continue

drain skip: hard-blocked (needs-human / high-risk / human topic); remaining continue
ci: add Woodpecker PR gitleaks gate for Forgejo status checks
All checks were successful
ci/woodpecker/pr/woodpecker gitleaks tracked-tree scan passed locally; .woodpecker.yaml added
699c15c1d5
PlasticDigits deleted branch issue/1231 2026-09-12 02:38:43 +00:00
PlasticDigits left a comment

Self-review blocked (author). CODEOWNERS team request: PlasticDigits is the only maintainer. AC matches #1231.

Self-review blocked (author). CODEOWNERS team request: PlasticDigits is the only maintainer. AC matches #1231.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1236
No description provided.