Skip to content

Commit

Permalink
Merge PR #3673: Message & Codec Registration Consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored and cwgoes committed Feb 25, 2019
1 parent 21bdeca commit b9be116
Show file tree
Hide file tree
Showing 52 changed files with 453 additions and 450 deletions.
3 changes: 3 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

### SDK

* [\#3669] Ensure consistency in message naming, codec registration, and JSON
tags.

### Tendermint

<!--------------------------------- FEATURES --------------------------------->
Expand Down
10 changes: 5 additions & 5 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func TestValidatorsQuery(t *testing.T) {
foundVal = true
}

require.True(t, foundVal, "pk %v, operator %v", operAddrs[0], validators[0].OperatorAddr)
require.True(t, foundVal, "pk %v, operator %v", operAddrs[0], validators[0].OperatorAddress)
}

func TestValidatorQuery(t *testing.T) {
Expand All @@ -425,7 +425,7 @@ func TestValidatorQuery(t *testing.T) {
require.Equal(t, 1, len(operAddrs))

validator := getValidator(t, port, operAddrs[0])
require.Equal(t, validator.OperatorAddr, operAddrs[0], "The returned validator does not hold the correct data")
require.Equal(t, validator.OperatorAddress, operAddrs[0], "The returned validator does not hold the correct data")
}

func TestBonding(t *testing.T) {
Expand Down Expand Up @@ -483,11 +483,11 @@ func TestBonding(t *testing.T) {

bondedValidators := getDelegatorValidators(t, port, addr)
require.Len(t, bondedValidators, 1)
require.Equal(t, operAddrs[0], bondedValidators[0].OperatorAddr)
require.Equal(t, operAddrs[0], bondedValidators[0].OperatorAddress)
require.Equal(t, validator.DelegatorShares.Add(amtDec).String(), bondedValidators[0].DelegatorShares.String())

bondedValidator := getDelegatorValidator(t, port, addr, operAddrs[0])
require.Equal(t, operAddrs[0], bondedValidator.OperatorAddr)
require.Equal(t, operAddrs[0], bondedValidator.OperatorAddress)

// testing unbonding
unbondingTokens := sdk.TokensFromTendermintPower(30)
Expand Down Expand Up @@ -547,7 +547,7 @@ func TestBonding(t *testing.T) {
// query delegations, unbondings and redelegations from validator and delegator
delegatorDels = getDelegatorDelegations(t, port, addr)
require.Len(t, delegatorDels, 1)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddr)
require.Equal(t, operAddrs[1], delegatorDels[0].ValidatorAddress)

// because the second validator never signs during these tests, if this
// this test takes a long time to run, eventually this second validator
Expand Down
30 changes: 15 additions & 15 deletions client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_addr:
validator_address:
$ref: "#/definitions/ValidatorAddress"
delegation:
$ref: "#/definitions/Coin"
Expand Down Expand Up @@ -550,9 +550,9 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_addr:
validator_address:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
Expand Down Expand Up @@ -653,11 +653,11 @@ paths:
properties:
base_req:
$ref: "#/definitions/BaseReq"
delegator_addr:
delegator_address:
$ref: "#/definitions/Address"
validator_src_addr:
validator_src_addressess:
$ref: "#/definitions/ValidatorAddress"
validator_dst_addr:
validator_dst_address:
$ref: "#/definitions/ValidatorAddress"
shares:
type: string
Expand Down Expand Up @@ -2131,9 +2131,9 @@ definitions:
Delegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_addr:
validator_address:
type: string
shares:
type: string
Expand All @@ -2142,9 +2142,9 @@ definitions:
UnbondingDelegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_addr:
validator_address:
type: string
initial_balance:
type: string
Expand All @@ -2157,11 +2157,11 @@ definitions:
Redelegation:
type: object
properties:
delegator_addr:
delegator_address:
type: string
validator_src_addr:
validator_src_address:
type: string
validator_dst_addr:
validator_dst_address:
type: string
creation_height:
type: integer
Expand All @@ -2178,7 +2178,7 @@ definitions:
ValidatorDistInfo:
type: object
properties:
operator_addr:
operator_address:
$ref: "#/definitions/ValidatorAddress"
self_bond_rewards:
type: array
Expand Down
52 changes: 26 additions & 26 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,10 @@ func doDelegate(

baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := msgDelegationsInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
}

req, err := cdc.MarshalJSON(msg)
Expand All @@ -838,10 +838,10 @@ func doDelegate(
}

type msgDelegationsInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
Delegation sdk.Coin `json:"delegation"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
Delegation sdk.Coin `json:"delegation"`
}

// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
Expand All @@ -858,10 +858,10 @@ func doUndelegate(

baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := msgUndelegateInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorAddr: valAddr,
SharesAmount: amount.ToDec(),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorAddress: valAddr,
SharesAmount: amount.ToDec(),
}

req, err := cdc.MarshalJSON(msg)
Expand All @@ -881,10 +881,10 @@ func doUndelegate(
}

type msgUndelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorAddr sdk.ValAddress `json:"validator_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorAddress sdk.ValAddress `json:"validator_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}

// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
Expand All @@ -901,11 +901,11 @@ func doBeginRedelegation(

baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
msg := stakingrest.MsgBeginRedelegateInput{
BaseReq: baseReq,
DelegatorAddr: delAddr,
ValidatorSrcAddr: valSrcAddr,
ValidatorDstAddr: valDstAddr,
SharesAmount: amount.ToDec(),
BaseReq: baseReq,
DelegatorAddress: delAddr,
ValidatorSrcAddress: valSrcAddr,
ValidatorDstAddress: valDstAddr,
SharesAmount: amount.ToDec(),
}

req, err := cdc.MarshalJSON(msg)
Expand All @@ -925,11 +925,11 @@ func doBeginRedelegation(
}

type msgBeginRedelegateInput struct {
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // in bech32
ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` // in bech32
ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
BaseReq rest.BaseReq `json:"base_req"`
DelegatorAddress sdk.AccAddress `json:"delegator_address"` // in bech32
ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` // in bech32
ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` // in bech32
SharesAmount sdk.Dec `json:"shares"`
}

// GET /staking/delegators/{delegatorAddr}/delegations Get all delegations from a delegator
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []st
// withdraw all delegator rewards
dels := app.stakingKeeper.GetAllDelegations(ctx)
for _, delegation := range dels {
_ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
_ = app.distrKeeper.WithdrawDelegationRewards(ctx, delegation.DelegatorAddress, delegation.ValidatorAddress)
}

// clear validator slash events
Expand All @@ -110,7 +110,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []st

// reinitialize all delegations
for _, del := range dels {
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, del.DelegatorAddr, del.ValidatorAddr)
app.distrKeeper.Hooks().BeforeDelegationCreated(ctx, del.DelegatorAddress, del.ValidatorAddress)
}

// reset context height
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tm

msg := msgs[0].(staking.MsgCreateValidator)
// validate delegator and validator addresses and funds against the accounts in the state
delAddr := msg.DelegatorAddr.String()
valAddr := sdk.AccAddress(msg.ValidatorAddr).String()
delAddr := msg.DelegatorAddress.String()
valAddr := sdk.AccAddress(msg.ValidatorAddress).String()

delAcc, delOk := addrMap[delAddr]
_, valOk := addrMap[valAddr]
Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/app/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func makeGenesisState(t *testing.T, genTxs []auth.StdTx) GenesisState {
require.Equal(t, 1, len(msgs))
msg := msgs[0].(staking.MsgCreateValidator)

acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddr))
acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddress))
acc.Coins = sdk.Coins{sdk.NewInt64Coin(defaultBondDenom, 150)}
genAccs[i] = NewGenesisAccount(&acc)
stakingData.Pool.NotBondedTokens = stakingData.Pool.NotBondedTokens.Add(sdk.NewInt(150)) // increase the supply
Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {

// Ensure that validator state is as expected
validator := f.QueryStakingValidator(barVal)
require.Equal(t, validator.OperatorAddr, barVal)
require.Equal(t, validator.OperatorAddress, barVal)
require.True(sdk.IntEq(t, newValTokens, validator.Tokens))

// Query delegations to the validator
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/ibc/mvp/mvp1.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ type IBCPacket struct {
}

// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
IBCPacket
}

// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
IBCPacket
Relayer sdk.Address
Sequence int64
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/ibc/mvp/mvp2.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ type TransferPayload struct {
}

// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}

// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
Relayer sdk.Address
Sequence int64
Expand Down
8 changes: 4 additions & 4 deletions docs/spec/ibc/mvp/mvp3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@


// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}

// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
}

Expand Down Expand Up @@ -42,12 +42,12 @@ type TransferPayload struct {
}

// Implements sdk.Msg
type IBCTransferMsg struct {
type MsgIBCTransfer struct {
Packet
}

// Implements sdk.Msg
type IBCReceiveMsg struct {
type MsgIBCReceive struct {
Packet
Proof iavl.Proof
FromChainID string
Expand Down
4 changes: 2 additions & 2 deletions x/bank/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

// Register concrete types on codec codec
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/Send", nil)
cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MultiSend", nil)
cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/MsgSend", nil)
cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil)
}

var msgCdc = codec.New()
Expand Down
4 changes: 2 additions & 2 deletions x/bank/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestMsgSendGetSignBytes(t *testing.T) {
var msg = NewMsgSend(addr1, addr2, coins)
res := msg.GetSignBytes()

expected := `{"type":"cosmos-sdk/Send","value":{"amount":[{"amount":"10","denom":"atom"}],"from_address":"cosmos1d9h8qat57ljhcm","to_address":"cosmos1da6hgur4wsmpnjyg"}}`
expected := `{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"10","denom":"atom"}],"from_address":"cosmos1d9h8qat57ljhcm","to_address":"cosmos1da6hgur4wsmpnjyg"}}`
require.Equal(t, expected, string(res))
}

Expand Down Expand Up @@ -224,7 +224,7 @@ func TestMsgMultiSendGetSignBytes(t *testing.T) {
}
res := msg.GetSignBytes()

expected := `{"type":"cosmos-sdk/MultiSend","value":{"inputs":[{"address":"cosmos1d9h8qat57ljhcm","coins":[{"amount":"10","denom":"atom"}]}],"outputs":[{"address":"cosmos1da6hgur4wsmpnjyg","coins":[{"amount":"10","denom":"atom"}]}]}}`
expected := `{"type":"cosmos-sdk/MsgMultiSend","value":{"inputs":[{"address":"cosmos1d9h8qat57ljhcm","coins":[{"amount":"10","denom":"atom"}]}],"outputs":[{"address":"cosmos1da6hgur4wsmpnjyg","coins":[{"amount":"10","denom":"atom"}]}]}}`
require.Equal(t, expected, string(res))
}

Expand Down
2 changes: 1 addition & 1 deletion x/distribution/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func delegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext, cdc *codec.Code
// ValidatorDistInfo defines the properties of
// validator distribution information response.
type ValidatorDistInfo struct {
OperatorAddress sdk.AccAddress `json:"operator_addr"`
OperatorAddress sdk.AccAddress `json:"operator_address"`
SelfBondRewards sdk.DecCoins `json:"self_bond_rewards"`
ValidatorCommission types.ValidatorAccumulatedCommission `json:"val_commission"`
}
Expand Down
Loading

0 comments on commit b9be116

Please sign in to comment.