-
Notifications
You must be signed in to change notification settings - Fork 9
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
Batch rewards distribution #125
Conversation
This is only missing tests on provider site, but I'm going to first try and add better abstractions to provider tests. |
cfe2704
to
b47b80b
Compare
@maurolacy I've noticed non-batch distribution returns no error when an invalid validator is provided. Is that intended? Do we want the same behavior for batch? |
That's OK, because that validators list comes from the blockchain. Take a look at the |
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.
Good start. Please adjust / remove tests, as invalid validators shouldn't be possible.
What's missing is to send a I'm realising now that this might be complex to do. Let's discuss details offline. |
What we can do to err on the safe side, is to add a sender check to the That way we'll prevent malicious actors on the Consumer sending small amounts with invalid validators to distribute, to mess with our mesh security impl. Update: That, or check that the validator is valid. This is related to #123 by the way. Let's discuss offline. |
@maurolacy How do we test the code in |
Good question. Short answer is, we don't have a good way to test some parts of it at this level at the moment. That's why it's mostly untested. By the way, now that Sylvia has support for custom queries, we can test the sudo entry point better (there's a On the bright side, the rewards gathering and distribution code was tested as part of mesh-security integration on a devnet, and it works. |
I have ideas about how to test this, but they might require some refactoring and bloat this PR even more. I think I'd be more comfortable getting this merged and starting a new PR. |
Looks good. Is this ready for (final) review? Can you mark it as such? Thanks. |
I was going to give it a once-over before doing that. |
81a5b22
to
8c102c4
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.
Reviewed the virtual-staking
integration and found some issues. Will review the rest later.
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.
Looks better, but I think that there are still a couple of issues with the main logic.
Since the tests didn't really require refactoring (just a bunch of new code), and the lack of them makes this PR development massively painful, I'm going to merge the tests here after all. Sorry about the LoC! |
…tability Test `virtual-staking` `reply_rewards`
6bd454e
to
e35ce75
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.
LGTM. Nice tests!
funds: vec![reward], | ||
let new_reward_amount = total - BATCH.total(deps.storage)?; | ||
|
||
let all_rewards = |storage| { |
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 logic is now more complex than before. 🙂
OK, I trust this is correct, based on the tests below.
Nice way of testing it, by the way.
Closes #77
There's this comment in the ticket:
Given that the ticket talks about batching distribution and not withdrawing, I don't understand the need for changing withdraw logic. I feel like maybe there's an implication withdrawing could be optimized too, but I have no way of knowing for sure what was meant. If I'm missing something or there's further work to be done, please let me know.