Merged
Conversation
open-junius
reviewed
Mar 4, 2025
precompiles/src/staking.rs
Outdated
| <<R as frame_system::Config>::Lookup as StaticLookup>::Source: From<R::AccountId>, | ||
| { | ||
| const INDEX: u64 = 2053; | ||
| const ADDRESS_SS58: [u8; 32] = [0; 32]; |
Contributor
There was a problem hiding this comment.
need set the valid value.
Contributor
Author
There was a problem hiding this comment.
This is not used in the new version, so I set it to 0s (as in Metagraph and Ed25519Verify contracts). But I now think, it's better to change this value to Option<[u8; 32]> in the trait, to prevent potential mistakes.
Contributor
Author
There was a problem hiding this comment.
Even better would be ridding of this constant and using a conversion from the contract's address. Just look at this value is hard to understand whether it came from the contract address or not. Would be good to have a method in PrecompileExt trait and use Self::INDEX to generate this value on-demand. Will introduce a little runtime overhead, but that would be a lot more sound.
sam0x17
approved these changes
Mar 5, 2025
This was referenced Mar 6, 2025
This was referenced May 13, 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
Recently we changed some methods in
StakingPrecompileto conform the amount precisions to our Substrate API. They were in ETH-precision before. But that affected some users.This PR takes back ETH-precisions to those methods and introduces a new version of
StakingPrecompile, that has API consistent with our Substrate API.Tests are here: opentensor/subtensor-js-tests#12
Related Issue(s)
Type of Change
Breaking Change
StakingPrecompileexists only for backward compatibility from now on and considered deprecated (replaced byStakingPrecompileV2at a new address)StakingPrecompile::get_stakenow again returns the amount, converted to ETH-precisionStakingPrecompile::remove_stakeaccepts amount in ETH-precision as it was beforeChecklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctlyScreenshots (if applicable)
Please include any relevant screenshots or GIFs that demonstrate the changes made.
Additional Notes
Please provide any additional information or context that may be helpful for reviewers.