Skip to content

Commit

Permalink
Merge branch 'main' into ty/remove_redacted
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed May 19, 2022
2 parents ebec0a8 + 78cafee commit b71dd4d
Show file tree
Hide file tree
Showing 418 changed files with 1,064 additions and 1,087 deletions.
1 change: 1 addition & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ v1.0.0-beta1 → v1.0.0-beta2 → ... → v1.0.0-rc1 → v1.0.0-rc2 → ... →
* create new release candidate tags after bugs are fixed.
* After the team feels the release branch is stable and everything works, create a full release:
* update `CHANGELOG.md`.
* run `gofumpt -w -l .` to format the code.
* create a new annotated git tag (eg `git -a v1.1.0`) in the release branch.
* Create a GitHub release.

Expand Down
6 changes: 0 additions & 6 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (app *BaseApp) FilterPeerByID(info string) abci.ResponseQuery {

// BeginBlock implements the ABCI application interface.
func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {

if app.cms.TracingEnabled() {
app.cms.SetTracingContext(sdk.TraceContext(
map[string]interface{}{"blockHeight": req.Header.Height},
Expand Down Expand Up @@ -209,7 +208,6 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg

// EndBlock implements the ABCI interface.
func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) {

if app.deliverState.ms.TracingEnabled() {
app.deliverState.ms = app.deliverState.ms.SetTracingContext(nil).(sdk.CacheMultiStore)
}
Expand Down Expand Up @@ -240,7 +238,6 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
// will contain releveant error information. Regardless of tx execution outcome,
// the ResponseCheckTx will contain relevant gas execution context.
func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {

var mode runTxMode

switch {
Expand Down Expand Up @@ -274,7 +271,6 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
// Regardless of tx execution outcome, the ResponseDeliverTx will contain relevant
// gas execution context.
func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {

var abciRes abci.ResponseDeliverTx
defer func() {
for _, streamingListener := range app.abciListeners {
Expand All @@ -297,7 +293,6 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
}

return abciRes

}

// Commit implements the ABCI interface. It will commit all state that exists in
Expand All @@ -308,7 +303,6 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx
// against that height and gracefully halt if it matches the latest committed
// height.
func (app *BaseApp) Commit() (res abci.ResponseCommit) {

header := app.deliverState.ctx.BlockHeader()
retainHeight := app.GetBlockRetentionHeight(header.Height)

Expand Down
4 changes: 1 addition & 3 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const (
runTxModeDeliver // Deliver a transaction
)

var (
_ abci.Application = (*BaseApp)(nil)
)
var _ abci.Application = (*BaseApp)(nil)

type (
// Enum mode for app.runTx
Expand Down
1 change: 0 additions & 1 deletion client/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ func TestBroadcastError(t *testing.T) {
require.Equal(t, txHash, resp.TxHash)
}
}

}
2 changes: 1 addition & 1 deletion client/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func writeConfigToFile(configFilePath string, config *ClientConfig) error {
return err
}

return os.WriteFile(configFilePath, buffer.Bytes(), 0600)
return os.WriteFile(configFilePath, buffer.Bytes(), 0o600)
}

// ensureConfigPath creates a directory configPath if it does not exist
Expand Down
7 changes: 1 addition & 6 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import (
legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"
)

var (
flagPubkeyType = "type"
)
var flagPubkeyType = "type"

// Cmd creates a main CLI command
func Cmd() *cobra.Command {
Expand Down Expand Up @@ -178,7 +176,6 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
cmd.Println("Bech32 Acc:", accPub)
cmd.Println("Bech32 Validator Operator:", valPub)
if pubkeyType == "ed25519" {

cmd.Println("Bech32 Validator Consensus:", consensusPub)
}

Expand All @@ -200,7 +197,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
`, version.AppName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

addrString := args[0]
var addr []byte

Expand All @@ -216,7 +212,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg

if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3)

}
}
}
Expand Down
1 change: 1 addition & 0 deletions client/grpc/tmservice/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tmservice

import (
"context"

"github.com/cosmos/cosmos-sdk/client"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/rpc/coretypes"
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/tmservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() {
s.Require().Equal(true, ok)
s.Require().Equal(content, val.PubKey)

//with pagination
// with pagination
_, err = s.queryClient.GetLatestValidatorSet(context.Background(), &tmservice.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{
Offset: 0,
Limit: 10,
Expand Down
5 changes: 3 additions & 2 deletions client/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
gocontext "context"
"errors"
"fmt"
"reflect"
"strconv"

"github.com/cosmos/cosmos-sdk/codec"
proto "github.com/gogo/protobuf/proto"
"google.golang.org/grpc/encoding"
"reflect"
"strconv"

gogogrpc "github.com/gogo/protobuf/grpc"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down
1 change: 1 addition & 0 deletions client/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build norace
// +build norace

package client_test
Expand Down
1 change: 0 additions & 1 deletion client/input/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ func TestReadLineFromBuf(t *testing.T) {
_, err := readLineFromBuf(buf)
require.ErrorIs(t, err, expectedErr)
})

}
2 changes: 1 addition & 1 deletion client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO
t.Cleanup(cleanupKeys(t, kb, "keyname1"))

keyfile := filepath.Join(kbHome, "key.asc")
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0644))
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644))

defer func() {
_ = os.RemoveAll(kbHome)
Expand Down
2 changes: 1 addition & 1 deletion client/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Test_runListCmd(t *testing.T) {
clientCtx := client.Context{}.WithKeyring(kb)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)

path := "" //sdk.GetConfig().GetFullBIP44Path()
path := "" // sdk.GetConfig().GetFullBIP44Path()
_, err = kb.NewAccount("something", testdata.TestMnemonic, "", path, hd.Secp256k1)
require.NoError(t, err)

Expand Down
3 changes: 1 addition & 2 deletions client/keys/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (s *MigrateTestSuite) SetupSuite() {
}

func (s *MigrateTestSuite) Test_runListAndShowCmd() {

// adding LegacyInfo item into keyring
multi := multisig.NewLegacyAminoPubKey(
1, []cryptotypes.PubKey{
Expand All @@ -60,7 +59,7 @@ func (s *MigrateTestSuite) Test_runListAndShowCmd() {
Description: "SDK keyring version",
}

//run test simd keys list - to see that the migrated key is there
// run test simd keys list - to see that the migrated key is there
cmd := ListKeysCmd()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())

Expand Down
2 changes: 1 addition & 1 deletion client/query_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build norace
// +build norace

package client_test
Expand All @@ -11,7 +12,6 @@ import (
)

func (s *IntegrationTestSuite) TestQueryABCIHeight() {

testCases := []struct {
name string
reqHeight int64
Expand Down
1 change: 0 additions & 1 deletion client/tx/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx,

err := CopyTx(tx, builder, true)
if err != nil {

return legacytx.StdTx{}, err
}

Expand Down
1 change: 0 additions & 1 deletion client/v2/cli/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

// Builder manages options for building CLI commands.
type Builder struct {

// flag.Builder embeds the flag builder and its options.
flag.Builder

Expand Down
1 change: 0 additions & 1 deletion client/v2/cli/flag/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type FieldValueBinder interface {

// Options specifies options for specific flags.
type Options struct {

// Prefix is a prefix to prepend to all flags.
Prefix string
}
Expand Down
1 change: 0 additions & 1 deletion client/v2/cli/flag/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

// Type specifies a custom flag type.
type Type interface {

// NewValue returns a new pflag.Value which must also implement either
// SimpleValue or ListValue.
NewValue(context.Context, *Builder) pflag.Value
Expand Down
2 changes: 0 additions & 2 deletions client/v2/cli/flag/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (

// SimpleValue wraps a simple (non-list and non-map) protobuf value.
type SimpleValue interface {

// Get returns the value.
Get() protoreflect.Value
}

// ListValue wraps a protobuf list/repeating value.
type ListValue interface {

// AppendTo appends the values to the provided list.
AppendTo(protoreflect.List)
}
2 changes: 1 addition & 1 deletion codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) {
func TestAminoCodecFullDecodeAndEncode(t *testing.T) {
// This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117.
txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"cosmos14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"cosmosvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"tendermint/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}`
var legacyCdc = simapp.MakeTestEncodingConfig().Amino
legacyCdc := simapp.MakeTestEncodingConfig().Amino
var tx legacytx.StdTx
err := legacyCdc.UnmarshalJSON([]byte(txSigned), &tx)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions codec/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestMarshalProtoPubKey(t *testing.T) {
var pkI cryptotypes.PubKey
err = ccfg.InterfaceRegistry.UnpackAny(&pkAny2, &pkI)
require.NoError(err)
var pk2 = pkAny2.GetCachedValue().(cryptotypes.PubKey)
pk2 := pkAny2.GetCachedValue().(cryptotypes.PubKey)
require.True(pk2.Equals(pk))

// **** test binary serialization ****
Expand All @@ -92,7 +92,7 @@ func TestMarshalProtoPubKey(t *testing.T) {
require.NoError(err)
err = ccfg.InterfaceRegistry.UnpackAny(&pkAny3, &pkI)
require.NoError(err)
var pk3 = pkAny3.GetCachedValue().(cryptotypes.PubKey)
pk3 := pkAny3.GetCachedValue().(cryptotypes.PubKey)
require.True(pk3.Equals(pk))
}

Expand Down
6 changes: 4 additions & 2 deletions codec/codec_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) {
&testdata.Cat{},
false,
true,
}}
},
}
if _, ok := cdc.(*codec.AminoCodec); ok {
testCases = append(testCases, testCase{
"any marshaling",
Expand All @@ -123,7 +124,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) {
func(i codec.ProtoMarshaler) ([]byte, error) { return cdc.MarshalJSON(i) },
func(i codec.ProtoMarshaler) []byte { return cdc.MustMarshalJSON(i) },
func(bz []byte, ptr codec.ProtoMarshaler) error { return cdc.UnmarshalJSON(bz, ptr) },
func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) }}
func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) },
}

t.Run(tc.name+"_BinaryBare",
func(t *testing.T) { testMarshalingTestCase(require.New(t), tc, m1) })
Expand Down
6 changes: 4 additions & 2 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ type ProtoCodec struct {
interfaceRegistry types.InterfaceRegistry
}

var _ Codec = &ProtoCodec{}
var _ ProtoCodecMarshaler = &ProtoCodec{}
var (
_ Codec = &ProtoCodec{}
_ ProtoCodecMarshaler = &ProtoCodec{}
)

// NewProtoCodec returns a reference to a new ProtoCodec
func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {
Expand Down
4 changes: 2 additions & 2 deletions codec/proto_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func mustAny(msg proto.Message) *types.Any {
}

func BenchmarkProtoCodecMarshalLengthPrefixed(b *testing.B) {
var pCdc = codec.NewProtoCodec(types.NewInterfaceRegistry())
var msg = &testdata.HasAnimal{
pCdc := codec.NewProtoCodec(types.NewInterfaceRegistry())
msg := &testdata.HasAnimal{
X: 1000,
Animal: mustAny(&testdata.HasAnimal{
X: 2000,
Expand Down
6 changes: 4 additions & 2 deletions codec/types/any_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ type Animal interface {
Greet() string
}

var _ Animal = (*Dog)(nil)
var _ proto.Message = (*Dog)(nil)
var (
_ Animal = (*Dog)(nil)
_ proto.Message = (*Dog)(nil)
)

func TestAnyPackUnpack(t *testing.T) {
registry := NewInterfaceRegistry()
Expand Down
3 changes: 3 additions & 0 deletions codec/unknownproto/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func init() {
func BenchmarkRejectUnknownFields_serial(b *testing.B) {
benchmarkRejectUnknownFields(b, false)
}

func BenchmarkRejectUnknownFields_parallel(b *testing.B) {
benchmarkRejectUnknownFields(b, true)
}
Expand Down Expand Up @@ -82,9 +83,11 @@ func benchmarkRejectUnknownFields(b *testing.B, parallel bool) {
func BenchmarkProtoUnmarshal_serial(b *testing.B) {
benchmarkProtoUnmarshal(b, false)
}

func BenchmarkProtoUnmarshal_parallel(b *testing.B) {
benchmarkProtoUnmarshal(b, true)
}

func benchmarkProtoUnmarshal(b *testing.B, parallel bool) {
b.ReportAllocs()

Expand Down
12 changes: 8 additions & 4 deletions codec/unknownproto/unknown_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ func RejectUnknownFields(bz []byte, msg proto.Message, allowUnknownNonCriticals
return hasUnknownNonCriticals, nil
}

var protoMessageForTypeNameMu sync.RWMutex
var protoMessageForTypeNameCache = make(map[string]proto.Message)
var (
protoMessageForTypeNameMu sync.RWMutex
protoMessageForTypeNameCache = make(map[string]proto.Message)
)

// protoMessageForTypeName takes in a fully qualified name e.g. testdata.TestVersionFD1
// and returns a corresponding empty protobuf message that serves the prototype for typechecking.
Expand Down Expand Up @@ -382,8 +384,10 @@ type descriptorMatch struct {
desc *descriptor.DescriptorProto
}

var descprotoCacheMu sync.RWMutex
var descprotoCache = make(map[reflect.Type]*descriptorMatch)
var (
descprotoCacheMu sync.RWMutex
descprotoCache = make(map[reflect.Type]*descriptorMatch)
)

// getDescriptorInfo retrieves the mapping of field numbers to their respective field descriptors.
func getDescriptorInfo(desc descriptorIface, msg proto.Message) (map[int32]*descriptor.FieldDescriptorProto, *descriptor.DescriptorProto, error) {
Expand Down
Loading

0 comments on commit b71dd4d

Please sign in to comment.