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

Remove Shares Concept from Unbond/Redelegate UX #3857

Merged
merged 22 commits into from
Mar 25, 2019

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Mar 11, 2019

  • Remove redundant msg* types from the LCD tests (they're already defined in staking)
  • Provide better names to staking REST types.
  • Update unbonding and redelegation messages/requests to accept an sdk.Coin amount instead of shares.
    • Update respective handlers to convert amount to shares.

I also have updates to update the queriers to return amounts instead of shares but I think that should be a separate PR.

closes: #3516


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alexanderbez alexanderbez added C:x/staking WIP T: State Machine Breaking State machine breaking changes (impacts consensus). labels Mar 11, 2019
@alexanderbez alexanderbez force-pushed the bez/3516-remove-shares-ux branch from 9f04a13 to 8b57e9d Compare March 12, 2019 12:53
@alexanderbez alexanderbez force-pushed the bez/3516-remove-shares-ux branch from 8b57e9d to 3716954 Compare March 12, 2019 12:54
@codecov
Copy link

codecov bot commented Mar 12, 2019

Codecov Report

Merging #3857 into develop will decrease coverage by 0.04%.
The diff coverage is 64.58%.

@@             Coverage Diff             @@
##           develop    #3857      +/-   ##
===========================================
- Coverage    60.95%   60.91%   -0.05%     
===========================================
  Files          192      192              
  Lines        14360    14385      +25     
===========================================
+ Hits          8753     8762       +9     
- Misses        5033     5041       +8     
- Partials       574      582       +8

@alexanderbez alexanderbez added the T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). label Mar 12, 2019
@alexanderbez alexanderbez marked this pull request as ready for review March 12, 2019 18:39
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Changes look straighforward. As long as tests pass, ACK from me

@@ -229,7 +229,17 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Below are the notable changes @cwgoes @rigelrozanski

@rigelrozanski
Copy link
Contributor

The issue I was concerned about today in the meeting does not apply (OK)

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

only looked at the core logic, needs some revisions

x/staking/handler.go Outdated Show resolved Hide resolved
x/staking/handler.go Outdated Show resolved Hide resolved
x/staking/handler.go Outdated Show resolved Hide resolved
x/staking/handler.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor Author

Updated @rigelrozanski @cwgoes

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

approved pending one comment is addressed

x/staking/handler.go Show resolved Hide resolved
@cwgoes
Copy link
Contributor

cwgoes commented Mar 14, 2019

I think this needs to be updated for #3828.

@codecov
Copy link

codecov bot commented Mar 14, 2019

Codecov Report

Merging #3857 into develop will decrease coverage by 0.1%.
The diff coverage is 55.07%.

@@             Coverage Diff             @@
##           develop    #3857      +/-   ##
===========================================
- Coverage    60.45%   60.35%   -0.11%     
===========================================
  Files          196      196              
  Lines        14485    14526      +41     
===========================================
+ Hits          8757     8767      +10     
- Misses        5147     5174      +27     
- Partials       581      585       +4

@alexanderbez
Copy link
Contributor Author

Updated pending entry. Left a followup response to @rigelrozanski.

@rigelrozanski
Copy link
Contributor

rigelrozanski commented Mar 14, 2019

per slack discussions:

func (v Validator) SharesFromTokensTruncate(amt sdk.Int) (sdk.Dec, sdk.Error) {
    if v.Tokens.IsZero() {
        return sdk.ZeroDec(), ErrInsufficientShares(DefaultCodespace)
    }

     return v.GetDelegatorShares().MulInt(amt).QuoTruncate(v.GetTokens()), nil
}
....

    // here TokensFromSharesRoundUp is a new function, where we round up in the final step 
    msgSharesRoundDown := validator.SharesFromTokensTruncate(msg.Tokens)
    delShares := del.GetShares()
    if msgSharesRoundDown.GT(delShares) {
        return ErrBadSharesAmount(k.Codespace()).Result()
    } 
    
    // now get the cap shares 
    shares = ...Capped shares amount (logic from redelegation) 

@cwgoes
Copy link
Contributor

cwgoes commented Mar 15, 2019

Failing simulation, looks like.

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

The changes make sense to me, however it would be good to have a test for this explicit edge case for using the cap of delegation shares. Also, simulations failing which must be rectified

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

update to MsgDelegate struct required

x/staking/simulation/msgs.go Outdated Show resolved Hide resolved
x/staking/simulation/msgs.go Outdated Show resolved Hide resolved
x/staking/types/msg.go Show resolved Hide resolved
@alexanderbez
Copy link
Contributor Author

alexanderbez commented Mar 20, 2019

@rigelrozanski Simulation passes now (not sure why it failed)
@fedekunze addressed your comments

wrt to unit tests, I'll be happy to add them but I'm not sure as to the best way to get fractional shares in the unit tests? Otherwise, there exist unit tests that already cover the over undelegation/redelegation cases.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM

@alexanderbez
Copy link
Contributor Author

@cwgoes mind taking a look at this prior to merging?

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Mostly LGTM; a few possible minor adjustments.

ACK pending comments addressed.

@@ -76,7 +76,7 @@ When a validator wishes to withdraw their transaction fees it must send
triggered each with any change in individual delegations, such as an unbond,
redelegation, or delegation of additional tokens to a specific validator. This
transaction withdraws the validators commission rewards, as well as any rewards
earning on their self-delegation.
earning on their self-delegation.
Copy link
Contributor

Choose a reason for hiding this comment

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

... we can just delete this whole directory, we're not going to implement the Lamborghini model, unless there's a reason to keep it around. Certainly we don't need to update it, since it doesn't reflect any implementation.

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 think that's why it's in "attic". Should we just wipe this @rigelrozanski ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a good idea to wipe... @ValarDragon wanted it in here for reference a while ago... either way I've added it to a new repo https://github.com/rigelrozanski/lamborghini-distribution

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like the best of both worlds to me! We should delete it here then.

x/staking/client/cli/tx.go Show resolved Hide resolved
x/staking/client/cli/tx.go Show resolved Hide resolved
x/staking/handler.go Outdated Show resolved Hide resolved
@cwgoes
Copy link
Contributor

cwgoes commented Mar 22, 2019

(oops - ACK pending comments addressed and conflict resolved)

@alexanderbez
Copy link
Contributor Author

Updated comments @cwgoes and @rigelrozanski.

@rigelrozanski rigelrozanski merged commit 59765ce into develop Mar 25, 2019
@rigelrozanski rigelrozanski deleted the bez/3516-remove-shares-ux branch March 25, 2019 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/staking T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove mentions of shares from client returns
7 participants