fix: scaling values of alpha precompiles#1832
Merged
sam0x17 merged 3 commits intoopentensor:devnet-readyfrom Jul 11, 2025
Merged
fix: scaling values of alpha precompiles#1832sam0x17 merged 3 commits intoopentensor:devnet-readyfrom
sam0x17 merged 3 commits intoopentensor:devnet-readyfrom
Conversation
JohnReedV
reviewed
Jul 8, 2025
Contributor
JohnReedV
left a comment
There was a problem hiding this comment.
The Validate-Benchmarks check will work after merging in the latest devnet-ready branch.
open-junius
approved these changes
Jul 10, 2025
l0r1s
reviewed
Jul 11, 2025
Comment on lines
-35
to
+36
| Ok(U256::from(price.saturating_to_num::<u64>())) | ||
| let price_scaled = price.saturating_mul(U96F32::saturating_from_num(1_000_000_000)); | ||
| Ok(U256::from(price_scaled.saturating_to_num::<u64>())) |
Collaborator
There was a problem hiding this comment.
Could be nice to have the 1_000_000_000 set as the EVM_TO_SUBSTRATE_DECIMALS and set this constant in the runtime common instead of the main runtime file to be able to reuse it.
Contributor
There was a problem hiding this comment.
In this case it is not EVM to Substrate conversion, but rather price being U96F32 type internally and u64 in per-bil format externally.
Contributor
Author
There was a problem hiding this comment.
what do u recommend I call the constant
l0r1s
requested changes
Jul 11, 2025
Collaborator
l0r1s
left a comment
There was a problem hiding this comment.
one change so we don't end up with magic constants across the codebase
camfairchild
approved these changes
Jul 11, 2025
gztensor
approved these changes
Jul 11, 2025
sam0x17
approved these changes
Jul 11, 2025
This was referenced Jul 16, 2025
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.
Description
Alpha precompile was converting the U96F32 price directly to u64 without proper scaling, while the runtime API applies a scaling factor of 1_000_000_000.
Introduced fix to apply proper scaling to getAlphaPrice and getMovingAlphaPrice and pull raw storage value of tao weight.
Type of Change
Breaking Change
No breaking change.
Checklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctly