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] Added Proto Definitions and spec #2745

Merged
merged 7 commits into from
Sep 29, 2022
Merged

Conversation

stackman27
Copy link
Contributor

Part of : #2579

This PR definies the proto messages to build validator-set-preference. There are 3 tx messages;

  1. CreateValidatorSetPreference (creates a new {valAddr, Weight} set)
  2. StakeToValidatorSet (gets the tokens and stakes to the existing validator set)
  3. UnStakeFromoValidatorSet (unstakes the coins from an existing validator set)

Brief Changelog

n/a

Testing and Verifying

n/a

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:CLI label Sep 14, 2022
@stackman27 stackman27 changed the title [ValSet-Pref] Added Proto Definitions and initialized types [ValSet-Pref] Added Proto Definitions and initialized= types Sep 14, 2022
@stackman27 stackman27 changed the title [ValSet-Pref] Added Proto Definitions and initialized= types [ValSet-Pref] Added Proto Definitions and initialize types Sep 14, 2022
proto/osmosis/validator-preference/v1beta1/state.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/state.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
@stackman27 stackman27 marked this pull request as ready for review September 20, 2022 17:24
@stackman27 stackman27 requested review from a team and czarcas7ic September 20, 2022 17:24
@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Sep 22, 2022
@stackman27 stackman27 force-pushed the sis/val-pref-protos branch 2 times, most recently from d992ac6 to 1a9abb4 Compare September 22, 2022 18:32
@stackman27 stackman27 changed the title [ValSet-Pref] Added Proto Definitions and initialize types [ValSet-Pref] Added Proto Definitions and spec Sep 22, 2022
x/validator-preference/README.md Outdated Show resolved Hide resolved
x/validator-preference/README.md Outdated Show resolved Hide resolved
x/validator-preference/README.md Outdated Show resolved Hide resolved
x/validator-preference/README.md Outdated Show resolved Hide resolved

UnStaking Calculation

- The user provides an amount to unstake and our `MsgUnStakeFromValidatorSet` divides the amount based on validator weight distribution.
Copy link
Member

Choose a reason for hiding this comment

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

What if I stake with set A, then I change my preferences to different proportions (set B) and try to unstake? Is there some kind of history of preferences to make sure that we don't attempt to unstake more or fewer tokens based on the changed preference list?

Copy link
Contributor Author

@stackman27 stackman27 Sep 22, 2022

Choose a reason for hiding this comment

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

hmm thats interesting. Are you recommending something like this approach?

UserA -> {ValA: 0.5, ValB: 0.2, ValC: 0.3}
User A stakes: 100osmo {ValA-> 50osmo, ValB-> 20osmo, ValC -> 30osmo} 
** Store the history of {weight, amount} ** 

UserA modifies the weight -> {ValA: 0.1, ValB: 0.1, ValC: 0.8}
** Internally check if this modification is possible **  
** Only allow weight modification if the newAmountToStake < oldAmountStaked which can be calculated by weight*TotalAmount ** 

UserA unstakes 50osmo -> {ValA -> 5osmo, ValB -> 10osmo, ValC -> 40osmo} 
**Result in error because ValC only has 30tokens staked** 

Copy link
Member

Choose a reason for hiding this comment

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

On another look, I think I just misinterpreted what is happening here.

I guess when userA changes their preferences list, the unstaking from the old set and restaking to a new set is going to happen behind the scenes. That way, the problem I originally mentioned wouldn't happen. It might be worth specifying in the doc that changing the preferences list implies that we unstake from the old + restake to a new set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aah i see. Yea i believe this is a much cleaner approach. I will mention it :))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to leave this unresolved, so that we can get more feedback from other reviewers

Copy link
Member

Choose a reason for hiding this comment

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

So this spec doesn't discuss the case of what is done when a user does some 'direct' undelegation.

So I set valset { A: .5, B: .2, C: .3 }, and suppose I stake 100 to it, to get:

A: 50, B: 20, C: 30

Then I directly undelegate 20 from B. (So I'm at A:50, C:30)

If I try to valset undelegate 80, what should happen. Options that I think are fine:

  • valset Undelegate fails
  • valset Undelegate Takes {arbitrary distribution across valset validators if theres been direct modification that is unsatisfiable}

Copy link
Member

@ValarDragon ValarDragon Sep 25, 2022

Choose a reason for hiding this comment

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

I find this generally not that concerning, since theres multiple direct user actions to fix this

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 i didn't really think about "direct unstake" and "val-set undelegate" colliding. Should i look into updating "validator-set" state based on the txs from "direct undelegate" and vice versa?

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.

Nice work! The implementation seems pretty straight foward!
Left some comments, please take a look 🌮

proto/osmosis/validator-preference/v1beta1/query.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/state.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/state.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/state.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/osmosis/validator-preference/v1beta1/tx.proto Outdated Show resolved Hide resolved
x/validator-preference/README.md Outdated Show resolved Hide resolved
x/validator-preference/README.md Outdated Show resolved Hide resolved
@stackman27
Copy link
Contributor Author

stackman27 commented Sep 23, 2022

Thank you @p0mvn and @mattverse for the feedback! Resolved pretty much all the suggestions

(:<. . 🌮

}

// MsgCreateValidatorSetPreference is a list that holds validator-set.
message MsgCreateValidatorSetPreference {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
message MsgCreateValidatorSetPreference {
message MsgSetValidatorSetPreference {

Copy link
Member

@ValarDragon ValarDragon Sep 25, 2022

Choose a reason for hiding this comment

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

I think we just make 1 message, SetValidatorSetPreference wdyt?

(As opposed to create + update)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @ValarDragon here

// to modify the weights and the validator.
message ValidatorSetPreferences {
// delegator is the address of the user who created the validator-set.
string delegator = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
Copy link
Member

Choose a reason for hiding this comment

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

Why is this in the struct? We should just be keying using the delegator address

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.

Changes LGTM Once @ValarDragon's suggestion of changing message name get's changed!

Copy link
Contributor

@alexanderbez alexanderbez 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. I think folks left some good feedback that looks like it's being addressed, so approving 👍

}

// MsgCreateValidatorSetPreference is a list that holds validator-set.
message MsgCreateValidatorSetPreference {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @ValarDragon here

@stackman27
Copy link
Contributor Author

Hi @ValarDragon, all comments resolved!

@mergify mergify bot merged commit b91f794 into main Sep 29, 2022
@mergify mergify bot deleted the sis/val-pref-protos branch September 29, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge C:CLI C:docs Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants