Merge PR #2943: Fix tag usage in handlers and EndBlocker
* Fix tag usage in handlers and EndBlocker * Prepend action tag in baseApp * Fix LCD * Remove unnecessary conversion * Fix invalid consensus pubkey in CLI tests * Fix tag usage in cli_test * Shorten bechify in test * Update docs and PENDING
This commit is contained in:
parent
aa72e72ce4
commit
ca43225851
|
@ -23,6 +23,7 @@ BREAKING CHANGES
|
||||||
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
|
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
|
||||||
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
|
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
|
||||||
* [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor')
|
* [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor')
|
||||||
|
* [\#2943](https://github.com/cosmos/cosmos-sdk/pull/2943) Transaction action tags equal the message type. Stake EndBlocker tags are included.
|
||||||
|
|
||||||
* Tendermint
|
* Tendermint
|
||||||
- Update to Tendermint 0.27.0
|
- Update to Tendermint 0.27.0
|
||||||
|
|
|
@ -615,13 +615,13 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re
|
||||||
if mode != runTxModeCheck {
|
if mode != runTxModeCheck {
|
||||||
msgResult = handler(ctx, msg)
|
msgResult = handler(ctx, msg)
|
||||||
}
|
}
|
||||||
msgResult.Tags = append(msgResult.Tags, sdk.MakeTag("action", []byte(msg.Type())))
|
|
||||||
|
|
||||||
// NOTE: GasWanted is determined by ante handler and
|
// NOTE: GasWanted is determined by ante handler and
|
||||||
// GasUsed by the GasMeter
|
// GasUsed by the GasMeter
|
||||||
|
|
||||||
// Append Data and Tags
|
// Append Data and Tags
|
||||||
data = append(data, msgResult.Data...)
|
data = append(data, msgResult.Data...)
|
||||||
|
tags = append(tags, sdk.MakeTag(sdk.TagAction, []byte(msg.Type())))
|
||||||
tags = append(tags, msgResult.Tags...)
|
tags = append(tags, msgResult.Tags...)
|
||||||
|
|
||||||
// Stop execution and return on first failed message.
|
// Stop execution and return on first failed message.
|
||||||
|
|
|
@ -564,7 +564,7 @@ func TestBonding(t *testing.T) {
|
||||||
|
|
||||||
// query tx
|
// query tx
|
||||||
txs = getTransactions(t, port,
|
txs = getTransactions(t, port,
|
||||||
fmt.Sprintf("action=begin-unbonding&delegator=%s", addr),
|
fmt.Sprintf("action=begin_unbonding&delegator=%s", addr),
|
||||||
fmt.Sprintf("source-validator=%s", operAddrs[0]),
|
fmt.Sprintf("source-validator=%s", operAddrs[0]),
|
||||||
)
|
)
|
||||||
require.Len(t, txs, 1)
|
require.Len(t, txs, 1)
|
||||||
|
@ -582,7 +582,7 @@ func TestBonding(t *testing.T) {
|
||||||
|
|
||||||
// query tx
|
// query tx
|
||||||
txs = getTransactions(t, port,
|
txs = getTransactions(t, port,
|
||||||
fmt.Sprintf("action=begin-redelegation&delegator=%s", addr),
|
fmt.Sprintf("action=begin_redelegate&delegator=%s", addr),
|
||||||
fmt.Sprintf("source-validator=%s", operAddrs[0]),
|
fmt.Sprintf("source-validator=%s", operAddrs[0]),
|
||||||
fmt.Sprintf("destination-validator=%s", operAddrs[1]),
|
fmt.Sprintf("destination-validator=%s", operAddrs[1]),
|
||||||
)
|
)
|
||||||
|
@ -649,7 +649,7 @@ func TestSubmitProposal(t *testing.T) {
|
||||||
require.Equal(t, "Test", proposal.GetTitle())
|
require.Equal(t, "Test", proposal.GetTitle())
|
||||||
|
|
||||||
// query tx
|
// query tx
|
||||||
txs := getTransactions(t, port, fmt.Sprintf("action=submit-proposal&proposer=%s", addr))
|
txs := getTransactions(t, port, fmt.Sprintf("action=submit_proposal&proposer=%s", addr))
|
||||||
require.Len(t, txs, 1)
|
require.Len(t, txs, 1)
|
||||||
require.Equal(t, resultTx.Height, txs[0].Height)
|
require.Equal(t, resultTx.Height, txs[0].Height)
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,8 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
|
||||||
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
|
|
||||||
tags := gov.EndBlocker(ctx, app.govKeeper)
|
tags := gov.EndBlocker(ctx, app.govKeeper)
|
||||||
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)
|
validatorUpdates, endBlockerTags := stake.EndBlocker(ctx, app.stakeKeeper)
|
||||||
|
tags = append(tags, endBlockerTags...)
|
||||||
|
|
||||||
app.assertRuntimeInvariants()
|
app.assertRuntimeInvariants()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// +build cli_test
|
|
||||||
|
|
||||||
package clitest
|
package clitest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -11,6 +9,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -222,8 +221,8 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
tests.WaitForNextNBlocksTM(2, port)
|
tests.WaitForNextNBlocksTM(2, port)
|
||||||
|
|
||||||
fooAddr, _ := executeGetAddrPK(t, fmt.Sprintf("gaiacli keys show foo --output=json --home=%s", gaiacliHome))
|
fooAddr, _ := executeGetAddrPK(t, fmt.Sprintf("gaiacli keys show foo --output=json --home=%s", gaiacliHome))
|
||||||
barAddr, barPubKey := executeGetAddrPK(t, fmt.Sprintf("gaiacli keys show bar --output=json --home=%s", gaiacliHome))
|
barAddr, _ := executeGetAddrPK(t, fmt.Sprintf("gaiacli keys show bar --output=json --home=%s", gaiacliHome))
|
||||||
barCeshPubKey := sdk.MustBech32ifyConsPub(barPubKey)
|
consPubKey := sdk.MustBech32ifyConsPub(ed25519.GenPrivKey().PubKey())
|
||||||
|
|
||||||
executeWrite(t, fmt.Sprintf("gaiacli tx send %v --amount=10%s --to=%s --from=foo", flags, stakeTypes.DefaultBondDenom, barAddr), app.DefaultKeyPass)
|
executeWrite(t, fmt.Sprintf("gaiacli tx send %v --amount=10%s --to=%s --from=foo", flags, stakeTypes.DefaultBondDenom, barAddr), app.DefaultKeyPass)
|
||||||
tests.WaitForNextNBlocksTM(2, port)
|
tests.WaitForNextNBlocksTM(2, port)
|
||||||
|
@ -240,7 +239,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||||
// create validator
|
// create validator
|
||||||
cvStr := fmt.Sprintf("gaiacli tx stake create-validator %v", flags)
|
cvStr := fmt.Sprintf("gaiacli tx stake create-validator %v", flags)
|
||||||
cvStr += fmt.Sprintf(" --from=%s", "bar")
|
cvStr += fmt.Sprintf(" --from=%s", "bar")
|
||||||
cvStr += fmt.Sprintf(" --pubkey=%s", barCeshPubKey)
|
cvStr += fmt.Sprintf(" --pubkey=%s", consPubKey)
|
||||||
cvStr += fmt.Sprintf(" --amount=%v", fmt.Sprintf("2%s", stakeTypes.DefaultBondDenom))
|
cvStr += fmt.Sprintf(" --amount=%v", fmt.Sprintf("2%s", stakeTypes.DefaultBondDenom))
|
||||||
cvStr += fmt.Sprintf(" --moniker=%v", "bar-vally")
|
cvStr += fmt.Sprintf(" --moniker=%v", "bar-vally")
|
||||||
cvStr += fmt.Sprintf(" --commission-rate=%v", "0.05")
|
cvStr += fmt.Sprintf(" --commission-rate=%v", "0.05")
|
||||||
|
@ -355,7 +354,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||||
executeWrite(t, spStr, app.DefaultKeyPass)
|
executeWrite(t, spStr, app.DefaultKeyPass)
|
||||||
tests.WaitForNextNBlocksTM(2, port)
|
tests.WaitForNextNBlocksTM(2, port)
|
||||||
|
|
||||||
txs := executeGetTxs(t, fmt.Sprintf("gaiacli query txs --tags='action:submit-proposal&proposer:%s' %v", fooAddr, flags))
|
txs := executeGetTxs(t, fmt.Sprintf("gaiacli query txs --tags='action:submit_proposal&proposer:%s' %v", fooAddr, flags))
|
||||||
require.Len(t, txs, 1)
|
require.Len(t, txs, 1)
|
||||||
|
|
||||||
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
|
||||||
|
|
|
@ -225,10 +225,11 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
|
||||||
// application updates every end block
|
// application updates every end block
|
||||||
// nolint: unparam
|
// nolint: unparam
|
||||||
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)
|
validatorUpdates, tags := stake.EndBlocker(ctx, app.stakeKeeper)
|
||||||
|
|
||||||
return abci.ResponseEndBlock{
|
return abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: validatorUpdates,
|
ValidatorUpdates: validatorUpdates,
|
||||||
|
Tags: tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,8 @@ gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'
|
||||||
|
|
||||||
::: tip Note
|
::: tip Note
|
||||||
|
|
||||||
|
The action tag always equals the message type returned by the `Type()` function of the relevant message.
|
||||||
|
|
||||||
You can find a list of available `tags` on each of the SDK modules:
|
You can find a list of available `tags` on each of the SDK modules:
|
||||||
|
|
||||||
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
|
- [Common tags](https://github.com/cosmos/cosmos-sdk/blob/d1e76221d8e28824bb4791cb4ad8662d2ae9051e/types/tags.go#L57-L63)
|
||||||
|
|
|
@ -72,12 +72,6 @@ var (
|
||||||
ErrNilWithdrawAddr = types.ErrNilWithdrawAddr
|
ErrNilWithdrawAddr = types.ErrNilWithdrawAddr
|
||||||
ErrNilValidatorAddr = types.ErrNilValidatorAddr
|
ErrNilValidatorAddr = types.ErrNilValidatorAddr
|
||||||
|
|
||||||
ActionModifyWithdrawAddress = tags.ActionModifyWithdrawAddress
|
|
||||||
ActionWithdrawDelegatorRewardsAll = tags.ActionWithdrawDelegatorRewardsAll
|
|
||||||
ActionWithdrawDelegatorReward = tags.ActionWithdrawDelegatorReward
|
|
||||||
ActionWithdrawValidatorRewardsAll = tags.ActionWithdrawValidatorRewardsAll
|
|
||||||
|
|
||||||
TagAction = tags.Action
|
|
||||||
TagValidator = tags.Validator
|
TagValidator = tags.Validator
|
||||||
TagDelegator = tags.Delegator
|
TagDelegator = tags.Delegator
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,7 +35,6 @@ func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg types.MsgSetWithdrawAdd
|
||||||
k.SetDelegatorWithdrawAddr(ctx, msg.DelegatorAddr, msg.WithdrawAddr)
|
k.SetDelegatorWithdrawAddr(ctx, msg.DelegatorAddr, msg.WithdrawAddr)
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionModifyWithdrawAddress,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
)
|
)
|
||||||
return sdk.Result{
|
return sdk.Result{
|
||||||
|
@ -48,7 +47,6 @@ func handleMsgWithdrawDelegatorRewardsAll(ctx sdk.Context, msg types.MsgWithdraw
|
||||||
k.WithdrawDelegationRewardsAll(ctx, msg.DelegatorAddr)
|
k.WithdrawDelegationRewardsAll(ctx, msg.DelegatorAddr)
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionWithdrawDelegatorRewardsAll,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
)
|
)
|
||||||
return sdk.Result{
|
return sdk.Result{
|
||||||
|
@ -64,7 +62,6 @@ func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg types.MsgWithdrawDele
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionWithdrawDelegatorReward,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
tags.Validator, []byte(msg.ValidatorAddr.String()),
|
tags.Validator, []byte(msg.ValidatorAddr.String()),
|
||||||
)
|
)
|
||||||
|
@ -81,7 +78,6 @@ func handleMsgWithdrawValidatorRewardsAll(ctx sdk.Context, msg types.MsgWithdraw
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionWithdrawValidatorRewardsAll,
|
|
||||||
tags.Validator, []byte(msg.ValidatorAddr.String()),
|
tags.Validator, []byte(msg.ValidatorAddr.String()),
|
||||||
)
|
)
|
||||||
return sdk.Result{
|
return sdk.Result{
|
||||||
|
|
|
@ -6,12 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ActionModifyWithdrawAddress = []byte("modify-withdraw-address")
|
|
||||||
ActionWithdrawDelegatorRewardsAll = []byte("withdraw-delegator-rewards-all")
|
|
||||||
ActionWithdrawDelegatorReward = []byte("withdraw-delegator-reward")
|
|
||||||
ActionWithdrawValidatorRewardsAll = []byte("withdraw-validator-rewards-all")
|
|
||||||
|
|
||||||
Action = sdk.TagAction
|
|
||||||
Validator = sdk.TagSrcValidator
|
Validator = sdk.TagSrcValidator
|
||||||
Delegator = sdk.TagDelegator
|
Delegator = sdk.TagDelegator
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,6 @@ func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitPropos
|
||||||
proposalIDBytes := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposal.GetProposalID())
|
proposalIDBytes := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposal.GetProposalID())
|
||||||
|
|
||||||
resTags := sdk.NewTags(
|
resTags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionSubmitProposal,
|
|
||||||
tags.Proposer, []byte(msg.Proposer.String()),
|
tags.Proposer, []byte(msg.Proposer.String()),
|
||||||
tags.ProposalID, proposalIDBytes,
|
tags.ProposalID, proposalIDBytes,
|
||||||
)
|
)
|
||||||
|
@ -62,7 +61,6 @@ func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) sdk.Result
|
||||||
|
|
||||||
// TODO: Add tag for if voting period started
|
// TODO: Add tag for if voting period started
|
||||||
resTags := sdk.NewTags(
|
resTags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionDeposit,
|
|
||||||
tags.Depositor, []byte(msg.Depositor.String()),
|
tags.Depositor, []byte(msg.Depositor.String()),
|
||||||
tags.ProposalID, proposalIDBytes,
|
tags.ProposalID, proposalIDBytes,
|
||||||
)
|
)
|
||||||
|
@ -86,7 +84,6 @@ func handleMsgVote(ctx sdk.Context, keeper Keeper, msg MsgVote) sdk.Result {
|
||||||
proposalIDBytes := keeper.cdc.MustMarshalBinaryBare(msg.ProposalID)
|
proposalIDBytes := keeper.cdc.MustMarshalBinaryBare(msg.ProposalID)
|
||||||
|
|
||||||
resTags := sdk.NewTags(
|
resTags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionVote,
|
|
||||||
tags.Voter, []byte(msg.Voter.String()),
|
tags.Voter, []byte(msg.Voter.String()),
|
||||||
tags.ProposalID, proposalIDBytes,
|
tags.ProposalID, proposalIDBytes,
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,9 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ActionSubmitProposal = []byte("submit-proposal")
|
|
||||||
ActionDeposit = []byte("deposit")
|
|
||||||
ActionVote = []byte("vote")
|
|
||||||
ActionProposalDropped = []byte("proposal-dropped")
|
ActionProposalDropped = []byte("proposal-dropped")
|
||||||
ActionProposalPassed = []byte("proposal-passed")
|
ActionProposalPassed = []byte("proposal-passed")
|
||||||
ActionProposalRejected = []byte("proposal-rejected")
|
ActionProposalRejected = []byte("proposal-rejected")
|
||||||
|
|
|
@ -52,9 +52,10 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) {
|
||||||
// stake endblocker
|
// stake endblocker
|
||||||
func getEndBlocker(keeper stake.Keeper) sdk.EndBlocker {
|
func getEndBlocker(keeper stake.Keeper) sdk.EndBlocker {
|
||||||
return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
validatorUpdates := stake.EndBlocker(ctx, keeper)
|
validatorUpdates, tags := stake.EndBlocker(ctx, keeper)
|
||||||
return abci.ResponseEndBlock{
|
return abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: validatorUpdates,
|
ValidatorUpdates: validatorUpdates,
|
||||||
|
Tags: tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) sdk.Result {
|
||||||
// unjail the validator
|
// unjail the validator
|
||||||
k.validatorSet.Unjail(ctx, consAddr)
|
k.validatorSet.Unjail(ctx, consAddr)
|
||||||
|
|
||||||
tags := sdk.NewTags("action", []byte("unjail"), "validator", []byte(msg.ValidatorAddr.String()))
|
tags := sdk.NewTags("validator", []byte(msg.ValidatorAddr.String()))
|
||||||
|
|
||||||
return sdk.Result{
|
return sdk.Result{
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
|
|
|
@ -409,7 +409,7 @@ func TestValidatorDippingInAndOut(t *testing.T) {
|
||||||
newAmt := int64(101)
|
newAmt := int64(101)
|
||||||
got = sh(ctx, NewTestMsgCreateValidator(addrs[1], pks[1], sdk.NewInt(newAmt)))
|
got = sh(ctx, NewTestMsgCreateValidator(addrs[1], pks[1], sdk.NewInt(newAmt)))
|
||||||
require.True(t, got.IsOK())
|
require.True(t, got.IsOK())
|
||||||
validatorUpdates := stake.EndBlocker(ctx, sk)
|
validatorUpdates, _ := stake.EndBlocker(ctx, sk)
|
||||||
require.Equal(t, 2, len(validatorUpdates))
|
require.Equal(t, 2, len(validatorUpdates))
|
||||||
validator, _ := sk.GetValidator(ctx, addr)
|
validator, _ := sk.GetValidator(ctx, addr)
|
||||||
require.Equal(t, sdk.Unbonding, validator.Status)
|
require.Equal(t, sdk.Unbonding, validator.Status)
|
||||||
|
@ -421,7 +421,7 @@ func TestValidatorDippingInAndOut(t *testing.T) {
|
||||||
// validator added back in
|
// validator added back in
|
||||||
got = sh(ctx, newTestMsgDelegate(sdk.AccAddress(addrs[2]), addrs[0], sdk.NewInt(2)))
|
got = sh(ctx, newTestMsgDelegate(sdk.AccAddress(addrs[2]), addrs[0], sdk.NewInt(2)))
|
||||||
require.True(t, got.IsOK())
|
require.True(t, got.IsOK())
|
||||||
validatorUpdates = stake.EndBlocker(ctx, sk)
|
validatorUpdates, _ = stake.EndBlocker(ctx, sk)
|
||||||
require.Equal(t, 2, len(validatorUpdates))
|
require.Equal(t, 2, len(validatorUpdates))
|
||||||
validator, _ = sk.GetValidator(ctx, addr)
|
validator, _ = sk.GetValidator(ctx, addr)
|
||||||
require.Equal(t, sdk.Bonded, validator.Status)
|
require.Equal(t, sdk.Bonded, validator.Status)
|
||||||
|
|
|
@ -42,10 +42,11 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) {
|
||||||
// getEndBlocker returns a stake endblocker.
|
// getEndBlocker returns a stake endblocker.
|
||||||
func getEndBlocker(keeper Keeper) sdk.EndBlocker {
|
func getEndBlocker(keeper Keeper) sdk.EndBlocker {
|
||||||
return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
return func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
validatorUpdates := EndBlocker(ctx, keeper)
|
validatorUpdates, tags := EndBlocker(ctx, keeper)
|
||||||
|
|
||||||
return abci.ResponseEndBlock{
|
return abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: validatorUpdates,
|
ValidatorUpdates: validatorUpdates,
|
||||||
|
Tags: tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -161,18 +162,18 @@ func delegatorTxsHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.Han
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case isBondTx:
|
case isBondTx:
|
||||||
actions = append(actions, string(tags.ActionDelegate))
|
actions = append(actions, stake.MsgDelegate{}.Type())
|
||||||
case isUnbondTx:
|
case isUnbondTx:
|
||||||
actions = append(actions, string(tags.ActionBeginUnbonding))
|
actions = append(actions, stake.MsgBeginUnbonding{}.Type())
|
||||||
actions = append(actions, string(tags.ActionCompleteUnbonding))
|
actions = append(actions, string(tags.ActionCompleteUnbonding))
|
||||||
case isRedTx:
|
case isRedTx:
|
||||||
actions = append(actions, string(tags.ActionBeginRedelegation))
|
actions = append(actions, stake.MsgBeginRedelegate{}.Type())
|
||||||
actions = append(actions, string(tags.ActionCompleteRedelegation))
|
actions = append(actions, string(tags.ActionCompleteRedelegation))
|
||||||
case noQuery:
|
case noQuery:
|
||||||
actions = append(actions, string(tags.ActionDelegate))
|
actions = append(actions, stake.MsgDelegate{}.Type())
|
||||||
actions = append(actions, string(tags.ActionBeginUnbonding))
|
actions = append(actions, stake.MsgBeginUnbonding{}.Type())
|
||||||
actions = append(actions, string(tags.ActionCompleteUnbonding))
|
actions = append(actions, string(tags.ActionCompleteUnbonding))
|
||||||
actions = append(actions, string(tags.ActionBeginRedelegation))
|
actions = append(actions, stake.MsgBeginRedelegate{}.Type())
|
||||||
actions = append(actions, string(tags.ActionCompleteRedelegation))
|
actions = append(actions, string(tags.ActionCompleteRedelegation))
|
||||||
default:
|
default:
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|
|
@ -31,9 +31,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every block, update validator set
|
// Called every block, update validator set
|
||||||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.ValidatorUpdate) {
|
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (validatorUpdates []abci.ValidatorUpdate, endBlockerTags sdk.Tags) {
|
||||||
endBlockerTags := sdk.EmptyTags()
|
|
||||||
|
|
||||||
// Reset the intra-transaction counter.
|
// Reset the intra-transaction counter.
|
||||||
k.SetIntraTxCounter(ctx, 0)
|
k.SetIntraTxCounter(ctx, 0)
|
||||||
|
|
||||||
|
@ -127,7 +125,6 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionCreateValidator,
|
|
||||||
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
||||||
tags.Moniker, []byte(msg.Description.Moniker),
|
tags.Moniker, []byte(msg.Description.Moniker),
|
||||||
tags.Identity, []byte(msg.Description.Identity),
|
tags.Identity, []byte(msg.Description.Identity),
|
||||||
|
@ -165,7 +162,6 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
|
||||||
k.SetValidator(ctx, validator)
|
k.SetValidator(ctx, validator)
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionEditValidator,
|
|
||||||
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
||||||
tags.Moniker, []byte(description.Moniker),
|
tags.Moniker, []byte(description.Moniker),
|
||||||
tags.Identity, []byte(description.Identity),
|
tags.Identity, []byte(description.Identity),
|
||||||
|
@ -196,7 +192,6 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionDelegate,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
tags.DstValidator, []byte(msg.ValidatorAddr.String()),
|
||||||
)
|
)
|
||||||
|
@ -215,7 +210,6 @@ func handleMsgBeginUnbonding(ctx sdk.Context, msg types.MsgBeginUnbonding, k kee
|
||||||
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(ubd.MinTime)
|
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(ubd.MinTime)
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionBeginUnbonding,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
tags.SrcValidator, []byte(msg.ValidatorAddr.String()),
|
tags.SrcValidator, []byte(msg.ValidatorAddr.String()),
|
||||||
tags.EndTime, finishTime,
|
tags.EndTime, finishTime,
|
||||||
|
@ -233,7 +227,6 @@ func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k k
|
||||||
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(red.MinTime)
|
finishTime := types.MsgCdc.MustMarshalBinaryLengthPrefixed(red.MinTime)
|
||||||
|
|
||||||
tags := sdk.NewTags(
|
tags := sdk.NewTags(
|
||||||
tags.Action, tags.ActionBeginRedelegation,
|
|
||||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||||
tags.SrcValidator, []byte(msg.ValidatorSrcAddr.String()),
|
tags.SrcValidator, []byte(msg.ValidatorSrcAddr.String()),
|
||||||
tags.DstValidator, []byte(msg.ValidatorDstAddr.String()),
|
tags.DstValidator, []byte(msg.ValidatorDstAddr.String()),
|
||||||
|
|
|
@ -37,9 +37,10 @@ func TestStakeWithRandomMessages(t *testing.T) {
|
||||||
distrKeeper := distribution.NewKeeper(mapp.Cdc, distrKey, paramstore.Subspace(distribution.DefaultParamspace), bankKeeper, stakeKeeper, feeCollectionKeeper, distribution.DefaultCodespace)
|
distrKeeper := distribution.NewKeeper(mapp.Cdc, distrKey, paramstore.Subspace(distribution.DefaultParamspace), bankKeeper, stakeKeeper, feeCollectionKeeper, distribution.DefaultCodespace)
|
||||||
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))
|
mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper))
|
||||||
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
mapp.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||||
validatorUpdates := stake.EndBlocker(ctx, stakeKeeper)
|
validatorUpdates, tags := stake.EndBlocker(ctx, stakeKeeper)
|
||||||
return abci.ResponseEndBlock{
|
return abci.ResponseEndBlock{
|
||||||
ValidatorUpdates: validatorUpdates,
|
ValidatorUpdates: validatorUpdates,
|
||||||
|
Tags: tags,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -151,12 +151,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ActionCreateValidator = tags.ActionCreateValidator
|
|
||||||
ActionEditValidator = tags.ActionEditValidator
|
|
||||||
ActionDelegate = tags.ActionDelegate
|
|
||||||
ActionBeginUnbonding = tags.ActionBeginUnbonding
|
|
||||||
ActionCompleteUnbonding = tags.ActionCompleteUnbonding
|
ActionCompleteUnbonding = tags.ActionCompleteUnbonding
|
||||||
ActionBeginRedelegation = tags.ActionBeginRedelegation
|
|
||||||
ActionCompleteRedelegation = tags.ActionCompleteRedelegation
|
ActionCompleteRedelegation = tags.ActionCompleteRedelegation
|
||||||
|
|
||||||
TagAction = tags.Action
|
TagAction = tags.Action
|
||||||
|
|
|
@ -6,12 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ActionCreateValidator = []byte("create-validator")
|
|
||||||
ActionEditValidator = []byte("edit-validator")
|
|
||||||
ActionDelegate = []byte("delegate")
|
|
||||||
ActionBeginUnbonding = []byte("begin-unbonding")
|
|
||||||
ActionCompleteUnbonding = []byte("complete-unbonding")
|
ActionCompleteUnbonding = []byte("complete-unbonding")
|
||||||
ActionBeginRedelegation = []byte("begin-redelegation")
|
|
||||||
ActionCompleteRedelegation = []byte("complete-redelegation")
|
ActionCompleteRedelegation = []byte("complete-redelegation")
|
||||||
|
|
||||||
Action = sdk.TagAction
|
Action = sdk.TagAction
|
||||||
|
|
Loading…
Reference in New Issue