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

Finish staking hooks merge #11677

Merged
merged 25 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3c67cba
allow stopping and completing of redelegations
jtremback Mar 23, 2022
7e9c3d6
refactor to remove BeforeUnbondingDelegationEntryComplete hook and no…
jtremback Mar 25, 2022
70e5a5b
WIP rough draft of validator unbonding hooks
jtremback Mar 26, 2022
a0959e2
add many of marius's suggested changes
jtremback Mar 29, 2022
eb379f0
More review changes
jtremback Mar 29, 2022
6986325
unbonding delegation tests pass
jtremback Mar 31, 2022
a6e1787
WIP adding redelegation tests
jtremback Mar 31, 2022
16b04d2
WIP redelegation tests work
jtremback Apr 4, 2022
a0a99ea
unbondingDelegation and redelegation tests pass and cleanup
jtremback Apr 4, 2022
4aac2da
WIP validator unbonding tests almost pass
jtremback Apr 5, 2022
c36b94e
tests for all new functionality pass
jtremback Apr 5, 2022
855d85e
fix index deleting logic
jtremback Apr 6, 2022
3722a6f
clean up TODOs
jtremback Apr 6, 2022
32dc5a3
Merge branch 'finish-staking-hooks' into finish-staking-hooks-merge
jtremback Apr 18, 2022
3e3d83d
fix small logic bug
jtremback Apr 21, 2022
dbb097e
fix slashing tests
sainoe May 9, 2022
995b4bf
Remove 'Op' from 'UnbondingOp'
sainoe May 9, 2022
ca5f326
rename 'unbonding_op' to 'unbonding' in doc and proto
sainoe May 9, 2022
7631c23
Rename UnbondingOpCanComplete
sainoe May 9, 2022
adfe7c9
unbondingOpId
sainoe May 9, 2022
08a9cef
IncrementUnbondingOpId
sainoe May 9, 2022
bea99e4
UnbondingDelegationByUnbondingOp-Id/Index setter, getter + PutUnbondi…
sainoe May 9, 2022
022d90a
AfterUnbondingOpInitiated
sainoe May 9, 2022
3ec6591
rename args in delegations.go named by UnbondingOpId
sainoe May 9, 2022
d319807
renaming details
sainoe May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,9 @@ tags are stringified and the log is JSON decoded.
| `gas_used` | [int64](#int64) | | Amount of gas consumed by transaction. |
| `tx` | [google.protobuf.Any](#google.protobuf.Any) | | The request transaction bytes. |
| `timestamp` | [string](#string) | | Time of the previous block. For heights > 1, it's the weighted median of the timestamps of the valid votes in the block.LastCommit. For height == 1, it's genesis time. |
| `events` | [tendermint.abci.Event](#tendermint.abci.Event) | repeated | Events defines all the events emitted by processing a transaction. Note, these events include those emitted by processing all the messages and those emitted from the ante handler. Whereas Logs contains the events, with additional metadata, emitted only by processing the messages.

Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 |



Expand Down Expand Up @@ -6484,6 +6487,8 @@ RedelegationEntry defines a redelegation object with relevant metadata.
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | completion_time defines the unix time for redelegation completion. |
| `initial_balance` | [string](#string) | | initial_balance defines the initial balance when redelegation started. |
| `shares_dst` | [string](#string) | | shares_dst is the amount of destination-validator shares created by redelegation. |
| `unbonding_id` | [uint64](#uint64) | | Incrementing id that uniquely identifies this entry |
| `unbonding_on_hold` | [bool](#bool) | | True if this entry's unbonding has been stopped by an external module |



Expand Down Expand Up @@ -6558,8 +6563,8 @@ UnbondingDelegationEntry defines an unbonding object with relevant metadata.
| `completion_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | completion_time is the unix time for unbonding completion. |
| `initial_balance` | [string](#string) | | initial_balance defines the tokens initially scheduled to receive at completion. |
| `balance` | [string](#string) | | balance defines the tokens to receive at completion. |
| `id` | [uint64](#uint64) | | Incrementing id that uniquely identifies this entry |
| `on_hold` | [bool](#bool) | | True if this entry's unbonding has been stopped by an external module |
| `unbonding_id` | [uint64](#uint64) | | Incrementing id that uniquely identifies this entry |
| `unbonding_on_hold` | [bool](#bool) | | True if this entry's unbonding has been stopped by an external module |



Expand Down Expand Up @@ -6607,6 +6612,7 @@ multiplied by exchange rate.
| `unbonding_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. |
| `commission` | [Commission](#cosmos.staking.v1beta1.Commission) | | commission defines the commission parameters. |
| `min_self_delegation` | [string](#string) | | min_self_delegation is the validator's self declared minimum self delegation. |
| `unbonding_on_hold` | [bool](#bool) | | True if this validator's unbonding has been stopped by an external module |



Expand Down
10 changes: 5 additions & 5 deletions proto/cosmos/bank/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ service Query {

// QueryBalanceRequest is the request type for the Query/Balance RPC method.
message QueryBalanceRequest {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
Expand All @@ -67,7 +67,7 @@ message QueryBalanceResponse {

// QueryBalanceRequest is the request type for the Query/AllBalances RPC method.
message QueryAllBalancesRequest {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
Expand All @@ -82,7 +82,7 @@ message QueryAllBalancesRequest {
message QueryAllBalancesResponse {
// balances is the balances of all the coins.
repeated cosmos.base.v1beta1.Coin balances = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
Expand All @@ -91,7 +91,7 @@ message QueryAllBalancesResponse {
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
// method.
message QueryTotalSupplyRequest {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// pagination defines an optional pagination for the request.
Expand All @@ -105,7 +105,7 @@ message QueryTotalSupplyRequest {
message QueryTotalSupplyResponse {
// supply is the supply of the coins
repeated cosmos.base.v1beta1.Coin supply = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// pagination defines the pagination in the response.
//
Expand Down
16 changes: 8 additions & 8 deletions proto/cosmos/base/tendermint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ message GetNodeInfoResponse {

// VersionInfo is the type for the GetNodeInfoResponse message.
message VersionInfo {
string name = 1;
string app_name = 2;
string version = 3;
string git_commit = 4;
string build_tags = 5;
string go_version = 6;
repeated Module build_deps = 7;
string name = 1;
string app_name = 2;
string version = 3;
string git_commit = 4;
string build_tags = 5;
string go_version = 6;
repeated Module build_deps = 7;
// Since: cosmos-sdk 0.43
string cosmos_sdk_version = 8;
string cosmos_sdk_version = 8;
}

// Module is the type for VersionInfo
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ message Vote {
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
VoteOption option = 3 [deprecated = true];
VoteOption option = 3 [deprecated = true];
// Since: cosmos-sdk 0.43
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false];
}
Expand Down
15 changes: 12 additions & 3 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ message Validator {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

// True if this validator's unbonding has been stopped by an external module
bool unbonding_on_hold = 12;
}

// BondStatus is the status of a validator.
Expand Down Expand Up @@ -225,13 +228,13 @@ message UnbondingDelegationEntry {
(gogoproto.moretags) = "yaml:\"initial_balance\""
];
// balance defines the tokens to receive at completion.
string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

// Incrementing id that uniquely identifies this entry
uint64 id = 5;
uint64 unbonding_id = 5;

// True if this entry's unbonding has been stopped by an external module
bool on_hold = 6;
bool unbonding_on_hold = 6;
}

// RedelegationEntry defines a redelegation object with relevant metadata.
Expand All @@ -253,6 +256,12 @@ message RedelegationEntry {
// shares_dst is the amount of destination-validator shares created by redelegation.
string shares_dst = 4
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];

// Incrementing id that uniquely identifies this entry
uint64 unbonding_id = 5;

// True if this entry's unbonding has been stopped by an external module
bool unbonding_on_hold = 6;
}

// Redelegation contains the list of a particular delegator's redelegating bonds
Expand Down
106 changes: 53 additions & 53 deletions x/bank/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions x/distribution/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -107,8 +105,5 @@ func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)
func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) {}
func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) {}
func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {}
func (h Hooks) UnbondingDelegationEntryCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress, _ int64, _ time.Time, _ sdk.Int, _ uint64) {
}
func (h Hooks) BeforeUnbondingDelegationEntryComplete(_ sdk.Context, _ uint64) bool {
return false
func (h Hooks) AfterUnbondingInitiated(_ sdk.Context, _ uint64) {
}
Loading