-
Notifications
You must be signed in to change notification settings - Fork 992
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
base: main
Are you sure you want to change the base?
Conversation
55449e7
to
5778606
Compare
There was a problem hiding this 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>, |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits
There was a problem hiding this 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...
@@ -3564,7 +3564,7 @@ fn dynamic_assets() -> Result<()> { | |||
) | |||
}); | |||
assert!(captured.result.is_ok()); | |||
assert!(captured.contains("nam: 0.06262")); | |||
assert!(captured.contains("nam: 0.063")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe some of the MASP integration tests had one or two cases where we were in fact testing the undated
/dated
rewards mechanism. Could you please quickly do a pass over all the tests in this file (crates/tests/src/integration/masp.rs
) to check whether they still make sense, given the changes from this PR?
It seems like you just updated the balances in the failing tests :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@murisi sorry to insist on this, but could you please check if the tests still make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please quickly do a pass over all the tests in this file (crates/tests/src/integration/masp.rs) to check whether they still make sense, given the changes from this PR?
@sug0 Thanks for highlighting that the integration tests might somehow be invalidated by these tracking changes, much appreciated. The logic of the tests still makes sense to me: everything about undated tokens never receiving rewards and dated tokens receiving rewards only after the rewards rate is raised above zero remains valid. The only exception to this is unrelated to the dated/undated concerns and can be found at
namada/crates/tests/src/integration/masp.rs
Line 3761 in 3558ccf
// Start distributing shielded rewards for NAM in next epoch |
It seems like you just updated the balances in the failing tests :p
I was a little surprised that the expected balances in dynamic_assets
had to be raised in a disproportionate manner to make the tests pass. But this is plausible in a hypothetical situation where inflation = 10
, total_tokens_in_masp = 6
, and rewardable_tokens_in_masp = 5
. If, as before, all dated and undated assets were being rewarded, then each note would get a reward of floor(10/6)=1
, which would imply an inflation of 6*floor(10/6)=6
. Whereas if only dated tokens are being rewarded, then each note would get a reward of floor(10/5)=2
, which would imply an inflation of 5*floor(10/5)=10
which is higher than before.
I think it doesn't really matter since that information is taken from the |
a8c2006
to
5d654d9
Compare
5d654d9
to
3ace08a
Compare
Codecov ReportAttention: Patch coverage is
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. |
31d732a
to
af8d276
Compare
b0607df
to
fc618e5
Compare
fc618e5
to
0c0efd1
Compare
0c0efd1
to
ef4471d
Compare
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:
Checklist before merging
breaking::
labelsnamada-docs
reponamada-indexer
ornamada-masp-indexer
, a corresponding PR is opened in that repo