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

R4R: Tags Cleanup & Docs #3137

Merged
merged 15 commits into from
Dec 20, 2018
Prev Previous commit
Next Next commit
Update staking tags and implement tags doc
  • Loading branch information
Aleksandr Bezobchuk committed Dec 19, 2018
commit 241fef925bc3502cd75dd40a0dbba18af3277da0
8 changes: 4 additions & 4 deletions docs/spec/governance/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The governance module emits the following events/tags:

## BeginBlocker
## EndBlocker
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? All governance events are tagged with these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly.


| Key | Value |
|-----------------|----------------------------------------------------|
| proposal-result | proposal-passed|proposal-rejected|proposal-dropped |
| Key | Value |
|-----------------|------------------------------------------------------|
| proposal-result | proposal-passed\|proposal-rejected\|proposal-dropped |

## Handlers

Expand Down
58 changes: 58 additions & 0 deletions docs/spec/staking/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Tags

The staking module emits the following events/tags:

## EndBlocker

| Key | Value |
|-----------------------|-------------------------------------------|
| action | complete-unbonding\|complete-redelegation |
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| destination-validator | {dstOperatorAddress} |

## Handlers

### MsgCreateValidator

| Key | Value |
|-----------------------|----------------------|
| destination-validator | {dstOperatorAddress} |
| moniker | {validatorMoniker} |
| identity | {validatorIdentity} |

### MsgEditValidator

| Key | Value |
|-----------------------|----------------------|
| destination-validator | {dstOperatorAddress} |
| moniker | {validatorMoniker} |
| identity | {validatorIdentity} |

### MsgDelegate

| Key | Value |
|-----------------------|-------------------------------------------|
| delegator | {delegatorAccountAddress} |
| destination-validator | {dstOperatorAddress} |

### MsgBeginRedelegate

| Key | Value |
|-----------------------|-------------------------------------------|
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| destination-validator | {dstOperatorAddress} |
| end-time [0] | {delegationFinishTime} |

* [0] Time is formatted in the RFC3339 standard

### MsgBeginUnbonding

| Key | Value |
|------------------|---------------------------|
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| end-time [0] | {delegationFinishTime} |

* [0] Time is formatted in the RFC3339 standard
28 changes: 17 additions & 11 deletions x/stake/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stake

import (
"bytes"
"time"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/common"
Expand Down Expand Up @@ -34,7 +35,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
}

// Called every block, update validator set
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.ValidatorUpdate, endBlockerTags sdk.Tags) {
func EndBlocker(ctx sdk.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, sdk.Tags) {
resTags := sdk.NewTags()

// Calculate validator set changes.
//
// NOTE: ApplyAndReturnValidatorSetUpdates has to come before
Expand All @@ -44,7 +47,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.Valid
// unbonded after the Endblocker (go from Bonded -> Unbonding during
// ApplyAndReturnValidatorSetUpdates and then Unbonding -> Unbonded during
// UnbondAllMatureValidatorQueue).
validatorUpdates = k.ApplyAndReturnValidatorSetUpdates(ctx)
validatorUpdates := k.ApplyAndReturnValidatorSetUpdates(ctx)

// Unbond all mature validators from the unbonding queue.
k.UnbondAllMatureValidatorQueue(ctx)
Expand All @@ -56,7 +59,8 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.Valid
if err != nil {
continue
}
endBlockerTags.AppendTags(sdk.NewTags(

resTags.AppendTags(sdk.NewTags(
tags.Action, ActionCompleteUnbonding,
tags.Delegator, []byte(dvPair.DelegatorAddr.String()),
tags.SrcValidator, []byte(dvPair.ValidatorAddr.String()),
Expand All @@ -70,14 +74,16 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.Valid
if err != nil {
continue
}
endBlockerTags.AppendTags(sdk.NewTags(

resTags.AppendTags(sdk.NewTags(
tags.Action, tags.ActionCompleteRedelegation,
tags.Delegator, []byte(dvvTriplet.DelegatorAddr.String()),
tags.SrcValidator, []byte(dvvTriplet.ValidatorSrcAddr.String()),
tags.DstValidator, []byte(dvvTriplet.ValidatorDstAddr.String()),
))
}
return

return validatorUpdates, resTags
}

//_____________________________________________________________________
Expand Down Expand Up @@ -215,12 +221,12 @@ func handleMsgBeginUnbonding(ctx sdk.Context, msg types.MsgBeginUnbonding, k kee
}

finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(ubd.MinTime)

tags := sdk.NewTags(
tags.Delegator, []byte(msg.DelegatorAddr.String()),
tags.SrcValidator, []byte(msg.ValidatorAddr.String()),
tags.EndTime, finishTime,
tags.EndTime, []byte(ubd.MinTime.Format(time.RFC3339)),
)

return sdk.Result{Data: finishTime, Tags: tags}
}

Expand All @@ -232,12 +238,12 @@ func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k k
}

finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(red.MinTime)

tags := sdk.NewTags(
resTags := sdk.NewTags(
tags.Delegator, []byte(msg.DelegatorAddr.String()),
tags.SrcValidator, []byte(msg.ValidatorSrcAddr.String()),
tags.DstValidator, []byte(msg.ValidatorDstAddr.String()),
tags.EndTime, finishTime,
tags.EndTime, []byte(red.MinTime.Format(time.RFC3339)),
)
return sdk.Result{Data: finishTime, Tags: tags}

return sdk.Result{Data: finishTime, Tags: resTags}
}