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

Unbonding, Redelegation #1119

Merged
merged 84 commits into from
Jun 27, 2018
Merged

Unbonding, Redelegation #1119

merged 84 commits into from
Jun 27, 2018

Conversation

rigelrozanski
Copy link
Contributor

@rigelrozanski rigelrozanski commented Jun 2, 2018

Closes #992
Closes #1122

  • Only Active Slashing for both redelegation and unbonding
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md

@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #1119 into develop will decrease coverage by 2.31%.
The diff coverage is 59.2%.

@@             Coverage Diff             @@
##           develop    #1119      +/-   ##
===========================================
- Coverage    64.47%   62.16%   -2.32%     
===========================================
  Files          112      103       -9     
  Lines         6300     5838     -462     
===========================================
- Hits          4062     3629     -433     
+ Misses        2014     1999      -15     
+ Partials       224      210      -14

@cwgoes
Copy link
Contributor

cwgoes commented Jun 26, 2018

@cwgoes yeah so I want to implement that change as a separate PR which also rips out the inflation - just the distinction between using rationals and integers to represent potentially (to small) rewards

OK; it makes #1278 a bit ugly but makes sense.

x/auth/ante.go Outdated
@@ -85,7 +85,7 @@ func NewAnteHandler(am AccountMapper, fck FeeCollectionKeeper) sdk.AnteHandler {
signerAddr, sig := signerAddrs[i], sigs[i]

// check signature, return account with incremented nonce
signBytes := StdSignBytes(ctx.ChainID(), accNums[i], sequences[i], fee, msgs, stdTx.GetMemo())
signBytes := StdSignBytes(chainID, accNums[i], sequences[i], fee, msgs, stdTx.GetMemo())
Copy link
Contributor

Choose a reason for hiding this comment

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

Does ctx.ChainID() not work? Why is this change in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

chainID comes from ctx.ChainID() - look at the few lines above - without this change signatures fail in lcd tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably somewhere we aren't passing chain_id correctly in the LCD request body then? The code on develop is confusing but it doesn't actually read from Viper.

Copy link
Contributor

Choose a reason for hiding this comment

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

)

func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error {
return newError(codespace, CodeInvalidValidator, "that address is not associated with any known validator")
return sdk.NewError(codespace, CodeInvalidValidator, "That address is not associated with any known validator")
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 we wanted lowercase error strings, nbd though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed all in x/slashing

}

// return the coinkeeper
func (k Keeper) CoinKeeper() bank.Keeper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to expose this? Means that anyone passed stake.Keeper can arbitrarily modify account balances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'll modify the structure of the handler to remove this

validatorDstAddrBech := sdk.MustBech32ifyVal(validatorDstAddr)

// send
jsonStr := []byte(fmt.Sprintf(`{
Copy link
Contributor

Choose a reason for hiding this comment

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

Here might be where you want to pass chain_id, and set ctx.ChainID = body.ChainID in the handler

CHANGELOG.md Outdated
* [cli] fixed cli-bash tests
* [ci] added cli-bash tests
* [basecoin] updated basecoin for stake and slashing
* [docs] fixed references to old cli commands
Copy link
Contributor

Choose a reason for hiding this comment

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

Did that happen in this PR? Some of these changelog entries look unrelated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah not sure how that got in there, removed the duplicate lines

"begin_unbondings": [],
"complete_unbondings": [],
"begin_redelegates": [],
"complete_redelegates": []
Copy link
Contributor

Choose a reason for hiding this comment

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

chain_id might be needed here if not specified already (can't see entire JSON struct in diff)

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, using viper to receive in the test (which needs to be changed), I think that'll be my next PR, refactor out viper usage, pretty much the same as using global variables

],
"complete_unbondings": [],
"begin_redelegates": [],
"complete_redelegates": []
Copy link
Contributor

Choose a reason for hiding this comment

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

chain_id might be needed here (can't see entire JSON struct in diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

// Update bond height
bond.Height = ctx.BlockHeight()
k.setDelegation(ctx, bond)
returnAmount, err := k.Unbond(ctx, msg.DelegatorAddr, msg.ValidatorSrcAddr, msg.SharesAmount)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we prevent transitive redelegation (redelegating from A to B, then again from B to C before the first redelegation has completed)? I think transitive redelegation will break some accounting, both here and in slashing.

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.

Tested ACK

Left for future PRs:

  • Refactoring out global pool shares (no longer necessary)
  • More permissive redelegation (can redelegate from any source other than a existing redelegation)
  • More randomized testcases!

@cwgoes cwgoes merged commit 6f140d7 into develop Jun 27, 2018
@rigelrozanski rigelrozanski deleted the rigel/unbonding branch June 27, 2018 18:48
@cwgoes cwgoes mentioned this pull request Jun 27, 2018
6 tasks
adrianbrink pushed a commit that referenced this pull request Jul 2, 2018
* stake/fees spec updates
* staking overview.md revisions, moving files
* docs reorganization
* staking spec state revisions
* transaction stake updates
* complete staking spec update
* WIP adding unbonding/redelegation commands
* added msg types for unbonding, redelegation
* stake sub-package reorg
* working stake reorg
* modify lcd tests to not use hardcoded json strings
* add description update
* index keys
* key managment for unbonding redelegation complete
* update stake errors
* completed handleMsgCompleteUnbonding fn
* updated to use begin/complete unbonding/redelegation
* fix token shares bug
* develop docs into unbonding
* got non-tests compiling after merge develop
* working fixing tests
* PrivlegedKeeper -> PrivilegedKeeper
* tests compile
* fix some tests
* fixing tests
* remove PrivilegedKeeper
* get unbonding bug
* only rpc sig verification failed tests now
* move percent unbonding/redelegation to the CLI and out of handler logic
* remove min unbonding height
* add lcd txs
* add pool sanity checks, fix a buncha tests
* fix ante. set lcd log to debug (#1322)
* redelegation tests, adding query functionality for bonds
* add self-delegations at genesis ref #1165
* PR comments (mostly) addressed
* cleanup, added Query LCD functionality
* test cleanup/fixes
* fix governance test
* SlashValidatorSet -> ValidatorSet
* changelog
* stake lcd fix
* x/auth: fix chainID in ante
* fix lcd test
* fix lint, update lint make command for spelling
* lowercase error string
* don't expose coinkeeper in staking
* remove a few duplicate lines in changelog
* chain_id in stake lcd tests
* added transient redelegation
* 'transient' => 'transitive'
* Re-add nolint instruction
* Fix tiny linter error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants