diff --git a/CHANGELOG.md b/CHANGELOG.md index cdcfd8133013..aabdda6c10a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,6 +119,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### API Breaking Changes +* (types)[#20369](https://github.com/cosmos/cosmos-sdk/pull/20369) The signature of `HasAminoCodec` has changed to accept a `core/legacy.Amino` interface instead of `codec.LegacyAmino`. * (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument. * (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`. * (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes: diff --git a/UPGRADING.md b/UPGRADING.md index 84374275e84a..3ae40ff63338 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -186,6 +186,13 @@ The signature of the extension interface `HasRegisterInterfaces` has been change +func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) { ``` +The signature of the extension interface `HasAminoCodec` has been changed to accept a `cosmossdk.io/core/legacy.Amino` instead of a `codec.LegacyAmino`. Modules should update their `HasAminoCodec` implementation to accept a `cosmossdk.io/core/legacy.Amino` interface. + +```diff +-func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { ++func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { +``` + ##### Simulation `MsgSimulatorFn` has been updated to return an error. Its context argument has been removed, and an address.Codec has diff --git a/baseapp/abci.go b/baseapp/abci.go index 7e83e68fc012..d0fb4b6c0985 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -2,12 +2,12 @@ package baseapp import ( "context" + "errors" "fmt" "sort" "strings" "time" - "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" "github.com/cosmos/gogoproto/proto" diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index c1fffef636eb..7c9aac3202a1 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -3,10 +3,10 @@ package baseapp import ( "bytes" "context" + "errors" "fmt" "slices" - "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" cryptoenc "github.com/cometbft/cometbft/crypto/encoding" diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index ba0c43cfd1f3..719eff6a2476 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -2,13 +2,13 @@ package baseapp import ( "context" + "errors" "fmt" "math" "sort" "strconv" "sync" - "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" "github.com/cometbft/cometbft/crypto/tmhash" diff --git a/client/cmd.go b/client/cmd.go index d4f0693d7e4a..3fc29ad62be7 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -3,11 +3,11 @@ package client import ( "context" "crypto/tls" + "errors" "fmt" "slices" "strings" - "github.com/cockroachdb/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" "google.golang.org/grpc" diff --git a/client/query.go b/client/query.go index 9e8fd30db71f..a90f80e79fa4 100644 --- a/client/query.go +++ b/client/query.go @@ -2,10 +2,10 @@ package client import ( "context" + "errors" "fmt" "strings" - "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" rpcclient "github.com/cometbft/cometbft/rpc/client" "google.golang.org/grpc/codes" diff --git a/client/v2/autocli/flag/binary.go b/client/v2/autocli/flag/binary.go index a1a93179f290..fc954d763148 100644 --- a/client/v2/autocli/flag/binary.go +++ b/client/v2/autocli/flag/binary.go @@ -4,9 +4,9 @@ import ( "context" "encoding/base64" "encoding/hex" + "errors" "os" - "github.com/cockroachdb/errors" "google.golang.org/protobuf/reflect/protoreflect" ) diff --git a/client/v2/autocli/flag/map.go b/client/v2/autocli/flag/map.go index c2f512503dfa..f6b21f8a963a 100644 --- a/client/v2/autocli/flag/map.go +++ b/client/v2/autocli/flag/map.go @@ -2,10 +2,10 @@ package flag import ( "context" + "errors" "fmt" "strings" - "github.com/cockroachdb/errors" "github.com/spf13/pflag" "google.golang.org/protobuf/reflect/protoreflect" diff --git a/client/v2/autocli/flag/maps/generic.go b/client/v2/autocli/flag/maps/generic.go index 3d610bf9a062..1a734faf0bb7 100644 --- a/client/v2/autocli/flag/maps/generic.go +++ b/client/v2/autocli/flag/maps/generic.go @@ -1,9 +1,8 @@ package maps import ( + "fmt" "strings" - - "github.com/cockroachdb/errors" ) type genericMapValueOptions[K comparable, V any] struct { @@ -31,7 +30,7 @@ func (gm *genericMapValue[K, V]) Set(val string) error { for _, pair := range ss { kv := strings.SplitN(pair, "=", 2) if len(kv) != 2 { - return errors.Errorf("%s must be formatted as key=value", pair) + return fmt.Errorf("%s must be formatted as key=value", pair) } key, err := gm.Options.keyParser(kv[0]) if err != nil { diff --git a/client/v2/autocli/msg.go b/client/v2/autocli/msg.go index 797c4c417348..25e7bbfa3c6d 100644 --- a/client/v2/autocli/msg.go +++ b/client/v2/autocli/msg.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/cockroachdb/errors" gogoproto "github.com/cosmos/gogoproto/proto" "github.com/spf13/cobra" "google.golang.org/protobuf/proto" @@ -69,7 +68,7 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc descriptor, err := b.FileResolver.FindDescriptorByName(protoreflect.FullName(cmdDescriptor.Service)) if err != nil { - return errors.Errorf("can't find service %s: %v", cmdDescriptor.Service, err) + return fmt.Errorf("can't find service %s: %w", cmdDescriptor.Service, err) } service := descriptor.(protoreflect.ServiceDescriptor) methods := service.Methods() diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index ace56f459c90..161abd75867e 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -10,7 +10,7 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/math" "cosmossdk.io/x/tx/signing/aminojson" - "github.com/cockroachdb/errors" + "github.com/spf13/cobra" "google.golang.org/protobuf/reflect/protoreflect" @@ -62,7 +62,7 @@ func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *aut descriptor, err := b.FileResolver.FindDescriptorByName(protoreflect.FullName(cmdDescriptor.Service)) if err != nil { - return errors.Errorf("can't find service %s: %v", cmdDescriptor.Service, err) + return fmt.Errorf("can't find service %s: %w", cmdDescriptor.Service, err) } service := descriptor.(protoreflect.ServiceDescriptor) diff --git a/client/v2/go.mod b/client/v2/go.mod index 1be5cc04ecf8..8a92728f702e 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -10,7 +10,7 @@ require ( cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/tx v0.13.3 github.com/chzyer/readline v1.5.1 // indirect - github.com/cockroachdb/errors v1.11.1 + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.51.0 github.com/manifoldco/promptui v0.9.0 // indirect diff --git a/codec/amino.go b/codec/amino.go index 6d4b70bb5736..7dcdb844d518 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -10,6 +10,8 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/tendermint/go-amino" + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -23,15 +25,17 @@ func (cdc *LegacyAmino) Seal() { cdc.Amino.Seal() } +var _ legacy.Amino = &LegacyAmino{} + func NewLegacyAmino() *LegacyAmino { return &LegacyAmino{amino.NewCodec()} } // RegisterEvidences registers CometBFT evidence types with the provided Amino // codec. -func RegisterEvidences(cdc *LegacyAmino) { - cdc.Amino.RegisterInterface((*cmttypes.Evidence)(nil), nil) - cdc.Amino.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence", nil) +func RegisterEvidences(cdc legacy.Amino) { + cdc.RegisterInterface((*cmttypes.Evidence)(nil), nil) + cdc.RegisterConcrete(&cmttypes.DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence") } // MarshalJSONIndent provides a utility for indented JSON encoding of an object @@ -175,12 +179,19 @@ func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error { return errors.New("AminoCodec can't handle unpack protobuf Any's") } -func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions) { - cdc.Amino.RegisterInterface(ptr, iopts) +func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *legacy.InterfaceOptions) { + if iopts == nil { + cdc.Amino.RegisterInterface(ptr, nil) + } else { + cdc.Amino.RegisterInterface(ptr, &amino.InterfaceOptions{ + Priority: iopts.Priority, + AlwaysDisambiguate: iopts.AlwaysDisambiguate, + }) + } } -func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions) { - cdc.Amino.RegisterConcrete(o, name, copts) +func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string) { + cdc.Amino.RegisterConcrete(o, name, nil) } func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) { diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index 24b612496572..63df85e83782 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -17,8 +17,8 @@ func createTestCodec() *codec.LegacyAmino { cdc.RegisterInterface((*testdata.Animal)(nil), nil) // NOTE: since we unmarshal interface using pointers, we need to register a pointer // types here. - cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog", nil) - cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat", nil) + cdc.RegisterConcrete(&testdata.Dog{}, "testdata/Dog") + cdc.RegisterConcrete(&testdata.Cat{}, "testdata/Cat") return cdc } diff --git a/codec/depinject.go b/codec/depinject.go new file mode 100644 index 000000000000..3414a7933a49 --- /dev/null +++ b/codec/depinject.go @@ -0,0 +1,47 @@ +package codec + +import ( + "github.com/cosmos/gogoproto/proto" + + "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" + "cosmossdk.io/x/tx/signing" + + "github.com/cosmos/cosmos-sdk/codec/types" +) + +func ProvideInterfaceRegistry( + addressCodec address.Codec, + validatorAddressCodec address.ValidatorAddressCodec, + customGetSigners []signing.CustomGetSigner, +) (types.InterfaceRegistry, error) { + signingOptions := signing.Options{ + AddressCodec: addressCodec, + ValidatorAddressCodec: validatorAddressCodec, + } + for _, signer := range customGetSigners { + signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn) + } + + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signingOptions, + }) + if err != nil { + return nil, err + } + + if err := interfaceRegistry.SigningContext().Validate(); err != nil { + return nil, err + } + + return interfaceRegistry, nil +} + +func ProvideLegacyAmino() legacy.Amino { + return NewLegacyAmino() +} + +func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec { + return NewProtoCodec(interfaceRegistry) +} diff --git a/codec/legacy/amino_msg.go b/codec/legacy/amino_msg.go index 58a02bed7b21..a3aca8e7a139 100644 --- a/codec/legacy/amino_msg.go +++ b/codec/legacy/amino_msg.go @@ -3,16 +3,17 @@ package legacy import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" + sdk "github.com/cosmos/cosmos-sdk/types" ) // RegisterAminoMsg first checks that the msgName is <40 chars // (else this would break ledger nano signing: https://github.com/cosmos/cosmos-sdk/issues/10870), // then registers the concrete msg type with amino. -func RegisterAminoMsg(cdc *codec.LegacyAmino, msg sdk.Msg, msgName string) { +func RegisterAminoMsg(cdc legacy.Amino, msg sdk.Msg, msgName string) { if len(msgName) > 39 { panic(fmt.Errorf("msg name %s is too long to be registered with amino", msgName)) } - cdc.RegisterConcrete(msg, msgName, nil) + cdc.RegisterConcrete(msg, msgName) } diff --git a/core/legacy/amino.go b/core/legacy/amino.go new file mode 100644 index 000000000000..63ae965ee03e --- /dev/null +++ b/core/legacy/amino.go @@ -0,0 +1,14 @@ +package legacy + +type Amino interface { + // RegisterInterface registers an interface and its concrete type with the Amino codec. + RegisterInterface(interfacePtr any, iopts *InterfaceOptions) + + // RegisterConcrete registers a concrete type with the Amino codec. + RegisterConcrete(cdcType interface{}, name string) +} + +type InterfaceOptions struct { + Priority []string // Disamb priority. + AlwaysDisambiguate bool // If true, include disamb for all types. +} diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 988c17ba1976..2c83723a6d48 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -3,7 +3,8 @@ package codec import ( "github.com/cometbft/cometbft/crypto/sr25519" - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -12,22 +13,22 @@ import ( // RegisterCrypto registers all crypto dependency types with the provided Amino // codec. -func RegisterCrypto(cdc *codec.LegacyAmino) { +func RegisterCrypto(cdc legacy.Amino) { cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) cdc.RegisterConcrete(sr25519.PubKey{}, - sr25519.PubKeyName, nil) + sr25519.PubKeyName) cdc.RegisterConcrete(&ed25519.PubKey{}, - ed25519.PubKeyName, nil) + ed25519.PubKeyName) cdc.RegisterConcrete(&secp256k1.PubKey{}, - secp256k1.PubKeyName, nil) + secp256k1.PubKeyName) cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, - kmultisig.PubKeyAminoRoute, nil) + kmultisig.PubKeyAminoRoute) cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(sr25519.PrivKey{}, - sr25519.PrivKeyName, nil) + sr25519.PrivKeyName) cdc.RegisterConcrete(&ed25519.PrivKey{}, - ed25519.PrivKeyName, nil) + ed25519.PrivKeyName) cdc.RegisterConcrete(&secp256k1.PrivKey{}, - secp256k1.PrivKeyName, nil) + secp256k1.PrivKeyName) } diff --git a/crypto/keyring/codec.go b/crypto/keyring/codec.go index 9b4c44039231..1393d2f35e1e 100644 --- a/crypto/keyring/codec.go +++ b/crypto/keyring/codec.go @@ -13,9 +13,9 @@ func init() { // RegisterLegacyAminoCodec registers concrete types and interfaces on the given codec. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*LegacyInfo)(nil), nil) - cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params", nil) - cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo", nil) - cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo", nil) - cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo", nil) - cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo", nil) + cdc.RegisterConcrete(hd.BIP44Params{}, "crypto/keys/hd/BIP44Params") + cdc.RegisterConcrete(legacyLocalInfo{}, "crypto/keys/localInfo") + cdc.RegisterConcrete(legacyLedgerInfo{}, "crypto/keys/ledgerInfo") + cdc.RegisterConcrete(legacyOfflineInfo{}, "crypto/keys/offlineInfo") + cdc.RegisterConcrete(LegacyMultiInfo{}, "crypto/keys/multiInfo") } diff --git a/crypto/keys/multisig/codec.go b/crypto/keys/multisig/codec.go index 7dc3ed262d0e..6572123af540 100644 --- a/crypto/keys/multisig/codec.go +++ b/crypto/keys/multisig/codec.go @@ -22,11 +22,11 @@ var AminoCdc = codec.NewLegacyAmino() func init() { AminoCdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) AminoCdc.RegisterConcrete(ed25519.PubKey{}, - ed25519.PubKeyName, nil) + ed25519.PubKeyName) AminoCdc.RegisterConcrete(sr25519.PubKey{}, - sr25519.PubKeyName, nil) + sr25519.PubKeyName) AminoCdc.RegisterConcrete(&secp256k1.PubKey{}, - secp256k1.PubKeyName, nil) + secp256k1.PubKeyName) AminoCdc.RegisterConcrete(&LegacyAminoPubKey{}, - PubKeyAminoRoute, nil) + PubKeyAminoRoute) } diff --git a/crypto/ledger/amino.go b/crypto/ledger/amino.go index 0e717a9604f0..8a5915f31abf 100644 --- a/crypto/ledger/amino.go +++ b/crypto/ledger/amino.go @@ -15,5 +15,5 @@ func init() { // RegisterAmino registers all go-crypto related types in the given (amino) codec. func RegisterAmino(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(PrivKeyLedgerSecp256k1{}, - "tendermint/PrivKeyLedgerSecp256k1", nil) + "tendermint/PrivKeyLedgerSecp256k1") } diff --git a/depinject/check_type.go b/depinject/check_type.go index 5df053fd6ccc..41ba36c8ffd2 100644 --- a/depinject/check_type.go +++ b/depinject/check_type.go @@ -1,11 +1,11 @@ package depinject import ( + "fmt" "reflect" "strings" "unicode" - "github.com/cockroachdb/errors" "golang.org/x/exp/slices" ) @@ -21,12 +21,12 @@ func isExportedType(typ reflect.Type) error { pkgPath := typ.PkgPath() if name != "" && pkgPath != "" { if unicode.IsLower([]rune(name)[0]) { - return errors.Errorf("type must be exported: %s", typ) + return fmt.Errorf("type must be exported: %s", typ) } pkgParts := strings.Split(pkgPath, "/") if slices.Contains(pkgParts, "internal") { - return errors.Errorf("type must not come from an internal package: %s", typ) + return fmt.Errorf("type must not come from an internal package: %s", typ) } return nil diff --git a/depinject/config.go b/depinject/config.go index 947539c4b34f..8547fda40f8b 100644 --- a/depinject/config.go +++ b/depinject/config.go @@ -1,9 +1,10 @@ package depinject import ( + "errors" + "fmt" "reflect" - - "github.com/cockroachdb/errors" + "runtime" ) // Config is a functional configuration of a container. @@ -33,7 +34,7 @@ func Provide(providers ...interface{}) Config { func ProvideInModule(moduleName string, providers ...interface{}) Config { return containerConfig(func(ctr *container) error { if moduleName == "" { - return errors.Errorf("expected non-empty module name") + return errors.New("expected non-empty module name") } return provide(ctr, ctr.moduleKeyContext.createOrGetModuleKey(moduleName), providers) @@ -44,11 +45,11 @@ func provide(ctr *container, key *moduleKey, providers []interface{}) error { for _, c := range providers { rc, err := extractProviderDescriptor(c) if err != nil { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) } _, err = ctr.addNode(&rc, key) if err != nil { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) } } return nil @@ -80,7 +81,7 @@ func Invoke(invokers ...interface{}) Config { func InvokeInModule(moduleName string, invokers ...interface{}) Config { return containerConfig(func(ctr *container) error { if moduleName == "" { - return errors.Errorf("expected non-empty module name") + return errors.New("expected non-empty module name") } return invoke(ctr, ctr.moduleKeyContext.createOrGetModuleKey(moduleName), invokers) @@ -91,7 +92,7 @@ func invoke(ctr *container, key *moduleKey, invokers []interface{}) error { for _, c := range invokers { rc, err := extractInvokerDescriptor(c) if err != nil { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) } err = ctr.addInvoker(&rc, key) if err != nil { @@ -151,7 +152,7 @@ func Supply(values ...interface{}) Config { for _, v := range values { err := ctr.supply(reflect.ValueOf(v), loc) if err != nil { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) } } return nil @@ -162,7 +163,7 @@ func Supply(values ...interface{}) Config { // fail immediately. func Error(err error) Config { return containerConfig(func(*container) error { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) }) } @@ -172,7 +173,7 @@ func Configs(opts ...Config) Config { for _, opt := range opts { err := opt.apply(ctr) if err != nil { - return errors.WithStack(err) + return fmt.Errorf("%w\n%s", err, getStackTrace()) } } return nil @@ -186,3 +187,9 @@ func (c containerConfig) apply(ctr *container) error { } var _ Config = (*containerConfig)(nil) + +func getStackTrace() string { + var stack [4096]byte + n := runtime.Stack(stack[:], false) + return string(stack[:n]) +} diff --git a/depinject/container.go b/depinject/container.go index 7816f56abf42..67772acdbca2 100644 --- a/depinject/container.go +++ b/depinject/container.go @@ -6,8 +6,6 @@ import ( "fmt" "reflect" - "github.com/cockroachdb/errors" - "cosmossdk.io/depinject/internal/graphviz" ) @@ -63,7 +61,7 @@ func (c *container) call(provider *providerDescriptor, moduleKey *moduleKey) ([] markGraphNodeAsFailed(graphNode) if c.callerMap[loc] { - return nil, errors.Errorf("cyclic dependency: %s -> %s", loc.Name(), loc.Name()) + return nil, fmt.Errorf("cyclic dependency: %s -> %s", loc.Name(), loc.Name()) } c.callerMap[loc] = true @@ -87,7 +85,7 @@ func (c *container) call(provider *providerDescriptor, moduleKey *moduleKey) ([] out, err := provider.Fn(inVals) if err != nil { - return nil, errors.Wrapf(err, "error calling provider %s", loc) + return nil, fmt.Errorf("error calling provider %s: %w", loc, err) } markGraphNodeAsUsed(graphNode) @@ -296,7 +294,7 @@ func (c *container) addNode(provider *providerDescriptor, key *moduleKey) (inter } if hasOwnModuleKeyParam { - return nil, errors.Errorf("%T and %T must not be declared as dependencies on the same provided", + return nil, fmt.Errorf("%T and %T must not be declared as dependencies on the same provided", ModuleKey{}, OwnModuleKey{}) } @@ -317,7 +315,7 @@ func (c *container) addNode(provider *providerDescriptor, key *moduleKey) (inter existing, ok := c.resolverByType(typ) if ok { - return nil, errors.Errorf("duplicate provision of type %v by module-scoped provider %s\n\talready provided by %s", + return nil, fmt.Errorf("duplicate provision of type %v by module-scoped provider %s\n\talready provided by %s", typ, provider.Location, existing.describeLocation()) } @@ -378,7 +376,7 @@ func (c *container) resolve(in providerInput, moduleKey *moduleKey, caller Locat if in.Type == moduleKeyType { if moduleKey == nil { - return reflect.Value{}, errors.Errorf("trying to resolve %T for %s but not inside of any module's scope", moduleKey, caller) + return reflect.Value{}, fmt.Errorf("trying to resolve %T for %s but not inside of any module's scope", moduleKey, caller) } c.logf("Providing ModuleKey %s", moduleKey.name) markGraphNodeAsUsed(typeGraphNode) @@ -387,7 +385,7 @@ func (c *container) resolve(in providerInput, moduleKey *moduleKey, caller Locat if in.Type == ownModuleKeyType { if moduleKey == nil { - return reflect.Value{}, errors.Errorf("trying to resolve %T for %s but not inside of any module's scope", moduleKey, caller) + return reflect.Value{}, fmt.Errorf("trying to resolve %T for %s but not inside of any module's scope", moduleKey, caller) } c.logf("Providing OwnModuleKey %s", moduleKey.name) markGraphNodeAsUsed(typeGraphNode) @@ -406,7 +404,7 @@ func (c *container) resolve(in providerInput, moduleKey *moduleKey, caller Locat } markGraphNodeAsFailed(typeGraphNode) - return reflect.Value{}, errors.Errorf("can't resolve type %v for %s:\n%s", + return reflect.Value{}, fmt.Errorf("can't resolve type %v for %s:\n%s", fullyQualifiedTypeName(in.Type), caller, c.formatResolveStack()) } @@ -475,7 +473,7 @@ func (c *container) build(loc Location, outputs ...interface{}) error { sn, ok := node.(*simpleProvider) if !ok { - return errors.Errorf("cannot run module-scoped provider as an invoker") + return stderrors.New("cannot run module-scoped provider as an invoker") } c.logf("Building container") diff --git a/depinject/errors.go b/depinject/errors.go index ebef77d47e38..94b9956a0115 100644 --- a/depinject/errors.go +++ b/depinject/errors.go @@ -3,8 +3,6 @@ package depinject import ( "fmt" "reflect" - - "github.com/cockroachdb/errors" ) // ErrMultipleImplicitInterfaceBindings defines an error condition where an attempt was made to implicitly bind @@ -63,6 +61,6 @@ func (err ErrNoTypeForExplicitBindingFound) Error() string { } func duplicateDefinitionError(typ reflect.Type, duplicateLoc Location, existingLoc string) error { - return errors.Errorf("duplicate provision of type %v by %s\n\talready provided by %s", + return fmt.Errorf("duplicate provision of type %v by %s\n\talready provided by %s", typ, duplicateLoc, existingLoc) } diff --git a/depinject/go.mod b/depinject/go.mod index 9bff496d0d27..bc7c1502927c 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -4,7 +4,6 @@ go 1.20 require ( cosmossdk.io/api v0.7.5 - github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb @@ -14,15 +13,9 @@ require ( ) require ( - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/redact v1.1.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/getsentry/sentry-go v0.23.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect golang.org/x/net v0.24.0 // indirect @@ -30,5 +23,6 @@ require ( golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/grpc v1.63.2 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/depinject/go.sum b/depinject/go.sum index 70a044e2810f..2e2254dccfe9 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -1,34 +1,21 @@ cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= -github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= -github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= -github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= @@ -36,41 +23,14 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -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.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -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/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= @@ -79,6 +39,7 @@ google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFW google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/depinject/group.go b/depinject/group.go index 43bbce7b396a..5ecb519f004c 100644 --- a/depinject/group.go +++ b/depinject/group.go @@ -4,8 +4,6 @@ import ( "fmt" "reflect" - "github.com/cockroachdb/errors" - "cosmossdk.io/depinject/internal/graphviz" ) @@ -85,7 +83,7 @@ func (g *sliceGroupResolver) resolve(c *container, _ *moduleKey, caller Location } func (g *groupResolver) resolve(_ *container, _ *moduleKey, _ Location) (reflect.Value, error) { - return reflect.Value{}, errors.Errorf("%v is an many-per-container type and cannot be used as an input value, instead use %v", g.typ, g.sliceType) + return reflect.Value{}, fmt.Errorf("%v is an many-per-container type and cannot be used as an input value, instead use %v", g.typ, g.sliceType) } func (g *groupResolver) addNode(n *simpleProvider, i int) error { diff --git a/depinject/one_per_module.go b/depinject/one_per_module.go index 69916434be3d..55d19a7d93f3 100644 --- a/depinject/one_per_module.go +++ b/depinject/one_per_module.go @@ -4,8 +4,6 @@ import ( "fmt" "reflect" - "github.com/cockroachdb/errors" - "cosmossdk.io/depinject/internal/graphviz" ) @@ -46,7 +44,7 @@ type mapOfOnePerModuleResolver struct { } func (o *onePerModuleResolver) resolve(_ *container, _ *moduleKey, _ Location) (reflect.Value, error) { - return reflect.Value{}, errors.Errorf("%v is a one-per-module type and thus can't be used as an input parameter, instead use %v", o.typ, o.mapType) + return reflect.Value{}, fmt.Errorf("%v is a one-per-module type and thus can't be used as an input parameter, instead use %v", o.typ, o.mapType) } func (o *onePerModuleResolver) describeLocation() string { @@ -72,7 +70,7 @@ func (o *mapOfOnePerModuleResolver) resolve(c *container, _ *moduleKey, caller L } idx := o.idxMap[key] if len(values) <= idx { - return reflect.Value{}, errors.Errorf("expected value of type %T at index %d", o.typ, idx) + return reflect.Value{}, fmt.Errorf("expected value of type %T at index %d", o.typ, idx) } value := values[idx] res.SetMapIndex(reflect.ValueOf(key.name), value) @@ -87,11 +85,11 @@ func (o *mapOfOnePerModuleResolver) resolve(c *container, _ *moduleKey, caller L func (o *onePerModuleResolver) addNode(n *simpleProvider, i int) error { if n.moduleKey == nil { - return errors.Errorf("cannot define a provider with one-per-module dependency %v which isn't provided in a module", o.typ) + return fmt.Errorf("cannot define a provider with one-per-module dependency %v which isn't provided in a module", o.typ) } if existing, ok := o.providers[n.moduleKey]; ok { - return errors.Errorf("duplicate provision for one-per-module type %v in module %s: %s\n\talready provided by %s", + return fmt.Errorf("duplicate provision for one-per-module type %v in module %s: %s\n\talready provided by %s", o.typ, n.moduleKey.name, n.provider.Location, existing.provider.Location) } @@ -102,7 +100,7 @@ func (o *onePerModuleResolver) addNode(n *simpleProvider, i int) error { } func (o *mapOfOnePerModuleResolver) addNode(s *simpleProvider, _ int) error { - return errors.Errorf("%v is a one-per-module type and thus %v can't be used as an output parameter in %s", o.typ, o.mapType, s.provider.Location) + return fmt.Errorf("%v is a one-per-module type and thus %v can't be used as an output parameter in %s", o.typ, o.mapType, s.provider.Location) } func (o onePerModuleResolver) typeGraphNode() *graphviz.Node { diff --git a/depinject/provider_desc.go b/depinject/provider_desc.go index dfbac5dabaf7..f17537ccb521 100644 --- a/depinject/provider_desc.go +++ b/depinject/provider_desc.go @@ -1,11 +1,11 @@ package depinject import ( + "fmt" "reflect" "strings" "unicode" - "github.com/cockroachdb/errors" "golang.org/x/exp/slices" ) @@ -65,32 +65,32 @@ func doExtractProviderDescriptor(ctr interface{}) (providerDescriptor, error) { val := reflect.ValueOf(ctr) typ := val.Type() if typ.Kind() != reflect.Func { - return providerDescriptor{}, errors.Errorf("expected a Func type, got %v", typ) + return providerDescriptor{}, fmt.Errorf("expected a Func type, got %v", typ) } loc := LocationFromPC(val.Pointer()).(*location) nameParts := strings.Split(loc.name, ".") if len(nameParts) == 0 { - return providerDescriptor{}, errors.Errorf("missing function name %s", loc) + return providerDescriptor{}, fmt.Errorf("missing function name %s", loc) } lastNamePart := nameParts[len(nameParts)-1] if unicode.IsLower([]rune(lastNamePart)[0]) { - return providerDescriptor{}, errors.Errorf("function must be exported: %s", loc) + return providerDescriptor{}, fmt.Errorf("function must be exported: %s", loc) } if strings.Contains(lastNamePart, "-") { - return providerDescriptor{}, errors.Errorf("function can't be used as a provider (it might be a bound instance method): %s", loc) + return providerDescriptor{}, fmt.Errorf("function can't be used as a provider (it might be a bound instance method): %s", loc) } pkgParts := strings.Split(loc.pkg, "/") if slices.Contains(pkgParts, "internal") { - return providerDescriptor{}, errors.Errorf("function must not be in an internal package: %s", loc) + return providerDescriptor{}, fmt.Errorf("function must not be in an internal package: %s", loc) } if typ.IsVariadic() { - return providerDescriptor{}, errors.Errorf("variadic function can't be used as a provider: %s", loc) + return providerDescriptor{}, fmt.Errorf("variadic function can't be used as a provider: %s", loc) } numIn := typ.NumIn() @@ -108,7 +108,7 @@ func doExtractProviderDescriptor(ctr interface{}) (providerDescriptor, error) { t := typ.Out(i) if t == errType { if i != numOut-1 { - return providerDescriptor{}, errors.Errorf("output error parameter is not last parameter in function %s", loc) + return providerDescriptor{}, fmt.Errorf("output error parameter is not last parameter in function %s", loc) } errIdx = i } else { diff --git a/depinject/struct_args.go b/depinject/struct_args.go index 565bee406c7d..16e4c7cc5a9c 100644 --- a/depinject/struct_args.go +++ b/depinject/struct_args.go @@ -3,8 +3,6 @@ package depinject import ( "fmt" "reflect" - - "github.com/cockroachdb/errors" ) // In can be embedded in another struct to inform the container that the @@ -121,7 +119,7 @@ func structArgsInTypes(typ reflect.Type) ([]providerInput, error) { if optTag == "true" { optional = true } else { - return nil, errors.Errorf("bad optional tag %q (should be \"true\") in %v", optTag, typ) + return nil, fmt.Errorf("bad optional tag %q (should be \"true\") in %v", optTag, typ) } } diff --git a/go.mod b/go.mod index 2590643809c0..76d1d5aece2c 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( cosmossdk.io/x/tx v0.13.3 github.com/99designs/keyring v1.2.2 github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 - github.com/cockroachdb/errors v1.11.1 github.com/cometbft/cometbft v1.0.0-alpha.2.0.20240429102542-490e9bc3de65 github.com/cometbft/cometbft/api v1.0.0-alpha.2.0.20240429102542-490e9bc3de65 github.com/cosmos/btcutil v1.0.5 @@ -79,6 +78,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect diff --git a/runtime/app.go b/runtime/app.go index 7c494e02ba00..2f208a635e09 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -10,6 +10,7 @@ import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtx "cosmossdk.io/x/auth/tx" @@ -46,7 +47,7 @@ type App struct { storeKeys []storetypes.StoreKey interfaceRegistry codectypes.InterfaceRegistry cdc codec.Codec - amino *codec.LegacyAmino + amino legacy.Amino baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter grpcQueryRouter *baseapp.GRPCQueryRouter diff --git a/runtime/module.go b/runtime/module.go index ad8aed2b0935..9e82cf6c30e0 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -19,12 +19,12 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -93,7 +93,11 @@ func init() { appconfig.RegisterModule(&runtimev1alpha1.Module{}, appconfig.Provide( ProvideApp, - ProvideInterfaceRegistry, + // to decouple runtime from sdk/codec ProvideInterfaceReistry can be registered from the app + // i.e. in the call to depinject.Inject(...) + codec.ProvideInterfaceRegistry, + codec.ProvideLegacyAmino, + codec.ProvideProtoCodec, ProvideKVStoreKey, ProvideTransientStoreKey, ProvideMemoryStoreKey, @@ -109,9 +113,11 @@ func init() { ) } -func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( - codec.Codec, - *codec.LegacyAmino, +func ProvideApp( + interfaceRegistry codectypes.InterfaceRegistry, + amino legacy.Amino, + protoCodec *codec.ProtoCodec, +) ( *AppBuilder, *baseapp.MsgServiceRouter, *baseapp.GRPCQueryRouter, @@ -130,25 +136,22 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( _, _ = fmt.Fprintln(os.Stderr, err.Error()) } - amino := codec.NewLegacyAmino() - std.RegisterInterfaces(interfaceRegistry) std.RegisterLegacyAminoCodec(amino) - cdc := codec.NewProtoCodec(interfaceRegistry) msgServiceRouter := baseapp.NewMsgServiceRouter() grpcQueryRouter := baseapp.NewGRPCQueryRouter() app := &App{ storeKeys: nil, interfaceRegistry: interfaceRegistry, - cdc: cdc, + cdc: protoCodec, amino: amino, msgServiceRouter: msgServiceRouter, grpcQueryRouter: grpcQueryRouter, } appBuilder := &AppBuilder{app} - return cdc, amino, appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil + return appBuilder, msgServiceRouter, grpcQueryRouter, appModule{app}, protoFiles, protoTypes, nil } type AppInputs struct { @@ -161,7 +164,7 @@ type AppInputs struct { ModuleManager *module.Manager BaseAppOptions []BaseAppOption InterfaceRegistry codectypes.InterfaceRegistry - LegacyAmino *codec.LegacyAmino + LegacyAmino legacy.Amino } func SetupAppBuilder(inputs AppInputs) { @@ -175,34 +178,6 @@ func SetupAppBuilder(inputs AppInputs) { app.ModuleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino) } -func ProvideInterfaceRegistry( - addressCodec address.Codec, - validatorAddressCodec address.ValidatorAddressCodec, - customGetSigners []signing.CustomGetSigner, -) (codectypes.InterfaceRegistry, error) { - signingOptions := signing.Options{ - AddressCodec: addressCodec, - ValidatorAddressCodec: validatorAddressCodec, - } - for _, signer := range customGetSigners { - signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn) - } - - interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{ - ProtoFiles: proto.HybridResolver, - SigningOptions: signingOptions, - }) - if err != nil { - return nil, err - } - - if err := interfaceRegistry.SigningContext().Validate(); err != nil { - return nil, err - } - - return interfaceRegistry, nil -} - func registerStoreKey(wrapper *AppBuilder, key storetypes.StoreKey) { wrapper.app.storeKeys = append(wrapper.app.storeKeys, key) } diff --git a/runtime/v2/store.go b/runtime/v2/store.go index e0f7c66528d7..8abd825c0b1f 100644 --- a/runtime/v2/store.go +++ b/runtime/v2/store.go @@ -26,8 +26,6 @@ type Store interface { // state. Must error when the version does not exist. StateAt(version uint64) (store.ReaderMap, error) - WorkingHash(*store.Changeset) ([]byte, error) - Commit(changeset *store.Changeset) (store.Hash, error) // Query is a key/value query directly to the underlying database. This skips the appmanager diff --git a/simapp/app_di.go b/simapp/app_di.go index eab4f0110f63..7a459a18507e 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -12,6 +12,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cast" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -67,7 +68,7 @@ var ( // capabilities aren't needed for testing. type SimApp struct { *runtime.App - legacyAmino *codec.LegacyAmino + legacyAmino legacy.Amino appCodec codec.Codec txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry @@ -342,7 +343,12 @@ func (app *SimApp) Close() error { // NOTE: This is solely to be used for testing purposes as it may be desirable // for modules to register their own custom testing types. func (app *SimApp) LegacyAmino() *codec.LegacyAmino { - return app.legacyAmino + switch cdc := app.legacyAmino.(type) { + case *codec.LegacyAmino: + return cdc + default: + panic("unexpected codec type") + } } // AppCodec returns SimApp's app codec. diff --git a/simapp/gomod2nix.toml b/simapp/gomod2nix.toml index 382cf0813963..e9430f86933b 100644 --- a/simapp/gomod2nix.toml +++ b/simapp/gomod2nix.toml @@ -2,11 +2,11 @@ schema = 3 [mod] [mod."buf.build/gen/go/cometbft/cometbft/protocolbuffers/go"] - version = "v1.33.0-20240312114316-c0d3497e35d6.1" - hash = "sha256-Y+tNsJqQsdFGSVTDzV/CGLyqR6e2kDywu3bxH7XL0mk=" + version = "v1.34.0-20240312114316-c0d3497e35d6.1" + hash = "sha256-Uoo+Gfx/mnzKRoBvmTJC7oUKMrxOT20ibdY6ArGKHLQ=" [mod."buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go"] - version = "v1.33.0-20240130113600-88ef6483f90f.1" - hash = "sha256-MwiW5ycryMhDAX6LJtOzbZd+xW+VcqnLExIKfy2VMFY=" + version = "v1.34.0-20240130113600-88ef6483f90f.1" + hash = "sha256-EpsIiMf8GKK56FgjSS3tCZtVCz4apPcJiaqsbhtF3kM=" [mod."cloud.google.com/go"] version = "v0.112.2" hash = "sha256-Bk5MD40eefJlyUk96arLU/X1+EHItM7MjRPJtV0CU58=" @@ -132,8 +132,8 @@ schema = 3 version = "v1.4.12" hash = "sha256-e2tbfaZtzLijq+EMnNG9GWKDCG4sBj8wIVnn6/R26iM=" [mod."github.com/cosmos/iavl"] - version = "v1.1.2" - hash = "sha256-fhh5fN1BMDxbF4PobERMQdIb9vIrxaSl0tRXas0WKmc=" + version = "v1.1.4" + hash = "sha256-bBU5w5rEMvpCWSzFBIVvnMHnsy2+a+e1DPDkb4hNOwU=" [mod."github.com/cosmos/ics23/go"] version = "v0.10.0" hash = "sha256-KYEv727BO/ht63JO02xiKFGFAddg41Ve9l2vSSZZBq0=" @@ -273,8 +273,8 @@ schema = 3 version = "v1.7.4" hash = "sha256-GtJSwcS1WXLn9lFAuTRCseIQBXJOElAywEhTtYrsfbE=" [mod."github.com/hashicorp/go-hclog"] - version = "v1.6.2" - hash = "sha256-cGlKyuctpU6Jd+L1ybCoJrBwnBlHXks4CQYkTQMCxDU=" + version = "v1.6.3" + hash = "sha256-BK2s+SH1tQyUaXCH4kC0/jgqiSu638UFbwamfKjFOYg=" [mod."github.com/hashicorp/go-immutable-radix"] version = "v1.3.1" hash = "sha256-65+A2HiVfS/GV9G+6/TkXXjzXhI/V98e6RlJWjxy+mg=" @@ -387,8 +387,8 @@ schema = 3 version = "v1.1.0" hash = "sha256-U4IS0keJa4BSBSeEBqtIV1Zg6N4b0zFiKfzN9ua4pWQ=" [mod."github.com/pelletier/go-toml/v2"] - version = "v2.2.1" - hash = "sha256-gmQ4CTz/MI97D3pYqU7mpxqo8gBTDccQ1Cp0lAMmJUc=" + version = "v2.2.2" + hash = "sha256-ukxk1Cfm6cQW18g/aa19tLcUu5BnF7VmfAvrDHAOl6A=" [mod."github.com/petermattis/goid"] version = "v0.0.0-20240327183114-c42a807a84ba" hash = "sha256-f2enuVnb6nrQX0uBc3WYEK68TiLUp4Y1qisx84ElaFA=" @@ -399,8 +399,8 @@ schema = 3 version = "v1.0.1-0.20181226105442-5d4384ee4fb2" hash = "sha256-XA4Oj1gdmdV/F/+8kMI+DBxKPthZ768hbKsO3d9Gx90=" [mod."github.com/prometheus/client_golang"] - version = "v1.19.0" - hash = "sha256-YV8sxMPR+xorTUCriTfcFsaV2b7PZfPJDQmOgUYOZJo=" + version = "v1.19.1" + hash = "sha256-MSLsMDi89uQc7Pa2fhqeamyfPJpenGj3r+eB/UotK7w=" [mod."github.com/prometheus/client_model"] version = "v0.6.1" hash = "sha256-rIDyUzNfxRA934PIoySR0EhuBbZVRK/25Jlc/r8WODw=" @@ -511,17 +511,17 @@ schema = 3 version = "v1.11.0" hash = "sha256-Lb6rHHfR62Ozg2j2JZy3MKOMKdsfzd1IYTR57r3Mhp0=" [mod."golang.org/x/crypto"] - version = "v0.22.0" - hash = "sha256-2+u9nd32+Bi7EEv7QFc12CRTbfV7DApNv+yKIr7+lTw=" + version = "v0.23.0" + hash = "sha256-6hZjb/OazWFBef0C/aH63l49YQnzCh2vpIduzyfSSG8=" [mod."golang.org/x/exp"] - version = "v0.0.0-20240416160154-fe59bbe5cc7f" - hash = "sha256-168CD9hlLJaQ7stQk/ztlP3zgaWXUMbIHa38gAeRRs4=" + version = "v0.0.0-20240506185415-9bf2ced13842" + hash = "sha256-5JZE4OhePWHtObIT4RJOS+2zv265Io1yJkFeE8wHXY4=" [mod."golang.org/x/mod"] version = "v0.17.0" hash = "sha256-CLaPeF6uTFuRDv4oHwOQE6MCMvrzkUjWN3NuyywZjKU=" [mod."golang.org/x/net"] - version = "v0.24.0" - hash = "sha256-w1c21ljta5wNIyel9CSIn/crPzwOCRofNKhqmfs4aEQ=" + version = "v0.25.0" + hash = "sha256-IjFfXLYNj27WLF7vpkZ6mfFXBnp+7QER3OQ0RgjxN54=" [mod."golang.org/x/oauth2"] version = "v0.19.0" hash = "sha256-IYdkq8R8BXnwoBt/ZLAMJr0DkLZDMVkjeBJNQ/Z9Bes=" @@ -529,20 +529,20 @@ schema = 3 version = "v0.7.0" hash = "sha256-2ETllEu2GDWoOd/yMkOkLC2hWBpKzbVZ8LhjLu0d2A8=" [mod."golang.org/x/sys"] - version = "v0.19.0" - hash = "sha256-cmuL31TYLJmDm/fDnI2Sn0wB88cpdOHV1+urorsJWx4=" + version = "v0.20.0" + hash = "sha256-mowlaoG2k4n1c1rApWef5EMiXd3I77CsUi8jPh6pTYA=" [mod."golang.org/x/term"] - version = "v0.19.0" - hash = "sha256-wFwEMwhtsr0C4mqjxukjMM7lxJLYPvb7gAPO95xyhyg=" + version = "v0.20.0" + hash = "sha256-kU+OVJbYktTIn4ZTAdomsOjL069Vj45sdroEMRKaRDI=" [mod."golang.org/x/text"] - version = "v0.14.0" - hash = "sha256-yh3B0tom1RfzQBf1RNmfdNWF1PtiqxV41jW1GVS6JAg=" + version = "v0.15.0" + hash = "sha256-pBnj0AEkfkvZf+3bN7h6epCD2kurw59clDP7yWvxKlk=" [mod."golang.org/x/time"] version = "v0.5.0" hash = "sha256-W6RgwgdYTO3byIPOFxrP2IpAZdgaGowAaVfYby7AULU=" [mod."golang.org/x/tools"] - version = "v0.20.0" - hash = "sha256-g5T5FrNPO/cf2W1lc+/93FcFB3HftPjqI72FueD9Wt8=" + version = "v0.21.0" + hash = "sha256-TU0gAxUX410AYc/nMxxZiaqXeORih1cXbKh3sxKufVg=" [mod."google.golang.org/api"] version = "v0.175.0" hash = "sha256-0NVK3UxAm8Sp8mux2GHeD4rA97u37U7yuE9vDd+wJlg=" @@ -553,14 +553,14 @@ schema = 3 version = "v0.0.0-20240415180920-8c6c420018be" hash = "sha256-0Bc66Utj1rydwYngQxTQoTyg1Td2D+nIxukc0zz7XFc=" [mod."google.golang.org/genproto/googleapis/rpc"] - version = "v0.0.0-20240415180920-8c6c420018be" - hash = "sha256-P5SBku16dYnK4koUQxTeGwPxAAWH8rxbDm2pOzFLo/Q=" + version = "v0.0.0-20240509183442-62759503f434" + hash = "sha256-w2SGX12NeDO33wjxEpHi+OMcpp9SioPtdBuZKUIun+U=" [mod."google.golang.org/grpc"] version = "v1.63.2" hash = "sha256-RmtVjYLam97k7IHTHU7Gn16xNX+GvA9AiLKlQwOiZXU=" [mod."google.golang.org/protobuf"] - version = "v1.34.0" - hash = "sha256-0fqsqQTyOicm4+NiuAf2IaJhavMVJh50VhNcRmZPSus=" + version = "v1.34.1" + hash = "sha256-qnHqY6KLZiZDbTVTN6uzF4jedxROYlPCYHoiv6XI0sc=" [mod."gopkg.in/ini.v1"] version = "v1.67.0" hash = "sha256-V10ahGNGT+NLRdKUyRg1dos5RxLBXBk1xutcnquc/+4=" diff --git a/simapp/simd/cmd/root_di.go b/simapp/simd/cmd/root_di.go index cfc8407edc11..adf8b6cef37c 100644 --- a/simapp/simd/cmd/root_di.go +++ b/simapp/simd/cmd/root_di.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/client/v2/autocli" clientv2keyring "cosmossdk.io/client/v2/autocli/keyring" "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/simapp" @@ -100,7 +101,7 @@ func ProvideClientContext( appCodec codec.Codec, interfaceRegistry codectypes.InterfaceRegistry, txConfigOpts tx.ConfigOptions, - legacyAmino *codec.LegacyAmino, + legacyAmino legacy.Amino, addressCodec address.Codec, validatorAddressCodec address.ValidatorAddressCodec, consensusAddressCodec address.ConsensusAddressCodec, @@ -109,10 +110,15 @@ func ProvideClientContext( ) client.Context { var err error + amino, ok := legacyAmino.(*codec.LegacyAmino) + if !ok { + panic("ProvideClientContext requires a *codec.LegacyAmino instance") + } + clientCtx := client.Context{}. WithCodec(appCodec). WithInterfaceRegistry(interfaceRegistry). - WithLegacyAmino(legacyAmino). + WithLegacyAmino(amino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). WithAddressCodec(addressCodec). diff --git a/std/codec.go b/std/codec.go index 9a5b6a7467a1..c6020c133029 100644 --- a/std/codec.go +++ b/std/codec.go @@ -1,6 +1,8 @@ package std import ( + "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -9,7 +11,7 @@ import ( ) // RegisterLegacyAminoCodec registers types with the Amino codec. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc legacy.Amino) { sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) codec.RegisterEvidences(cdc) diff --git a/store/v2/go.mod b/store/v2/go.mod index 6f9f64b30e58..3b85d7fb8e87 100644 --- a/store/v2/go.mod +++ b/store/v2/go.mod @@ -6,7 +6,6 @@ require ( cosmossdk.io/core v0.12.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 - github.com/cockroachdb/errors v1.11.1 github.com/cockroachdb/pebble v1.1.0 github.com/cometbft/cometbft v0.38.7 github.com/cosmos/gogoproto v1.4.12 @@ -27,6 +26,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect diff --git a/store/v2/root/store.go b/store/v2/root/store.go index a8e717fd5a64..b0db1ee21748 100644 --- a/store/v2/root/store.go +++ b/store/v2/root/store.go @@ -2,11 +2,11 @@ package root import ( "bytes" + "errors" "fmt" "sync" "time" - "github.com/cockroachdb/errors" "golang.org/x/sync/errgroup" coreheader "cosmossdk.io/core/header" diff --git a/tests/sims/authz/operations_test.go b/tests/sims/authz/operations_test.go index fa1e422f68a1..6abed781569f 100644 --- a/tests/sims/authz/operations_test.go +++ b/tests/sims/authz/operations_test.go @@ -57,7 +57,6 @@ type SimTestSuite struct { ctx sdk.Context app *runtime.App - legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry txConfig client.TxConfig @@ -72,7 +71,6 @@ func (suite *SimTestSuite) SetupTest() { AppConfig, depinject.Supply(log.NewNopLogger()), ), - &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, &suite.txConfig, diff --git a/tests/sims/feegrant/operations_test.go b/tests/sims/feegrant/operations_test.go index dba7785cedf7..d280cd6c40ba 100644 --- a/tests/sims/feegrant/operations_test.go +++ b/tests/sims/feegrant/operations_test.go @@ -49,7 +49,6 @@ type SimTestSuite struct { accountKeeper authkeeper.AccountKeeper bankKeeper bankkeeper.Keeper cdc codec.Codec - legacyAmino *codec.LegacyAmino } func (suite *SimTestSuite) SetupTest() { @@ -74,7 +73,6 @@ func (suite *SimTestSuite) SetupTest() { &suite.interfaceRegistry, &suite.txConfig, &suite.cdc, - &suite.legacyAmino, ) suite.Require().NoError(err) diff --git a/tests/sims/slashing/operations_test.go b/tests/sims/slashing/operations_test.go index e19241c1c775..f3263f1ab6e1 100644 --- a/tests/sims/slashing/operations_test.go +++ b/tests/sims/slashing/operations_test.go @@ -47,7 +47,6 @@ type SimTestSuite struct { accounts []simtypes.Account app *runtime.App - legacyAmino *codec.LegacyAmino codec codec.Codec interfaceRegistry codectypes.InterfaceRegistry txConfig client.TxConfig @@ -86,7 +85,6 @@ func (suite *SimTestSuite) SetupTest() { depinject.Supply(log.NewNopLogger()), ), startupCfg, - &suite.legacyAmino, &suite.codec, &suite.interfaceRegistry, &suite.txConfig, diff --git a/testutil/network/network.go b/testutil/network/network.go index 1c867bd42521..17c9c19fc38b 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -21,6 +21,7 @@ import ( "github.com/spf13/cobra" "cosmossdk.io/core/address" + "cosmossdk.io/core/legacy" "cosmossdk.io/depinject" "cosmossdk.io/log" sdkmath "cosmossdk.io/math" @@ -184,7 +185,7 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { var ( appBuilder *runtime.AppBuilder txConfig client.TxConfig - legacyAmino *codec.LegacyAmino + legacyAmino legacy.Amino cdc codec.Codec interfaceRegistry codectypes.InterfaceRegistry addressCodec address.Codec @@ -214,7 +215,11 @@ func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { }) cfg.Codec = cdc cfg.TxConfig = txConfig - cfg.LegacyAmino = legacyAmino + amino, ok := legacyAmino.(*codec.LegacyAmino) + if !ok { + return Config{}, errors.New("legacyAmino must be a *codec.LegacyAmino") + } + cfg.LegacyAmino = amino cfg.InterfaceRegistry = interfaceRegistry cfg.GenesisState = appBuilder.DefaultGenesis() cfg.AppConstructor = func(val ValidatorI) servertypes.Application { diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index 94caf41c7aa4..d85a50913fe3 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -7,7 +7,6 @@ require ( cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240118210941-3897926e722e cosmossdk.io/core v0.11.0 cosmossdk.io/errors v1.0.1 - github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-sdk v0.50.6 github.com/manifoldco/promptui v0.9.0 github.com/pelletier/go-toml/v2 v2.2.2 @@ -35,6 +34,7 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect diff --git a/tools/hubl/internal/load.go b/tools/hubl/internal/load.go index 9b0069ff6cc5..e59954215e69 100644 --- a/tools/hubl/internal/load.go +++ b/tools/hubl/internal/load.go @@ -8,7 +8,6 @@ import ( "os" "path" - cockroachdberrors "github.com/cockroachdb/errors" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" @@ -183,7 +182,7 @@ func (c *ChainInfo) OpenClient() (*grpc.ClientConn, error) { return c.client, nil } - return nil, cockroachdberrors.Wrapf(res, "error loading gRPC client") + return nil, fmt.Errorf("error loading gRPC client: %w", res) } // getAddressPrefix returns the address prefix of the chain. @@ -195,7 +194,7 @@ func getAddressPrefix(ctx context.Context, conn grpc.ClientConnInterface) (strin } if resp == nil || resp.Bech32Prefix == "" { - return "", cockroachdberrors.New("bech32 account address prefix is not set") + return "", errors.New("bech32 account address prefix is not set") } return resp.Bech32Prefix, nil diff --git a/types/codec.go b/types/codec.go index 7cad97227b38..b24eff214356 100644 --- a/types/codec.go +++ b/types/codec.go @@ -1,9 +1,9 @@ package types import ( + "cosmossdk.io/core/legacy" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -13,7 +13,7 @@ const ( ) // RegisterLegacyAminoCodec registers the sdk message type. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc legacy.Amino) { cdc.RegisterInterface((*coretransaction.Msg)(nil), nil) cdc.RegisterInterface((*Tx)(nil), nil) } diff --git a/types/module/core_module.go b/types/module/core_module.go index 26acf836bd68..97466ffeb165 100644 --- a/types/module/core_module.go +++ b/types/module/core_module.go @@ -9,11 +9,11 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -198,9 +198,9 @@ func (c coreAppModuleAdaptor) RegisterInterfaces(reg registry.InterfaceRegistrar } // RegisterLegacyAminoCodec implements HasAminoCodec -func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { +func (c coreAppModuleAdaptor) RegisterLegacyAminoCodec(amino legacy.Amino) { if mod, ok := c.module.(interface { - RegisterLegacyAminoCodec(amino *codec.LegacyAmino) + RegisterLegacyAminoCodec(amino legacy.Amino) }); ok { mod.RegisterLegacyAminoCodec(amino) } diff --git a/types/module/module.go b/types/module/module.go index 1d718b9d4aac..306db89d4fbf 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -34,12 +34,12 @@ import ( "cosmossdk.io/core/appmodule" appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/genesis" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -78,7 +78,7 @@ type HasGenesisBasics interface { // HasAminoCodec is the interface for modules that have amino codec registration. // Deprecated: modules should not need to register their own amino codecs. type HasAminoCodec interface { - RegisterLegacyAminoCodec(*codec.LegacyAmino) + RegisterLegacyAminoCodec(legacy.Amino) } // HasGRPCGateway is the interface for modules to register their gRPC gateway routes. @@ -299,7 +299,7 @@ func (m *Manager) SetOrderMigrations(moduleNames ...string) { } // RegisterLegacyAminoCodec registers all module codecs -func (m *Manager) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (m *Manager) RegisterLegacyAminoCodec(cdc legacy.Amino) { for _, b := range m.Modules { if mod, ok := b.(HasAminoCodec); ok { mod.RegisterLegacyAminoCodec(cdc) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index b589b41a1504..65491692675c 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -108,7 +108,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { require.NoError(t, err) // We're using TestMsg encoding in some tests, so register it here. - suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg") testdata.RegisterInterfaces(suite.encCfg.InterfaceRegistry) suite.clientCtx = client.Context{}. diff --git a/x/auth/migrations/legacytx/codec.go b/x/auth/migrations/legacytx/codec.go index 2bad4718e1e6..541a15470687 100644 --- a/x/auth/migrations/legacytx/codec.go +++ b/x/auth/migrations/legacytx/codec.go @@ -1,9 +1,9 @@ package legacytx import ( - "github.com/cosmos/cosmos-sdk/codec" + "cosmossdk.io/core/legacy" ) -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil) +func RegisterLegacyAminoCodec(cdc legacy.Amino) { + cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx") } diff --git a/x/auth/module.go b/x/auth/module.go index 8459fd4aa610..a2ceba435aea 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" @@ -48,7 +49,12 @@ type AppModule struct { func (am AppModule) IsAppModule() {} // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, ak types.AccountsModKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule { +func NewAppModule( + cdc codec.Codec, + accountKeeper keeper.AccountKeeper, + ak types.AccountsModKeeper, + randGenAccountsFn types.RandomGenesisAccountsFn, +) AppModule { return AppModule{ accountKeeper: accountKeeper, randGenAccountsFn: randGenAccountsFn, @@ -63,7 +69,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the auth module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index d4d59a6a840e..473e3d94ab21 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -1,11 +1,11 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/auth/migrations/legacytx" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,14 +13,14 @@ import ( // RegisterLegacyAminoCodec registers the account interfaces and concrete types on the // provided LegacyAmino codec. These types are used for Amino JSON serialization -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*sdk.ModuleAccountI)(nil), nil) cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*sdk.AccountI)(nil), nil) - cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil) - cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil) - cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential", nil) + cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount") + cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount") + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params") + cdc.RegisterConcrete(&ModuleCredential{}, "cosmos-sdk/GroupAccountCredential") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/auth/MsgUpdateParams") diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 8835309db9ed..0baec3da3b01 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -2,11 +2,11 @@ package vesting import ( "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -38,8 +38,8 @@ func (AppModule) Name() string { return types.ModuleName } -// RegisterCodec registers the module's types with the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +// RegisterLegacyAminoCodec registers the module's types with the given codec. +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index c415488afdbf..99246287c315 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -1,12 +1,12 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/auth/vesting/exported" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -14,13 +14,13 @@ import ( // RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the // provided LegacyAmino codec. These types are used for Amino JSON serialization -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*exported.VestingAccount)(nil), nil) - cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) - cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) - cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) - cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil) - cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount", nil) + cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount") + cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount") + cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount") + cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount") + cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount") legacy.RegisterAminoMsg(cdc, &MsgCreateVestingAccount{}, "cosmos-sdk/MsgCreateVestingAccount") legacy.RegisterAminoMsg(cdc, &MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount") legacy.RegisterAminoMsg(cdc, &MsgCreatePeriodicVestingAccount{}, "cosmos-sdk/MsgCreatePeriodVestAccount") diff --git a/x/authz/codec.go b/x/authz/codec.go index 18e65dbb4c0a..925fd90b639b 100644 --- a/x/authz/codec.go +++ b/x/authz/codec.go @@ -1,25 +1,25 @@ package authz import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" bank "cosmossdk.io/x/bank/types" staking "cosmossdk.io/x/staking/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgGrant{}, "cosmos-sdk/MsgGrant") legacy.RegisterAminoMsg(cdc, &MsgRevoke{}, "cosmos-sdk/MsgRevoke") legacy.RegisterAminoMsg(cdc, &MsgExec{}, "cosmos-sdk/MsgExec") cdc.RegisterInterface((*Authorization)(nil), nil) - cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization", nil) + cdc.RegisterConcrete(&GenericAuthorization{}, "cosmos-sdk/GenericAuthorization") } // RegisterInterfaces registers the interfaces types with the interface registry diff --git a/x/authz/module/module.go b/x/authz/module/module.go index bf39198c6412..3d14c8f2cccc 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/authz" @@ -50,7 +51,13 @@ type AppModule struct { } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak authz.AccountKeeper, bk authz.BankKeeper, registry cdctypes.InterfaceRegistry) AppModule { +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + ak authz.AccountKeeper, + bk authz.BankKeeper, + registry cdctypes.InterfaceRegistry, +) AppModule { return AppModule{ cdc: cdc, keeper: keeper, @@ -87,7 +94,7 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error { } // RegisterLegacyAminoCodec registers the authz module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { authz.RegisterLegacyAminoCodec(cdc) } diff --git a/x/bank/module.go b/x/bank/module.go index d9db2b6abe96..78295ca268e6 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/bank/client/cli" "cosmossdk.io/x/bank/keeper" @@ -63,7 +64,7 @@ func (am AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index 500fb979b494..643621fe90dd 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -1,24 +1,24 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgSend{}, "cosmos-sdk/MsgSend") legacy.RegisterAminoMsg(cdc, &MsgMultiSend{}, "cosmos-sdk/MsgMultiSend") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/bank/MsgUpdateParams") legacy.RegisterAminoMsg(cdc, &MsgSetSendEnabled{}, "cosmos-sdk/MsgSetSendEnabled") - cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization", nil) - cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params", nil) + cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization") + cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/circuit/ante/circuit.go b/x/circuit/ante/circuit.go index ab1876242b28..9d3ea0a49f4b 100644 --- a/x/circuit/ante/circuit.go +++ b/x/circuit/ante/circuit.go @@ -2,8 +2,7 @@ package ante import ( "context" - - "github.com/cockroachdb/errors" + "errors" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/circuit/go.mod b/x/circuit/go.mod index cfda7a3a3f40..2b5f6baee9cd 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -11,7 +11,6 @@ require ( cosmossdk.io/log v1.3.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 - github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.12 github.com/golang/protobuf v1.5.4 @@ -40,6 +39,7 @@ require ( github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect diff --git a/x/consensus/module.go b/x/consensus/module.go index adeed0733025..4ef57fcb39e6 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -7,6 +7,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/consensus/keeper" "cosmossdk.io/x/consensus/types" @@ -49,7 +50,7 @@ func (AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the consensus module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/consensus/types/codec.go b/x/consensus/types/codec.go index 069b198a5be4..2573b41d4beb 100644 --- a/x/consensus/types/codec.go +++ b/x/consensus/types/codec.go @@ -1,10 +1,10 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -20,6 +20,6 @@ func RegisterInterfaces(registrar registry.InterfaceRegistrar) { // RegisterLegacyAminoCodec registers the necessary x/consensus interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/consensus/MsgUpdateParams") } diff --git a/x/crisis/module.go b/x/crisis/module.go index 0a17ce54908b..245b6797c350 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "github.com/cosmos/cosmos-sdk/codec" @@ -66,7 +67,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the crisis module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 82a880305314..ca3f0e52afb8 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/crisis interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/crisis/MsgUpdateParams") } diff --git a/x/distribution/go.mod b/x/distribution/go.mod index 8637f0657051..83050bb44f8f 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -14,7 +14,6 @@ require ( cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 - github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.12 @@ -30,6 +29,8 @@ require ( gotest.tools/v3 v3.5.1 ) +require github.com/cockroachdb/errors v1.11.1 // indirect + require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.0-20240312114316-c0d3497e35d6.1 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.0-20240130113600-88ef6483f90f.1 // indirect diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index dfc90cdc4eef..58f141ca0e33 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -2,10 +2,9 @@ package keeper import ( "context" + "errors" "fmt" - "github.com/cockroachdb/errors" - "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/appmodule" diff --git a/x/distribution/module.go b/x/distribution/module.go index eebf6ac2517d..e9bfb03a179f 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" @@ -75,7 +76,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the distribution module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index d40ee6db22da..79e5c78c0613 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -1,10 +1,10 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -12,14 +12,14 @@ import ( // RegisterLegacyAminoCodec registers the necessary x/distribution interfaces // and concrete types on the provided LegacyAmino codec. These types are used // for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward") legacy.RegisterAminoMsg(cdc, &MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValCommission") legacy.RegisterAminoMsg(cdc, &MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/distribution/MsgUpdateParams") legacy.RegisterAminoMsg(cdc, &MsgDepositValidatorRewardsPool{}, "cosmos-sdk/distr/MsgDepositValRewards") - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params", nil) + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/distribution/Params") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/epochs/module.go b/x/epochs/module.go index d520fe0e2436..23f39c362075 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/x/epochs/keeper" "cosmossdk.io/x/epochs/simulation" "cosmossdk.io/x/epochs/types" @@ -55,8 +56,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the epochs module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { -} +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the epochs module. func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { diff --git a/x/evidence/module.go b/x/evidence/module.go index 4482fbf36fd8..22756148485d 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" @@ -65,7 +66,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the evidence module's types to the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index fe592cba9bf7..d26766dad7d5 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -1,21 +1,21 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" "cosmossdk.io/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // evidence module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*exported.Evidence)(nil), nil) legacy.RegisterAminoMsg(cdc, &MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence") - cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil) + cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation") } // RegisterInterfaces registers the interfaces types with the interface registry. diff --git a/x/feegrant/codec.go b/x/feegrant/codec.go index d5da542a11fc..d27a3a22db90 100644 --- a/x/feegrant/codec.go +++ b/x/feegrant/codec.go @@ -1,24 +1,24 @@ package feegrant import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/feegrant interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgGrantAllowance{}, "cosmos-sdk/MsgGrantAllowance") legacy.RegisterAminoMsg(cdc, &MsgRevokeAllowance{}, "cosmos-sdk/MsgRevokeAllowance") cdc.RegisterInterface((*FeeAllowanceI)(nil), nil) - cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance", nil) - cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance", nil) - cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance", nil) + cdc.RegisterConcrete(&BasicAllowance{}, "cosmos-sdk/BasicAllowance") + cdc.RegisterConcrete(&PeriodicAllowance{}, "cosmos-sdk/PeriodicAllowance") + cdc.RegisterConcrete(&AllowedMsgAllowance{}, "cosmos-sdk/AllowedMsgAllowance") } // RegisterInterfaces registers the interfaces types with the interface registry diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index b02978dbd906..237705f5b997 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" @@ -66,7 +67,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the feegrant module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { feegrant.RegisterLegacyAminoCodec(cdc) } diff --git a/x/gov/module.go b/x/gov/module.go index f88ed628a4fe..38ff794653ef 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" @@ -79,7 +80,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the gov module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { v1beta1.RegisterLegacyAminoCodec(cdc) v1.RegisterLegacyAminoCodec(cdc) } diff --git a/x/gov/types/v1/codec.go b/x/gov/types/v1/codec.go index 767b1276bb96..bb0beae33ea7 100644 --- a/x/gov/types/v1/codec.go +++ b/x/gov/types/v1/codec.go @@ -1,17 +1,17 @@ package v1 import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // governance module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/v1/MsgSubmitProposal") legacy.RegisterAminoMsg(cdc, &MsgSubmitMultipleChoiceProposal{}, "gov/MsgSubmitMultipleChoiceProposal") legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/v1/MsgDeposit") diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index aebb575ce2aa..475a8dc451dd 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -1,23 +1,23 @@ package v1beta1 import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the // governance module. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*Content)(nil), nil) legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal") legacy.RegisterAminoMsg(cdc, &MsgDeposit{}, "cosmos-sdk/MsgDeposit") legacy.RegisterAminoMsg(cdc, &MsgVote{}, "cosmos-sdk/MsgVote") legacy.RegisterAminoMsg(cdc, &MsgVoteWeighted{}, "cosmos-sdk/MsgVoteWeighted") - cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil) + cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal") } // RegisterInterfaces registers the interfaces types with the Interface Registry. diff --git a/x/group/codec.go b/x/group/codec.go index 19b2d7c02749..f4d80229fb79 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -1,10 +1,10 @@ package group import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - codectypes "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -12,10 +12,10 @@ import ( // RegisterLegacyAminoCodec registers all the necessary group module concrete // types and interfaces with the provided codec reference. // These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codectypes.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { cdc.RegisterInterface((*DecisionPolicy)(nil), nil) - cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy", nil) - cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy", nil) + cdc.RegisterConcrete(&ThresholdDecisionPolicy{}, "cosmos-sdk/ThresholdDecisionPolicy") + cdc.RegisterConcrete(&PercentageDecisionPolicy{}, "cosmos-sdk/PercentageDecisionPolicy") legacy.RegisterAminoMsg(cdc, &MsgCreateGroup{}, "cosmos-sdk/MsgCreateGroup") legacy.RegisterAminoMsg(cdc, &MsgUpdateGroupMembers{}, "cosmos-sdk/MsgUpdateGroupMembers") diff --git a/x/group/module/module.go b/x/group/module/module.go index 42c4ede0af51..c66756457517 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/group" "cosmossdk.io/x/group/client/cli" @@ -88,7 +89,7 @@ func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) { } // RegisterLegacyAminoCodec registers the group module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { group.RegisterLegacyAminoCodec(cdc) } diff --git a/x/mint/module.go b/x/mint/module.go index 617868e39019..8c0d69bce55a 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" @@ -77,7 +78,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index c492772d05f5..a90efe4abbe1 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/mint/MsgUpdateParams") } diff --git a/x/params/keeper/common_test.go b/x/params/keeper/common_test.go index 5a577e51b649..07a7ddd8a475 100644 --- a/x/params/keeper/common_test.go +++ b/x/params/keeper/common_test.go @@ -34,7 +34,7 @@ type s struct { func createTestCodec() *codec.LegacyAmino { cdc := codec.NewLegacyAmino() sdk.RegisterLegacyAminoCodec(cdc) - cdc.RegisterConcrete(s{}, "test/s", nil) - cdc.RegisterConcrete(invalid{}, "test/invalid", nil) + cdc.RegisterConcrete(s{}, "test/s") + cdc.RegisterConcrete(invalid{}, "test/invalid") return cdc } diff --git a/x/params/module.go b/x/params/module.go index 0ed3a514fb3c..bba2218ea3e0 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -7,12 +7,12 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/params/keeper" "cosmossdk.io/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -52,7 +52,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { proposal.RegisterLegacyAminoCodec(cdc) } diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index 78cbcb5c371d..a2a226e683e8 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -1,15 +1,14 @@ package proposal import ( + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" govtypes "cosmossdk.io/x/gov/types/v1beta1" - - "github.com/cosmos/cosmos-sdk/codec" ) // RegisterLegacyAminoCodec registers all necessary param module types with a given LegacyAmino codec. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) +func RegisterLegacyAminoCodec(cdc legacy.Amino) { + cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal") } func RegisterInterfaces(registrar registry.InterfaceRegistrar) { diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 78b53339a215..a3a79decf8fb 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" @@ -60,7 +61,7 @@ func (AppModule) IsAppModule() {} func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the pool module's types on the LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { diff --git a/x/slashing/depinject.go b/x/slashing/depinject.go index d1af9fa19b94..ead44b6fd8f2 100644 --- a/x/slashing/depinject.go +++ b/x/slashing/depinject.go @@ -35,7 +35,6 @@ type ModuleInputs struct { Config *modulev1.Module Environment appmodule.Environment Cdc codec.Codec - LegacyAmino *codec.LegacyAmino Registry cdctypes.InterfaceRegistry CometService comet.Service @@ -64,7 +63,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { panic(fmt.Errorf("unable to decode authority in slashing: %w", err)) } - k := keeper.NewKeeper(in.Environment, in.Cdc, in.LegacyAmino, in.StakingKeeper, authStr) + k := keeper.NewKeeper(in.Environment, in.Cdc, nil, in.StakingKeeper, authStr) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.Registry, in.CometService) return ModuleOutputs{ Keeper: k, diff --git a/x/slashing/go.mod b/x/slashing/go.mod index f7daf9c5fb2e..8e77adb512f8 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -14,7 +14,6 @@ require ( cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/bits-and-blooms/bitset v1.10.0 - github.com/cockroachdb/errors v1.11.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.12 @@ -45,6 +44,7 @@ require ( github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect diff --git a/x/slashing/keeper/infractions.go b/x/slashing/keeper/infractions.go index f044210cb9cd..df190f43c5ab 100644 --- a/x/slashing/keeper/infractions.go +++ b/x/slashing/keeper/infractions.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - "github.com/cockroachdb/errors" - st "cosmossdk.io/api/cosmos/staking/v1beta1" "cosmossdk.io/core/comet" "cosmossdk.io/core/event" @@ -76,7 +74,7 @@ func (k Keeper) HandleValidatorSignatureWithParams(ctx context.Context, params t // determine if the validator signed the previous block previous, err := k.GetMissedBlockBitmapValue(ctx, consAddr, index) if err != nil { - return errors.Wrap(err, "failed to get the validator's bitmap value") + return fmt.Errorf("failed to get the validator's bitmap value: %w", err) } modifiedSignInfo := false diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index 1a511626e5ab..1aa8c1f8c59b 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -20,7 +20,8 @@ import ( type Keeper struct { appmodule.Environment - cdc codec.BinaryCodec + cdc codec.BinaryCodec + // deprecated! legacyAmino *codec.LegacyAmino sk types.StakingKeeper diff --git a/x/slashing/module.go b/x/slashing/module.go index c38157b2d8b6..f3a8a3f3e506 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/simulation" @@ -81,7 +82,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the slashing module's types for the given codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 18eb7aa2f419..7e58c25d9f5a 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/slashing/Params") legacy.RegisterAminoMsg(cdc, &MsgUnjail{}, "cosmos-sdk/MsgUnjail") legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/slashing/MsgUpdateParams") } diff --git a/x/staking/module.go b/x/staking/module.go index a315ae1a1963..622b088ca1ed 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/depinject" "cosmossdk.io/x/staking/client/cli" @@ -76,7 +77,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the staking module's types on the given LegacyAmino codec. -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 922a069e918e..0d4fb4a4d001 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -1,17 +1,17 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { legacy.RegisterAminoMsg(cdc, &MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator") legacy.RegisterAminoMsg(cdc, &MsgEditValidator{}, "cosmos-sdk/MsgEditValidator") legacy.RegisterAminoMsg(cdc, &MsgDelegate{}, "cosmos-sdk/MsgDelegate") @@ -22,10 +22,10 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgRotateConsPubKey{}, "cosmos-sdk/MsgRotateConsPubKey") cdc.RegisterInterface((*isStakeAuthorization_Validators)(nil), nil) - cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList", nil) - cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList", nil) - cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization", nil) - cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params", nil) + cdc.RegisterConcrete(&StakeAuthorization_AllowList{}, "cosmos-sdk/StakeAuthorization/AllowList") + cdc.RegisterConcrete(&StakeAuthorization_DenyList{}, "cosmos-sdk/StakeAuthorization/DenyList") + cdc.RegisterConcrete(&StakeAuthorization{}, "cosmos-sdk/StakeAuthorization") + cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/staking/Params") } // RegisterInterfaces registers the x/staking interfaces types with the interface registry diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 70e8bc0d3ee2..76c6e4e4ce38 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -10,20 +10,16 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" ) -func init() { - types.RegisterLegacyAminoCodec(codec.NewLegacyAmino()) -} - // ConsensusVersion defines the current x/upgrade module consensus version. const ConsensusVersion uint64 = 3 @@ -61,7 +57,7 @@ func (AppModule) Name() string { } // RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec -func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +func (AppModule) RegisterLegacyAminoCodec(cdc legacy.Amino) { types.RegisterLegacyAminoCodec(cdc) } diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 98bec26aa4d9..64d3b919cb1c 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -1,19 +1,19 @@ package types import ( + corelegacy "cosmossdk.io/core/legacy" "cosmossdk.io/core/registry" coretransaction "cosmossdk.io/core/transaction" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil) - cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) - cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil) +func RegisterLegacyAminoCodec(cdc corelegacy.Amino) { + cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan") + cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") + cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") legacy.RegisterAminoMsg(cdc, &MsgSoftwareUpgrade{}, "cosmos-sdk/MsgSoftwareUpgrade") legacy.RegisterAminoMsg(cdc, &MsgCancelUpgrade{}, "cosmos-sdk/MsgCancelUpgrade") }