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

GetRewardEst iterates all over the locked tokens #109

Closed
mconcat opened this issue Apr 21, 2021 · 2 comments
Closed

GetRewardEst iterates all over the locked tokens #109

mconcat opened this issue Apr 21, 2021 · 2 comments
Assignees

Comments

@mconcat
Copy link
Collaborator

mconcat commented Apr 21, 2021

GetRewardsEst(which is called in RewardsEst grpc query) calls FilteredLocksDistributionEst, which iterates all over the locked tokens(https://github.com/osmosis-labs/osmosis/blob/main/x/incentives/keeper/pot.go#L164). This causes issues on performance side, as it need to recalculate the reward every time when the query happens.

The suggested solution is limit the lockup period to the epoch, and make the lockup module updates the total amount when there is lock related event happens. The incentive module will read the cached state when queried.

ref @Thunnini

@ValarDragon
Copy link
Member

GetRewardsEst is for a single address, so we should be able to determine the rewards for that address without iterating over all locks. We just need to get the locks associated with that address, and the total amount of shares for each pot that the lock contributes to. Then we can calculate the reward going to that address

@mconcat
Copy link
Collaborator Author

mconcat commented Apr 22, 2021

Adding a lock reference for the owner address and adding total share for a pot(which is updated by lock hook) would work.

@mconcat mconcat self-assigned this Apr 22, 2021
@sunnya97 sunnya97 added this to To do in Minimum Viable Osmosis via automation May 8, 2021
@sunnya97 sunnya97 moved this from To do to In progress in Minimum Viable Osmosis May 13, 2021
@sunnya97 sunnya97 moved this from In progress to To do in Minimum Viable Osmosis May 13, 2021
@sunnya97 sunnya97 moved this from To do to In progress in Minimum Viable Osmosis May 21, 2021
@sunnya97 sunnya97 moved this from In progress to Done in Minimum Viable Osmosis May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants