-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor!: use time-based queued staking and reserve unharvested rewards #305
Conversation
@hallazzang Great works!
|
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.
Great work overall! I don't find any critical/major issue with the changes, but I request to update some documents and inline comments.
to eliminate bottlenecks of processing queued coins at end-of-epoch, we decided to use time-based processing of queued stakings this commit does not include full tests refactoring
also check end time when getting queued staking coins
also prune total stakings immediately in Unstake
also panic when HistoricalRewards is not found
- rename previous `Stakings` endpoint to `Position` - add new `Stakings` and `QueuedStakings` endpoints
35c10f4
to
bac9f4f
Compare
- add `rewards` field to `QueryPositionResponse` - make `Rewards` query endpoint to return rewards by staking coin denom
@hallazzang looks |
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!
refactor!: use time-based queued staking and reserve unharvested rewards #305
Description
This PR changes queued stakings to be handled in time-based(24 hours) manner, rather than epoch-based.
Also, auto-withdrawn rewards due to changes of staked coin amount now accumulated in separate module account.
Farmers have to manually claim their unharvested rewards using
MsgHarvest
.Note that unstaking whole staked coin results in withdrawal of all current rewards and unharvested rewards.
Background
Since
ProcessQueuedCoins
is being called at the end of epoch, when there are too many queued stakings it could impact the chain's performance(see #274). By handling queued staking at the moment it should be changed to staked, it mitigates the mentioned performance issue.Also, automatic withdrawal of accrued rewards when there's a change in staking coin amount(by staking more or unstaking) could confuse many users. Our solution is to move rewards to a separate module account(
UnharvestedRewardsReserveAcc
) and make users to claim it throughMsgHarvest
. In this way, users can know how many rewards are still unharvested and claim rewards as they wish.Note that when unstaking whole amount of coin for a specific denom, all previous unharvested rewards are automatically withdrawn for convenience.
Upgrading
When upgrading a chain which uses the farming module, set
EndTime
of newQueuedStaking
to24 * CurrentEpochDays
hours after current (block)time. It'll result in smooth transition to new time-based staking logic.Closes #302
Closes #274
Tasks
UnharvestedRewards
structCurrentEpoch
preservation ruleUnharvestedRewards
genesis(UnharvestedRewardsRecords)clinet/docs/config.json
References