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

[ValSet-Pref] Add Msgs for Delegate and Undelegate Tokens #3260

Merged
merged 11 commits into from
Dec 1, 2022

Conversation

stackman27
Copy link
Contributor

Part of : #2579

What is the purpose of the change

This message MsgDelegateToValidatorSet allows delegators to delegate to a set of defined validator set. For ex: delegate 10osmo with validator-set {ValA -> 0.5, ValB -> 0.3, ValC -> 0.2} our delegate logic would attempt to delegate 5osmo to A , 2osmo to B, 3osmo to C

Brief Changelog

n/a

Testing and Verifying

Added tests for TestDelegateToValidatorSet

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Nov 7, 2022
@stackman27 stackman27 added the V:state/compatible/backport State machine compatible PR, should be backported label Nov 7, 2022
@stackman27 stackman27 marked this pull request as ready for review November 7, 2022 01:52
@stackman27 stackman27 requested review from a team and alexanderbez November 7, 2022 01:52
@stackman27 stackman27 changed the title [ValSet-Pref] Created MsgDelegateToValidatorSet [ValSet-Pref] Delegate tokens for a val-set using MsgDelegateToValidatorSet Nov 7, 2022
@stackman27 stackman27 changed the title [ValSet-Pref] Delegate tokens for a val-set using MsgDelegateToValidatorSet [ValSet-Pref] Delegate tokens to a val-set using MsgDelegateToValidatorSet Nov 7, 2022
@faddat
Copy link
Member

faddat commented Nov 8, 2022

why?

not that I have any issue with it, it seems cool, but curious on thinking here

@stackman27
Copy link
Contributor Author

why?

not that I have any issue with it, it seems cool, but curious on thinking here

Hi @faddat! This feature can technically be done off-chain today with front-ends, having preference lists stored locally, but Having this on chain:

  1. eases front-end code burden that is already very high in cosmos
  2. reduces front-end lock-in, giving you the same UX across multiple front-ends
  3. Opens door for features such as auto-staking

x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far!
Main logic looks lgtm, left some minor comments for the first round of review

x/valset-pref/README.md Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Show resolved Hide resolved
expectedShares []sdk.Dec
expectPass bool
valSetExists bool
}{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to add a test case that deals delegating coins that wouldn't be calculated perfectly under the ratio and test the rounding conditions? Ex) 739 or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added it here 45964da

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot see it due to force push :( , can you point me to the specific test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectPass bool
valSetExists bool
}{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto with the comment above regarding jailed validator. Consider adding a test case on it as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm not sure how i can create a test scenario where a validator is jailed and user tries to delegate to that validator 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i did some digging around and found out that "It is possible to delegate to a jailed validator, the only difference being it will not be added to the power index until it is unjailed" therefore, i dont think we can add a very indepth test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about unbonded or unbonding validators?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what i found;

  1. unbonded: Validators will be removed from active set but still can receive delegations
  2. unbonding: Validators leaves active set either through slashing, jailing etc, all delegations can be unbonded but will have to wait for unbonding time to exhaust

I am hoping to test all these in either e2e or testnet

@stackman27
Copy link
Contributor Author

Thank you @mattverse and @czarcas7ic for the feedback. Everything should be resolved now :))

@stackman27 stackman27 changed the title [ValSet-Pref] Delegate tokens to a val-set using MsgDelegateToValidatorSet [ValSet-Pref] Add Msgs for Delegate and Undelegate Tokens Nov 21, 2022
Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, well done! Once we get another review here and this gets merged, please ensure to test this on a localosmosis instance with all the applicable CLI commands you used. This way we can easily test come next upgrade!

x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/msg_server_test.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added the C:x/twap Changes to the twap module label Nov 26, 2022
@stackman27
Copy link
Contributor Author

Thank you @czarcas7ic addressed all you comments and added more test coverage 06f64d

still looking on tombstoned validators and ways to approach them

@czarcas7ic
Copy link
Member

@stackman27 that comment was more to add it to the TODO, and not a blocker for this PR IMO

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Left some minor comments I would love to see before merging!

x/twap/api.go Outdated
@@ -58,17 +93,16 @@ func (k Keeper) GetArithmeticTwap(
if err != nil {
return sdk.Dec{}, err
}
return computeArithmeticTwap(startRecord, endRecord, quoteAssetDenom)
return strategy.computeTwap(startRecord, endRecord, quoteAssetDenom)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt this change to getTwapToNow anyways if endTime.Equal(ctx.BlockTime())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops this change wasn't supposed to be in this PR, but endTime = BlockTime logic is covered in line 84. We can follow up this conversation in this PR #3529

expectPass bool
valSetExists bool
}{
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about unbonded or unbonding validators?

x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
x/valset-pref/validator_set.go Outdated Show resolved Hide resolved
expectedShares []sdk.Dec
expectPass bool
valSetExists bool
}{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot see it due to force push :( , can you point me to the specific test case?

@github-actions github-actions bot removed the C:x/twap Changes to the twap module label Nov 29, 2022
@ValarDragon ValarDragon added V:state/breaking State machine breaking PR and removed V:state/compatible/backport State machine compatible PR, should be backported labels Dec 1, 2022
@ValarDragon ValarDragon merged commit a095e33 into main Dec 1, 2022
@ValarDragon ValarDragon deleted the sis/valset-pref-DelMsg branch December 1, 2022 20:45
@ValarDragon
Copy link
Member

Merging due to approvals, and this PR not being merged blocking things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:docs Improvements or additions to documentation V:state/breaking State machine breaking PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants