-
Notifications
You must be signed in to change notification settings - Fork 601
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
feat: Add option to designate Reward Recipient to Lock and Incentives #5281
Conversation
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.
Shouldn't we default rewardReceiver to a blank string, and only use this field if the field has an entry? This would save a bit of storage for all these locks. We also wouldn't need to do a state migration for all pre-existing locks.
Also it appears e2e is failing at the create balancer pool step with this change |
@czarcas7ic good call, will apply fix and reassign you for review |
Please ping on slack when its R4R, thank you @mattverse |
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.
There are three things that need to be addressed prior to merge:
- Split lock issue
- Same reward receiver check in order to merge locks
- Msg server fix and test
@@ -94,7 +94,7 @@ func MergeLockupsForSimilarDurations( | |||
} | |||
// create a normalized lock that will absorb the locks in the duration window | |||
normalID = k.GetLastLockID(ctx) + 1 | |||
normalLock = types.NewPeriodLock(normalID, owner, normalizedDuration, time.Time{}, lock.Coins) | |||
normalLock = types.NewPeriodLock(normalID, owner, lock.RewardReceiverAddress, normalizedDuration, time.Time{}, lock.Coins) |
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 also feels like unexpected behavior. What if we have 5 locks, all with different rewardReceiverAddresses? This would set the normalized lock to whatever the final lock's rewardRecieverAddress is. Should we require that all locks have the same rewardReceiverAddress in order to merge them?
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.
IMO we should not be using this method anymore, since this was a method created use for migration in v7, and our codebase has changed alot since then.
however, I do think that your case states a valid point thus added logic to prevent merging locks if the reward address is not the owner as a saftey measure just in case we do come across using this method in 2d6aa30
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.
If this method is unused, can we remove it?
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.
We still need the method though since we have the old upgrade handler :(
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
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.
Nice, looks solid to me!! Can you ping one more person to get a second ACK? Would feel more comfortable since this is core lockup logic.
x/lockup/keeper/msg_server_test.go
Outdated
s.Require().Equal(newLock.RewardReceiverAddress, "") | ||
} else { | ||
s.Require().Equal(newLock.RewardReceiverAddress, s.TestAccs[1].String()) |
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.
nit: these are flipped. The expected value should be the first value and actual should be the second value.
|
||
// check if the reward receiver is the lock owner. | ||
// if not, we do not normalize the lock. | ||
if lock.RewardReceiverAddress != "" { | ||
continue | ||
} |
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.
ref: https://github.com/osmosis-labs/osmosis/pull/5281/files#r1208613288
I don't understand why we use an empty string placeholder when we could use the owner address directly. Please let me know
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 LGTM, nice work! Only had minor comments.
Please ping me for one more skim once the comments are addressed. I would like to see the reply to the "empty string placeholder" discussion
…#5281) * Add Reward Recepient to lock * Add changelog * Store receiver if receiver is lock owner * Add defense in depth * Debuggoing.. * Add debug * More logs * Fixed * Update x/incentives/keeper/distribute.go * Update x/lockup/keeper/lock.go * Update x/lockup/keeper/lock_test.go Co-authored-by: Adam Tucker <[email protected]> * Update x/lockup/types/msgs.go Co-authored-by: Adam Tucker <[email protected]> * Update x/lockup/types/msgs.go Co-authored-by: Adam Tucker <[email protected]> * Adams review * Adam's review * Fix test * Add romans comment --------- Co-authored-by: Adam Tucker <[email protected]>
Sub-component of #5044
What is the purpose of the change
This PR introduces a new state entry
reward_receiver_address
to the period lock. This field would be set to the lock owner by default at the time of lock's creation, and only would be changed by a separate messageSetLockRewardReceiverAddress
.Distribution at epoch time would be done to the reward receiver address set in state, instead of directly using the lock owner.
By utilizing this field, further integration with contracts or authz would be possible.
Testing and Verifying
According tests has been added.
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)