-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Unbonding, Redelegation #1119
Conversation
159e796
to
d8d7525
Compare
Codecov Report
@@ 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 |
7a51657
to
2153e0d
Compare
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()) |
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.
Does ctx.ChainID()
not work? Why is this change in this PR?
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.
chainID comes from ctx.ChainID() - look at the few lines above - without this change signatures fail in lcd tests
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.
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.
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.
x/slashing/errors.go
Outdated
) | ||
|
||
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") |
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.
I think we wanted lowercase error strings, nbd though
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.
addressed all in x/slashing
x/stake/keeper/keeper.go
Outdated
} | ||
|
||
// return the coinkeeper | ||
func (k Keeper) CoinKeeper() bank.Keeper { |
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.
Do we need to expose this? Means that anyone passed stake.Keeper
can arbitrarily modify account balances.
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.
Yeah I'll modify the structure of the handler to remove this
client/lcd/lcd_test.go
Outdated
validatorDstAddrBech := sdk.MustBech32ifyVal(validatorDstAddr) | ||
|
||
// send | ||
jsonStr := []byte(fmt.Sprintf(`{ |
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.
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 |
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.
Did that happen in this PR? Some of these changelog entries look unrelated
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.
yeah not sure how that got in there, removed the duplicate lines
client/lcd/lcd_test.go
Outdated
"begin_unbondings": [], | ||
"complete_unbondings": [], | ||
"begin_redelegates": [], | ||
"complete_redelegates": [] |
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.
chain_id
might be needed here if not specified already (can't see entire JSON struct in diff)
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.
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
client/lcd/lcd_test.go
Outdated
], | ||
"complete_unbondings": [], | ||
"begin_redelegates": [], | ||
"complete_redelegates": [] |
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.
chain_id
might be needed here (can't see entire JSON struct in diff)
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.
same as above
x/stake/handler.go
Outdated
// Update bond height | ||
bond.Height = ctx.BlockHeight() | ||
k.setDelegation(ctx, bond) | ||
returnAmount, err := k.Unbond(ctx, msg.DelegatorAddr, msg.ValidatorSrcAddr, msg.SharesAmount) |
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.
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.
…into rigel/unbonding
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.
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!
* 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
Closes #992
Closes #1122