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

DONTMERGE: v0.42.0 release train PR #8805

Closed
wants to merge 9 commits into from
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,21 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## [v0.41.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.3) - 2021-03-02
## [v0.42.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.0) - 2021-03-08

**IMPORTANT**: This release contains an important security fix for all non Cosmos Hub chains running Stargate version of the Cosmos SDK (>0.40). Non-hub chains should not be using any version of the SDK in the v0.40.x or v0.41.x release series. See [#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) for more details.

### Improvements

* (x/ibc) [\#8624](https://github.com/cosmos/cosmos-sdk/pull/8624) Emit full header in IBC UpdateClient message.
* (x/crisis) [\#8621](https://github.com/cosmos/cosmos-sdk/issues/8621) crisis invariants names now print to loggers.

**IMPORTANT**: Due to a bug in the v0.41.x series with how evidence handles validator consensus addresses #8461, SDK based chains that are not using the default bech32 prefix (cosmos, aka all chains except for the Cosmos Hub) should not use this release or any release in the v0.41.x series. Please see #8668 for tracking & timeline for the v0.42.0 release, which will include a fix for this issue.
### Bug fixes

* (x/evidence) [\#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) Fix bech32 prefix in evidence validator address conversion
* (x/gov) [\#8806](https://github.com/cosmos/cosmos-sdk/issues/8806) Fix q gov proposals command's mishandling of the --status parameter's values.

## [v0.41.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.3) - 2021-03-02

### Features

Expand Down
31 changes: 9 additions & 22 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
# Cosmos SDK v0.41.4 "Stargate" Release Notes
# Cosmos SDK v0.42.0 "Stargate" Release Notes

This release includes the addition of the multisign-batch command, minor bug fixes, and performance improvements.
This release includes an important security fix for all non "Cosmos Hub" chains (e.g. any chain that does not use the default `cosmos` bech32 prefix), and a few performance improvements.

See the [Cosmos SDK v0.41.4 milestone](https://github.com/cosmos/cosmos-sdk/milestone/40?closed=1) on our issue tracker for details.
See the [Cosmos SDK v0.42.0 milestone](https://github.com/cosmos/cosmos-sdk/milestone/42?closed=1) on our issue tracker for further details.

## multisign-batch command
# Security fix: validator address conversion in evidence handling

Multisign-batch command was added and it allows generating multiple multisig transactions by merging batches of signatures.
The security fix resolves the issue regarding incorrect handling of validators' consensus addresses. Because of this incorrect handling, Cosmos SDK apps that were not using the default `cosmos` Bech32 address prefix were not able to jail validators that committed misbehaviors such as double signing.

## Query tx with multisig addresses
Although the issue does **not** affect the Cosmos Hub, this issue potentially renders the `v0.41` and `v0.40` release series unsafe for most chains.

Now the rest endpoint allows to query transactions with multisig addresses.
# Full header is emitted on IBC UpdateClient message event

## Improvements

Major performance improvements in store and balance which will speed up genesis verification and initialization.

Genesis now allows 0 coin account balances. This means that genesis initialization will not fail if an address with no balance will be included.

## Bugfixes

The keys migration command (i.e. `keys migrate`) is now functional for offline, multisign, and ledger keys.

Minor bugfixes were included regarding missing errors and fields on some responses.

## Tendermint new release

Tendermint was upgraded to v0.34.8. This release of Tendermint introduces various changes that should make the logs much, much quieter. See [Tendermint's changelog](https://github.com/tendermint/tendermint/blob/v0.34.8/CHANGELOG.md#v0.34.8) for more information.
The event emitted by the IBC UpdateClient message now contains the full header.
This change makes header tracking easier and improves the handling of misbehaviors.
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaB
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 h1:2vLKys4RBU4pn2T/hjXMbvwTr1Cvy5THHrQkbeY9HRk=
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25/go.mod h1:hTr8+TLQmkUkgcuh3mcr5fjrT9c64ZzsBCdCEC6UppY=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
Expand Down Expand Up @@ -224,7 +223,6 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
Expand Down Expand Up @@ -486,7 +484,6 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y=
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4=
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
Expand Down Expand Up @@ -538,7 +535,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand All @@ -560,7 +556,6 @@ github.com/tendermint/tendermint v0.34.0/go.mod h1:Aj3PIipBFSNO21r+Lq3TtzQ+uKESx
github.com/tendermint/tendermint v0.34.8 h1:PMWgUx47FrNTsfhxCWzoiIlVAC1SE9+WBlnsF9oQW0I=
github.com/tendermint/tendermint v0.34.8/go.mod h1:JVuu3V1ZexOaZG8VJMRl8lnfrGw6hEB2TVnoUwKRbss=
github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI=
github.com/tendermint/tm-db v0.6.3 h1:ZkhQcKnB8/2jr5EaZwGndN4owkPsGezW2fSisS9zGbg=
github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8=
github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ=
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/memiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type memIterator struct {
}

func newMemIterator(start, end []byte, items *list.List, ascending bool) *memIterator {
itemsInDomain := make([]*kv.Pair, 0)
itemsInDomain := make([]*kv.Pair, 0, items.Len())

var entered bool

Expand Down
2 changes: 1 addition & 1 deletion x/crisis/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (k Keeper) AssertInvariants(ctx sdk.Context) {
invarRoutes := k.Routes()
n := len(invarRoutes)
for i, ir := range invarRoutes {
logger.Info("asserting crisis invariants", "inv", fmt.Sprint(i, "/", n))
logger.Info("asserting crisis invariants", "inv", fmt.Sprint(i, "/", n), "name", ir.FullRoute())
if res, stop := ir.Invar(ctx); stop {
// TODO: Include app name as part of context to allow for this to be
// variable.
Expand Down
3 changes: 2 additions & 1 deletion x/evidence/types/evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func (e Equivocation) GetTotalPower() int64 { return 0 }
// FromABCIEvidence converts a Tendermint concrete Evidence type to
// SDK Evidence using Equivocation as the concrete type.
func FromABCIEvidence(e abci.Evidence) exported.Evidence {
consAddr, err := sdk.Bech32ifyAddressBytes(sdk.Bech32PrefixConsAddr, e.Validator.Address)
bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix()
consAddr, err := sdk.Bech32ifyAddressBytes(bech32PrefixConsAddr, e.Validator.Address)
if err != nil {
panic(err)
}
Expand Down
20 changes: 20 additions & 0 deletions x/evidence/types/evidence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/evidence/types"
Expand Down Expand Up @@ -57,3 +58,22 @@ func TestEquivocationValidateBasic(t *testing.T) {
})
}
}

func TestEvidenceAddressConversion(t *testing.T) {
sdk.GetConfig().SetBech32PrefixForConsensusNode("testcnclcons", "testcnclconspub")
tmEvidence := abci.Evidence{
Type: abci.EvidenceType_DUPLICATE_VOTE,
Validator: abci.Validator{
Address: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Power: 100,
},
Height: 1,
Time: time.Now(),
TotalVotingPower: 100,
}
evidence := types.FromABCIEvidence(tmEvidence).(*types.Equivocation)
consAddr := evidence.GetConsensusAddress()
// Check the address is the same after conversion
require.Equal(t, tmEvidence.Validator.Address, consAddr.Bytes())
sdk.GetConfig().SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
}
8 changes: 8 additions & 0 deletions x/gov/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() {
},
false,
},
{
"get proposals with invalid status",
[]string{
"--status=unknown",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
true,
},
}

for _, tc := range testCases {
Expand Down
20 changes: 15 additions & 5 deletions x/gov/client/rest/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,33 @@ func (s *IntegrationTestSuite) TestGetProposalsGRPC() {
val := s.network.Validators[0]

testCases := []struct {
name string
url string
headers map[string]string
expErr bool
name string
url string
headers map[string]string
wantNumProposals int
expErr bool
}{
{
"get proposals with height 1",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals", val.APIAddress),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
0,
true,
},
{
"valid request",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals", val.APIAddress),
map[string]string{},
2,
false,
},
{
"valid request with filter by status",
fmt.Sprintf("%s/cosmos/gov/v1beta1/proposals?proposal_status=1", val.APIAddress),
map[string]string{},
1,
false,
},
}
Expand All @@ -141,7 +151,7 @@ func (s *IntegrationTestSuite) TestGetProposalsGRPC() {
s.Require().Empty(proposals.Proposals)
} else {
s.Require().NoError(err)
s.Require().Len(proposals.Proposals, 2)
s.Require().Len(proposals.Proposals, tc.wantNumProposals)
}
})
}
Expand Down
56 changes: 56 additions & 0 deletions x/gov/client/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,62 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types"
)

func (s *IntegrationTestSuite) TestLegacyGetAllProposals() {
val := s.network.Validators[0]

testCases := []struct {
name string
url string
numProposals int
expErr bool
expErrMsg string
}{
{
"get all existing proposals",
fmt.Sprintf("%s/gov/proposals", val.APIAddress),
2, false, "",
},
{
"get proposals in deposit period",
fmt.Sprintf("%s/gov/proposals?status=deposit_period", val.APIAddress),
1, false, "",
},
{
"get proposals in voting period",
fmt.Sprintf("%s/gov/proposals?status=voting_period", val.APIAddress),
1, false, "",
},
{
"wrong status parameter",
fmt.Sprintf("%s/gov/proposals?status=invalidstatus", val.APIAddress),
0, true, "'invalidstatus' is not a valid proposal status",
},
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
respJSON, err := rest.GetRequest(tc.url)
s.Require().NoError(err)

if tc.expErr {
var errResp rest.ErrorResponse
s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(respJSON, &errResp))
s.Require().Equal(errResp.Error, tc.expErrMsg)
} else {
var resp = rest.ResponseWithHeight{}
err = val.ClientCtx.LegacyAmino.UnmarshalJSON(respJSON, &resp)
s.Require().NoError(err)

// Check results.
var proposals types.Proposals
s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(resp.Result, &proposals))
s.Require().Equal(tc.numProposals, len(proposals))
}
})
}
}

func (s *IntegrationTestSuite) TestLegacyGetVote() {
val := s.network.Validators[0]
voterAddressBech32 := val.Address.String()
Expand Down
8 changes: 4 additions & 4 deletions x/gov/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ func NormalizeProposalType(proposalType string) string {
func NormalizeProposalStatus(status string) string {
switch status {
case "DepositPeriod", "deposit_period":
return "DepositPeriod"
return types.StatusDepositPeriod.String()
case "VotingPeriod", "voting_period":
return "VotingPeriod"
return types.StatusVotingPeriod.String()
case "Passed", "passed":
return "Passed"
return types.StatusPassed.String()
case "Rejected", "rejected":
return "Rejected"
return types.StatusRejected.String()
default:
return status
}
Expand Down
35 changes: 35 additions & 0 deletions x/gov/client/utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package utils_test

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/gov/client/utils"
)

func TestNormalizeProposalStatus(t *testing.T) {
type args struct {
status string
}
tests := []struct {
name string
args args
want string
}{
{"invalid", args{"unknown"}, "unknown"},
{"deposit_period", args{"deposit_period"}, "PROPOSAL_STATUS_DEPOSIT_PERIOD"},
{"DepositPeriod", args{"DepositPeriod"}, "PROPOSAL_STATUS_DEPOSIT_PERIOD"},
{"voting_period", args{"deposit_period"}, "PROPOSAL_STATUS_DEPOSIT_PERIOD"},
{"VotingPeriod", args{"DepositPeriod"}, "PROPOSAL_STATUS_DEPOSIT_PERIOD"},
{"passed", args{"passed"}, "PROPOSAL_STATUS_PASSED"},
{"Passed", args{"Passed"}, "PROPOSAL_STATUS_PASSED"},
{"Rejected", args{"Rejected"}, "PROPOSAL_STATUS_REJECTED"},
{"rejected", args{"rejected"}, "PROPOSAL_STATUS_REJECTED"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.want, utils.NormalizeProposalStatus(tt.args.status))
})
}
}
13 changes: 13 additions & 0 deletions x/ibc/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"encoding/hex"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
Expand Down Expand Up @@ -95,13 +97,24 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
)
}()

// emit the full header in events
var headerStr string
if header != nil {
// Marshal the Header as an Any and encode the resulting bytes to hex.
// This prevents the event value from containing invalid UTF-8 characters
// which may cause data to be lost when JSON encoding/decoding.
headerStr = hex.EncodeToString(types.MustMarshalHeader(k.cdc, header))

}

// emitting events in the keeper emits for both begin block and handler client updates
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeUpdateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()),
sdk.NewAttribute(types.AttributeKeyHeader, headerStr),
),
)

Expand Down
Loading