diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a95abae91610..1c47eeca6b03 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ permissions: jobs: golangci: permissions: - pull-requests: read # for technote-space/get-diff-action to get git reference + pull-requests: read # for technote-space/get-diff-action to get git reference name: golangci-lint runs-on: ubuntu-latest steps: diff --git a/.golangci.yml b/.golangci.yml index 173d530b9b32..c6d8e3e5aeb4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,8 +12,7 @@ linters: - exportloopref - goconst - gocritic - - gofmt - - goimports + - gofumpt - gosec - gosimple - govet @@ -32,6 +31,9 @@ issues: - text: "Use of weak random number generator" linters: - gosec + - text: "without leading space" + linters: + - nolintlint - text: "comment on exported var" linters: - golint diff --git a/api/go.mod b/api/go.mod index c2cf1a41ae0c..94efcd4a9055 100644 --- a/api/go.mod +++ b/api/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.8 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/api/go.sum b/api/go.sum index c4f245da910e..08e662106219 100644 --- a/api/go.sum +++ b/api/go.sum @@ -81,8 +81,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -100,8 +99,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 096228614922..7f0a38d874f4 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -42,7 +42,7 @@ type ( ) // BaseApp reflects the ABCI application implementation. -type BaseApp struct { // nolint: maligned +type BaseApp struct { //nolint: maligned // initialized on creation logger log.Logger name string // application name from abci.Info diff --git a/baseapp/msg_service_router.go b/baseapp/msg_service_router.go index f6c8d4b21ce7..e9f2311cae23 100644 --- a/baseapp/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -46,9 +46,9 @@ func (msr *MsgServiceRouter) HandlerByTypeURL(typeURL string) MsgServiceHandler // service description, handler is an object which implements that gRPC service. // // This function PANICs: -// - if it is called before the service `Msg`s have been registered using -// RegisterInterfaces, -// - or if a service is being registered twice. +// - if it is called before the service `Msg`s have been registered using +// RegisterInterfaces, +// - or if a service is being registered twice. func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) { // Adds a top-level query handler based on the gRPC service name. for _, method := range sd.Methods { diff --git a/client/keys/add.go b/client/keys/add.go index 9e26da210f34..62bdc67dbab3 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -93,12 +93,13 @@ func runAddCmdPrepare(cmd *cobra.Command, args []string) error { /* input - - bip39 mnemonic - - bip39 passphrase - - bip44 path - - local encryption password + - bip39 mnemonic + - bip39 passphrase + - bip44 path + - local encryption password + output - - armor encrypted private key (saved to file) + - armor encrypted private key (saved to file) */ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error { var err error diff --git a/client/v2/go.mod b/client/v2/go.mod index 5f6d7c0686eb..8b59eb8dc7fa 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -18,8 +18,8 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.8 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect ) diff --git a/client/v2/go.sum b/client/v2/go.sum index 3fbd98dc7289..8b1e7c796056 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -94,8 +94,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -113,8 +112,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/codec/amino_codec.go b/codec/amino_codec.go index 69f4dc133d29..77969d22df25 100644 --- a/codec/amino_codec.go +++ b/codec/amino_codec.go @@ -96,8 +96,9 @@ func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error) { // NOTE: to unmarshal a concrete type, you should use Unmarshal instead // // Example: -// var x MyInterface -// err := cdc.UnmarshalInterface(bz, &x) +// +// var x MyInterface +// err := cdc.UnmarshalInterface(bz, &x) func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error { return ac.LegacyAmino.Unmarshal(bz, ptr) } @@ -117,8 +118,9 @@ func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error) { // NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead // // Example: -// var x MyInterface -// err := cdc.UnmarshalInterfaceJSON(bz, &x) +// +// var x MyInterface +// err := cdc.UnmarshalInterfaceJSON(bz, &x) func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error { return ac.LegacyAmino.UnmarshalJSON(bz, ptr) } diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 9b5b72b6e4f2..317cc33e0481 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -204,8 +204,9 @@ func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) { // NOTE: to unmarshal a concrete type, you should use Unmarshal instead // // Example: -// var x MyInterface -// err := cdc.UnmarshalInterface(bz, &x) +// +// var x MyInterface +// err := cdc.UnmarshalInterface(bz, &x) func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error { any := &types.Any{} err := pc.Unmarshal(bz, any) @@ -233,8 +234,9 @@ func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error) // NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead // // Example: -// var x MyInterface // must implement proto.Message -// err := cdc.UnmarshalInterfaceJSON(&x, bz) +// +// var x MyInterface // must implement proto.Message +// err := cdc.UnmarshalInterfaceJSON(&x, bz) func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error { any := &types.Any{} err := pc.UnmarshalJSON(bz, any) diff --git a/codec/unknownproto/doc.go b/codec/unknownproto/doc.go index 0e0a46342291..cef3f8f253e9 100644 --- a/codec/unknownproto/doc.go +++ b/codec/unknownproto/doc.go @@ -8,17 +8,17 @@ b) Mismatched wire types for a field -- this is indicative of mismatched service Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case - if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { - // Handle the error. - } + if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { + // Handle the error. + } and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above. By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields: - if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil { - // Handle the error. - } + if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil { + // Handle the error. + } */ package unknownproto diff --git a/core/go.mod b/core/go.mod index 93f164d46e6b..105a699d50fb 100644 --- a/core/go.mod +++ b/core/go.mod @@ -17,8 +17,8 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect google.golang.org/grpc v1.48.0 // indirect diff --git a/core/go.sum b/core/go.sum index d33d65fb9e5a..70e2a0739d44 100644 --- a/core/go.sum +++ b/core/go.sum @@ -94,8 +94,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -112,8 +112,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/cosmovisor/args.go b/cosmovisor/args.go index b50120c36d14..229d5336b293 100644 --- a/cosmovisor/args.go +++ b/cosmovisor/args.go @@ -311,7 +311,7 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) { return err } _, err = f.Write(bz) - return err + return err } func (cfg *Config) UpgradeInfo() (upgradetypes.Plan, error) { diff --git a/cosmovisor/args_test.go b/cosmovisor/args_test.go index 3ecb6f871b15..e42749e0c76a 100644 --- a/cosmovisor/args_test.go +++ b/cosmovisor/args_test.go @@ -81,8 +81,9 @@ func (c *cosmovisorEnv) Set(envVar, envVal string) { // clearEnv clears environment variables and what they were. // Designed to be used like this: -// initialEnv := clearEnv() -// defer setEnv(nil, initialEnv) +// +// initialEnv := clearEnv() +// defer setEnv(nil, initialEnv) func (s *argsTestSuite) clearEnv() *cosmovisorEnv { s.T().Logf("Clearing environment variables.") rv := cosmovisorEnv{} diff --git a/cosmovisor/cmd/cosmovisor/help_test.go b/cosmovisor/cmd/cosmovisor/help_test.go index 86339cabe422..3332cc777dd0 100644 --- a/cosmovisor/cmd/cosmovisor/help_test.go +++ b/cosmovisor/cmd/cosmovisor/help_test.go @@ -47,8 +47,9 @@ func (c *cosmovisorHelpEnv) Set(envVar, envVal string) { // clearEnv clears environment variables and returns what they were. // Designed to be used like this: -// initialEnv := clearEnv() -// defer setEnv(nil, initialEnv) +// +// initialEnv := clearEnv() +// defer setEnv(nil, initialEnv) func (s *HelpTestSuite) clearEnv() *cosmovisorHelpEnv { s.T().Logf("Clearing environment variables.") rv := cosmovisorHelpEnv{} diff --git a/cosmovisor/cmd/cosmovisor/init_test.go b/cosmovisor/cmd/cosmovisor/init_test.go index 056571f3bbb2..7733bd2ae879 100644 --- a/cosmovisor/cmd/cosmovisor/init_test.go +++ b/cosmovisor/cmd/cosmovisor/init_test.go @@ -53,8 +53,9 @@ func (c *cosmovisorInitEnv) Set(envVar, envVal string) { // clearEnv clears environment variables and returns what they were. // Designed to be used like this: -// initialEnv := clearEnv() -// defer setEnv(nil, initialEnv) +// +// initialEnv := clearEnv() +// defer setEnv(nil, initialEnv) func (s *InitTestSuite) clearEnv() *cosmovisorInitEnv { s.T().Logf("Clearing environment variables.") rv := cosmovisorInitEnv{} @@ -137,8 +138,9 @@ func NewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error // StartNewBufferedPipe creates a new BufferedPipe and starts it. // // This is functionally equivalent to: -// p, _ := NewBufferedPipe(name, replicateTo...) -// p.Start() +// +// p, _ := NewBufferedPipe(name, replicateTo...) +// p.Start() func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) { p, err := NewBufferedPipe(name, replicateTo...) if err != nil { diff --git a/cosmovisor/go.mod b/cosmovisor/go.mod index d31f08c6ce43..66e1908ed2eb 100644 --- a/cosmovisor/go.mod +++ b/cosmovisor/go.mod @@ -17,7 +17,7 @@ require ( cloud.google.com/go/iam v0.3.0 // indirect cloud.google.com/go/storage v1.14.0 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/math v1.0.0-beta.2 // indirect + cosmossdk.io/math v1.0.0-beta.3 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -30,13 +30,12 @@ require ( github.com/btcsuite/btcd v0.22.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/coinbase/rosetta-sdk-go v0.7.10 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/iavl v0.19.0 // indirect + github.com/cosmos/iavl v0.19.1 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -57,7 +56,6 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.1 // indirect - github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -114,9 +112,9 @@ require ( go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect @@ -124,8 +122,7 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect google.golang.org/grpc v1.48.0 // indirect - google.golang.org/protobuf v1.28.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/cosmovisor/go.sum b/cosmovisor/go.sum index fe9043477a4a..b14884188f93 100644 --- a/cosmovisor/go.sum +++ b/cosmovisor/go.sum @@ -67,8 +67,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/math v1.0.0-beta.2 h1:17hSVc9ne1c31IaLDfjRojtN+y4Rd2N8H/6Fht2sBzw= -cosmossdk.io/math v1.0.0-beta.2/go.mod h1:u/MXvf8wbUbCsAEyQSSYXXMsczAsFX48e2D6JI86T4o= +cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= +cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -220,8 +220,7 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/coinbase/rosetta-sdk-go v0.7.10 h1:m5Prrqg9CD1GFZm0tu8z3LEDF/BY5RKUSkODZRpAkEc= -github.com/coinbase/rosetta-sdk-go v0.7.10/go.mod h1:/glajndJEMrp+D7cO2PJZWKeclK8mDyzSCokCMc6Ftc= +github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= @@ -247,8 +246,8 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps= -github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA= +github.com/cosmos/iavl v0.19.1 h1:3gaq9b6SjiB0KBTygRnAvEGml2pQlu1TH8uma5g63Ys= +github.com/cosmos/iavl v0.19.1/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -469,9 +468,8 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8 github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -806,6 +804,7 @@ github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1t github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.7.11/go.mod h1:gX+MP7DWMKJmNa1HfMozK+u04hQd3na9i0hyqf3/dOI= github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= @@ -1313,8 +1312,9 @@ golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1468,8 +1468,8 @@ golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1799,16 +1799,16 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= diff --git a/crypto/armor.go b/crypto/armor.go index 1da3e9703326..7ef3da5e6842 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -4,11 +4,11 @@ import ( "bytes" "encoding/hex" "fmt" - "io/ioutil" + "io" "github.com/tendermint/crypto/bcrypt" "github.com/tendermint/tendermint/crypto" - "golang.org/x/crypto/openpgp/armor" // nolint: staticcheck + "golang.org/x/crypto/openpgp/armor" //nolint: staticcheck "github.com/cosmos/cosmos-sdk/codec/legacy" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -235,7 +235,7 @@ func DecodeArmor(armorStr string) (blockType string, headers map[string]string, if err != nil { return "", nil, nil, err } - data, err = ioutil.ReadAll(block.Body) + data, err = io.ReadAll(block.Body) if err != nil { return "", nil, nil, err } diff --git a/crypto/hd/doc.go b/crypto/hd/doc.go index 38d65213c177..85b6369e75e3 100644 --- a/crypto/hd/doc.go +++ b/crypto/hd/doc.go @@ -1,8 +1,9 @@ // Package hd provides support for hierarchical deterministic wallets generation and derivation. // // The user must understand the overall concept of the BIP 32 and the BIP 44 specs: -// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki -// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki +// +// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki +// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki // // In combination with the bip39 package in go-crypto this package provides the functionality for // deriving keys using a BIP 44 HD path, or, more general, by passing a BIP 32 path. diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go index 96056a99b53a..172e3e0f76bd 100644 --- a/crypto/hd/hdpath.go +++ b/crypto/hd/hdpath.go @@ -215,7 +215,7 @@ func DerivePrivateKeyForPath(privKeyBytes, chainCode [32]byte, path string) ([]b // If harden is true, the derivation is 'hardened'. // It returns the new private key and new chain code. // For more information on hardened keys see: -// - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki +// - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) { var data []byte diff --git a/crypto/keyring/doc.go b/crypto/keyring/doc.go index b642680c0662..c5c17bf160b7 100644 --- a/crypto/keyring/doc.go +++ b/crypto/keyring/doc.go @@ -1,19 +1,18 @@ // Package keys provides common key management API. // -// -// The Keyring interface +// # The Keyring interface // // The Keyring interface defines the methods that a type needs to implement to be used // as key storage backend. This package provides few implementations out-of-the-box. // -// NewInMemory +// # NewInMemory // // The NewInMemory constructor returns an implementation backed by an in-memory, goroutine-safe // map that has historically been used for testing purposes or on-the-fly key generation as the // generated keys are discarded when the process terminates or the type instance is garbage // collected. // -// New +// # New // // The New constructor returns an implementation backed by a keyring library // (https://github.com/99designs/keyring), whose aim is to provide a common abstraction and uniform @@ -21,20 +20,21 @@ // as well as operating system-agnostic encrypted file-based backends. // // The backends: -// os The instance returned by this constructor uses the operating system's default -// credentials store to handle keys storage operations securely. It should be noted -// that the keyring keyring may be kept unlocked for the whole duration of the user -// session. -// file This backend more closely resembles the previous keyring storage used prior to -// v0.38.1. It stores the keyring encrypted within the app's configuration directory. -// This keyring will request a password each time it is accessed, which may occur -// multiple times in a single command resulting in repeated password prompts. -// kwallet This backend uses KDE Wallet Manager as a credentials management application: -// https://github.com/KDE/kwallet -// pass This backend uses the pass command line utility to store and retrieve keys: -// https://www.passwordstore.org/ -// test This backend stores keys insecurely to disk. It does not prompt for a password to -// be unlocked and it should be use only for testing purposes. -// memory Same instance as returned by NewInMemory. This backend uses a transient storage. Keys -// are discarded when the process terminates or the type instance is garbage collected. +// +// os The instance returned by this constructor uses the operating system's default +// credentials store to handle keys storage operations securely. It should be noted +// that the keyring keyring may be kept unlocked for the whole duration of the user +// session. +// file This backend more closely resembles the previous keyring storage used prior to +// v0.38.1. It stores the keyring encrypted within the app's configuration directory. +// This keyring will request a password each time it is accessed, which may occur +// multiple times in a single command resulting in repeated password prompts. +// kwallet This backend uses KDE Wallet Manager as a credentials management application: +// https://github.com/KDE/kwallet +// pass This backend uses the pass command line utility to store and retrieve keys: +// https://www.passwordstore.org/ +// test This backend stores keys insecurely to disk. It does not prompt for a password to +// be unlocked and it should be use only for testing purposes. +// memory Same instance as returned by NewInMemory. This backend uses a transient storage. Keys +// are discarded when the process terminates or the type instance is garbage collected. package keyring diff --git a/crypto/keyring/output.go b/crypto/keyring/output.go index 87bec26ad84e..37ba3bffd124 100644 --- a/crypto/keyring/output.go +++ b/crypto/keyring/output.go @@ -21,7 +21,7 @@ type KeyOutput struct { } // NewKeyOutput creates a default KeyOutput instance without Mnemonic, Threshold and PubKeys -func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { // nolint:interfacer +func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { //nolint:interfacer apk, err := codectypes.NewAnyWithValue(pk) if err != nil { return KeyOutput{}, err diff --git a/crypto/keys/multisig/codec.go b/crypto/keys/multisig/codec.go index d501e1b427cf..9f85ce552362 100644 --- a/crypto/keys/multisig/codec.go +++ b/crypto/keys/multisig/codec.go @@ -15,7 +15,7 @@ const ( PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold" ) -//nolint +// nolint // Deprecated: Amino is being deprecated in the SDK. But even if you need to // use Amino for some reason, please use `codec/legacy.Cdc` instead. var AminoCdc = codec.NewLegacyAmino() diff --git a/crypto/keys/secp256k1/internal/secp256k1/curve.go b/crypto/keys/secp256k1/internal/secp256k1/curve.go index 764769033f46..cbdf3a3ddd98 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/curve.go +++ b/crypto/keys/secp256k1/internal/secp256k1/curve.go @@ -6,17 +6,17 @@ // modification, are permitted provided that the following conditions are // met: // -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// * The name of ThePiachu may not be used to endorse or promote products -// derived from this software without specific prior written permission. +// - Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// - Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// - Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// - The name of ThePiachu may not be used to endorse or promote products +// derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -29,7 +29,7 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -//nolint // this nolint lets us use this file in its original and unmodified form. +// nolint // this nolint lets us use this file in its original and unmodified form. package secp256k1 import ( diff --git a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go index d3e0d2eb2c41..33566723c1a5 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go +++ b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go @@ -5,7 +5,7 @@ //go:build !gofuzz && cgo // +build !gofuzz,cgo -//nolint // this nolint lets us use this file in its original and unmodified form. +// nolint // this nolint lets us use this file in its original and unmodified form. package secp256k1 import ( diff --git a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go index 0c1f96f3e78c..e95e85586972 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go +++ b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go @@ -5,7 +5,7 @@ //go:build gofuzz || !cgo // +build gofuzz !cgo -//nolint // this nolint lets us use this file in its original and unmodified form. +// nolint // this nolint lets us use this file in its original and unmodified form. package secp256k1 import "math/big" diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 51034275cd94..9ec713acbe36 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -10,7 +10,7 @@ import ( secp256k1 "github.com/btcsuite/btcd/btcec" "github.com/tendermint/tendermint/crypto" - "golang.org/x/crypto/ripemd160" // nolint: staticcheck // necessary for Bitcoin address format + "golang.org/x/crypto/ripemd160" //nolint: staticcheck // necessary for Bitcoin address format "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/crypto/keys/secp256k1/secp256k1_nocgo.go b/crypto/keys/secp256k1/secp256k1_nocgo.go index 60fd9577978c..e12a410a81cc 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo.go @@ -13,8 +13,8 @@ import ( // used to reject malleable signatures // see: -// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/signature_nocgo.go#L90-L93 -// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/crypto.go#L39 +// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/signature_nocgo.go#L90-L93 +// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/crypto.go#L39 var secp256k1halfN = new(big.Int).Rsh(secp256k1.S256().N, 1) // Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg. diff --git a/db/go.mod b/db/go.mod index a4c6cbbf2a54..7eba171e09d8 100644 --- a/db/go.mod +++ b/db/go.mod @@ -31,9 +31,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect - google.golang.org/protobuf v1.28.0 // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/db/go.sum b/db/go.sum index b92f6d2ce84a..cf568f2c3a70 100644 --- a/db/go.sum +++ b/db/go.sum @@ -152,8 +152,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -168,8 +167,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -207,8 +205,7 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/db/types.go b/db/types.go index a800672bebfe..d4aac2cf98cc 100644 --- a/db/types.go +++ b/db/types.go @@ -146,16 +146,16 @@ type ReadWriter interface { // // Typical usage: // -// var itr Iterator = ... -// defer itr.Close() +// var itr Iterator = ... +// defer itr.Close() // -// for itr.Next() { -// k, v := itr.Key(); itr.Value() -// ... -// } -// if err := itr.Error(); err != nil { -// ... -// } +// for itr.Next() { +// k, v := itr.Key(); itr.Value() +// ... +// } +// if err := itr.Error(); err != nil { +// ... +// } type Iterator interface { // Domain returns the start (inclusive) and end (exclusive) limits of the iterator. // CONTRACT: start, end readonly []byte diff --git a/depinject/config.go b/depinject/config.go index e489e28a5a4b..156cb7103240 100644 --- a/depinject/config.go +++ b/depinject/config.go @@ -92,6 +92,7 @@ func invoke(ctr *container, key *moduleKey, invokers []interface{}) error { // instance when an interface of type Duck is requested as an input. // // BindInterface( +// // "cosmossdk.io/depinject_test/depinject_test.Duck", // "cosmossdk.io/depinject_test/depinject_test.Canvasback") func BindInterface(inTypeName string, outTypeName string) Config { @@ -106,9 +107,10 @@ func BindInterface(inTypeName string, outTypeName string) Config { // "moduleFoo". // // BindInterfaceInModule( -// "moduleFoo", -// "cosmossdk.io/depinject_test/depinject_test.Duck", -// "cosmossdk.io/depinject_test/depinject_test.Canvasback") +// +// "moduleFoo", +// "cosmossdk.io/depinject_test/depinject_test.Duck", +// "cosmossdk.io/depinject_test/depinject_test.Canvasback") func BindInterfaceInModule(moduleName string, inTypeName string, outTypeName string) Config { return containerConfig(func(ctr *container) error { return bindInterface(ctr, inTypeName, outTypeName, moduleName) diff --git a/depinject/container.go b/depinject/container.go index 47fd95d32b18..13965e9239d7 100644 --- a/depinject/container.go +++ b/depinject/container.go @@ -449,7 +449,6 @@ func (c *container) build(loc Location, outputs ...interface{}) error { if !values[i].CanInterface() { return []reflect.Value{}, fmt.Errorf("depinject.Out struct %s on package can't have unexported field", values[i].String()) - } val.Elem().Set(values[i]) } diff --git a/depinject/inject.go b/depinject/inject.go index 1f3194e37105..609845781a7b 100644 --- a/depinject/inject.go +++ b/depinject/inject.go @@ -7,8 +7,9 @@ package depinject // can be provided by the container. // // Ex: -// var x int -// Inject(Provide(func() int { return 1 }), &x) +// +// var x int +// Inject(Provide(func() int { return 1 }), &x) // // Inject uses the debug mode provided by AutoDebug which means there will be // verbose debugging information if there is an error and nothing upon success. diff --git a/depinject/provider_desc.go b/depinject/provider_desc.go index 16a8f3c7972f..90d1dfd624be 100644 --- a/depinject/provider_desc.go +++ b/depinject/provider_desc.go @@ -9,7 +9,8 @@ import ( // ProviderDescriptor defines a special provider type that is defined by // reflection. It should be passed as a value to the Provide function. // Ex: -// option.Provide(ProviderDescriptor{ ... }) +// +// option.Provide(ProviderDescriptor{ ... }) type ProviderDescriptor struct { // Inputs defines the in parameter types to Fn. Inputs []ProviderInput diff --git a/depinject/struct_args.go b/depinject/struct_args.go index 07dda03c9340..d82dd3c2f856 100644 --- a/depinject/struct_args.go +++ b/depinject/struct_args.go @@ -13,9 +13,10 @@ import ( // positional parameters. // // Fields of the struct may support the following tags: -// optional if set to true, the dependency is optional and will -// be set to its default value if not found, rather than causing -// an error +// +// optional if set to true, the dependency is optional and will +// be set to its default value if not found, rather than causing +// an error type In struct{} func (In) isIn() {} @@ -176,7 +177,6 @@ func buildIn(typ reflect.Type, values []reflect.Value) (reflect.Value, int, erro } if !values[j].CanInterface() { return reflect.Value{}, 0, fmt.Errorf("depinject.Out struct %s on package %s can't have unexported field", res.Elem().String(), f.PkgPath) - } res.Elem().Field(i).Set(values[j]) diff --git a/errors/doc.go b/errors/doc.go index 6cca61580d06..ed6b9a69bfca 100644 --- a/errors/doc.go +++ b/errors/doc.go @@ -11,24 +11,23 @@ of the errors package. If it will be needed my many extensions, please consider registering it in the errors package. To create a new error instance use Register function. You must provide a unique, non zero error code and a short description, for example: - var ErrZeroDivision = errors.Register(9241, "zero division") + var ErrZeroDivision = errors.Register(9241, "zero division") When returning an error, you can attach to it an additional context information by using Wrap function, for example: - func safeDiv(val, div int) (int, err) { - if div == 0 { - return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val) + func safeDiv(val, div int) (int, err) { + if div == 0 { + return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val) + } + return val / div, nil } - return val / div, nil - } The first time an error instance is wrapped a stacktrace is attached as well. Stacktrace information can be printed using %+v and %v formats. - %s is just the error message - %+v is the full stack trace - %v appends a compressed [filename:line] where the error was created - + %s is just the error message + %+v is the full stack trace + %v appends a compressed [filename:line] where the error was created */ package errors diff --git a/errors/go.mod b/errors/go.mod index 07f4da52aa3d..99daf5584741 100644 --- a/errors/go.mod +++ b/errors/go.mod @@ -15,10 +15,10 @@ require ( github.com/kr/pretty v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect - google.golang.org/protobuf v1.28.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/errors/go.sum b/errors/go.sum index 19bd71f4b916..ef4bb0777caf 100644 --- a/errors/go.sum +++ b/errors/go.sum @@ -90,8 +90,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -107,8 +106,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -150,8 +148,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/errors/stacktrace.go b/errors/stacktrace.go index dc60870763a5..7453284dd378 100644 --- a/errors/stacktrace.go +++ b/errors/stacktrace.go @@ -80,7 +80,8 @@ func writeSimpleFrame(s io.Writer, f errors.Frame) { // %s is just the error message // %+v is the full stack trace // %v appends a compressed [filename:line] where the error -// was created +// +// was created // // Inspired by https://github.com/pkg/errors/blob/v0.8.1/errors.go#L162-L176 func (e *wrappedError) Format(s fmt.State, verb rune) { diff --git a/go.work b/go.work index 9b88cc75ee56..5f1d2f1f95ff 100644 --- a/go.work +++ b/go.work @@ -5,6 +5,7 @@ use ( ./api ./client/v2 ./core + ./cosmovisor ./db ./depinject ./errors diff --git a/go.work.sum b/go.work.sum index 1808dec105ba..d3104538840c 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,33 +1,23 @@ cosmossdk.io/core v0.1.1-0.20220726092710-f848e4300a8a/go.mod h1:NI7jc1kHeG47qN5RCEHuJQ8hpuy+I5l4iQ595nFCZno= cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= github.com/Antonboom/errname v0.1.6/go.mod h1:7lz79JAnuoMNDAWE9MeeIr1/c/VpSUWatBv2FH9NYpI= -github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/GaijinEntertainment/go-exhaustruct/v2 v2.1.0/go.mod h1:LGOGuvEgCfCQsy3JF2tRmpGDpzA53iZfyGEWSPwQ6/4= github.com/bufbuild/buf v1.4.0/go.mod h1:mwHG7klTHnX+rM/ym8LXGl7vYpVmnwT96xWoRB4H5QI= -github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 h1:CC8p43RhsrtZdPOkT/Q5q8QkEGKCq3BbTr/wG/3vJ70= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1/go.mod h1:JUMM2MxF9wuwzRWZJjb8BjXsn1BmPmdBd3a75pIct4I= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/firefart/nonamedreturns v1.0.1/go.mod h1:D3dpIBojGGNh5UfElmwPu73SwDCm+VKhHYqwlNOk2uQ= -github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fzipp/gocyclo v0.5.1/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ= -github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golangci/golangci-lint v1.46.2/go.mod h1:3DkdHnxn9eoTTrpT2gB0TEv8KSziuoqe9FitgQLHvAY= github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kulti/thelper v0.6.2/go.mod h1:DsqKShOvP40epevkFrvIwkCMNYxMeTNjdWL4dqWHZ6I= github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4= github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/nishanths/exhaustive v0.7.11/go.mod h1:gX+MP7DWMKJmNa1HfMozK+u04hQd3na9i0hyqf3/dOI= github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= @@ -44,13 +34,12 @@ github.com/tendermint/tendermint v0.34.20-rc1/go.mod h1:u2xI6q3IeLQQ2NdIpRKLUKBN github.com/tendermint/tendermint v0.34.20/go.mod h1:KtOwCLYJcsS1ymtAfnjjAtXfXClbqcqjdqzFt2Em1Ac= github.com/tomarrell/wrapcheck/v2 v2.6.1/go.mod h1:Eo+Opt6pyMW1b6cNllOcDSSoHO0aTJ+iF6BfCUbHltA= github.com/uudashr/gocognit v1.0.5/go.mod h1:wgYz0mitoKOTysqxTDMOUXg+Jb5SvtihkfmugIZYpEA= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= gitlab.com/bosi/decorder v0.2.1/go.mod h1:6C/nhLSbF6qZbYD8bRmISBwc6vcWdNsiIBkRvjJFrH0= go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/client/pkg/v3 v3.5.2/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.2/go.mod h1:2D7ZejHVMIfog1221iLSYlQRzrtECw3kz4I4VAQm3qI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/math/dec.go b/math/dec.go index 90bb8c7ace7c..6d8a473c063b 100644 --- a/math/dec.go +++ b/math/dec.go @@ -128,12 +128,15 @@ func LegacyNewDecFromIntWithPrec(i Int, prec int64) LegacyDec { // create a decimal from an input decimal string. // valid must come in the form: -// (-) whole integers (.) decimal integers +// +// (-) whole integers (.) decimal integers +// // examples of acceptable input include: -// -123.456 -// 456.7890 -// 345 -// -456789 +// +// -123.456 +// 456.7890 +// 345 +// -456789 // // NOTE - An error will return if more decimal places // are provided in the string than the constant Precision. diff --git a/math/dec_test.go b/math/dec_test.go index 637ef71ee083..7bbb8a146697 100644 --- a/math/dec_test.go +++ b/math/dec_test.go @@ -628,7 +628,7 @@ func BenchmarkLegacyQuoMut(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - sink = b1.QuoMut(b2) + sink = b1.QuoMut(b2) } if sink == nil { @@ -643,7 +643,7 @@ func BenchmarkLegacyQuoTruncateMut(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - sink = b1.QuoTruncateMut(b2) + sink = b1.QuoTruncateMut(b2) } if sink == nil { @@ -658,7 +658,7 @@ func BenchmarkLegacyQuoRoundupMut(b *testing.B) { b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - sink = b1.QuoRoundupMut(b2) + sink = b1.QuoRoundupMut(b2) } if sink == nil { diff --git a/orm/go.mod b/orm/go.mod index e05c41436f35..54dd6c22c268 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -49,8 +49,8 @@ require ( github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect - golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/orm/go.sum b/orm/go.sum index 3afa0c445479..c1cfed168450 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -219,8 +219,7 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -250,8 +249,7 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/orm/testing/ormtest/membackend.go b/orm/testing/ormtest/membackend.go index 02e6c85f00c4..f757daab1508 100644 --- a/orm/testing/ormtest/membackend.go +++ b/orm/testing/ormtest/membackend.go @@ -10,9 +10,10 @@ import ( // testing purposes independent of any storage layer. // // Example: -// backend := ormtest.NewMemoryBackend() -// ctx := ormtable.WrapContextDefault() -// ... +// +// backend := ormtest.NewMemoryBackend() +// ctx := ormtable.WrapContextDefault() +// ... func NewMemoryBackend() ormtable.Backend { return testkv.NewSplitMemBackend() } diff --git a/runtime/app.go b/runtime/app.go index f9e03d41943b..dbc82543cde9 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -33,7 +33,7 @@ import ( // done declaratively with an app config and the rest of it is done the old way. // See simapp/app.go for an example of this setup. // -// nolint:unused +//nolint:unused type App struct { *baseapp.BaseApp diff --git a/server/config/toml.go b/server/config/toml.go index a93fffd1ecd6..65dceec60efd 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -3,7 +3,6 @@ package config import ( "bytes" "fmt" - "io/ioutil" "os" "text/template" @@ -280,7 +279,7 @@ func WriteConfigFile(configFilePath string, config interface{}) { } func mustWriteFile(filePath string, contents []byte, mode os.FileMode) { - if err := ioutil.WriteFile(filePath, contents, mode); err != nil { + if err := os.WriteFile(filePath, contents, mode); err != nil { fmt.Printf(fmt.Sprintf("failed to write file: %v", err) + "\n") os.Exit(1) } diff --git a/server/grpc/gogoreflection/fix_registration.go b/server/grpc/gogoreflection/fix_registration.go index ab7750574845..32fc0e8e34e1 100644 --- a/server/grpc/gogoreflection/fix_registration.go +++ b/server/grpc/gogoreflection/fix_registration.go @@ -9,7 +9,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor gogoproto "github.com/gogo/protobuf/proto" - // nolint: staticcheck + //nolint: staticcheck "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" _ "github.com/regen-network/cosmos-proto" // look above @@ -86,7 +86,7 @@ func getFileDescriptor(filePath string) []byte { if len(fd) != 0 { return fd } - // nolint: staticcheck + //nolint: staticcheck return proto.FileDescriptor(filePath) } @@ -95,7 +95,7 @@ func getMessageType(name string) reflect.Type { if typ != nil { return typ } - // nolint: staticcheck + //nolint: staticcheck return proto.MessageType(name) } @@ -107,7 +107,7 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc { } } // check into proto registry - // nolint: staticcheck + //nolint: staticcheck for id, desc := range proto.RegisteredExtensions(m) { if id == extID { return &gogoproto.ExtensionDesc{ @@ -133,7 +133,7 @@ func getExtensionsNumbers(m proto.Message) []int32 { if len(out) != 0 { return out } - // nolint: staticcheck + //nolint: staticcheck protoExts := proto.RegisteredExtensions(m) out = make([]int32, 0, len(protoExts)) for id := range protoExts { diff --git a/server/grpc/gogoreflection/serverreflection.go b/server/grpc/gogoreflection/serverreflection.go index e98ffe1e1412..ac1e3c2d0526 100644 --- a/server/grpc/gogoreflection/serverreflection.go +++ b/server/grpc/gogoreflection/serverreflection.go @@ -23,6 +23,7 @@ The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto. To register server reflection on a gRPC server: + import "google.golang.org/grpc/reflection" s := grpc.NewServer() @@ -32,7 +33,6 @@ To register server reflection on a gRPC server: reflection.Register(s) s.Serve(lis) - */ package gogoreflection // import "google.golang.org/grpc/reflection" @@ -46,7 +46,7 @@ import ( "sort" "sync" - // nolint: staticcheck + //nolint: staticcheck "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" "google.golang.org/grpc" diff --git a/server/mock/helpers.go b/server/mock/helpers.go index 69a8504c3ccc..9aa0ff61c1f9 100644 --- a/server/mock/helpers.go +++ b/server/mock/helpers.go @@ -2,7 +2,6 @@ package mock import ( "fmt" - "io/ioutil" "os" "github.com/rs/zerolog" @@ -23,7 +22,7 @@ func SetupApp() (abci.Application, func(), error) { } logger = logger.With("module", "mock") - rootDir, err := ioutil.TempDir("", "mock-sdk") + rootDir, err := os.MkdirTemp("", "mock-sdk") if err != nil { return nil, nil, err } diff --git a/server/mock/tx.go b/server/mock/tx.go index 3c93ffb83410..6898e0937b2d 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -1,4 +1,4 @@ -//nolint +// nolint package mock import ( diff --git a/server/rosetta/client_online.go b/server/rosetta/client_online.go index 478bfe6aafbe..d971518e521f 100644 --- a/server/rosetta/client_online.go +++ b/server/rosetta/client_online.go @@ -256,7 +256,8 @@ func (c *Client) TxOperationsAndSignersAccountIdentifiers(signed bool, txBytes [ } // GetTx returns a transaction given its hash. For Rosetta we make a synthetic transaction for BeginBlock -// and EndBlock to adhere to balance tracking rules. +// +// and EndBlock to adhere to balance tracking rules. func (c *Client) GetTx(ctx context.Context, hash string) (*rosettatypes.Transaction, error) { hashBytes, err := hex.DecodeString(hash) if err != nil { diff --git a/server/rosetta/converter.go b/server/rosetta/converter.go index 02321a1a0e2a..2beca0e47168 100644 --- a/server/rosetta/converter.go +++ b/server/rosetta/converter.go @@ -31,9 +31,9 @@ import ( // Converter is a utility that can be used to convert // back and forth from rosetta to sdk and tendermint types // IMPORTANT NOTES: -// - IT SHOULD BE USED ONLY TO DEAL WITH THINGS -// IN A STATELESS WAY! IT SHOULD NEVER INTERACT DIRECTLY -// WITH TENDERMINT RPC AND COSMOS GRPC +// - IT SHOULD BE USED ONLY TO DEAL WITH THINGS +// IN A STATELESS WAY! IT SHOULD NEVER INTERACT DIRECTLY +// WITH TENDERMINT RPC AND COSMOS GRPC // // - IT SHOULD RETURN cosmos rosetta gateway error types! type Converter interface { diff --git a/simapp/export.go b/simapp/export.go index 990a426c4dc0..d47e23a80f0f 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -47,7 +47,8 @@ func (app *SimApp) ExportAppStateAndValidators( // prepare for fresh start at zero height // NOTE zero height genesis is a temporary feature which will be deprecated -// in favour of export at a block height +// +// in favour of export at a block height func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 1fd12e5a8727..38e9ed4c1889 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -6,7 +6,6 @@ import ( "bufio" "encoding/json" "fmt" - "io/ioutil" "net" "os" "path/filepath" @@ -476,7 +475,7 @@ func writeFile(name string, dir string, contents []byte) error { return err } - err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec + err = os.WriteFile(file, contents, 0o644) //nolint: gosec if err != nil { return err } diff --git a/tests/e2e/bank/client/suite.go b/tests/e2e/bank/client/suite.go index 3ed0faa766c5..2c7f3c2ceb12 100644 --- a/tests/e2e/bank/client/suite.go +++ b/tests/e2e/bank/client/suite.go @@ -2,7 +2,7 @@ package client import ( "fmt" - "io/ioutil" + "io" "os" "github.com/gogo/protobuf/proto" @@ -419,7 +419,7 @@ func (s *EndToEndTestSuite) TestNewSendTxCmdDryRun() { s.Require().NoError(err) w.Close() - out, _ := ioutil.ReadAll(r) + out, _ := io.ReadAll(r) os.Stderr = oldSterr s.Require().Regexp("gas estimate: [0-9]+", string(out)) diff --git a/tests/e2e/client/grpc/tmservice/service_test.go b/tests/e2e/client/grpc/tmservice/service_test.go index f75b15347d77..8ce21b566f34 100644 --- a/tests/e2e/client/grpc/tmservice/service_test.go +++ b/tests/e2e/client/grpc/tmservice/service_test.go @@ -31,7 +31,6 @@ type IntegrationTestSuite struct { } func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) } diff --git a/tests/integration/bank/keeper/keeper_test.go b/tests/integration/bank/keeper/keeper_test.go index bd79a6a3602d..bfdc9d2be978 100644 --- a/tests/integration/bank/keeper/keeper_test.go +++ b/tests/integration/bank/keeper/keeper_test.go @@ -122,7 +122,6 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str } func (suite *IntegrationTestSuite) SetupTest() { - var interfaceRegistry codectypes.InterfaceRegistry app, err := sims.Setup( @@ -139,7 +138,7 @@ func (suite *IntegrationTestSuite) SetupTest() { suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) suite.fetchStoreKey = app.UnsafeFindStoreKey - //suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())) + // suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())) suite.Require().NoError(suite.bankKeeper.SetParams(suite.ctx, types.DefaultParams())) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry) diff --git a/testutil/network/network.go b/testutil/network/network.go index 4b3213c3b714..47e4dcd82646 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -62,8 +62,10 @@ var lock = new(sync.Mutex) // AppConstructor defines a function which accepts a network configuration and // creates an ABCI Application to provide to Tendermint. -type AppConstructor = func(val moduletestutil.Validator) servertypes.Application -type TestFixtureFactory = func() TestFixture +type ( + AppConstructor = func(val moduletestutil.Validator) servertypes.Application + TestFixtureFactory = func() TestFixture +) type TestFixture struct { AppConstructor AppConstructor diff --git a/testutil/network/util.go b/testutil/network/util.go index e3ace5544445..9cb8fbc27507 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -3,7 +3,7 @@ package network import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "time" @@ -200,7 +200,7 @@ func writeFile(name string, dir string, contents []byte) error { return err } - err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec + err = os.WriteFile(file, contents, 0o644) //nolint: gosec if err != nil { return err } diff --git a/testutil/rest/rest.go b/testutil/rest/rest.go index c2cd418d0d14..89a16b3ff286 100644 --- a/testutil/rest/rest.go +++ b/testutil/rest/rest.go @@ -12,7 +12,7 @@ import ( // GetRequest defines a wrapper around an HTTP GET request with a provided URL. // An error is returned if the request or reading the body fails. func GetRequest(url string) ([]byte, error) { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) //nolint:gosec if err != nil { return nil, err } @@ -31,7 +31,7 @@ func GetRequest(url string) ([]byte, error) { // PostRequest defines a wrapper around an HTTP POST request with a provided URL and data. // An error is returned if the request or reading the body fails. func PostRequest(url string, contentType string, data []byte) ([]byte, error) { - res, err := http.Post(url, contentType, bytes.NewBuffer(data)) // nolint:gosec + res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec if err != nil { return nil, fmt.Errorf("error while sending post request: %w", err) } diff --git a/tx/go.mod b/tx/go.mod index 27403eab1e98..5b541c2beb7a 100644 --- a/tx/go.mod +++ b/tx/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/math v1.0.0-beta.3 github.com/cosmos/cosmos-proto v1.0.0-alpha7 github.com/stretchr/testify v1.8.0 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 ) require ( diff --git a/tx/go.sum b/tx/go.sum index 763656e5f36b..7521781b1c73 100644 --- a/tx/go.sum +++ b/tx/go.sum @@ -66,8 +66,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/tx/textual/valuerenderer/bytes.go b/tx/textual/valuerenderer/bytes.go index 2600c87be20a..79ee076ed0cd 100644 --- a/tx/textual/valuerenderer/bytes.go +++ b/tx/textual/valuerenderer/bytes.go @@ -9,8 +9,7 @@ import ( ) // bytesValueRenderer implements ValueRenderer for bytes -type bytesValueRenderer struct { -} +type bytesValueRenderer struct{} var _ ValueRenderer = bytesValueRenderer{} diff --git a/tx/textual/valuerenderer/bytes_test.go b/tx/textual/valuerenderer/bytes_test.go index 63565282743b..c5853d56214a 100644 --- a/tx/textual/valuerenderer/bytes_test.go +++ b/tx/textual/valuerenderer/bytes_test.go @@ -4,7 +4,7 @@ import ( "context" "encoding/hex" "encoding/json" - "io/ioutil" + "os" "strings" "testing" @@ -14,7 +14,7 @@ import ( func TestFormatBytes(t *testing.T) { var testcases []bytesTest - raw, err := ioutil.ReadFile("../internal/testdata/bytes.json") + raw, err := os.ReadFile("../internal/testdata/bytes.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) diff --git a/tx/textual/valuerenderer/valuerenderer_test.go b/tx/textual/valuerenderer/valuerenderer_test.go index 9d5361674554..23d51d84f844 100644 --- a/tx/textual/valuerenderer/valuerenderer_test.go +++ b/tx/textual/valuerenderer/valuerenderer_test.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "os" "strconv" "strings" "testing" @@ -20,7 +20,7 @@ import ( func TestFormatInteger(t *testing.T) { type integerTest []string var testcases []integerTest - raw, err := ioutil.ReadFile("../internal/testdata/integers.json") + raw, err := os.ReadFile("../internal/testdata/integers.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) require.NoError(t, err) @@ -67,7 +67,7 @@ func TestFormatInteger(t *testing.T) { func TestFormatDecimal(t *testing.T) { type decimalTest []string var testcases []decimalTest - raw, err := ioutil.ReadFile("../internal/testdata/decimals.json") + raw, err := os.ReadFile("../internal/testdata/decimals.json") require.NoError(t, err) err = json.Unmarshal(raw, &testcases) require.NoError(t, err) diff --git a/types/coin.go b/types/coin.go index 145aa2cdb7a3..52155a6edd13 100644 --- a/types/coin.go +++ b/types/coin.go @@ -489,10 +489,11 @@ func (coins Coins) SafeQuoInt(x Int) (Coins, bool) { // of AmountOf(D) of the inputs. Note that the result might be not // be equal to either input. For any valid Coins a, b, and c, the // following are always true: -// a.IsAllLTE(a.Max(b)) -// b.IsAllLTE(a.Max(b)) -// a.IsAllLTE(c) && b.IsAllLTE(c) == a.Max(b).IsAllLTE(c) -// a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...)) +// +// a.IsAllLTE(a.Max(b)) +// b.IsAllLTE(a.Max(b)) +// a.IsAllLTE(c) && b.IsAllLTE(c) == a.Max(b).IsAllLTE(c) +// a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...)) // // E.g. // {1A, 3B, 2C}.Max({4A, 2B, 2C} == {4A, 3B, 2C}) @@ -534,10 +535,11 @@ func (coins Coins) Max(coinsB Coins) Coins { // of AmountOf(D) of the inputs. Note that the result might be not // be equal to either input. For any valid Coins a, b, and c, the // following are always true: -// a.Min(b).IsAllLTE(a) -// a.Min(b).IsAllLTE(b) -// c.IsAllLTE(a) && c.IsAllLTE(b) == c.IsAllLTE(a.Min(b)) -// a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...)) +// +// a.Min(b).IsAllLTE(a) +// a.Min(b).IsAllLTE(b) +// c.IsAllLTE(a) && c.IsAllLTE(b) == c.IsAllLTE(a.Min(b)) +// a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...)) // // E.g. // {1A, 3B, 2C}.Min({4A, 2B, 2C} == {1A, 2B, 2C}) diff --git a/types/config.go b/types/config.go index 00b701a025d7..fce6c73526e2 100644 --- a/types/config.go +++ b/types/config.go @@ -91,7 +91,8 @@ func (config *Config) SetBech32PrefixForAccount(addressPrefix, pubKeyPrefix stri } // SetBech32PrefixForValidator builds the Config with Bech32 addressPrefix and publKeyPrefix for validators -// and returns the config instance +// +// and returns the config instance func (config *Config) SetBech32PrefixForValidator(addressPrefix, pubKeyPrefix string) { config.assertNotSealed() config.bech32AddressPrefix["validator_addr"] = addressPrefix diff --git a/types/errors/errors.go b/types/errors/errors.go index 52cd584b209a..1c2036f8eb75 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -7,7 +7,9 @@ import ( // Type Aliases to errors module // // Deprecated: functionality of this package has been moved to it's own module: -// cosmossdk.io/errors +// +// cosmossdk.io/errors +// // Please use the above module instead of this package. var ( SuccessABCICode = errorsmod.SuccessABCICode diff --git a/types/handler.go b/types/handler.go index 03d1f02d5806..87762744ee86 100644 --- a/types/handler.go +++ b/types/handler.go @@ -43,21 +43,22 @@ func ChainAnteDecorators(chain ...AnteDecorator) AnteHandler { // Terminator AnteDecorator will get added to the chain to simplify decorator code // Don't need to check if next == nil further up the chain -// ______ -// <((((((\\\ -// / . }\ -// ;--..--._|} -// (\ '--/\--' ) -// \\ | '-' :'| -// \\ . -==- .-| -// \\ \.__.' \--._ -// [\\ __.--| // _/'--. -// \ \\ .'-._ ('-----'/ __/ \ -// \ \\ / __>| | '--. | -// \ \\ | \ | / / / -// \ '\ / \ | | _/ / -// \ \ \ | | / / -// snd \ \ \ / +// +// ______ +// <((((((\\\ +// / . }\ +// ;--..--._|} +// (\ '--/\--' ) +// \\ | '-' :'| +// \\ . -==- .-| +// \\ \.__.' \--._ +// [\\ __.--| // _/'--. +// \ \\ .'-._ ('-----'/ __/ \ +// \ \\ / __>| | '--. | +// \ \\ | \ | / / / +// \ '\ / \ | | _/ / +// \ \ \ | | / / +// snd \ \ \ / type Terminator struct{} // Simply return provided Context and nil error diff --git a/types/module/module.go b/types/module/module.go index da4719fb7fad..08910d33ca40 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -1,10 +1,10 @@ /* Package module contains application module patterns and associated "manager" functionality. The module pattern has been broken down by: - - independent module functionality (AppModuleBasic) - - inter-dependent module genesis functionality (AppModuleGenesis) - - inter-dependent module simulation functionality (AppModuleSimulation) - - inter-dependent module full functionality (AppModule) + - independent module functionality (AppModuleBasic) + - inter-dependent module genesis functionality (AppModuleGenesis) + - inter-dependent module simulation functionality (AppModuleSimulation) + - inter-dependent module full functionality (AppModule) inter-dependent module functionality is module functionality which somehow depends on other modules, typically through the module keeper. Many of the @@ -364,19 +364,21 @@ type VersionMap map[string]uint64 // returning RunMigrations should be enough: // // Example: -// cfg := module.NewConfigurator(...) -// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { -// return app.mm.RunMigrations(ctx, cfg, fromVM) -// }) +// +// cfg := module.NewConfigurator(...) +// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { +// return app.mm.RunMigrations(ctx, cfg, fromVM) +// }) // // Internally, RunMigrations will perform the following steps: // - create an `updatedVM` VersionMap of module with their latest ConsensusVersion // - make a diff of `fromVM` and `udpatedVM`, and for each module: -// - if the module's `fromVM` version is less than its `updatedVM` version, -// then run in-place store migrations for that module between those versions. -// - if the module does not exist in the `fromVM` (which means that it's a new module, -// because it was not in the previous x/upgrade's store), then run -// `InitGenesis` on that module. +// - if the module's `fromVM` version is less than its `updatedVM` version, +// then run in-place store migrations for that module between those versions. +// - if the module does not exist in the `fromVM` (which means that it's a new module, +// because it was not in the previous x/upgrade's store), then run +// `InitGenesis` on that module. +// // - return the `updatedVM` to be persisted in the x/upgrade's store. // // Migrations are run in an order defined by `Manager.OrderMigrations` or (if not set) defined by @@ -389,18 +391,19 @@ type VersionMap map[string]uint64 // running anything for foo. // // Example: -// cfg := module.NewConfigurator(...) -// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { -// // Assume "foo" is a new module. -// // `fromVM` is fetched from existing x/upgrade store. Since foo didn't exist -// // before this upgrade, `v, exists := fromVM["foo"]; exists == false`, and RunMigration will by default -// // run InitGenesis on foo. -// // To skip running foo's InitGenesis, you need set `fromVM`'s foo to its latest -// // consensus version: -// fromVM["foo"] = foo.AppModule{}.ConsensusVersion() // -// return app.mm.RunMigrations(ctx, cfg, fromVM) -// }) +// cfg := module.NewConfigurator(...) +// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { +// // Assume "foo" is a new module. +// // `fromVM` is fetched from existing x/upgrade store. Since foo didn't exist +// // before this upgrade, `v, exists := fromVM["foo"]; exists == false`, and RunMigration will by default +// // run InitGenesis on foo. +// // To skip running foo's InitGenesis, you need set `fromVM`'s foo to its latest +// // consensus version: +// fromVM["foo"] = foo.AppModule{}.ConsensusVersion() +// +// return app.mm.RunMigrations(ctx, cfg, fromVM) +// }) // // Please also refer to docs/core/upgrade.md for more information. func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM VersionMap) (VersionMap, error) { diff --git a/types/msgservice/msg_service.go b/types/msgservice/msg_service.go index f8dc5aff5029..65a81c0ddf21 100644 --- a/types/msgservice/msg_service.go +++ b/types/msgservice/msg_service.go @@ -4,7 +4,7 @@ import ( "bytes" "compress/gzip" "fmt" - "io/ioutil" + "io" "reflect" "github.com/gogo/protobuf/proto" @@ -64,7 +64,7 @@ func unzip(b []byte) []byte { panic(err) } - unzipped, err := ioutil.ReadAll(r) + unzipped, err := io.ReadAll(r) if err != nil { panic(err) } diff --git a/types/query/pagination.pb.go b/types/query/pagination.pb.go index 3e7cc5486220..45d700b9f3ce 100644 --- a/types/query/pagination.pb.go +++ b/types/query/pagination.pb.go @@ -25,10 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // PageRequest is to be embedded in gRPC request messages for efficient // pagination. Ex: // -// message SomeRequest { -// Foo some_parameter = 1; -// PageRequest pagination = 2; -// } +// message SomeRequest { +// Foo some_parameter = 1; +// PageRequest pagination = 2; +// } type PageRequest struct { // key is a value returned in PageResponse.next_key to begin // querying the next page most efficiently. Only one of offset or key @@ -123,10 +123,10 @@ func (m *PageRequest) GetReverse() bool { // PageResponse is to be embedded in gRPC response messages where the // corresponding request message has used PageRequest. // -// message SomeResponse { -// repeated Bar results = 1; -// PageResponse page = 2; -// } +// message SomeResponse { +// repeated Bar results = 1; +// PageResponse page = 2; +// } type PageResponse struct { // next_key is the key to be passed to PageRequest.key to // query the next page most efficiently. It will be empty if diff --git a/types/tx/types.go b/types/tx/types.go index 0db3cf9529be..089243e5e9ad 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -13,8 +13,10 @@ import ( const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. -var _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} -var _ sdk.Tx = &Tx{} +var ( + _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _ sdk.Tx = &Tx{} +) // GetMsgs implements the GetMsgs method on sdk.Tx. func (t *Tx) GetMsgs() []sdk.Msg { diff --git a/version/version.go b/version/version.go index cfb37683f12e..a41834e336c2 100644 --- a/version/version.go +++ b/version/version.go @@ -3,17 +3,17 @@ // produces apps versioning information based on flags // passed at compile time. // -// Configure the version command +// # Configure the version command // // The version command can be just added to your cobra root command. // At build time, the variables Name, Version, Commit, and BuildTags // can be passed as build flags as shown in the following example: // -// go build -X github.com/cosmos/cosmos-sdk/version.Name=gaia \ -// -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad \ -// -X github.com/cosmos/cosmos-sdk/version.Version=1.0 \ -// -X github.com/cosmos/cosmos-sdk/version.Commit=f0f7b7dab7e36c20b757cebce0e8f4fc5b95de60 \ -// -X "github.com/cosmos/cosmos-sdk/version.BuildTags=linux darwin amd64" +// go build -X github.com/cosmos/cosmos-sdk/version.Name=gaia \ +// -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad \ +// -X github.com/cosmos/cosmos-sdk/version.Version=1.0 \ +// -X github.com/cosmos/cosmos-sdk/version.Commit=f0f7b7dab7e36c20b757cebce0e8f4fc5b95de60 \ +// -X "github.com/cosmos/cosmos-sdk/version.BuildTags=linux darwin amd64" package version import ( diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 017653dc06b7..0ff3cdaefbf0 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -69,7 +69,8 @@ func TestSimulateGasCost(t *testing.T) { testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()), } - return TestCaseArgs{accNums: []uint64{0, 1, 2}, + return TestCaseArgs{ + accNums: []uint64{0, 1, 2}, accSeqs: []uint64{0, 0, 0}, feeAmount: feeAmount, gasLimit: simulatedGas, @@ -867,7 +868,8 @@ func TestAnteHandlerMultiSigner(t *testing.T) { privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{1, 1, 1} - return TestCaseArgs{accNums: accNums, + return TestCaseArgs{ + accNums: accNums, accSeqs: accSeqs, msgs: msgs, privs: privs, @@ -950,7 +952,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { return TestCaseArgs{ chainID: suite.ctx.ChainID(), accNums: []uint64{0}, - accSeqs: []uint64{2}, //wrong accSeq + accSeqs: []uint64{2}, // wrong accSeq feeAmount: feeAmount, gasLimit: gasLimit, msgs: []sdk.Msg{msg0}, @@ -1018,7 +1020,6 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { msgs: []sdk.Msg{msg0}, privs: []cryptotypes.PrivKey{accs[1].priv}, } - }, false, false, diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index 9729b14c6879..d14b798df1a1 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -31,17 +31,18 @@ func TestDeductFeesNoDelegation(t *testing.T) { valid bool err error malleate func(*AnteTestSuite) (signer TestAccount, feeAcc sdk.AccAddress) - }{"paying with low funds": { - fee: 50, - valid: false, - err: sdkerrors.ErrInsufficientFunds, - malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { - accs := suite.CreateTestAccounts(1) - // 2 calls are needed because we run the ante twice - suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(sdkerrors.ErrInsufficientFunds).Times(2) - return accs[0], nil + }{ + "paying with low funds": { + fee: 50, + valid: false, + err: sdkerrors.ErrInsufficientFunds, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(1) + // 2 calls are needed because we run the ante twice + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(sdkerrors.ErrInsufficientFunds).Times(2) + return accs[0], nil + }, }, - }, "paying with good funds": { fee: 50, valid: true, diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index d996dcc3bddb..93318e7fdb4c 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -52,7 +52,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { key := sdk.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")) - suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) //app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1) + suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) // app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1) suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) maccPerms := map[string][]string{ diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index ab1778bd24cd..510e39ebf4ff 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -238,7 +238,7 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI { } // MarshalAccount protobuf serializes an Account interface -func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { // nolint:interfacer +func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { //nolint:interfacer return ak.cdc.MarshalInterface(accountI) } diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index 6d652a040679..ea7de4247602 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -107,6 +107,7 @@ func (tx StdTx) GetMsgs() []sdk.Msg { return tx.Msgs } // ValidateBasic does a simple and lightweight validation check that doesn't // require access to any other information. +// //nolint:revive // we need to change the receiver name here, because otherwise we conflict with tx.MaxGasWanted. func (stdTx StdTx) ValidateBasic() error { stdSigs := stdTx.GetSignatures() diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index fe23c487e82c..88ee4426413f 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -7,7 +7,7 @@ import ( "strings" gogogrpc "github.com/gogo/protobuf/grpc" - "github.com/golang/protobuf/proto" // nolint: staticcheck + "github.com/golang/protobuf/proto" //nolint: staticcheck "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/auth/types/account.go b/x/auth/types/account.go index a8331c82c8eb..104fe0e4d333 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -26,6 +26,7 @@ var ( ) // NewBaseAccount creates a new BaseAccount object +// //nolint:interfacer func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount { acc := &BaseAccount{ diff --git a/x/auth/types/params.go b/x/auth/types/params.go index a97544e6e6b1..ebfb11ca67c0 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -41,8 +41,10 @@ func DefaultParams() Params { // SigVerifyCostSecp256r1 returns gas fee of secp256r1 signature verification. // Set by benchmarking current implementation: -// BenchmarkSig/secp256k1 4334 277167 ns/op 4128 B/op 79 allocs/op -// BenchmarkSig/secp256r1 10000 108769 ns/op 1672 B/op 33 allocs/op +// +// BenchmarkSig/secp256k1 4334 277167 ns/op 4128 B/op 79 allocs/op +// BenchmarkSig/secp256r1 10000 108769 ns/op 1672 B/op 33 allocs/op +// // Based on the results above secp256k1 is 2.7x is slwer. However we propose to discount it // because we are we don't compare the cgo implementation of secp256k1, which is faster. func (p Params) SigVerifyCostSecp256r1() uint64 { diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 2387513cb3dd..fbce860cede4 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -23,6 +23,7 @@ var _ sdk.Msg = &MsgCreatePermanentLockedAccount{} var _ sdk.Msg = &MsgCreatePeriodicVestingAccount{} // NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount. +// //nolint:interfacer func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount { return &MsgCreateVestingAccount{ @@ -77,6 +78,7 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress { } // NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount. +// //nolint:interfacer func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount { return &MsgCreatePermanentLockedAccount{ @@ -125,6 +127,7 @@ func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress { } // NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount. +// //nolint:interfacer func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount { return &MsgCreatePeriodicVestingAccount{ diff --git a/x/authz/codec/doc.go b/x/authz/codec/doc.go index ecc365a2211b..90ba63f6d690 100644 --- a/x/authz/codec/doc.go +++ b/x/authz/codec/doc.go @@ -6,13 +6,12 @@ can be (de)serialized properly. Amino types should be ideally registered inside this codec within the init function of each module's codec.go file as follows: -func init() { - // ... + func init() { + // ... - RegisterLegacyAminoCodec(authzcodec.Amino) -} + RegisterLegacyAminoCodec(authzcodec.Amino) + } The codec instance is put inside this package and not the x/authz package in order to avoid any dependency cycle. - */ package codec diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index a079b71ddd6c..c4343d18925c 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -15,7 +15,6 @@ import ( // // - 0x01: Grant // - 0x02: GrantQueueItem -// var ( GrantKey = []byte{0x01} // prefix for each key GrantQueuePrefix = []byte{0x02} @@ -78,7 +77,8 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress, // GrantQueueKey - return grant queue store key. If a given grant doesn't have a defined // expiration, then it should not be used in the pruning queue. // Key format is: -// 0x02: GrantQueueItem +// +// 0x02: GrantQueueItem func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte { exp := sdk.FormatTimeBytes(expiration) granter = address.MustLengthPrefix(granter) diff --git a/x/authz/migrations/v046/keys.go b/x/authz/migrations/v046/keys.go index 9b4c74fb9f3d..8754185a7b9b 100644 --- a/x/authz/migrations/v046/keys.go +++ b/x/authz/migrations/v046/keys.go @@ -14,7 +14,6 @@ import ( // // - 0x01: Grant // - 0x02: GrantQueueItem -// var ( GrantPrefix = []byte{0x01} GrantQueuePrefix = []byte{0x02} diff --git a/x/authz/msgs.go b/x/authz/msgs.go index dd8257e16713..f60e53472005 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -28,6 +28,7 @@ var ( ) // NewMsgGrant creates a new MsgGrant +// //nolint:interfacer func NewMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) { m := &MsgGrant{ @@ -118,6 +119,7 @@ func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // NewMsgRevoke creates a new MsgRevoke +// //nolint:interfacer func NewMsgRevoke(granter sdk.AccAddress, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke { return MsgRevoke{ @@ -171,6 +173,7 @@ func (msg MsgRevoke) GetSignBytes() []byte { } // NewMsgExec creates a new MsgExecAuthorized +// //nolint:interfacer func NewMsgExec(grantee sdk.AccAddress, msgs []sdk.Msg) MsgExec { msgsAny := make([]*cdctypes.Any, len(msgs)) diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 5418d6468d45..ab2e0ac845a5 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -26,6 +26,7 @@ var ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials. const ( OpWeightMsgGrant = "op_weight_msg_grant" diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 520861526869..f8ce411b4cbe 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -115,7 +115,8 @@ func NewBaseKeeper( // WithMintCoinsRestriction restricts the bank Keeper used within a specific module to // have restricted permissions on minting via function passed in parameter. // Previous restriction functions can be nested as such: -// bankKeeper.WithMintCoinsRestriction(restriction1).WithMintCoinsRestriction(restriction2) +// +// bankKeeper.WithMintCoinsRestriction(restriction1).WithMintCoinsRestriction(restriction2) func (k BaseKeeper) WithMintCoinsRestriction(check MintingRestrictionFn) BaseKeeper { oldRestrictionFn := k.mintCoinsRestrictionFn k.mintCoinsRestrictionFn = func(ctx sdk.Context, coins sdk.Coins) error { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index a800b19d2387..fd8b4bf46c1c 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -681,8 +681,9 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) newCoins2 := sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) inputs := []banktypes.Input{ - {Address: accAddrs[0].String(), - Coins: coins, + { + Address: accAddrs[0].String(), + Coins: coins, }, } outputs := []banktypes.Output{ diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index e21b5bcef41b..e7f7727c98c9 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -99,6 +99,7 @@ func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) { } // SetParams sets the total set of bank parameters. +// //nolint:staticcheck // params.SendEnabled is deprecated but it should be here regardless. func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { // normally SendEnabled is deprecated but we still support it for backwards compatibility @@ -466,11 +467,12 @@ func (k BaseSendKeeper) GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEn // getSendEnabled returns whether send is enabled and whether that flag was set for a denom. // // Example usage: -// store := ctx.KVStore(k.storeKey) -// sendEnabled, found := getSendEnabled(store, "atom") -// if !found { -// sendEnabled = DefaultSendEnabled -// } +// +// store := ctx.KVStore(k.storeKey) +// sendEnabled, found := getSendEnabled(store, "atom") +// if !found { +// sendEnabled = DefaultSendEnabled +// } func (k BaseSendKeeper) getSendEnabled(store sdk.KVStore, denom string) (bool, bool) { key := types.CreateSendEnabledKey(denom) if !store.Has(key) { diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 86ef2d496a46..fd682faf6323 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -17,6 +17,7 @@ import ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials. const ( OpWeightMsgSend = "op_weight_msg_send" diff --git a/x/bank/types/metadata.go b/x/bank/types/metadata.go index 9583b85ce44d..a6df1bf426e6 100644 --- a/x/bank/types/metadata.go +++ b/x/bank/types/metadata.go @@ -9,12 +9,12 @@ import ( ) // Validate performs a basic validation of the coin metadata fields. It checks: -// - Name and Symbol are not blank -// - Base and Display denominations are valid coin denominations -// - Base and Display denominations are present in the DenomUnit slice -// - Base denomination has exponent 0 -// - Denomination units are sorted in ascending order -// - Denomination units not duplicated +// - Name and Symbol are not blank +// - Base and Display denominations are valid coin denominations +// - Base and Display denominations are present in the DenomUnit slice +// - Base denomination has exponent 0 +// - Denomination units are sorted in ascending order +// - Denomination units not duplicated func (m Metadata) Validate() error { if strings.TrimSpace(m.Name) == "" { return errors.New("name field cannot be blank") diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index 881126f9cbf7..e164c37ca7da 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -20,6 +20,7 @@ var ( ) // NewMsgSend - construct a msg to send coins from one account to another. +// //nolint:interfacer func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgSend { return &MsgSend{FromAddress: fromAddr.String(), ToAddress: toAddr.String(), Amount: amount} @@ -128,6 +129,7 @@ func (in Input) ValidateBasic() error { } // NewInput - create a transaction input, used with MsgMultiSend +// //nolint:interfacer func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input { return Input{ @@ -154,6 +156,7 @@ func (out Output) ValidateBasic() error { } // NewOutput - create a transaction output, used with MsgMultiSend +// //nolint:interfacer func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output { return Output{ diff --git a/x/bank/types/params.go b/x/bank/types/params.go index bd93bf85797c..6c03e2fad72b 100644 --- a/x/bank/types/params.go +++ b/x/bank/types/params.go @@ -52,6 +52,7 @@ func (se SendEnabled) Validate() error { } // validateSendEnabledParams is used by the x/params module to validate the params for the bank module. +// //nolint:deadcode,unused func validateSendEnabledParams(i interface{}) error { params, ok := i.([]*SendEnabled) @@ -87,6 +88,7 @@ func (se SendEnabled) String() string { } // validateSendEnabled is used by the x/params module to validate a single SendEnabled entry. +// //nolint:unused func validateSendEnabled(i interface{}) error { param, ok := i.(SendEnabled) diff --git a/x/bank/types/querier.go b/x/bank/types/querier.go index 117b87f17c68..3ffe7a320fa8 100644 --- a/x/bank/types/querier.go +++ b/x/bank/types/querier.go @@ -14,12 +14,14 @@ const ( ) // NewQueryBalanceRequest creates a new instance of QueryBalanceRequest. +// //nolint:interfacer func NewQueryBalanceRequest(addr sdk.AccAddress, denom string) *QueryBalanceRequest { return &QueryBalanceRequest{Address: addr.String(), Denom: denom} } // NewQueryAllBalancesRequest creates a new instance of QueryAllBalancesRequest. +// //nolint:interfacer func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QueryAllBalancesRequest { return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req} @@ -27,7 +29,8 @@ func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *Qu // NewQuerySpendableBalancesRequest creates a new instance of a // QuerySpendableBalancesRequest. -// nolint:interfacer +// +//nolint:interfacer func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest { return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req} } diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 3143c6a82a74..6ee517769c76 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -25,7 +25,7 @@ func TestSendAuthorization(t *testing.T) { allowList := make([]sdk.AccAddress, 1) allowList[0] = toAddr authorization := types.NewSendAuthorization(coins1000, nil) - + t.Log("verify authorization returns valid method name") require.Equal(t, authorization.MsgTypeURL(), "/cosmos.bank.v1beta1.MsgSend") require.NoError(t, authorization.ValidateBasic()) diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index 02f37af6f912..b7af338a081b 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -14,6 +14,7 @@ const ( var _, _ sdk.Msg = &MsgVerifyInvariant{}, &MsgUpdateParams{} // NewMsgVerifyInvariant creates a new MsgVerifyInvariant object +// //nolint:interfacer func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant { return &MsgVerifyInvariant{ diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index b93e8cf3533f..4a08a1f53acc 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -19,6 +19,7 @@ import ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials. const ( OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" diff --git a/x/distribution/types/distribution.pb.go b/x/distribution/types/distribution.pb.go index 714525f71f09..438535e0f0b0 100644 --- a/x/distribution/types/distribution.pb.go +++ b/x/distribution/types/distribution.pb.go @@ -80,11 +80,12 @@ func (m *Params) GetWithdrawAddrEnabled() bool { // The reference count indicates the number of objects // which might need to reference this historical entry at any point. // ReferenceCount = -// number of outstanding delegations which ended the associated period (and -// might need to read that record) -// + number of slashes which ended the associated period (and might need to -// read that record) -// + one per validator for the zeroeth period, set on initialization +// +// number of outstanding delegations which ended the associated period (and +// might need to read that record) +// + number of slashes which ended the associated period (and might need to +// read that record) +// + one per validator for the zeroeth period, set on initialization type ValidatorHistoricalRewards struct { CumulativeRewardRatio github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=cumulative_reward_ratio,json=cumulativeRewardRatio,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"cumulative_reward_ratio"` ReferenceCount uint32 `protobuf:"varint,2,opt,name=reference_count,json=referenceCount,proto3" json:"reference_count,omitempty"` diff --git a/x/distribution/types/proposal.go b/x/distribution/types/proposal.go index a60291b9eb24..c2b9130b614d 100644 --- a/x/distribution/types/proposal.go +++ b/x/distribution/types/proposal.go @@ -21,6 +21,7 @@ func init() { } // NewCommunityPoolSpendProposal creates a new community pool spend proposal. +// //nolint:interfacer func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) *CommunityPoolSpendProposal { return &CommunityPoolSpendProposal{title, description, recipient.String(), amount} diff --git a/x/distribution/types/query.go b/x/distribution/types/query.go index ef3d34ceae5a..38f6c0a35264 100644 --- a/x/distribution/types/query.go +++ b/x/distribution/types/query.go @@ -32,6 +32,7 @@ func (res QueryDelegatorTotalRewardsResponse) String() string { } // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. +// //nolint:interfacer func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward { return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} diff --git a/x/evidence/keeper/infraction_test.go b/x/evidence/keeper/infraction_test.go index ad9bf8bf8810..8cd9ddbe7702 100644 --- a/x/evidence/keeper/infraction_test.go +++ b/x/evidence/keeper/infraction_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "time" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -18,7 +20,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "time" ) type InfractionTestSuite struct { @@ -38,9 +39,7 @@ type InfractionTestSuite struct { } func (suite *InfractionTestSuite) SetupTest() { - var ( - evidenceKeeper keeper.Keeper - ) + var evidenceKeeper keeper.Keeper app, err := simtestutil.Setup(testutil.AppConfig, &evidenceKeeper, diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 3d3bddefa5b1..8f6ea80087fc 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -3,13 +3,14 @@ package keeper_test import ( "encoding/hex" "fmt" + "time" + "github.com/cosmos/cosmos-sdk/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/evidence" evidencetestutil "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/golang/mock/gomock" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "time" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" diff --git a/x/evidence/types/expected_keepers.go b/x/evidence/types/expected_keepers.go index 93e1ef72dbea..1101b8ae2031 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -1,9 +1,10 @@ package types import ( - "github.com/cosmos/cosmos-sdk/x/auth/types" "time" + "github.com/cosmos/cosmos-sdk/x/auth/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 89b0d414d05d..87c1d261a44f 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -23,6 +23,7 @@ var ( ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. +// //nolint:interfacer func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (*MsgSubmitEvidence, error) { msg, ok := evi.(proto.Message) diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index f8d7823ff06a..f169720cc606 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -11,6 +11,7 @@ import ( var _ types.UnpackInterfacesMessage = &Grant{} // NewGrant creates a new FeeAllowanceGrant. +// //nolint:interfacer func NewGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (Grant, error) { msg, ok := feeAllowance.(proto.Message) diff --git a/x/feegrant/msgs.go b/x/feegrant/msgs.go index 8cdc0f1962eb..864fd7c5e31f 100644 --- a/x/feegrant/msgs.go +++ b/x/feegrant/msgs.go @@ -17,6 +17,7 @@ var ( ) // NewMsgGrantAllowance creates a new MsgGrantAllowance. +// //nolint:interfacer func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error) { msg, ok := feeAllowance.(proto.Message) @@ -93,6 +94,7 @@ func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error // NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given // granter and grantee +// //nolint:interfacer func NewMsgRevokeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeAllowance { return MsgRevokeAllowance{Granter: granter.String(), Grantee: grantee.String()} diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 0bd3993528af..4079a90ef9d4 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -15,6 +15,7 @@ import ( ) // Simulation operation weights constants +// //nolint:gosec // These aren't harcoded credentials. const ( OpWeightMsgGrantAllowance = "op_weight_msg_grant_fee_allowance" diff --git a/x/genutil/doc.go b/x/genutil/doc.go index bccc82a1af00..6aa85b97755b 100644 --- a/x/genutil/doc.go +++ b/x/genutil/doc.go @@ -1,10 +1,10 @@ /* Package genutil contains a variety of genesis utility functionality for usage within a blockchain application. Namely: - - Genesis transactions related (gentx) - - commands for collection and creation of gentxs - - initchain processing of gentxs - - Genesis file validation - - Tendermint related initialization + - Genesis transactions related (gentx) + - commands for collection and creation of gentxs + - initchain processing of gentxs + - Genesis file validation + - Tendermint related initialization */ package genutil diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index fc7f73c1a544..02108ffbace8 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -541,11 +541,11 @@ $ %s query gov params return err } - vp := v1.NewVotingParams(res.Params.VotingPeriod) - res.VotingParams = &vp + vp := v1.NewVotingParams(res.Params.VotingPeriod) //nolint:staticcheck // TODO: refactor to only refer to Params + res.VotingParams = &vp //nolint:staticcheck // TODO: refactor to only refer to Params - tp := v1.NewTallyParams(res.Params.Quorum, res.Params.Threshold, res.Params.VetoThreshold) - res.TallyParams = &tp + tp := v1.NewTallyParams(res.Params.Quorum, res.Params.Threshold, res.Params.VetoThreshold) //nolint:staticcheck // TODO: refactor to only refer to Params + res.TallyParams = &tp //nolint:staticcheck // TODO: refactor to only refer to Params return clientCtx.PrintProto(res) }, @@ -591,11 +591,11 @@ $ %s query gov param deposit var out fmt.Stringer switch args[0] { case "voting": - out = res.GetVotingParams() + out = res.GetVotingParams() //nolint:staticcheck // TODO: refactor to only refer to Params case "tallying": - out = res.GetTallyParams() + out = res.GetTallyParams() //nolint:staticcheck // TODO: refactor to only refer to Params case "deposit": - out = res.GetDepositParams() + out = res.GetDepositParams() //nolint:staticcheck // TODO: refactor to only refer to Params default: return fmt.Errorf("argument must be one of (voting|tallying|deposit), was %s", args[0]) } diff --git a/x/gov/client/testutil/grpc.go b/x/gov/client/testutil/grpc.go index dbcca6ad1188..de1747cc746c 100644 --- a/x/gov/client/testutil/grpc.go +++ b/x/gov/client/testutil/grpc.go @@ -357,9 +357,9 @@ func (s *IntegrationTestSuite) TestGetParamsGRPC() { val := s.network.Validators[0] params := v1.DefaultParams() - dp := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) - vp := v1.NewVotingParams(params.VotingPeriod) - tp := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) + dp := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) //nolint:staticcheck // TODO: refactor to only refer to Params + vp := v1.NewVotingParams(params.VotingPeriod) //nolint:staticcheck // TODO: refactor to only refer to Params + tp := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) //nolint:staticcheck // TODO: refactor to only refer to Params testCases := []struct { name string diff --git a/x/gov/client/testutil/helpers.go b/x/gov/client/testutil/helpers.go index 174d7af0f429..97098783a38e 100644 --- a/x/gov/client/testutil/helpers.go +++ b/x/gov/client/testutil/helpers.go @@ -18,6 +18,7 @@ var commonArgs = []string{ } // MsgSubmitLegacyProposal creates a tx for submit legacy proposal +// //nolint:staticcheck // we are intentionally using a deprecated flag here. func MsgSubmitLegacyProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) { args := append([]string{ diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 4a29424c2295..fc454ce8cbcf 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -58,9 +58,9 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *v1.GenesisState { proposals := k.GetProposals(ctx) params := k.GetParams(ctx) - depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) - votingParams := v1.NewVotingParams(params.VotingPeriod) - tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) + depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) //nolint:staticcheck // TODO: refactor to only refer to Params + votingParams := v1.NewVotingParams(params.VotingPeriod) //nolint:staticcheck // TODO: refactor to only refer to Params + tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) //nolint:staticcheck // TODO: refactor to only refer to Params var proposalsDeposits v1.Deposits var proposalsVotes v1.Votes diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index a8e859798edd..c9f375e8143d 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -162,6 +162,7 @@ func (q Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.Query response := &v1.QueryParamsResponse{} + //nolint:staticcheck // TODO: refactor to only refer to Params switch req.ParamsType { case v1.ParamDeposit: depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) @@ -375,22 +376,21 @@ func (q legacyQueryServer) Params(c context.Context, req *v1beta1.QueryParamsReq resp, err := q.keeper.Params(c, &v1.QueryParamsRequest{ ParamsType: req.ParamsType, }) - if err != nil { return nil, err } response := &v1beta1.QueryParamsResponse{} - + //nolint:staticcheck // TODO: refactor to only refer to Params if resp.DepositParams != nil { minDeposit := sdk.NewCoins(resp.DepositParams.MinDeposit...) response.DepositParams = v1beta1.NewDepositParams(minDeposit, *resp.DepositParams.MaxDepositPeriod) } - + //nolint:staticcheck // TODO: refactor to only refer to Params if resp.VotingParams != nil { response.VotingParams = v1beta1.NewVotingParams(*resp.VotingParams.VotingPeriod) } - + //nolint:staticcheck // TODO: refactor to only refer to Params if resp.TallyParams != nil { quorum, err := sdk.NewDecFromStr(resp.TallyParams.Quorum) if err != nil { diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 5cbb3e78ed12..307152f9633a 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -19,7 +19,7 @@ import ( // Keeper defines the governance module Keeper type Keeper struct { // The reference to the Paramstore to get and set gov specific params - paramSpace types.ParamSubspace + paramSpace types.ParamSubspace //nolint:unused authKeeper types.AccountKeeper bankKeeper types.BankKeeper diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index fc0b92756142..de7eb963fcfa 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -7,12 +7,10 @@ import ( "github.com/armon/go-metrics" + "cosmossdk.io/errors" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -59,7 +57,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos "submit proposal", ) - defer telemetry.IncrCounter(1, types.ModuleName, "proposal") + defer telemetry.IncrCounter(1, govtypes.ModuleName, "proposal") proposer, _ := sdk.AccAddressFromBech32(msg.GetProposer()) votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.Id, proposer, msg.GetInitialDeposit()) @@ -70,14 +68,14 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer()), ), ) if votingStarted { - submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, - sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)), + submitEvent := sdk.NewEvent(govtypes.EventTypeSubmitProposal, + sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)), ) ctx.EventManager().EmitEvent(submitEvent) @@ -93,22 +91,22 @@ func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegac govAcct := k.GetGovernanceAccount(ctx).GetAddress().String() if govAcct != msg.Authority { - return nil, sdkerrors.Wrapf(types.ErrInvalidSigner, "expected %s got %s", govAcct, msg.Authority) + return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "expected %s got %s", govAcct, msg.Authority) } content, err := v1.LegacyContentFromMessage(msg) if err != nil { - return nil, sdkerrors.Wrapf(types.ErrInvalidProposalContent, "%+v", err) + return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "%+v", err) } // Ensure that the content has a respective handler if !k.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) { - return nil, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute()) + return nil, errors.Wrap(govtypes.ErrNoProposalHandlerExists, content.ProposalRoute()) } handler := k.Keeper.legacyRouter.GetRoute(content.ProposalRoute()) if err := handler(ctx, content); err != nil { - return nil, sdkerrors.Wrapf(types.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err) + return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err) } return &v1.MsgExecLegacyContentResponse{}, nil @@ -126,7 +124,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp } defer telemetry.IncrCounterWithLabels( - []string{types.ModuleName, "vote"}, + []string{govtypes.ModuleName, "vote"}, 1, []metrics.Label{ telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), @@ -136,7 +134,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter), ), ) @@ -156,7 +154,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted) } defer telemetry.IncrCounterWithLabels( - []string{types.ModuleName, "vote"}, + []string{govtypes.ModuleName, "vote"}, 1, []metrics.Label{ telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), @@ -166,7 +164,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted) ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter), ), ) @@ -186,7 +184,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe } defer telemetry.IncrCounterWithLabels( - []string{types.ModuleName, "deposit"}, + []string{govtypes.ModuleName, "deposit"}, 1, []metrics.Label{ telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), @@ -196,7 +194,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe ctx.EventManager().EmitEvent( sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor), ), ) @@ -204,8 +202,8 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe if votingStarted { ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeProposalDeposit, - sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)), + govtypes.EventTypeProposalDeposit, + sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)), ), ) } diff --git a/x/gov/keeper/msg_server_test.go b/x/gov/keeper/msg_server_test.go index 3c12cc5ef9b5..ee2ddb040f4c 100644 --- a/x/gov/keeper/msg_server_test.go +++ b/x/gov/keeper/msg_server_test.go @@ -740,7 +740,6 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() { } func (suite *KeeperTestSuite) TestMsgUpdateParams() { - authority := suite.app.GovKeeper.GetAuthority() params := v1.DefaultParams() testCases := []struct { @@ -1015,7 +1014,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() { func (suite *KeeperTestSuite) TestSubmitProposal_InitialDeposit() { const meetsDepositValue = baseDepositTestAmount * baseDepositTestPercent / 100 - var baseDepositRatioDec = sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100)) + baseDepositRatioDec := sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100)) testcases := map[string]struct { minDeposit sdk.Coins diff --git a/x/gov/module.go b/x/gov/module.go index 3aa73ccfb0d3..30c05f8fece4 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -32,7 +32,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/client/cli" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/simulation" - "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -62,7 +61,7 @@ func NewAppModuleBasic(legacyProposalHandlers []govclient.ProposalHandler) AppMo // Name returns the gov module's name. func (AppModuleBasic) Name() string { - return types.ModuleName + return govtypes.ModuleName } // RegisterLegacyAminoCodec registers the gov module's types for the given codec. @@ -81,7 +80,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { var data v1.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + return fmt.Errorf("failed to unmarshal %s genesis state: %w", govtypes.ModuleName, err) } return v1.ValidateGenesis(&data) @@ -128,19 +127,18 @@ type AppModule struct { AppModuleBasic keeper *keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper + accountKeeper govtypes.AccountKeeper + bankKeeper govtypes.BankKeeper // legacySubspace is used solely for migration of x/params managed parameters - legacySubspace types.ParamSubspace + legacySubspace govtypes.ParamSubspace } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper *keeper.Keeper, - ak types.AccountKeeper, bk types.BankKeeper, ss types.ParamSubspace, + ak govtypes.AccountKeeper, bk govtypes.BankKeeper, ss govtypes.ParamSubspace, ) AppModule { - return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -171,12 +169,12 @@ type govInputs struct { MsgServiceRouter *baseapp.MsgServiceRouter Authority map[string]sdk.AccAddress `optional:"true"` - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - StakingKeeper types.StakingKeeper + AccountKeeper govtypes.AccountKeeper + BankKeeper govtypes.BankKeeper + StakingKeeper govtypes.StakingKeeper // LegacySubspace is used solely for migration of x/params managed parameters - LegacySubspace types.ParamSubspace + LegacySubspace govtypes.ParamSubspace } type govOutputs struct { @@ -188,7 +186,7 @@ type govOutputs struct { } func provideModule(in govInputs) govOutputs { - kConfig := types.DefaultConfig() + kConfig := govtypes.DefaultConfig() if in.Config.MaxMetadataLen != 0 { kConfig.MaxMetadataLen = in.Config.MaxMetadataLen } @@ -209,7 +207,7 @@ func provideModule(in govInputs) govOutputs { authority.String(), ) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) - hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: types.RouterKey} + hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: govtypes.RouterKey} return govOutputs{Module: runtime.WrapAppModule(m), Keeper: k, HandlerRoute: hr} } @@ -236,7 +234,7 @@ func invokeAddRoutes(keeper *keeper.Keeper, routes []v1beta1.HandlerRoute) { keeper.SetLegacyRouter(router) } -func invokeSetHooks(keeper *keeper.Keeper, govHooks map[string]types.GovHooksWrapper) error { +func invokeSetHooks(keeper *keeper.Keeper, govHooks map[string]govtypes.GovHooksWrapper) error { if keeper == nil || govHooks == nil { return nil } @@ -247,7 +245,7 @@ func invokeSetHooks(keeper *keeper.Keeper, govHooks map[string]types.GovHooksWra order := modNames sort.Strings(order) - var multiHooks types.MultiGovHooks + var multiHooks govtypes.MultiGovHooks for _, modName := range order { hook, ok := govHooks[modName] if !ok { @@ -262,7 +260,7 @@ func invokeSetHooks(keeper *keeper.Keeper, govHooks map[string]types.GovHooksWra // Name returns the gov module's name. func (AppModule) Name() string { - return types.ModuleName + return govtypes.ModuleName } // RegisterInvariants registers module invariants @@ -273,7 +271,7 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { msgServer := keeper.NewMsgServerImpl(am.keeper) - v1beta1.RegisterMsgServer(cfg.MsgServer(), keeper.NewLegacyMsgServerImpl(am.accountKeeper.GetModuleAddress(types.ModuleName).String(), msgServer)) + v1beta1.RegisterMsgServer(cfg.MsgServer(), keeper.NewLegacyMsgServerImpl(am.accountKeeper.GetModuleAddress(govtypes.ModuleName).String(), msgServer)) v1.RegisterMsgServer(cfg.MsgServer(), msgServer) legacyQueryServer := keeper.NewLegacyQueryServer(am.keeper) @@ -281,15 +279,15 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { v1.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := keeper.NewMigrator(am.keeper, am.legacySubspace) - err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + err := cfg.RegisterMigration(govtypes.ModuleName, 1, m.Migrate1to2) if err != nil { panic(err) } - err = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3) + err = cfg.RegisterMigration(govtypes.ModuleName, 2, m.Migrate2to3) if err != nil { panic(err) } - err = cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4) + err = cfg.RegisterMigration(govtypes.ModuleName, 3, m.Migrate3to4) if err != nil { panic(err) } @@ -343,7 +341,7 @@ func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { // RegisterStoreDecoder registers a decoder for gov module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) + sdr[govtypes.StoreKey] = simulation.NewDecodeStore(am.cdc) } // WeightedOperations returns the all the gov module operations with their respective weights. diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 2bca30c4c12a..bdd53e433f2f 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -28,6 +28,7 @@ var ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hard-coded credentials. const ( OpWeightMsgDeposit = "op_weight_msg_deposit" diff --git a/x/gov/types/v1/deposit.go b/x/gov/types/v1/deposit.go index 5c374919d9ef..a3e601c8dfde 100644 --- a/x/gov/types/v1/deposit.go +++ b/x/gov/types/v1/deposit.go @@ -7,6 +7,7 @@ import ( ) // NewDeposit creates a new Deposit instance +// //nolint:interfacer func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit { return Deposit{proposalID, depositor.String(), amount} diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index 56a48b599f05..ed1aa7820966 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -18,6 +18,7 @@ var ( ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. +// //nolint:interfacer func NewMsgSubmitProposal(messages []sdk.Msg, initialDeposit sdk.Coins, proposer string, metadata string) (*MsgSubmitProposal, error) { m := &MsgSubmitProposal{ @@ -99,6 +100,7 @@ func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err } // NewMsgDeposit creates a new MsgDeposit instance +// //nolint:interfacer func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) *MsgDeposit { return &MsgDeposit{proposalID, depositor.String(), amount} @@ -139,6 +141,7 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress { } // NewMsgVote creates a message to cast a vote on an active proposal +// //nolint:interfacer func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption, metadata string) *MsgVote { return &MsgVote{proposalID, voter.String(), option, metadata} @@ -175,6 +178,7 @@ func (msg MsgVote) GetSigners() []sdk.AccAddress { } // NewMsgVoteWeighted creates a message to cast a vote on an active proposal +// //nolint:interfacer func NewMsgVoteWeighted(voter sdk.AccAddress, proposalID uint64, options WeightedVoteOptions, metadata string) *MsgVoteWeighted { return &MsgVoteWeighted{proposalID, voter.String(), options, metadata} diff --git a/x/gov/types/v1/params.go b/x/gov/types/v1/params.go index 189becbfbc52..6722d49bded4 100644 --- a/x/gov/types/v1/params.go +++ b/x/gov/types/v1/params.go @@ -75,7 +75,6 @@ func DefaultParams() Params { } func (p Params) ValidateBasic() error { - if minDeposit := sdk.Coins(p.MinDeposit); minDeposit.Empty() || !minDeposit.IsValid() { return fmt.Errorf("invalid minimum deposit: %s", minDeposit) } diff --git a/x/gov/types/v1/vote.go b/x/gov/types/v1/vote.go index 64357f54ccae..94d9ab52de62 100644 --- a/x/gov/types/v1/vote.go +++ b/x/gov/types/v1/vote.go @@ -17,6 +17,7 @@ const ( ) // NewVote creates a new Vote instance +// //nolint:interfacer func NewVote(proposalID uint64, voter sdk.AccAddress, options WeightedVoteOptions, metadata string) Vote { return Vote{ProposalId: proposalID, Voter: voter.String(), Options: options, Metadata: metadata} diff --git a/x/gov/types/v1beta1/deposit.go b/x/gov/types/v1beta1/deposit.go index 92d6ab1cb707..23cf422a3a74 100644 --- a/x/gov/types/v1beta1/deposit.go +++ b/x/gov/types/v1beta1/deposit.go @@ -9,6 +9,7 @@ import ( ) // NewDeposit creates a new Deposit instance +// //nolint:interfacer func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit { return Deposit{proposalID, depositor.String(), amount} diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index 6aafbb51da49..85ef0c66eb7d 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -27,6 +27,7 @@ var ( ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. +// //nolint:interfacer func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) { m := &MsgSubmitProposal{ @@ -133,6 +134,7 @@ func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err } // NewMsgDeposit creates a new MsgDeposit instance +// //nolint:interfacer func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) *MsgDeposit { return &MsgDeposit{proposalID, depositor.String(), amount} @@ -178,6 +180,7 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress { } // NewMsgVote creates a message to cast a vote on an active proposal +// //nolint:interfacer func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) *MsgVote { return &MsgVote{proposalID, voter.String(), option} @@ -220,6 +223,7 @@ func (msg MsgVote) GetSigners() []sdk.AccAddress { } // NewMsgVoteWeighted creates a message to cast a vote on an active proposal +// //nolint:interfacer func NewMsgVoteWeighted(voter sdk.AccAddress, proposalID uint64, options WeightedVoteOptions) *MsgVoteWeighted { return &MsgVoteWeighted{proposalID, voter.String(), options} diff --git a/x/gov/types/v1beta1/vote.go b/x/gov/types/v1beta1/vote.go index b2c0469db79b..c5b60b5fc0d9 100644 --- a/x/gov/types/v1beta1/vote.go +++ b/x/gov/types/v1beta1/vote.go @@ -11,6 +11,7 @@ import ( ) // NewVote creates a new Vote instance +// //nolint:interfacer func NewVote(proposalID uint64, voter sdk.AccAddress, options WeightedVoteOptions) Vote { return Vote{ProposalId: proposalID, Voter: voter.String(), Options: options} diff --git a/x/group/client/cli/util.go b/x/group/client/cli/util.go index fccf7626a2df..7afc43873f4b 100644 --- a/x/group/client/cli/util.go +++ b/x/group/client/cli/util.go @@ -3,7 +3,6 @@ package cli import ( "encoding/json" "fmt" - "io/ioutil" "os" "github.com/cosmos/cosmos-sdk/codec" @@ -16,7 +15,7 @@ func parseDecisionPolicy(cdc codec.Codec, decisionPolicyFile string) (group.Deci return nil, fmt.Errorf("decision policy is required") } - contents, err := ioutil.ReadFile(decisionPolicyFile) + contents, err := os.ReadFile(decisionPolicyFile) if err != nil { return nil, err } @@ -36,7 +35,7 @@ func parseMembers(membersFile string) ([]group.MemberRequest, error) { return members.Members, nil } - contents, err := ioutil.ReadFile(membersFile) + contents, err := os.ReadFile(membersFile) if err != nil { return nil, err } diff --git a/x/group/internal/orm/auto_uint64.go b/x/group/internal/orm/auto_uint64.go index 688027268da9..01f1b326d816 100644 --- a/x/group/internal/orm/auto_uint64.go +++ b/x/group/internal/orm/auto_uint64.go @@ -86,12 +86,13 @@ func (a AutoUInt64Table) GetOne(store sdk.KVStore, rowID uint64, dest codec.Prot // WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose // this as an endpoint to the public without further limits. // Example: -// it, err := idx.PrefixScan(ctx, start, end) -// if err !=nil { -// return err -// } -// const defaultLimit = 20 -// it = LimitIterator(it, defaultLimit) +// +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (a AutoUInt64Table) PrefixScan(store sdk.KVStore, start, end uint64) (Iterator, error) { diff --git a/x/group/internal/orm/index.go b/x/group/internal/orm/index.go index f19de60d3e40..2c4cc21911cb 100644 --- a/x/group/internal/orm/index.go +++ b/x/group/internal/orm/index.go @@ -123,12 +123,13 @@ func (i MultiKeyIndex) GetPaginated(store sdk.KVStore, searchKey interface{}, pa // WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose // this as an endpoint to the public without further limits. // Example: -// it, err := idx.PrefixScan(ctx, start, end) -// if err !=nil { -// return err -// } -// const defaultLimit = 20 -// it = LimitIterator(it, defaultLimit) +// +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (i MultiKeyIndex) PrefixScan(store sdk.KVStore, startI interface{}, endI interface{}) (Iterator, error) { @@ -261,12 +262,13 @@ func (i indexIterator) Close() error { // PrefixRange turns a prefix into a (start, end) range. The start is the given prefix value and // the end is calculated by adding 1 bit to the start value. Nil is not allowed as prefix. -// Example: []byte{1, 3, 4} becomes []byte{1, 3, 5} -// []byte{15, 42, 255, 255} becomes []byte{15, 43, 0, 0} +// +// Example: []byte{1, 3, 4} becomes []byte{1, 3, 5} +// []byte{15, 42, 255, 255} becomes []byte{15, 43, 0, 0} // // In case of an overflow the end is set to nil. -// Example: []byte{255, 255, 255, 255} becomes nil // +// Example: []byte{255, 255, 255, 255} becomes nil func PrefixRange(prefix []byte) ([]byte, []byte) { if prefix == nil { panic("nil key not allowed") diff --git a/x/group/internal/orm/iterator.go b/x/group/internal/orm/iterator.go index 71c3b32272ae..11fb4c64a014 100644 --- a/x/group/internal/orm/iterator.go +++ b/x/group/internal/orm/iterator.go @@ -104,10 +104,10 @@ func First(it Iterator, dest codec.ProtoMarshaler) (RowID, error) { // an non-nil pointer to a slice. // // If pageRequest is nil, then we will use these default values: -// - Offset: 0 -// - Key: nil -// - Limit: 100 -// - CountTotal: true +// - Offset: 0 +// - Key: nil +// - Limit: 100 +// - CountTotal: true // // If pageRequest.Key was provided, it got used beforehand to instantiate the Iterator, // using for instance UInt64Index.GetPaginated method. Only one of pageRequest.Offset or @@ -229,10 +229,10 @@ type ModelSlicePtr interface{} // The slice can be empty when the iterator does not return any values but not nil. The iterator // is closed afterwards. // Example: -// var loaded []testdata.GroupInfo -// rowIDs, err := ReadAll(it, &loaded) -// require.NoError(t, err) // +// var loaded []testdata.GroupInfo +// rowIDs, err := ReadAll(it, &loaded) +// require.NoError(t, err) func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { if it == nil { return nil, sdkerrors.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") diff --git a/x/group/internal/orm/key_codec.go b/x/group/internal/orm/key_codec.go index 074b67b3ebc4..2203491e8e8a 100644 --- a/x/group/internal/orm/key_codec.go +++ b/x/group/internal/orm/key_codec.go @@ -14,9 +14,9 @@ const MaxBytesLen = 255 // They can be []byte, string, and integer types. The function will return // an error if there is a part of any other type. // Key parts, except the last part, follow these rules: -// - []byte is encoded with a single byte length prefix -// - strings are null-terminated -// - integers are encoded using 8 byte big endian. +// - []byte is encoded with a single byte length prefix +// - strings are null-terminated +// - integers are encoded using 8 byte big endian. func buildKeyFromParts(parts []interface{}) ([]byte, error) { bytesSlice := make([][]byte, len(parts)) totalLen := 0 diff --git a/x/group/internal/orm/primary_key.go b/x/group/internal/orm/primary_key.go index 7655c5a9d535..5b3f257bb1ff 100644 --- a/x/group/internal/orm/primary_key.go +++ b/x/group/internal/orm/primary_key.go @@ -123,12 +123,13 @@ func (a PrimaryKeyTable) GetOne(store sdk.KVStore, primKey RowID, dest codec.Pro // WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose // this as an endpoint to the public without further limits. // Example: -// it, err := idx.PrefixScan(ctx, start, end) -// if err !=nil { -// return err -// } -// const defaultLimit = 20 -// it = LimitIterator(it, defaultLimit) +// +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (a PrimaryKeyTable) PrefixScan(store sdk.KVStore, start, end []byte) (Iterator, error) { diff --git a/x/group/internal/orm/table.go b/x/group/internal/orm/table.go index 4d6987bd73b2..e21b15ef61bf 100644 --- a/x/group/internal/orm/table.go +++ b/x/group/internal/orm/table.go @@ -192,12 +192,13 @@ func (a table) GetOne(store sdk.KVStore, rowID RowID, dest codec.ProtoMarshaler) // WARNING: The use of a PrefixScan can be very expensive in terms of Gas. Please make sure you do not expose // this as an endpoint to the public without further limits. // Example: -// it, err := idx.PrefixScan(ctx, start, end) -// if err !=nil { -// return err -// } -// const defaultLimit = 20 -// it = LimitIterator(it, defaultLimit) +// +// it, err := idx.PrefixScan(ctx, start, end) +// if err !=nil { +// return err +// } +// const defaultLimit = 20 +// it = LimitIterator(it, defaultLimit) // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (a table) PrefixScan(store sdk.KVStore, start, end RowID) (Iterator, error) { diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 20bd2691050d..d210ff508929 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -42,6 +42,7 @@ var ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials. const ( OpMsgCreateGroup = "op_weight_msg_create_group" diff --git a/x/group/types.pb.go b/x/group/types.pb.go index 5815d7da7138..de8bded11bd9 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -297,10 +297,10 @@ func (m *MemberRequest) GetMetadata() string { // ThresholdDecisionPolicy is a decision policy where a proposal passes when it // satisfies the two following conditions: -// 1. The sum of all `YES` voters' weights is greater or equal than the defined -// `threshold`. -// 2. The voting and execution periods of the proposal respect the parameters -// given by `windows`. +// 1. The sum of all `YES` voters' weights is greater or equal than the defined +// `threshold`. +// 2. The voting and execution periods of the proposal respect the parameters +// given by `windows`. type ThresholdDecisionPolicy struct { // threshold is the minimum weighted sum of `YES` votes that must be met or // exceeded for a proposal to succeed. @@ -358,10 +358,10 @@ func (m *ThresholdDecisionPolicy) GetWindows() *DecisionPolicyWindows { // PercentageDecisionPolicy is a decision policy where a proposal passes when // it satisfies the two following conditions: -// 1. The percentage of all `YES` voters' weights out of the total group weight -// is greater or equal than the given `percentage`. -// 2. The voting and execution periods of the proposal respect the parameters -// given by `windows`. +// 1. The percentage of all `YES` voters' weights out of the total group weight +// is greater or equal than the given `percentage`. +// 2. The voting and execution periods of the proposal respect the parameters +// given by `windows`. type PercentageDecisionPolicy struct { // percentage is the minimum percentage the weighted sum of `YES` votes must // meet for a proposal to succeed. diff --git a/x/simulation/doc.go b/x/simulation/doc.go index 6543bc5c1532..f92a6cac8bab 100644 --- a/x/simulation/doc.go +++ b/x/simulation/doc.go @@ -2,7 +2,7 @@ Package simulation implements a full fledged Cosmos SDK application used for executing simulation test suites. -Simulation App +# Simulation App The SimApp type defines an application used for running extensive simulation testing suites. It contains all core modules, including governance, staking, @@ -30,7 +30,7 @@ still be pseudo-randomly simulated. The simulation test suite also supports testing determinism and import/export functionality. -Randomness +# Randomness Currently, simulation uses a single seed (integer) as a source for a PRNG by which all random operations are executed from. Any call to the PRNG changes all @@ -44,75 +44,74 @@ the simulation suite is expected to support a series of PRNGs that can be used uniquely per module and simulation component so that they will not effect each others state execution outcome. -Usage +# Usage To execute a completely pseudo-random simulation: - $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ - -run=TestFullAppSimulation \ - -Enabled=true \ - -NumBlocks=100 \ - -BlockSize=200 \ - -Commit=true \ - -Seed=99 \ - -Period=5 \ - -v -timeout 24h + $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ + -run=TestFullAppSimulation \ + -Enabled=true \ + -NumBlocks=100 \ + -BlockSize=200 \ + -Commit=true \ + -Seed=99 \ + -Period=5 \ + -v -timeout 24h To execute simulation from a genesis file: - $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ - -run=TestFullAppSimulation \ - -Enabled=true \ - -NumBlocks=100 \ - -BlockSize=200 \ - -Commit=true \ - -Seed=99 \ - -Period=5 \ - -Genesis=/path/to/genesis.json \ - -v -timeout 24h + $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ + -run=TestFullAppSimulation \ + -Enabled=true \ + -NumBlocks=100 \ + -BlockSize=200 \ + -Commit=true \ + -Seed=99 \ + -Period=5 \ + -Genesis=/path/to/genesis.json \ + -v -timeout 24h To execute simulation from a simulation params file: - $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ - -run=TestFullAppSimulation \ - -Enabled=true \ - -NumBlocks=100 \ - -BlockSize=200 \ - -Commit=true \ - -Seed=99 \ - -Period=5 \ - -Params=/path/to/params.json \ - -v -timeout 24h + $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ + -run=TestFullAppSimulation \ + -Enabled=true \ + -NumBlocks=100 \ + -BlockSize=200 \ + -Commit=true \ + -Seed=99 \ + -Period=5 \ + -Params=/path/to/params.json \ + -v -timeout 24h To export the simulation params to a file at a given block height: - $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ - -run=TestFullAppSimulation \ - -Enabled=true \ - -NumBlocks=100 \ - -BlockSize=200 \ - -Commit=true \ - -Seed=99 \ - -Period=5 \ - -ExportParamsPath=/path/to/params.json \ - -ExportParamsHeight=50 \ - -v -timeout 24h - + $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ + -run=TestFullAppSimulation \ + -Enabled=true \ + -NumBlocks=100 \ + -BlockSize=200 \ + -Commit=true \ + -Seed=99 \ + -Period=5 \ + -ExportParamsPath=/path/to/params.json \ + -ExportParamsHeight=50 \ + -v -timeout 24h To export the simulation app state (i.e genesis) to a file: - $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ - -run=TestFullAppSimulation \ - -Enabled=true \ - -NumBlocks=100 \ - -BlockSize=200 \ - -Commit=true \ - -Seed=99 \ - -Period=5 \ - -ExportStatePath=/path/to/genesis.json \ - v -timeout 24h - -Params + $ go test -mod=readonly github.com/cosmos/cosmos-sdk/simapp \ + -run=TestFullAppSimulation \ + -Enabled=true \ + -NumBlocks=100 \ + -BlockSize=200 \ + -Commit=true \ + -Seed=99 \ + -Period=5 \ + -ExportStatePath=/path/to/genesis.json \ + v -timeout 24h + +# Params Params that are provided to simulation from a JSON file are used to used to set both module parameters and simulation parameters. See sim_test.go for the full diff --git a/x/simulation/util.go b/x/simulation/util.go index 534b984566b0..f65a3f035b2d 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -30,9 +30,9 @@ func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B // getBlockSize returns a block size as determined from the transition matrix. // It targets making average block size the provided parameter. The three // states it moves between are: -// - "over stuffed" blocks with average size of 2 * avgblocksize, -// - normal sized blocks, hitting avgBlocksize on average, -// - and empty blocks, with no txs / only txs scheduled from the past. +// - "over stuffed" blocks with average size of 2 * avgblocksize, +// - normal sized blocks, hitting avgBlocksize on average, +// - and empty blocks, with no txs / only txs scheduled from the past. func getBlockSize(r *rand.Rand, params Params, lastBlockSizeState, avgBlockSize int) (state, blockSize int) { // TODO: Make default blocksize transition matrix actually make the average // blocksize equal to avgBlockSize. diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index e7e5b8289d49..26228fa88283 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -18,6 +18,7 @@ import ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials. const ( OpWeightMsgUnjail = "op_weight_msg_unjail" diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index a4b893708153..c3756eb0580f 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -17,6 +17,7 @@ var ( ) // NewMsgUnjail creates a new MsgUnjail instance +// //nolint:interfacer func NewMsgUnjail(validatorAddr sdk.ValAddress) *MsgUnjail { return &MsgUnjail{ diff --git a/x/slashing/types/signing_info.go b/x/slashing/types/signing_info.go index d9b00da199e6..3dacd12d630c 100644 --- a/x/slashing/types/signing_info.go +++ b/x/slashing/types/signing_info.go @@ -9,6 +9,7 @@ import ( ) // NewValidatorSigningInfo creates a new ValidatorSigningInfo instance +// //nolint:interfacer func NewValidatorSigningInfo( condAddr sdk.ConsAddress, startHeight, indexOffset int64, diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index 23c466d377fb..a74c14978954 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -317,8 +317,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { require.True(math.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) } -//// test undelegating self delegation from a validator pushing it below MinSelfDelegation -//// shift it from the bonded to unbonding state and jailed +// // test undelegating self delegation from a validator pushing it below MinSelfDelegation +// // shift it from the bonded to unbonding state and jailed func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { _, app, ctx := createTestInput(t) diff --git a/x/staking/keeper/historical_info.go b/x/staking/keeper/historical_info.go index df13dff357f1..243612d38743 100644 --- a/x/staking/keeper/historical_info.go +++ b/x/staking/keeper/historical_info.go @@ -35,7 +35,9 @@ func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { } // IterateHistoricalInfo provides an interator over all stored HistoricalInfo -// objects. For each HistoricalInfo object, cb will be called. If the cb returns +// +// objects. For each HistoricalInfo object, cb will be called. If the cb returns +// // true, the iterator will close and stop. func (k Keeper) IterateHistoricalInfo(ctx sdk.Context, cb func(types.HistoricalInfo) bool) { store := ctx.KVStore(k.storeKey) diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 9d892b18c432..c0a147510963 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -14,15 +14,22 @@ import ( // of it, updating unbonding delegations & redelegations appropriately // // CONTRACT: -// slashFactor is non-negative +// +// slashFactor is non-negative +// // CONTRACT: -// Infraction was committed equal to or less than an unbonding period in the past, -// so all unbonding delegations and redelegations from that height are stored +// +// Infraction was committed equal to or less than an unbonding period in the past, +// so all unbonding delegations and redelegations from that height are stored +// // CONTRACT: -// Slash will not slash unbonded validators (for the above reason) +// +// Slash will not slash unbonded validators (for the above reason) +// // CONTRACT: -// Infraction was committed at the current height or at a past height, -// not at a height in the future +// +// Infraction was committed at the current height or at a past height, +// not at a height in the future func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int { logger := k.Logger(ctx) diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 28704a13b843..542536fc8e82 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -16,6 +16,7 @@ import ( ) // Simulation operation weights constants +// //nolint:gosec // these are not hardcoded credentials const ( OpWeightMsgCreateValidator = "op_weight_msg_create_validator" diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index b86f1a179950..cad8f5f0d497 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -28,6 +28,7 @@ func (dvv DVVTriplet) String() string { } // NewDelegation creates a new delegation object +// //nolint:interfacer func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, shares sdk.Dec) Delegation { return Delegation{ @@ -112,6 +113,7 @@ func (e UnbondingDelegationEntry) IsMature(currentTime time.Time) bool { } // NewUnbondingDelegation - create a new unbonding delegation object +// //nolint:interfacer func NewUnbondingDelegation( delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, @@ -333,6 +335,7 @@ func (d DelegationResponses) String() (out string) { } // NewRedelegationResponse crates a new RedelegationEntryResponse instance. +// //nolint:interfacer func NewRedelegationResponse( delegatorAddr sdk.AccAddress, validatorSrc, validatorDst sdk.ValAddress, entries []RedelegationEntryResponse, diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 32d5ea72f221..e72e68a03963 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -141,6 +141,7 @@ func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) } // NewMsgEditValidator creates a new MsgEditValidator instance +// //nolint:interfacer func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec, newMinSelfDelegation *math.Int) *MsgEditValidator { return &MsgEditValidator{ @@ -196,6 +197,7 @@ func (msg MsgEditValidator) ValidateBasic() error { } // NewMsgDelegate creates a new MsgDelegate instance. +// //nolint:interfacer func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgDelegate { return &MsgDelegate{ @@ -243,6 +245,7 @@ func (msg MsgDelegate) ValidateBasic() error { } // NewMsgBeginRedelegate creates a new MsgBeginRedelegate instance. +// //nolint:interfacer func NewMsgBeginRedelegate( delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount sdk.Coin, @@ -296,6 +299,7 @@ func (msg MsgBeginRedelegate) ValidateBasic() error { } // NewMsgUndelegate creates a new MsgUndelegate instance. +// //nolint:interfacer func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgUndelegate { return &MsgUndelegate{ @@ -343,6 +347,7 @@ func (msg MsgUndelegate) ValidateBasic() error { } // NewMsgCancelUnbondingDelegation creates a new MsgCancelUnbondingDelegation instance. +// //nolint:interfacer func NewMsgCancelUnbondingDelegation(delAddr sdk.AccAddress, valAddr sdk.ValAddress, creationHeight int64, amount sdk.Coin) *MsgCancelUnbondingDelegation { return &MsgCancelUnbondingDelegation{ diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index ffc861bafd96..434589554b91 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -39,6 +39,7 @@ var ( var _ ValidatorI = Validator{} // NewValidator constructs a new Validator +// //nolint:interfacer func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, description Description) (Validator, error) { pkAny, err := codectypes.NewAnyWithValue(pubKey) @@ -416,7 +417,8 @@ func (v Validator) RemoveTokens(tokens math.Int) Validator { // RemoveDelShares removes delegator shares from a validator. // NOTE: because token fractions are left in the valiadator, -// the exchange rate of future shares of this validator can increase. +// +// the exchange rate of future shares of this validator can increase. func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, math.Int) { remainingShares := v.DelegatorShares.Sub(delShares) diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index 1bcfe0a8fcef..7f6490f1277f 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -42,7 +42,6 @@ type TestSuite struct { var s TestSuite func setupTest(t *testing.T, height int64, skip map[int64]bool) TestSuite { - s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) key := sdk.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) diff --git a/x/upgrade/doc.go b/x/upgrade/doc.go index b66fe38c1db0..5589ac6eda92 100644 --- a/x/upgrade/doc.go +++ b/x/upgrade/doc.go @@ -7,7 +7,7 @@ Without software support for upgrades, upgrading a live chain is risky because a their state machines at exactly the same point in the process. If this is not done correctly, there can be state inconsistencies which are hard to recover from. -General Workflow +# General Workflow Let's assume we are running v0.38.0 of our software in our testnet and want to upgrade to v0.40.0. How would this look in practice? First of all, we want to finalize the v0.40.0 release candidate @@ -40,25 +40,27 @@ the rest of the block as normal. Once 2/3 of the voting power has upgraded, the resume the consensus mechanism. If the majority of operators add a custom `do-upgrade` script, this should be a matter of minutes and not even require them to be awake at that time. -Integrating With An App +# Integrating With An App Setup an upgrade Keeper for the app and then define a BeginBlocker that calls the upgrade keeper's BeginBlocker method: - func (app *myApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - app.upgradeKeeper.BeginBlocker(ctx, req) - return abci.ResponseBeginBlock{} - } + + func (app *myApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + app.upgradeKeeper.BeginBlocker(ctx, req) + return abci.ResponseBeginBlock{} + } The app must then integrate the upgrade keeper with its governance module as appropriate. The governance module should call ScheduleUpgrade to schedule an upgrade and ClearUpgradePlan to cancel a pending upgrade. -Performing Upgrades +# Performing Upgrades Upgrades can be scheduled at a predefined block height. Once this block height is reached, the existing software will cease to process ABCI messages and a new version with code that handles the upgrade must be deployed. All upgrades are coordinated by a unique upgrade name that cannot be reused on the same blockchain. In order for the upgrade module to know that the upgrade has been safely applied, a handler with the name of the upgrade must be installed. Here is an example handler for an upgrade named "my-fancy-upgrade": + app.upgradeKeeper.SetUpgradeHandler("my-fancy-upgrade", func(ctx sdk.Context, plan upgrade.Plan) { // Perform any migrations of the state store needed for this upgrade }) @@ -93,18 +95,20 @@ Here is a sample code to set store migrations with an upgrade: app.SetStoreLoader(upgrade.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } -Halt Behavior +# Halt Behavior Before halting the ABCI state machine in the BeginBlocker method, the upgrade module will log an error that looks like: + UPGRADE "" NEEDED at height : + where Name are Info are the values of the respective fields on the upgrade Plan. To perform the actual halt of the blockchain, the upgrade keeper simply panics which prevents the ABCI state machine from proceeding but doesn't actually exit the process. Exiting the process can cause issues for other nodes that start to lose connectivity with the exiting nodes, thus this module prefers to just halt but not exit. -Automation and Plan.Info +# Automation and Plan.Info We have deprecated calling out to scripts, instead with propose https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor as a model for a watcher daemon that can launch simd as a subprocess and then read the upgrade log message @@ -113,7 +117,7 @@ specified here https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor/README. This will allow a properly configured cosmsod daemon to auto-download new binaries and auto-upgrade. As noted there, this is intended more for full nodes than validators. -Cancelling Upgrades +# Cancelling Upgrades There are two ways to cancel a planned upgrade - with on-chain governance or off-chain social consensus. For the first one, there is a CancelSoftwareUpgrade proposal type, which can be voted on and will @@ -134,6 +138,7 @@ If over two-thirds run their nodes with this flag on the old binary, it will all the upgrade with a manual override. (This must be well-documented for anyone syncing from genesis later on). Example: + simd start --unsafe-skip-upgrades ... NOTE: Here simd is used as an example binary, replace it with original binary diff --git a/x/upgrade/handler.go b/x/upgrade/handler.go index f880cd7f9ec8..d866f8e4f2b1 100644 --- a/x/upgrade/handler.go +++ b/x/upgrade/handler.go @@ -11,7 +11,7 @@ import ( // NewSoftwareUpgradeProposalHandler creates a governance handler to manage new proposal types. // It enables SoftwareUpgradeProposal to propose an Upgrade, and CancelSoftwareUpgradeProposal // to abort a previously voted upgrade. -//nolint: staticcheck // we are intentionally using a deprecated proposal here. +// nolint: staticcheck // we are intentionally using a deprecated proposal here. func NewSoftwareUpgradeProposalHandler(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 6c98948411fa..41f904ccbede 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -30,7 +30,6 @@ type UpgradeTestSuite struct { } func (suite *UpgradeTestSuite) SetupTest() { - suite.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) key := sdk.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index f087f12910fa..795724c1435e 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -35,7 +35,6 @@ type KeeperTestSuite struct { } func (s *KeeperTestSuite) SetupTest() { - s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) key := sdk.NewKVStoreKey(types.StoreKey) testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) diff --git a/x/upgrade/plan/downloader.go b/x/upgrade/plan/downloader.go index 7686b7aec823..d09d4725b8ea 100644 --- a/x/upgrade/plan/downloader.go +++ b/x/upgrade/plan/downloader.go @@ -17,8 +17,10 @@ import ( // This is an opinionated directory structure that corresponds with Cosmovisor requirements. // If the url is not an archive, it is downloaded and saved to {dstRoot}/bin/{daemonName}. // If the url is an archive, it is downloaded and unpacked to {dstRoot}. -// If the archive does not contain a /bin/{daemonName} file, then this will attempt to move /{daemonName} to /bin/{daemonName}. -// If the archive does not contain either /bin/{daemonName} or /{daemonName}, an error is returned. +// +// If the archive does not contain a /bin/{daemonName} file, then this will attempt to move /{daemonName} to /bin/{daemonName}. +// If the archive does not contain either /bin/{daemonName} or /{daemonName}, an error is returned. +// // Note: Because a checksum is required, this function cannot be used to download non-archive directories. // If dstRoot already exists, some or all of its contents might be updated. func DownloadUpgrade(dstRoot, url, daemonName string) error { @@ -74,9 +76,9 @@ func downloadUpgradeAsArchive(dstDir, url, daemonName string) error { // EnsureBinary checks that the given file exists as a regular file and is executable. // An error is returned if: -// - The file does not exist. -// - The path exists, but is one of: Dir, Symlink, NamedPipe, Socket, Device, CharDevice, or Irregular. -// - The file exists, is not executable by all three of User, Group, and Other, and cannot be made executable. +// - The file does not exist. +// - The path exists, but is one of: Dir, Symlink, NamedPipe, Socket, Device, CharDevice, or Irregular. +// - The file exists, is not executable by all three of User, Group, and Other, and cannot be made executable. func EnsureBinary(path string) error { info, err := os.Stat(path) if err != nil { @@ -99,11 +101,11 @@ func EnsureBinary(path string) error { // The provided url must contain a checksum parameter that matches the file being downloaded. // If there isn't an error, the content returned by the url will be returned as a string. // Returns an error if: -// - The url is not a URL or does not contain a checksum parameter. -// - Downloading the URL fails. -// - The checksum does not match what is returned by the URL. -// - The URL does not return a regular file. -// - The downloaded file is empty or only whitespace. +// - The url is not a URL or does not contain a checksum parameter. +// - Downloading the URL fails. +// - The checksum does not match what is returned by the URL. +// - The URL does not return a regular file. +// - The downloaded file is empty or only whitespace. func DownloadURLWithChecksum(url string) (string, error) { if err := ValidateIsURLWithChecksum(url); err != nil { return "", err diff --git a/x/upgrade/plan/info.go b/x/upgrade/plan/info.go index 9661844c2cde..c29ec2ab5a06 100644 --- a/x/upgrade/plan/info.go +++ b/x/upgrade/plan/info.go @@ -50,8 +50,9 @@ func ParseInfo(infoStr string) (*Info, error) { // ValidateFull does all possible validation of this Info. // The provided daemonName is the name of the executable file expected in all downloaded directories. // It checks that: -// * Binaries.ValidateBasic() doesn't return an error -// * Binaries.CheckURLs(daemonName) doesn't return an error. +// - Binaries.ValidateBasic() doesn't return an error +// - Binaries.CheckURLs(daemonName) doesn't return an error. +// // Warning: This is an expensive process. See BinaryDownloadURLMap.CheckURLs for more info. func (m Info) ValidateFull(daemonName string) error { if err := m.Binaries.ValidateBasic(); err != nil { @@ -65,10 +66,10 @@ func (m Info) ValidateFull(daemonName string) error { // ValidateBasic does stateless validation of this BinaryDownloadURLMap. // It validates that: -// * This has at least one entry. -// * All entry keys have the format "os/arch" or are "any". -// * All entry values are valid URLs. -// * All URLs contain a checksum query parameter. +// - This has at least one entry. +// - All entry keys have the format "os/arch" or are "any". +// - All entry values are valid URLs. +// - All URLs contain a checksum query parameter. func (m BinaryDownloadURLMap) ValidateBasic() error { // Make sure there's at least one. if len(m) == 0 {