From 088ab52fabb951c8f33e92e9c179de451ff104a8 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Mon, 28 Mar 2022 11:25:58 +0530 Subject: [PATCH 1/3] docs: add the spec for `cancel-unbond` to cli cmd --- x/staking/spec/02_state_transitions.md | 6 ++++++ x/staking/spec/03_messages.md | 21 +++++++++++++++++++++ x/staking/spec/07_events.md | 12 ++++++++++++ x/staking/spec/09_client.md | 13 +++++++++++++ x/staking/spec/README.md | 1 + 5 files changed, 53 insertions(+) diff --git a/x/staking/spec/02_state_transitions.md b/x/staking/spec/02_state_transitions.md index 1eda63bc8c20..87ba790e1332 100644 --- a/x/staking/spec/02_state_transitions.md +++ b/x/staking/spec/02_state_transitions.md @@ -91,6 +91,12 @@ Delegation may be called. shares from the `BondedPool` to the `NotBondedPool` `ModuleAccount` * remove the validator if it is unbonded and there are no more delegation shares. +### Cancel an `UnbondingDelegation` Entry +When a `cancel unbond delegation` occures both the `validator` and the `delegation` and an `UnbondingDelegationQueue` state will be affected +* if cancel unbonding delegation amount equals to an `UnbondingDelegation` Entry `balance` then an `UnbondingDelegation` Entry deleted from `UnbondingDelegationQueue`. +* if cancel unbonding delegation amount is less then an `UnbondingDelegation` Entry balance then an `UnbondingDelegation` Entry updated with new balance to the `UnbondingDelegationQueue`. +* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to previous `validator` + ### Complete Unbonding For undelegations which do not complete immediately, the following operations diff --git a/x/staking/spec/03_messages.md b/x/staking/spec/03_messages.md index 27c307b24994..69d2334c50d2 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -116,6 +116,27 @@ When this message is processed the following actions occur: ![Unbond sequence](../../../docs/uml/svg/unbond_sequence.svg) +## MsgCancelUnbondingDelegation +The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbondingDelegation` entry and re-deleagate back to previous validator. + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L36-L38 + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L144-L154 + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L156-L157 + + +This message is expected to fail if: +* if an `unbondingDelegation` entry is already processed +* if cancel unbonding delegation amount is greater than the `unbondingDelegation` entry balance +* if cancel unbonding delegation height is not exists in the `unbondingDelegationQueue` of the delegator + +When this message is processed the following actions occur: +* if delegator `unbondingDelegation` entry is not processed +* if cancel `unbondingDelegation` amount is less than or equal to the `unbondingDelegation` entry of delegator +* if cancel unbonding delegation height is exists in the `unbondingDelegation` queue of the delegator + + ## MsgBeginRedelegate The redelegation command allows delegators to instantly switch validators. Once diff --git a/x/staking/spec/07_events.md b/x/staking/spec/07_events.md index 3f9203033cd2..eeeb84c4b902 100644 --- a/x/staking/spec/07_events.md +++ b/x/staking/spec/07_events.md @@ -63,6 +63,18 @@ The staking module emits the following events: * [0] Time is formatted in the RFC3339 standard +### MsgCancelUnbondingDelegation + +| Type | Attribute Key | Attribute Value | +| ----------------------------- | ------------------ | ------------------------------------| +| cancel_unbonding_delegation | validator | {validatorAddress} | +| cancel_unbonding_delegation | delegator | {delegatorAddress} | +| cancel_unbonding_delegation | amount | {cancelUnbondingDelegationAmount} | +| cancel_unbonding_delegation | creation_height | {unbondingCreationHeight} | +| message | module | staking | +| message | action | cancel_unbond | +| message | sender | {senderAddress} | + ### MsgBeginRedelegate | Type | Attribute Key | Attribute Value | diff --git a/x/staking/spec/09_client.md b/x/staking/spec/09_client.md index 608705352cfc..36622d312ea7 100644 --- a/x/staking/spec/09_client.md +++ b/x/staking/spec/09_client.md @@ -712,6 +712,19 @@ Example: ```bash simd tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey ``` +#### cancel unbond +The command `cancel-unbond` allow users to cancel unbonding delegation entry and re-delegate back to previous validator. + +Usage: +```bash +simd tx staking cancel-unbond [validator-addr] [amount] [creation-height] +``` + +Example: +```bash +simd tx staking cancel-unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 123123 --from mykey +``` + ## gRPC diff --git a/x/staking/spec/README.md b/x/staking/spec/README.md index 688fd810afbb..08c21234e427 100644 --- a/x/staking/spec/README.md +++ b/x/staking/spec/README.md @@ -42,6 +42,7 @@ network. * [MsgEditValidator](03_messages.md#msgeditvalidator) * [MsgDelegate](03_messages.md#msgdelegate) * [MsgUndelegate](03_messages.md#msgundelegate) + * [MsgCancelUnbondingDelegation](03_messages.md#msgcancelunbondingdelegation) * [MsgBeginRedelegate](03_messages.md#msgbeginredelegate) 4. **[Begin-Block](04_begin_block.md)** * [Historical Info Tracking](04_begin_block.md#historical-info-tracking) From 62425f42c679d94868887e79f43d031beeeb1b39 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 5 Apr 2022 21:49:18 +0530 Subject: [PATCH 2/3] chore : address the pr review comments --- CHANGELOG.md | 2 +- x/staking/spec/02_state_transitions.md | 8 ++++---- x/staking/spec/03_messages.md | 16 ++++++++-------- x/staking/spec/09_client.md | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79b5c3169f71..e576ddc415a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -263,7 +263,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#11011](https://github.com/cosmos/cosmos-sdk/pull/11011) Remove burning of deposits when qourum is not reached on a governance proposal and when the deposit is not fully met. * [\#11019](https://github.com/cosmos/cosmos-sdk/pull/11019) Add `MsgCreatePermanentLockedAccount` and CLI method for creating permanent locked account * (x/staking) [\#10885] (https://github.com/cosmos/cosmos-sdk/pull/10885) Add new `CancelUnbondingDelegation` - transaction to `x/staking` module. Delegators can now cancel unbonding delegation entry and re-delegate back to validator. + transaction to `x/staking` module. Delegators can now cancel unbonding delegation entry and delegate back to validator. * (x/feegrant) [\#10830](https://github.com/cosmos/cosmos-sdk/pull/10830) Expired allowances will be pruned from state. * (x/authz,x/feegrant) [\#11214](https://github.com/cosmos/cosmos-sdk/pull/11214) Fix Amino JSON encoding of authz and feegrant Msgs to be consistent with other modules. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time. diff --git a/x/staking/spec/02_state_transitions.md b/x/staking/spec/02_state_transitions.md index 87ba790e1332..3c6c27a72218 100644 --- a/x/staking/spec/02_state_transitions.md +++ b/x/staking/spec/02_state_transitions.md @@ -92,10 +92,10 @@ Delegation may be called. * remove the validator if it is unbonded and there are no more delegation shares. ### Cancel an `UnbondingDelegation` Entry -When a `cancel unbond delegation` occures both the `validator` and the `delegation` and an `UnbondingDelegationQueue` state will be affected -* if cancel unbonding delegation amount equals to an `UnbondingDelegation` Entry `balance` then an `UnbondingDelegation` Entry deleted from `UnbondingDelegationQueue`. -* if cancel unbonding delegation amount is less then an `UnbondingDelegation` Entry balance then an `UnbondingDelegation` Entry updated with new balance to the `UnbondingDelegationQueue`. -* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to previous `validator` +When a `cancel unbond delegation` occurs both the `validator`, the `delegation` and an `UnbondingDelegationQueue` state will be updated +* if cancel unbonding delegation amount equals to the `UnbondingDelegation` Entry `balance`, then the `UnbondingDelegation` Entry deleted from `UnbondingDelegationQueue`. +* if the `cancel unbonding delegation amount is less than the `UnbondingDelegation` Entry balance, then the `UnbondingDelegation` entry will be updated with new balance in the `UnbondingDelegationQueue`. +* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to the original `validator` ### Complete Unbonding diff --git a/x/staking/spec/03_messages.md b/x/staking/spec/03_messages.md index 69d2334c50d2..866021320c55 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -117,7 +117,7 @@ When this message is processed the following actions occur: ![Unbond sequence](../../../docs/uml/svg/unbond_sequence.svg) ## MsgCancelUnbondingDelegation -The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbondingDelegation` entry and re-deleagate back to previous validator. +The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbondingDelegation` entry and deleagate back to a previous validator. +++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L36-L38 @@ -127,15 +127,15 @@ The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbo This message is expected to fail if: -* if an `unbondingDelegation` entry is already processed -* if cancel unbonding delegation amount is greater than the `unbondingDelegation` entry balance -* if cancel unbonding delegation height is not exists in the `unbondingDelegationQueue` of the delegator +* the `unbondingDelegation` entry is already processed +* the `cancel unbonding delegation` amount is greater than the `unbondingDelegation` entry balance. +* the `cancel unbonding delegation` height doesn't exists in the `unbondingDelegationQueue` of the delegator. When this message is processed the following actions occur: -* if delegator `unbondingDelegation` entry is not processed -* if cancel `unbondingDelegation` amount is less than or equal to the `unbondingDelegation` entry of delegator -* if cancel unbonding delegation height is exists in the `unbondingDelegation` queue of the delegator - +* if the `unbondingDelegation` Entry balance is zero + * in this condition `unbondingDelegation` entry will be removed from `unbondingDelegationQueue`. + * otherwise `unbondingDelegationQueue` will be updated with new `unbondingDelegation` entry balance and initial balance +* the validator's `DelegatorShares` and the delegation's `Shares` are both increased by the message `Amount`. ## MsgBeginRedelegate diff --git a/x/staking/spec/09_client.md b/x/staking/spec/09_client.md index 36622d312ea7..0c3383d01446 100644 --- a/x/staking/spec/09_client.md +++ b/x/staking/spec/09_client.md @@ -713,7 +713,7 @@ Example: simd tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey ``` #### cancel unbond -The command `cancel-unbond` allow users to cancel unbonding delegation entry and re-delegate back to previous validator. +The command `cancel-unbond` allow users to cancel the unbonding delegation entry and delegate back to the original validator. Usage: ```bash From 1609b2037d242f940896cbf266adc35acbbc9ca9 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Thu, 7 Apr 2022 11:58:44 +0530 Subject: [PATCH 3/3] chore: address the review comments --- x/staking/spec/02_state_transitions.md | 8 ++++---- x/staking/spec/03_messages.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x/staking/spec/02_state_transitions.md b/x/staking/spec/02_state_transitions.md index 3c6c27a72218..9e9efffaeaa2 100644 --- a/x/staking/spec/02_state_transitions.md +++ b/x/staking/spec/02_state_transitions.md @@ -92,10 +92,10 @@ Delegation may be called. * remove the validator if it is unbonded and there are no more delegation shares. ### Cancel an `UnbondingDelegation` Entry -When a `cancel unbond delegation` occurs both the `validator`, the `delegation` and an `UnbondingDelegationQueue` state will be updated -* if cancel unbonding delegation amount equals to the `UnbondingDelegation` Entry `balance`, then the `UnbondingDelegation` Entry deleted from `UnbondingDelegationQueue`. -* if the `cancel unbonding delegation amount is less than the `UnbondingDelegation` Entry balance, then the `UnbondingDelegation` entry will be updated with new balance in the `UnbondingDelegationQueue`. -* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to the original `validator` +When a `cancel unbond delegation` occurs both the `validator`, the `delegation` and an `UnbondingDelegationQueue` state will be updated. +* if cancel unbonding delegation amount equals to the `UnbondingDelegation` entry `balance`, then the `UnbondingDelegation` entry deleted from `UnbondingDelegationQueue`. +* if the `cancel unbonding delegation amount is less than the `UnbondingDelegation` entry balance, then the `UnbondingDelegation` entry will be updated with new balance in the `UnbondingDelegationQueue`. +* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to the original `validator`. ### Complete Unbonding diff --git a/x/staking/spec/03_messages.md b/x/staking/spec/03_messages.md index 866021320c55..a9ef8d05a99a 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -127,7 +127,7 @@ The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbo This message is expected to fail if: -* the `unbondingDelegation` entry is already processed +* the `unbondingDelegation` entry is already processed. * the `cancel unbonding delegation` amount is greater than the `unbondingDelegation` entry balance. * the `cancel unbonding delegation` height doesn't exists in the `unbondingDelegationQueue` of the delegator.