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

Murisi/track undated assets #4303

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

Murisi/track undated assets #4303

wants to merge 7 commits into from

Conversation

murisi
Copy link
Collaborator

@murisi murisi commented Feb 3, 2025

Describe your changes

This PR attempts to address issue #4304 by distributing rewards only among the dated assets. Doing this involved tracking the balance of dated/undated assets in the MASP at any point in time. More specifically, the following changes have been made:

  • A new storage key has been introduced to track the amount of undated tokens of each token address in the MASP
  • The transfer WASMs have been modified to update the storage key that tracks undated token amounts
  • The MASP VP has been modified to check that the undated token tracking storage keys are updated correctly
  • Rewards are now only distributed to the total undated assets of some token rather than to all assets of some token
    • Hence undated tokens that may have been locked into the MASP pool prior to enabling the rewards program for the token are no longer "rewarded"

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 force-pushed the murisi/track-undated-assets branch from 55449e7 to 5778606 Compare February 3, 2025 15:30
@murisi murisi requested review from grarco, batconjurer and sug0 February 3, 2025 15:39
@murisi murisi mentioned this pull request Feb 3, 2025
3 tasks
@murisi murisi added the MASP label Feb 4, 2025
Copy link
Collaborator

@grarco grarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Net of the failing tests and some minor things this PR looks good to me

@@ -437,7 +437,7 @@ pub trait ShieldedApi<U: ShieldedUtils + MaybeSend + MaybeSync>:
async fn precompute_asset_types<C: Client + Sync>(
&mut self,
client: &C,
tokens: Vec<&Address>,
tokens: BTreeSet<&Address>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could just be an impl Iterator<Item=&Address>

Copy link
Collaborator Author

@murisi murisi Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The motivation for this change was to try and avoid doing the same precomputation twice (with the redundant querying and encoding that comes with it) if the input contains duplicates, not that this is actually a serious problem.

Copy link
Member

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits

Copy link
Collaborator

@sug0 sug0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a few suggestions, nothing too annoying to fix, I hope. Overall, this is a fine solution. The only thing I would point out is that it partitions the privacy set into dated and undated assets. After a shielding transaction is applied, you can tell whether the shielded asset was dated or not, based on the keys changed in storage. Whether this is relevant information or not isn't really clear to me.

EDIT: I guess this doesn't matter, because we could already tell before this PR if the asset was dated or not, given its presence or absence in the token map...

@grarco
Copy link
Collaborator

grarco commented Feb 5, 2025

I have left a few suggestions, nothing too annoying to fix, I hope. Overall, this is a fine solution. The only thing I would point out is that it partitions the privacy set into dated and undated assets. After a shielding transaction is applied, you can tell whether the shielded asset was dated or not, based on the keys changed in storage. Whether this is relevant information or not isn't really clear to me.

EDIT: I guess this doesn't matter, because we could already tell before this PR if the asset was dated or not, given its presence or absence in the token map...

I think it doesn't really matter since that information is taken from the sapling_value_balance which is already publicly available and displays the asset types and the amounts. That value is only populated with assets coming in or out of the pool: the assets and amounts that are instead circulating inside the pool won't show up there and therefore won't leak any data

@murisi murisi force-pushed the murisi/track-undated-assets branch from a8c2006 to 5d654d9 Compare February 5, 2025 14:59
@tzemanovic tzemanovic added breaking:consensus Consensus breaking change that requires a hard-fork breaking:state State breaking change that is not backwards compatible with a state recorded by current version labels Feb 5, 2025
@murisi murisi marked this pull request as draft February 5, 2025 16:45
@murisi murisi marked this pull request as ready for review February 5, 2025 16:45
@murisi murisi force-pushed the murisi/track-undated-assets branch from 5d654d9 to 3ace08a Compare February 6, 2025 09:32
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 72.84768% with 82 lines in your changes missing coverage. Please review.

Project coverage is 74.25%. Comparing base (4990b9c) to head (ef4471d).
Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
crates/token/src/tx.rs 8.62% 53 Missing ⚠️
wasm/tx_ibc/src/lib.rs 0.00% 13 Missing ⚠️
crates/tx_prelude/src/token.rs 0.00% 8 Missing ⚠️
crates/shielded_token/src/vp.rs 92.59% 6 Missing ⚠️
crates/ibc/src/msg.rs 95.65% 1 Missing ⚠️
crates/shielded_token/src/masp/shielded_wallet.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4303      +/-   ##
==========================================
+ Coverage   74.17%   74.25%   +0.07%     
==========================================
  Files         345      343       -2     
  Lines      110624   110909     +285     
==========================================
+ Hits        82060    82360     +300     
+ Misses      28564    28549      -15     

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

@murisi murisi force-pushed the murisi/track-undated-assets branch from 31d732a to af8d276 Compare February 7, 2025 13:25
@murisi murisi requested review from yito88, sug0 and batconjurer February 7, 2025 14:04
@murisi murisi force-pushed the murisi/track-undated-assets branch from b0607df to fc618e5 Compare February 10, 2025 07:29
@murisi murisi force-pushed the murisi/track-undated-assets branch from fc618e5 to 0c0efd1 Compare February 10, 2025 15:42
@murisi murisi force-pushed the murisi/track-undated-assets branch from 0c0efd1 to ef4471d Compare February 10, 2025 15:43
@tzemanovic tzemanovic added the do-not-merge Do not merge for now label Feb 13, 2025
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 breaking:state State breaking change that is not backwards compatible with a state recorded by current version do-not-merge Do not merge for now MASP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants