Repository navigation
fix: make price smoothing direction independent - #1552
Merged
Merged
Conversation
|
Crate versions that have been updated:
Runtime version has been increased. |
|
Quick benchmark at commit 25d0ebb has been executed successfully. |
enthusiastmartin
approved these changes
Oct 16, 2026
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.
Price smoothing currently depends on the stored asset order because smoothing a price and then taking its reciprocal is not equivalent to smoothing the reciprocal directly. This change applies the slower legacy response consistently in both directions, so querying either orientation of an asset pair produces reciprocal prices with the same effective weighting.
The runtime migration settles stale EMA entries through the last completed block with the legacy arithmetic calculation before enabling the new calculation. Runtime upgrade hooks run before
System::initialize, so the stored system block already identifies that completed block and must not be decremented again. This addresses audit finding IND-01 and avoids applying one direction-independent update to legacy history. The storage layout is unchanged.The one-block migration processes at most 768 oracle rows, which keeps the estimated oracle proof near 2 MiB and covers all 547 rows in the validated production snapshot with headroom. If the limit is reached, later rows remain unchanged while the v3 storage-version upgrade completes; there is no lazy follow-up migration. The migration charges the existing benchmarked EMA finalize weight so its returned weight includes EMA computation and storage proof size.
The ORML token and XYK benchmark assertions are aligned with the base branch's retired insufficient-asset ED scheme. External and XYK share benchmark assets now correctly expect zero system sufficient references; these changes repair benchmark validation without changing runtime behavior.
Versions are bumped to
runtime-integration-tests1.126.1,hydra-dx-math13.2.4,pallet-ema-oracle1.13.1, and Hydration runtime spec 454.Validation:
make test— passed; runtime integration tests: 1,236 passed, 50 ignoredmake test-release— passed; runtime integration tests: 1,236 passed, 50 ignoredmake build-release— passedmake clippy-all— passedcargo fmt --all -- --checkandgit diff --check— passed after merging currentmasterscripts/list_crate_updates.sh— passed with all modified crate and runtime versions recognizedpallet_ema_oraclebenchmark — passed at 50 steps and 20 repeats; generated weights committed asc1bdb8f8apallet-ema-oracletests pass, including a 769-row case proving that exactly 768 rows migrate and the excess row remains unchangedcargo check -p pallet-ema-oracle --features try-runtime --locked— passed after merging currentmasterwss://hdx.tarn.hydration.cloudat finalized block 15,835,245 applied the preauthorized production WASM throughsystem.applyAuthorizedUpgradeThe repository-wide live-fork
try-runtime Allflow is currently blocked after the EMA migration by existing DCA and global storage-version checks against the selected mainnet snapshot. The EMA-specific migration check passes.A full
pallet_ema_oraclebenchmark on the dedicated runner is tracked in workflow run 38907027281.