Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the shielded reward precision for tokens to be explicitly set. #4423

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

murisi
Copy link
Collaborator

@murisi murisi commented Feb 27, 2025

Describe your changes

An attempt to address #4422 by introducing new storage keys to hold the shielded reward precision for each token and reading that instead of deducting it. More precisely, the changes are as follows:

  • Made a new storage key to hold the shielded rewards precision for each token
  • The function for obtaining a token's reward precision now reads this new storage key
    • And if the storage key is uninitialized, it initializes it using the old algorithm: 10^(max(denom,3)-3)

This PR should be backwards compatible in the sense it can read/support current mainnet state without any migrations. And simultaneously it allows the shielded rewards precision to be set for new tokens as they are introduced by governance proposals. But to fix the precision of IBC tokens that have already been introduced into the system, purging of its ConversionLeaf::conversion entries (by setting them to MaspAmount::zero()) would also have to be done in addition to setting its desired shielded reward precision in storage. (More generally, once the shielded reward precision for a token is set, it cannot be changed without doing a similar purging process.)

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes
  • If this PR requires changes to the docs or specs, a corresponding PR is opened in the namada-docs repo
    • Relevant PR if applies:
  • If this PR affects services such as namada-indexer or namada-masp-indexer, a corresponding PR is opened in that repo
    • Relevant PR if applies:

@murisi murisi changed the title Allow the MASP reward precision for tokens to be explicitly set. Allow the shielded reward precision for tokens to be explicitly set. Feb 27, 2025
@murisi murisi added the MASP label Feb 27, 2025
@github-actions github-actions bot added the backport-libs-0.47 Backport libraries to 0.47 maintenance branch label Feb 27, 2025
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.49%. Comparing base (7ca07c9) to head (35b1045).
Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
crates/token/src/lib.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4423      +/-   ##
==========================================
- Coverage   74.53%   74.49%   -0.05%     
==========================================
  Files         339      339              
  Lines      110504   110653     +149     
==========================================
+ Hits        82368    82433      +65     
- Misses      28136    28220      +84     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@murisi murisi added the breaking:consensus Consensus breaking change that requires a hard-fork label Feb 27, 2025
@yito88
Copy link
Member

yito88 commented Feb 27, 2025

@murisi Do we need to modify the e2e test ibc_token_inflation to check this change is effective?

@tzemanovic tzemanovic removed the backport-libs-0.47 Backport libraries to 0.47 maintenance branch label Feb 28, 2025
@murisi murisi force-pushed the murisi/configurable-masp-precision branch from 1e4409b to 35b1045 Compare March 8, 2025 16:22
@murisi
Copy link
Collaborator Author

murisi commented Mar 8, 2025

@murisi Do we need to modify the e2e test ibc_token_inflation to check this change is effective?

Thanks, good point. I've introduced an integration test named masp::dynamic_precision to test this behaviour since that's easier (and probably faster) to run than an E2E test, and because this change this change is not IBC specific.

@murisi murisi requested review from grarco, sug0 and batconjurer March 8, 2025 19:15
@murisi murisi force-pushed the murisi/configurable-masp-precision branch from d9234d3 to 20a497c Compare March 8, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:consensus Consensus breaking change that requires a hard-fork MASP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants