diff --git a/api/cosmos/app/v1alpha1/types.go b/api/cosmos/app/v1alpha1/types.go new file mode 100644 index 000000000000..f9fef776b707 --- /dev/null +++ b/api/cosmos/app/v1alpha1/types.go @@ -0,0 +1,28 @@ +package appv1alpha1 + +import "fmt" + +func (x *ModuleConfig) GetTypeUrl() (string, error) { + if x != nil { + if x.Config != nil { + return x.Config.TypeUrl, nil + } else { + return "", fmt.Errorf("module %q is missing a config object", x.Name) + } + } + return "", fmt.Errorf("Module is nil") +} + +func (x *ModuleConfig) GetGolangBindingsStrings() ([]string, []string) { + if x != nil { + interfaceTypes := make([]string, len(x.GolangBindings)) + imple := make([]string, len(x.GolangBindings)) + + for i, binding := range x.GolangBindings { + interfaceTypes[i] = binding.InterfaceType + imple[i] = binding.Implementation + } + return interfaceTypes, imple + } + return nil, nil +} \ No newline at end of file diff --git a/api/cosmos/app/v2/config.pb.go b/api/cosmos/app/v2/config.pb.go new file mode 100644 index 000000000000..4a0be52db670 --- /dev/null +++ b/api/cosmos/app/v2/config.pb.go @@ -0,0 +1,942 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/app/v2/config.proto + +package v2 + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + any "github.com/cosmos/gogoproto/types/any" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +type Config struct { + // modules are the module configurations for the app. + Modules []*ModuleConfig `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + GolangBindings []*GolangBinding `protobuf:"bytes,2,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (m *Config) Reset() { *m = Config{} } +func (m *Config) String() string { return proto.CompactTextString(m) } +func (*Config) ProtoMessage() {} +func (*Config) Descriptor() ([]byte, []int) { + return fileDescriptor_21129ebcee5a273d, []int{0} +} +func (m *Config) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Config.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Config) XXX_Merge(src proto.Message) { + xxx_messageInfo_Config.Merge(m, src) +} +func (m *Config) XXX_Size() int { + return m.Size() +} +func (m *Config) XXX_DiscardUnknown() { + xxx_messageInfo_Config.DiscardUnknown(m) +} + +var xxx_messageInfo_Config proto.InternalMessageInfo + +func (m *Config) GetModules() []*ModuleConfig { + if m != nil { + return m.Modules + } + return nil +} + +func (m *Config) GetGolangBindings() []*GolangBinding { + if m != nil { + return m.GolangBindings + } + return nil +} + +// ModuleConfig is a module configuration for an app. +type ModuleConfig struct { + // name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + Config *any.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + GolangBindings []*GolangBinding `protobuf:"bytes,3,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (m *ModuleConfig) Reset() { *m = ModuleConfig{} } +func (m *ModuleConfig) String() string { return proto.CompactTextString(m) } +func (*ModuleConfig) ProtoMessage() {} +func (*ModuleConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_21129ebcee5a273d, []int{1} +} +func (m *ModuleConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleConfig.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleConfig.Merge(m, src) +} +func (m *ModuleConfig) XXX_Size() int { + return m.Size() +} +func (m *ModuleConfig) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleConfig proto.InternalMessageInfo + +func (m *ModuleConfig) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ModuleConfig) GetConfig() *any.Any { + if m != nil { + return m.Config + } + return nil +} + +func (m *ModuleConfig) GetGolangBindings() []*GolangBinding { + if m != nil { + return m.GolangBindings + } + return nil +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +type GolangBinding struct { + // interface_type is the interface type which will be bound to a specific implementation type + InterfaceType string `protobuf:"bytes,1,opt,name=interface_type,json=interfaceType,proto3" json:"interface_type,omitempty"` + // implementation is the implementing type which will be supplied when an input of type interface is requested + Implementation string `protobuf:"bytes,2,opt,name=implementation,proto3" json:"implementation,omitempty"` +} + +func (m *GolangBinding) Reset() { *m = GolangBinding{} } +func (m *GolangBinding) String() string { return proto.CompactTextString(m) } +func (*GolangBinding) ProtoMessage() {} +func (*GolangBinding) Descriptor() ([]byte, []int) { + return fileDescriptor_21129ebcee5a273d, []int{2} +} +func (m *GolangBinding) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GolangBinding) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GolangBinding.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GolangBinding) XXX_Merge(src proto.Message) { + xxx_messageInfo_GolangBinding.Merge(m, src) +} +func (m *GolangBinding) XXX_Size() int { + return m.Size() +} +func (m *GolangBinding) XXX_DiscardUnknown() { + xxx_messageInfo_GolangBinding.DiscardUnknown(m) +} + +var xxx_messageInfo_GolangBinding proto.InternalMessageInfo + +func (m *GolangBinding) GetInterfaceType() string { + if m != nil { + return m.InterfaceType + } + return "" +} + +func (m *GolangBinding) GetImplementation() string { + if m != nil { + return m.Implementation + } + return "" +} + +func init() { + proto.RegisterType((*Config)(nil), "cosmos.app.v2.Config") + proto.RegisterType((*ModuleConfig)(nil), "cosmos.app.v2.ModuleConfig") + proto.RegisterType((*GolangBinding)(nil), "cosmos.app.v2.GolangBinding") +} + +func init() { proto.RegisterFile("cosmos/app/v2/config.proto", fileDescriptor_21129ebcee5a273d) } + +var fileDescriptor_21129ebcee5a273d = []byte{ + // 331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x4f, 0x3a, 0x31, + 0x1c, 0xc6, 0x29, 0xfc, 0xc2, 0x2f, 0x14, 0xc1, 0xa4, 0x71, 0x38, 0xd1, 0x5c, 0x08, 0x89, 0x86, + 0x41, 0xdb, 0xe4, 0x8c, 0x2f, 0x40, 0x8c, 0xd1, 0xc5, 0xe5, 0xe2, 0xe4, 0x20, 0xe9, 0x1d, 0xa5, + 0x36, 0x5e, 0xff, 0x84, 0x16, 0x92, 0x7b, 0x03, 0xce, 0x6e, 0xbe, 0x25, 0x47, 0x46, 0x47, 0x03, + 0x6f, 0xc4, 0xa4, 0x05, 0x03, 0xc4, 0xc9, 0xa9, 0xed, 0xf7, 0xfb, 0x79, 0xda, 0xe7, 0x69, 0x0b, + 0x3b, 0xb9, 0xb6, 0x52, 0x5b, 0x42, 0x8d, 0x21, 0xb3, 0x84, 0xe4, 0x5a, 0x8d, 0x05, 0xc7, 0x66, + 0xa2, 0x9d, 0x46, 0xad, 0xd0, 0xc3, 0xd4, 0x18, 0x3c, 0x4b, 0x3a, 0x87, 0x5c, 0x6b, 0x5e, 0x30, + 0xe2, 0x9b, 0xd9, 0x74, 0x4c, 0xa8, 0x2a, 0x03, 0xd9, 0x7b, 0x05, 0xb0, 0x7e, 0xed, 0xa5, 0xe8, + 0x12, 0xfe, 0x97, 0x7a, 0x34, 0x2d, 0x98, 0x8d, 0x40, 0xb7, 0xd6, 0x6f, 0x26, 0x47, 0x78, 0x6b, + 0x1b, 0x7c, 0xef, 0xbb, 0x81, 0x4e, 0xd7, 0x2c, 0xba, 0x81, 0xfb, 0x5c, 0x17, 0x54, 0xf1, 0x61, + 0x26, 0xd4, 0x48, 0x28, 0x6e, 0xa3, 0xaa, 0x97, 0x1f, 0xef, 0xc8, 0x6f, 0x3d, 0x35, 0x08, 0x50, + 0xda, 0xe6, 0x9b, 0x4b, 0xdb, 0x7b, 0x07, 0x70, 0x6f, 0xf3, 0x00, 0x84, 0xe0, 0x3f, 0x45, 0x25, + 0x8b, 0x40, 0x17, 0xf4, 0x1b, 0xa9, 0x9f, 0xa3, 0x33, 0x58, 0x0f, 0x39, 0xa3, 0x6a, 0x17, 0xf4, + 0x9b, 0xc9, 0x01, 0x0e, 0xc9, 0xf0, 0x3a, 0x19, 0xbe, 0x52, 0x65, 0xba, 0x62, 0x7e, 0x73, 0x56, + 0xfb, 0x83, 0xb3, 0x27, 0xd8, 0xda, 0x02, 0xd0, 0x09, 0x6c, 0x0b, 0xe5, 0xd8, 0x64, 0x4c, 0x73, + 0x36, 0x74, 0xa5, 0x59, 0x7b, 0x6c, 0xfd, 0x54, 0x1f, 0x4a, 0xc3, 0xd0, 0x29, 0x6c, 0x0b, 0x69, + 0x0a, 0x26, 0x99, 0x72, 0xd4, 0x09, 0xad, 0xbc, 0xe9, 0x46, 0xba, 0x53, 0x1d, 0xdc, 0x7d, 0x2c, + 0x62, 0x30, 0x5f, 0xc4, 0xe0, 0x6b, 0x11, 0x83, 0xb7, 0x65, 0x5c, 0x99, 0x2f, 0xe3, 0xca, 0xe7, + 0x32, 0xae, 0x3c, 0x62, 0x2e, 0xdc, 0xf3, 0x34, 0xc3, 0xb9, 0x96, 0x64, 0xf5, 0xda, 0x61, 0x38, + 0xb7, 0xa3, 0x17, 0x42, 0x8d, 0x20, 0x5b, 0x7f, 0x20, 0xab, 0xfb, 0x6b, 0xb8, 0xf8, 0x0e, 0x00, + 0x00, 0xff, 0xff, 0x28, 0x1c, 0x81, 0x18, 0x1b, 0x02, 0x00, 0x00, +} + +func (m *Config) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Config) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Config) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GolangBindings) > 0 { + for iNdEx := len(m.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GolangBindings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Modules) > 0 { + for iNdEx := len(m.Modules) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Modules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ModuleConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.GolangBindings) > 0 { + for iNdEx := len(m.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GolangBindings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Config != nil { + { + size, err := m.Config.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintConfig(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintConfig(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GolangBinding) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GolangBinding) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GolangBinding) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Implementation) > 0 { + i -= len(m.Implementation) + copy(dAtA[i:], m.Implementation) + i = encodeVarintConfig(dAtA, i, uint64(len(m.Implementation))) + i-- + dAtA[i] = 0x12 + } + if len(m.InterfaceType) > 0 { + i -= len(m.InterfaceType) + copy(dAtA[i:], m.InterfaceType) + i = encodeVarintConfig(dAtA, i, uint64(len(m.InterfaceType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintConfig(dAtA []byte, offset int, v uint64) int { + offset -= sovConfig(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Config) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Modules) > 0 { + for _, e := range m.Modules { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + if len(m.GolangBindings) > 0 { + for _, e := range m.GolangBindings { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + return n +} + +func (m *ModuleConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + if m.Config != nil { + l = m.Config.Size() + n += 1 + l + sovConfig(uint64(l)) + } + if len(m.GolangBindings) > 0 { + for _, e := range m.GolangBindings { + l = e.Size() + n += 1 + l + sovConfig(uint64(l)) + } + } + return n +} + +func (m *GolangBinding) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.InterfaceType) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + l = len(m.Implementation) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } + return n +} + +func sovConfig(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConfig(x uint64) (n int) { + return sovConfig(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Config) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Config: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Config: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Modules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Modules = append(m.Modules, &ModuleConfig{}) + if err := m.Modules[len(m.Modules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GolangBindings = append(m.GolangBindings, &GolangBinding{}) + if err := m.GolangBindings[len(m.GolangBindings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Config == nil { + m.Config = &any.Any{} + } + if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GolangBindings = append(m.GolangBindings, &GolangBinding{}) + if err := m.GolangBindings[len(m.GolangBindings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GolangBinding) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GolangBinding: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GolangBinding: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InterfaceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InterfaceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Implementation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Implementation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConfig(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthConfig + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConfig + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConfig + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConfig = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfig = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfig = fmt.Errorf("proto: unexpected end of group") +) diff --git a/api/cosmos/app/v2/module.pb.go b/api/cosmos/app/v2/module.pb.go new file mode 100644 index 000000000000..a6809babac60 --- /dev/null +++ b/api/cosmos/app/v2/module.pb.go @@ -0,0 +1,893 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/app/v2/module.proto + +package v2 + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ModuleDescriptor describes an app module. +type ModuleDescriptor struct { + // go_import names the package that should be imported by an app to load the + // module in the runtime module registry. It is required to make debugging + // of configuration errors easier for users. + GoImport string `protobuf:"bytes,1,opt,name=go_import,json=goImport,proto3" json:"go_import,omitempty"` + // use_package refers to a protobuf package that this module + // uses and exposes to the world. In an app, only one module should "use" + // or own a single protobuf package. It is assumed that the module uses + // all of the .proto files in a single package. + UsePackage []*PackageReference `protobuf:"bytes,2,rep,name=use_package,json=usePackage,proto3" json:"use_package,omitempty"` + // can_migrate_from defines which module versions this module can migrate + // state from. The framework will check that one module version is able to + // migrate from a previous module version before attempting to update its + // config. It is assumed that modules can transitively migrate from earlier + // versions. For instance if v3 declares it can migrate from v2, and v2 + // declares it can migrate from v1, the framework knows how to migrate + // from v1 to v3, assuming all 3 module versions are registered at runtime. + CanMigrateFrom []*MigrateFromInfo `protobuf:"bytes,3,rep,name=can_migrate_from,json=canMigrateFrom,proto3" json:"can_migrate_from,omitempty"` +} + +func (m *ModuleDescriptor) Reset() { *m = ModuleDescriptor{} } +func (m *ModuleDescriptor) String() string { return proto.CompactTextString(m) } +func (*ModuleDescriptor) ProtoMessage() {} +func (*ModuleDescriptor) Descriptor() ([]byte, []int) { + return fileDescriptor_4b23c047c529564d, []int{0} +} +func (m *ModuleDescriptor) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleDescriptor.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleDescriptor) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleDescriptor.Merge(m, src) +} +func (m *ModuleDescriptor) XXX_Size() int { + return m.Size() +} +func (m *ModuleDescriptor) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleDescriptor.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleDescriptor proto.InternalMessageInfo + +func (m *ModuleDescriptor) GetGoImport() string { + if m != nil { + return m.GoImport + } + return "" +} + +func (m *ModuleDescriptor) GetUsePackage() []*PackageReference { + if m != nil { + return m.UsePackage + } + return nil +} + +func (m *ModuleDescriptor) GetCanMigrateFrom() []*MigrateFromInfo { + if m != nil { + return m.CanMigrateFrom + } + return nil +} + +// PackageReference is a reference to a protobuf package used by a module. +type PackageReference struct { + // name is the fully-qualified name of the package. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // revision is the optional revision of the package that is being used. + // Protobuf packages used in Cosmos should generally have a major version + // as the last part of the package name, ex. foo.bar.baz.v1. + // The revision of a package can be thought of as the minor version of a + // package which has additional backwards compatible definitions that weren't + // present in a previous version. + // + // A package should indicate its revision with a source code comment + // above the package declaration in one of its files containing the + // text "Revision N" where N is an integer revision. All packages start + // at revision 0 the first time they are released in a module. + // + // When a new version of a module is released and items are added to existing + // .proto files, these definitions should contain comments of the form + // "Since: Revision N" where N is an integer revision. + // + // When the module runtime starts up, it will check the pinned proto + // image and panic if there are runtime protobuf definitions that are not + // in the pinned descriptor which do not have + // a "Since Revision N" comment or have a "Since Revision N" comment where + // N is <= to the revision specified here. This indicates that the protobuf + // files have been updated, but the pinned file descriptor hasn't. + // + // If there are items in the pinned file descriptor with a revision + // greater than the value indicated here, this will also cause a panic + // as it may mean that the pinned descriptor for a legacy module has been + // improperly updated or that there is some other versioning discrepancy. + // Runtime protobuf definitions will also be checked for compatibility + // with pinned file descriptors to make sure there are no incompatible changes. + // + // This behavior ensures that: + // - pinned proto images are up-to-date + // - protobuf files are carefully annotated with revision comments which + // are important good client UX + // - protobuf files are changed in backwards and forwards compatible ways + Revision uint32 `protobuf:"varint,2,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (m *PackageReference) Reset() { *m = PackageReference{} } +func (m *PackageReference) String() string { return proto.CompactTextString(m) } +func (*PackageReference) ProtoMessage() {} +func (*PackageReference) Descriptor() ([]byte, []int) { + return fileDescriptor_4b23c047c529564d, []int{1} +} +func (m *PackageReference) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PackageReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PackageReference.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PackageReference) XXX_Merge(src proto.Message) { + xxx_messageInfo_PackageReference.Merge(m, src) +} +func (m *PackageReference) XXX_Size() int { + return m.Size() +} +func (m *PackageReference) XXX_DiscardUnknown() { + xxx_messageInfo_PackageReference.DiscardUnknown(m) +} + +var xxx_messageInfo_PackageReference proto.InternalMessageInfo + +func (m *PackageReference) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *PackageReference) GetRevision() uint32 { + if m != nil { + return m.Revision + } + return 0 +} + +// MigrateFromInfo is information on a module version that a newer module +// can migrate from. +type MigrateFromInfo struct { + // module is the fully-qualified protobuf name of the module config object + // for the previous module version, ex: "cosmos.group.module.v1.Module". + Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` +} + +func (m *MigrateFromInfo) Reset() { *m = MigrateFromInfo{} } +func (m *MigrateFromInfo) String() string { return proto.CompactTextString(m) } +func (*MigrateFromInfo) ProtoMessage() {} +func (*MigrateFromInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_4b23c047c529564d, []int{2} +} +func (m *MigrateFromInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MigrateFromInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MigrateFromInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MigrateFromInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_MigrateFromInfo.Merge(m, src) +} +func (m *MigrateFromInfo) XXX_Size() int { + return m.Size() +} +func (m *MigrateFromInfo) XXX_DiscardUnknown() { + xxx_messageInfo_MigrateFromInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_MigrateFromInfo proto.InternalMessageInfo + +func (m *MigrateFromInfo) GetModule() string { + if m != nil { + return m.Module + } + return "" +} + +var E_Module = &proto.ExtensionDesc{ + ExtendedType: (*descriptorpb.MessageOptions)(nil), + ExtensionType: (*ModuleDescriptor)(nil), + Field: 57193490, + Name: "cosmos.app.v2.module", + Tag: "bytes,57193490,opt,name=module", + Filename: "cosmos/app/v2/module.proto", +} + +func init() { + proto.RegisterType((*ModuleDescriptor)(nil), "cosmos.app.v2.ModuleDescriptor") + proto.RegisterType((*PackageReference)(nil), "cosmos.app.v2.PackageReference") + proto.RegisterType((*MigrateFromInfo)(nil), "cosmos.app.v2.MigrateFromInfo") + proto.RegisterExtension(E_Module) +} + +func init() { proto.RegisterFile("cosmos/app/v2/module.proto", fileDescriptor_4b23c047c529564d) } + +var fileDescriptor_4b23c047c529564d = []byte{ + // 363 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x41, 0x8b, 0x1a, 0x31, + 0x18, 0x35, 0x5a, 0x44, 0x23, 0xb6, 0x92, 0x43, 0x19, 0x14, 0xc6, 0xc1, 0x93, 0x3d, 0x34, 0x01, + 0x7b, 0xeb, 0xa9, 0x48, 0x29, 0x7a, 0x90, 0x96, 0x39, 0x76, 0x0f, 0x43, 0x1c, 0x33, 0xd9, 0xa0, + 0x99, 0x2f, 0x24, 0x33, 0xfe, 0x8e, 0x65, 0x7f, 0xc2, 0xfe, 0x8d, 0xfd, 0x03, 0x7b, 0xf4, 0xb8, + 0xc7, 0x45, 0x2f, 0xfb, 0x33, 0x16, 0x66, 0x46, 0x59, 0x87, 0x3d, 0x25, 0xef, 0xbd, 0xe4, 0xbd, + 0x8f, 0x97, 0xe0, 0x61, 0x0c, 0x4e, 0x83, 0x63, 0xdc, 0x18, 0xb6, 0x9f, 0x31, 0x0d, 0x9b, 0x7c, + 0x27, 0xa8, 0xb1, 0x90, 0x01, 0xe9, 0x97, 0x1a, 0xe5, 0xc6, 0xd0, 0xfd, 0x6c, 0x18, 0x48, 0x00, + 0xb9, 0x13, 0xac, 0x10, 0xd7, 0x79, 0xc2, 0x36, 0xc2, 0xc5, 0x56, 0x99, 0x0c, 0x6c, 0x79, 0x61, + 0xf2, 0x88, 0xf0, 0x60, 0x55, 0x38, 0xfc, 0xbe, 0x48, 0x64, 0x84, 0xbb, 0x12, 0x22, 0xa5, 0x0d, + 0xd8, 0xcc, 0x43, 0x01, 0x9a, 0x76, 0xc3, 0x8e, 0x84, 0x65, 0x81, 0xc9, 0x2f, 0xdc, 0xcb, 0x9d, + 0x88, 0x0c, 0x8f, 0xb7, 0x5c, 0x0a, 0xaf, 0x19, 0xb4, 0xa6, 0xbd, 0xd9, 0x98, 0x5e, 0x05, 0xd3, + 0x7f, 0xa5, 0x1a, 0x8a, 0x44, 0x58, 0x91, 0xc6, 0x22, 0xc4, 0xb9, 0x13, 0x15, 0x49, 0x16, 0x78, + 0x10, 0xf3, 0x34, 0xd2, 0x4a, 0x5a, 0x9e, 0x89, 0x28, 0xb1, 0xa0, 0xbd, 0x56, 0x61, 0xe3, 0xd7, + 0x6c, 0x56, 0xe5, 0x91, 0x3f, 0x16, 0xf4, 0x32, 0x4d, 0x20, 0xfc, 0x1c, 0xf3, 0xf4, 0x1d, 0x37, + 0x99, 0xe3, 0x41, 0x3d, 0x89, 0x10, 0xfc, 0x29, 0xe5, 0x5a, 0x54, 0x73, 0x17, 0x7b, 0x32, 0xc4, + 0x1d, 0x2b, 0xf6, 0xca, 0x29, 0x48, 0xbd, 0x66, 0x80, 0xa6, 0xfd, 0xf0, 0x82, 0x27, 0xdf, 0xf0, + 0x97, 0x5a, 0x0c, 0xf9, 0x8a, 0xdb, 0x65, 0xab, 0x95, 0x49, 0x85, 0x7e, 0xde, 0x9c, 0x79, 0x32, + 0xa6, 0x65, 0xb3, 0xf4, 0xdc, 0x2c, 0x5d, 0x09, 0xe7, 0xb8, 0x14, 0x7f, 0x4d, 0xa6, 0x20, 0x75, + 0xde, 0xfd, 0xeb, 0xc3, 0x28, 0x40, 0x1f, 0x34, 0x53, 0x2f, 0xfb, 0x6c, 0x3e, 0x5f, 0x3c, 0x1d, + 0x7d, 0x74, 0x38, 0xfa, 0xe8, 0xe5, 0xe8, 0xa3, 0xbb, 0x93, 0xdf, 0x38, 0x9c, 0xfc, 0xc6, 0xf3, + 0xc9, 0x6f, 0xfc, 0xa7, 0x52, 0x65, 0xb7, 0xf9, 0x9a, 0xc6, 0xa0, 0x59, 0xf5, 0xf6, 0xe5, 0xf2, + 0xdd, 0x6d, 0xb6, 0x8c, 0x1b, 0xc5, 0xae, 0x7e, 0xc4, 0xba, 0x5d, 0x0c, 0xf5, 0xe3, 0x2d, 0x00, + 0x00, 0xff, 0xff, 0xad, 0x42, 0xd1, 0x52, 0x29, 0x02, 0x00, 0x00, +} + +func (m *ModuleDescriptor) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleDescriptor) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleDescriptor) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CanMigrateFrom) > 0 { + for iNdEx := len(m.CanMigrateFrom) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CanMigrateFrom[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.UsePackage) > 0 { + for iNdEx := len(m.UsePackage) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UsePackage[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.GoImport) > 0 { + i -= len(m.GoImport) + copy(dAtA[i:], m.GoImport) + i = encodeVarintModule(dAtA, i, uint64(len(m.GoImport))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PackageReference) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PackageReference) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PackageReference) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Revision != 0 { + i = encodeVarintModule(dAtA, i, uint64(m.Revision)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModule(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MigrateFromInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MigrateFromInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MigrateFromInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Module) > 0 { + i -= len(m.Module) + copy(dAtA[i:], m.Module) + i = encodeVarintModule(dAtA, i, uint64(len(m.Module))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintModule(dAtA []byte, offset int, v uint64) int { + offset -= sovModule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ModuleDescriptor) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.GoImport) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + if len(m.UsePackage) > 0 { + for _, e := range m.UsePackage { + l = e.Size() + n += 1 + l + sovModule(uint64(l)) + } + } + if len(m.CanMigrateFrom) > 0 { + for _, e := range m.CanMigrateFrom { + l = e.Size() + n += 1 + l + sovModule(uint64(l)) + } + } + return n +} + +func (m *PackageReference) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + if m.Revision != 0 { + n += 1 + sovModule(uint64(m.Revision)) + } + return n +} + +func (m *MigrateFromInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Module) + if l > 0 { + n += 1 + l + sovModule(uint64(l)) + } + return n +} + +func sovModule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModule(x uint64) (n int) { + return sovModule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ModuleDescriptor) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleDescriptor: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleDescriptor: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GoImport", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GoImport = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsePackage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UsePackage = append(m.UsePackage, &PackageReference{}) + if err := m.UsePackage[len(m.UsePackage)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanMigrateFrom", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CanMigrateFrom = append(m.CanMigrateFrom, &MigrateFromInfo{}) + if err := m.CanMigrateFrom[len(m.CanMigrateFrom)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PackageReference) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PackageReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PackageReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MigrateFromInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MigrateFromInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MigrateFromInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Module", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Module = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModule(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModule + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModule = fmt.Errorf("proto: unexpected end of group") +) diff --git a/api/cosmos/app/v2/types.go b/api/cosmos/app/v2/types.go new file mode 100644 index 000000000000..a61228664f7c --- /dev/null +++ b/api/cosmos/app/v2/types.go @@ -0,0 +1,28 @@ +package v2 + +import "fmt" + +func (x *ModuleConfig) GetTypeUrl() (string, error) { + if x != nil { + if x.Config != nil { + return x.Config.TypeUrl, nil + } else { + return "", fmt.Errorf("module %q is missing a config object", x.Name) + } + } + return "", fmt.Errorf("Module is nil") +} + +func (x *ModuleConfig) GetGolangBindingsStrings() ([]string, []string) { + if x != nil { + interfaceTypes := make([]string, len(x.GolangBindings)) + imple := make([]string, len(x.GolangBindings)) + + for i, binding := range x.GolangBindings { + interfaceTypes[i] = binding.InterfaceType + imple[i] = binding.Implementation + } + return interfaceTypes, imple + } + return nil, nil +} \ No newline at end of file diff --git a/api/go.mod b/api/go.mod index d888181d5a1e..0d7525af7f53 100644 --- a/api/go.mod +++ b/api/go.mod @@ -13,7 +13,9 @@ require ( require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.1-20240130113600-88ef6483f90f.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/tendermint/go-amino v0.16.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.20.0 // indirect diff --git a/api/go.sum b/api/go.sum index c10bff4ed738..5e4cff83c258 100644 --- a/api/go.sum +++ b/api/go.sum @@ -6,19 +6,38 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+R github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +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/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= @@ -28,3 +47,5 @@ google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLp google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 83160ad3790b..72280f6c905c 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -5,14 +5,18 @@ import ( "strings" "github.com/cosmos/cosmos-proto/anyutil" + "github.com/cosmos/gogoproto/jsonpb" + "github.com/cosmos/gogoproto/proto" + gogotypes "github.com/cosmos/gogoproto/types" "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" + protov2 "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/known/anypb" "sigs.k8s.io/yaml" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + appv2 "cosmossdk.io/api/cosmos/app/v2" "cosmossdk.io/depinject" internal "cosmossdk.io/depinject/internal/appconfig" ) @@ -21,11 +25,17 @@ import ( func LoadJSON(bz []byte) depinject.Config { config := &appv1alpha1.Config{} err := protojson.Unmarshal(bz, config) - if err != nil { - return depinject.Error(err) + if err == nil { + return Compose(config) } - return Compose(config) + gogoConfig := &appv2.Config{} + err = jsonpb.UnmarshalString(string(bz), gogoConfig) + if err == nil { + return Compose(gogoConfig) + } + + return depinject.Error(err) } // LoadYAML loads an app config in YAML format. @@ -48,67 +58,142 @@ func WrapAny(config protoreflect.ProtoMessage) *anypb.Any { return cfg } +type ModuleConfigI interface { + GetName() string + GetTypeUrl() (string, error) + GetGolangBindingsStrings() ([]string, []string) +} + // Compose composes a v1alpha1 app config into a container option by resolving // the required modules and composing their options. -func Compose(appConfig *appv1alpha1.Config) depinject.Config { +func Compose(appConfig proto.Message) depinject.Config { opts := []depinject.Config{ depinject.Supply(appConfig), } - for _, module := range appConfig.Modules { - if module.Name == "" { - return depinject.Error(fmt.Errorf("module is missing name")) + modules, err := internal.ModulesByProtoMessageName() + if err != nil { + return depinject.Error(err) + } + + var configModules []ModuleConfigI + + appConfigV2, isProtov2 := appConfig.(*appv1alpha1.Config) + if isProtov2 { + for _, m := range appConfigV2.Modules { + configModules = append(configModules, m) + } + } else { + appConfigV1 := appConfig.(*appv2.Config) + for _, m := range appConfigV1.Modules { + configModules = append(configModules, m) } + } - if module.Config == nil { - return depinject.Error(fmt.Errorf("module %q is missing a config object", module.Name)) + for _, module := range configModules { + if module.GetName() == "" { + return depinject.Error(fmt.Errorf("module is missing name")) } - msgType, err := protoregistry.GlobalTypes.FindMessageByURL(module.Config.TypeUrl) + msgTypeUrl, err := module.GetTypeUrl() if err != nil { return depinject.Error(err) } - modules, err := internal.ModulesByProtoMessageName() - if err != nil { - return depinject.Error(err) + var descriptor protoreflect.MessageDescriptor + + var moduleV2 *appv1alpha1.ModuleConfig + var moduleV1 *appv2.ModuleConfig + + if isProtov2 { + moduleV2 = module.(*appv1alpha1.ModuleConfig) + } else { + moduleV1 = module.(*appv2.ModuleConfig) } - init, ok := modules[msgType.Descriptor().FullName()] + if isProtov2 { + msgType, err := protoregistry.GlobalTypes.FindMessageByURL(msgTypeUrl) + if err != nil { + return depinject.Error(err) + } + descriptor = msgType.Descriptor() + } else { + des, err := proto.GogoResolver.FindDescriptorByName(protoreflect.FullName(GetProtoV1MsgNameFromAnyTypeUrl(msgTypeUrl))) + if err != nil { + return depinject.Error(err) + } + descriptor = des.(protoreflect.MessageDescriptor) + } + + init, ok := modules[descriptor.FullName()] if !ok { - modDesc := proto.GetExtension(msgType.Descriptor().Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + modDesc := protov2.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) if modDesc == nil { return depinject.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s", - module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules))) + msgTypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules))) } return depinject.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s: find more information on how to make a module ready for app wiring: https://docs.cosmos.network/main/building-modules/depinject\n\n%s", - module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules))) + msgTypeUrl, modDesc.GoImport, dumpRegisteredModules(modules))) } - config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface() - err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{}) - if err != nil { - return depinject.Error(err) - } + if isProtov2 { + config := init.ConfigProtoMessage.(protov2.Message).ProtoReflect().Type().New().Interface() + err = anypb.UnmarshalTo(moduleV2.Config, config, protov2.UnmarshalOptions{}) + if err != nil { + return depinject.Error(err) + } + opts = append(opts, depinject.Supply(config)) + for _, binding := range moduleV2.GolangBindings { + opts = append(opts, depinject.BindInterfaceInModule(moduleV2.GetName(), binding.InterfaceType, binding.Implementation)) + } + } else { + config := init.ConfigProtoMessage.(proto.Message) + + anyCfg := &gogotypes.Any{ + TypeUrl: moduleV1.Config.TypeUrl, + Value: moduleV1.Config.Value, + XXX_NoUnkeyedLiteral: moduleV1.Config.XXX_NoUnkeyedLiteral, + XXX_unrecognized: moduleV1.Config.XXX_unrecognized, + XXX_sizecache: moduleV1.Config.XXX_sizecache, + } + if err != nil { + return depinject.Error(err) + } - opts = append(opts, depinject.Supply(config)) + err = gogotypes.UnmarshalAny(anyCfg, config) + if err != nil { + return depinject.Error(err) + } + opts = append(opts, depinject.Supply(config)) + for _, binding := range moduleV1.GolangBindings { + opts = append(opts, depinject.BindInterfaceInModule(moduleV1.GetName(), binding.InterfaceType, binding.Implementation)) + } + } for _, provider := range init.Providers { - opts = append(opts, depinject.ProvideInModule(module.Name, provider)) + opts = append(opts, depinject.ProvideInModule(module.GetName(), provider)) } for _, invoker := range init.Invokers { - opts = append(opts, depinject.InvokeInModule(module.Name, invoker)) + opts = append(opts, depinject.InvokeInModule(module.GetName(), invoker)) } - for _, binding := range module.GolangBindings { - opts = append(opts, depinject.BindInterfaceInModule(module.Name, binding.InterfaceType, binding.Implementation)) + interfaceTypes, implementations := module.GetGolangBindingsStrings() + for i := range interfaceTypes { + opts = append(opts, depinject.BindInterfaceInModule(module.GetName(), interfaceTypes[i], implementations[i])) } } - for _, binding := range appConfig.GolangBindings { - opts = append(opts, depinject.BindInterface(binding.InterfaceType, binding.Implementation)) + if isProtov2 { + for _, binding := range appConfigV2.GolangBindings { + opts = append(opts, depinject.BindInterface(binding.InterfaceType, binding.Implementation)) + } + } else { + appConfigV1 := appConfig.(*appv2.Config) + for _, binding := range appConfigV1.GolangBindings { + opts = append(opts, depinject.BindInterface(binding.InterfaceType, binding.Implementation)) + } } return depinject.Configs(opts...) @@ -121,3 +206,8 @@ func dumpRegisteredModules(modules map[protoreflect.FullName]*internal.ModuleIni } return fmt.Sprintf("registered modules are:\n%s", strings.Join(mods, "\n")) } + +func GetProtoV1MsgNameFromAnyTypeUrl(url string) string { + msgName := strings.Split(url, "/") + return msgName[1] +} diff --git a/depinject/appconfig/config_test.go b/depinject/appconfig/config_test.go index 1bb799749d70..0dcf04000d92 100644 --- a/depinject/appconfig/config_test.go +++ b/depinject/appconfig/config_test.go @@ -35,7 +35,7 @@ modules: config: "@type": testpb.ModuleFoo `)) - expectContainerErrorContains(t, opt, `unable to resolve`) + expectContainerErrorContains(t, opt, `unknown message type`) opt = appconfig.LoadYAML([]byte(` modules: @@ -121,11 +121,122 @@ modules: expectContainerErrorContains(t, opt, "module should have ModuleDescriptor.go_import specified") } +func TestComposeGogoTypes(t *testing.T) { + opt := appconfig.LoadJSON([]byte(`{"modules":[{}]}`)) + expectContainerErrorContains(t, opt, "module is missing name") + + opt = appconfig.LoadJSON([]byte(`{"modules":[{"name": "a"}]}`)) + expectContainerErrorContains(t, opt, `module "a" is missing a config object`) + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": /testpb.ModuleFoo +`)) + expectContainerErrorContains(t, opt, `unknown message type`) + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": /cosmos.app.v1alpha1.Config # this is not actually a module config type! +`)) + expectContainerErrorContains(t, opt, "does not have the option cosmos.app.v1alpha1.module") + expectContainerErrorContains(t, opt, "registered modules are") + expectContainerErrorContains(t, opt, "testpb.TestModuleA") + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": /testpb.TestGogoUnregisteredModule +`)) + expectContainerErrorContains(t, opt, "did you forget to import cosmossdk.io/core/internal/testpb") + expectContainerErrorContains(t, opt, "registered modules are") + expectContainerErrorContains(t, opt, "testpb.TestModuleA") + + var app App + opt = appconfig.LoadYAML([]byte(` +modules: +- name: runtime + config: + "@type": /testpb.TestGogoRuntimeModule +- name: a + config: + "@type": /testpb.TestGogoModuleA +- name: b + config: + "@type": /testpb.TestGogoModuleB +`)) + assert.NilError(t, depinject.Inject(opt, &app)) + buf := &bytes.Buffer{} + app(buf) + const expected = `got store key a +got store key b +running module handler a +result: hello +running module handler b +result: goodbye +` + assert.Equal(t, expected, buf.String()) + + opt = appconfig.LoadYAML([]byte(` +golang_bindings: + - interfaceType: interfaceType/package.name + implementation: implementationType/package.name + - interfaceType: interfaceType/package.nameTwo + implementation: implementationType/package.nameTwo +modules: + - name: a + config: + "@type": /testpb.TestGogoModuleA + golang_bindings: + - interfaceType: interfaceType/package.name + implementation: implementationType/package.name + - interfaceType: interfaceType/package.nameTwo + implementation: implementationType/package.nameTwo +`)) + assert.NilError(t, depinject.Inject(opt)) + + // module registration failures: + appconfig.RegisterModule(&testpb.TestGogoNoModuleOptionModule{}) + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": /testpb.TestNoGoImportModule +`)) + expectContainerErrorContains(t, opt, "module should have the option cosmos.app.v1alpha1.module") + + internal.ModuleRegistry = map[reflect.Type]*internal.ModuleInitializer{} // reset module registry + appconfig.RegisterModule(&testpb.TestGogoNoGoImportModule{}) + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": /testpb.TestNoGoImportModule +`)) + expectContainerErrorContains(t, opt, "module should have ModuleDescriptor.go_import specified") +} + // // Test Module Initialization Logic // func init() { + appconfig.RegisterModule(&testpb.TestGogoRuntimeModule{}, + appconfig.Provide(ProvideRuntimeState, ProvideStoreKey, ProvideApp), + ) + + appconfig.RegisterModule(&testpb.TestGogoModuleA{}, + appconfig.Provide(ProvideModuleA), + ) + + appconfig.RegisterModule(&testpb.TestGogoModuleB{}, + appconfig.Provide(ProvideModuleB), + ) + appconfig.RegisterModule(&testpb.TestRuntimeModule{}, appconfig.Provide(ProvideRuntimeState, ProvideStoreKey, ProvideApp), ) diff --git a/depinject/appconfig/module.go b/depinject/appconfig/module.go index 7fc03957d1b5..7a707f6c4210 100644 --- a/depinject/appconfig/module.go +++ b/depinject/appconfig/module.go @@ -3,7 +3,7 @@ package appconfig import ( "reflect" - "google.golang.org/protobuf/proto" + "github.com/cosmos/gogoproto/proto" internal "cosmossdk.io/depinject/internal/appconfig" ) diff --git a/depinject/go.mod b/depinject/go.mod index 324fda6ded1d..add66dbf260c 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -1,23 +1,25 @@ module cosmossdk.io/depinject -go 1.20 +go 1.21 require ( cosmossdk.io/api v0.7.5 github.com/cosmos/cosmos-proto v1.0.0-beta.5 + github.com/cosmos/gogoproto v1.4.12 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb + golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 google.golang.org/protobuf v1.34.1 gotest.tools/v3 v3.5.1 sigs.k8s.io/yaml v1.4.0 ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/tendermint/go-amino v0.16.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect @@ -26,3 +28,5 @@ require ( gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace cosmossdk.io/api => ../api diff --git a/depinject/go.sum b/depinject/go.sum index ab7249c2d53e..fb6c7691fa16 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -1,13 +1,19 @@ -cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= -cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= 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/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= +github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= 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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= 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/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 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= @@ -16,21 +22,30 @@ 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/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -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/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= diff --git a/depinject/internal/appconfig/buf.gen.gogo.yaml b/depinject/internal/appconfig/buf.gen.gogo.yaml new file mode 100644 index 000000000000..cbb08d47e4e1 --- /dev/null +++ b/depinject/internal/appconfig/buf.gen.gogo.yaml @@ -0,0 +1,11 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/depinject/internal + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: gocosmos + out: . + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm,paths=source_relative diff --git a/depinject/internal/appconfig/registry.go b/depinject/internal/appconfig/registry.go index c79a50b4d29a..3a5de9b8313e 100644 --- a/depinject/internal/appconfig/registry.go +++ b/depinject/internal/appconfig/registry.go @@ -4,10 +4,12 @@ import ( "fmt" "reflect" - "google.golang.org/protobuf/proto" + protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/protoadapt" "google.golang.org/protobuf/reflect/protoreflect" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + "github.com/cosmos/gogoproto/proto" ) // ModuleRegistry is the registry of module initializers indexed by their golang @@ -30,13 +32,22 @@ func ModulesByProtoMessageName() (map[protoreflect.FullName]*ModuleInitializer, res := map[protoreflect.FullName]*ModuleInitializer{} for _, initializer := range ModuleRegistry { - descriptor := initializer.ConfigProtoMessage.ProtoReflect().Descriptor() + var descriptor protoreflect.MessageDescriptor + v2Msg, ok := initializer.ConfigProtoMessage.(protov2.Message) + if ok { + descriptor = v2Msg.ProtoReflect().Descriptor() + } else { + v1Msg, _ := initializer.ConfigProtoMessage.(proto.Message) + v2Msg := protoadapt.MessageV2Of(v1Msg) + descriptor = v2Msg.ProtoReflect().Descriptor() + } + fullName := descriptor.FullName() if _, ok := res[fullName]; ok { return nil, fmt.Errorf("duplicate module registration for %s", fullName) } - modDesc := proto.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + modDesc := protov2.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) if modDesc == nil { return nil, fmt.Errorf( "protobuf type %s registered as a module should have the option %s", diff --git a/depinject/internal/appconfig/testpb/test_gogo.pb.go b/depinject/internal/appconfig/testpb/test_gogo.pb.go new file mode 100644 index 000000000000..95be23f6dcd9 --- /dev/null +++ b/depinject/internal/appconfig/testpb/test_gogo.pb.go @@ -0,0 +1,869 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: testpb/test_gogo.proto + +package testpb + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type TestGogoRuntimeModule struct { +} + +func (m *TestGogoRuntimeModule) Reset() { *m = TestGogoRuntimeModule{} } +func (m *TestGogoRuntimeModule) String() string { return proto.CompactTextString(m) } +func (*TestGogoRuntimeModule) ProtoMessage() {} +func (*TestGogoRuntimeModule) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{0} +} +func (m *TestGogoRuntimeModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoRuntimeModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoRuntimeModule.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoRuntimeModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoRuntimeModule.Merge(m, src) +} +func (m *TestGogoRuntimeModule) XXX_Size() int { + return m.Size() +} +func (m *TestGogoRuntimeModule) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoRuntimeModule.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoRuntimeModule proto.InternalMessageInfo + +type TestGogoModuleA struct { +} + +func (m *TestGogoModuleA) Reset() { *m = TestGogoModuleA{} } +func (m *TestGogoModuleA) String() string { return proto.CompactTextString(m) } +func (*TestGogoModuleA) ProtoMessage() {} +func (*TestGogoModuleA) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{1} +} +func (m *TestGogoModuleA) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoModuleA) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoModuleA.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoModuleA) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoModuleA.Merge(m, src) +} +func (m *TestGogoModuleA) XXX_Size() int { + return m.Size() +} +func (m *TestGogoModuleA) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoModuleA.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoModuleA proto.InternalMessageInfo + +type TestGogoModuleB struct { +} + +func (m *TestGogoModuleB) Reset() { *m = TestGogoModuleB{} } +func (m *TestGogoModuleB) String() string { return proto.CompactTextString(m) } +func (*TestGogoModuleB) ProtoMessage() {} +func (*TestGogoModuleB) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{2} +} +func (m *TestGogoModuleB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoModuleB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoModuleB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoModuleB) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoModuleB.Merge(m, src) +} +func (m *TestGogoModuleB) XXX_Size() int { + return m.Size() +} +func (m *TestGogoModuleB) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoModuleB.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoModuleB proto.InternalMessageInfo + +type TestGogoUnregisteredModule struct { +} + +func (m *TestGogoUnregisteredModule) Reset() { *m = TestGogoUnregisteredModule{} } +func (m *TestGogoUnregisteredModule) String() string { return proto.CompactTextString(m) } +func (*TestGogoUnregisteredModule) ProtoMessage() {} +func (*TestGogoUnregisteredModule) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{3} +} +func (m *TestGogoUnregisteredModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoUnregisteredModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoUnregisteredModule.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoUnregisteredModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoUnregisteredModule.Merge(m, src) +} +func (m *TestGogoUnregisteredModule) XXX_Size() int { + return m.Size() +} +func (m *TestGogoUnregisteredModule) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoUnregisteredModule.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoUnregisteredModule proto.InternalMessageInfo + +type TestGogoNoModuleOptionModule struct { +} + +func (m *TestGogoNoModuleOptionModule) Reset() { *m = TestGogoNoModuleOptionModule{} } +func (m *TestGogoNoModuleOptionModule) String() string { return proto.CompactTextString(m) } +func (*TestGogoNoModuleOptionModule) ProtoMessage() {} +func (*TestGogoNoModuleOptionModule) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{4} +} +func (m *TestGogoNoModuleOptionModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoNoModuleOptionModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoNoModuleOptionModule.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoNoModuleOptionModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoNoModuleOptionModule.Merge(m, src) +} +func (m *TestGogoNoModuleOptionModule) XXX_Size() int { + return m.Size() +} +func (m *TestGogoNoModuleOptionModule) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoNoModuleOptionModule.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoNoModuleOptionModule proto.InternalMessageInfo + +type TestGogoNoGoImportModule struct { +} + +func (m *TestGogoNoGoImportModule) Reset() { *m = TestGogoNoGoImportModule{} } +func (m *TestGogoNoGoImportModule) String() string { return proto.CompactTextString(m) } +func (*TestGogoNoGoImportModule) ProtoMessage() {} +func (*TestGogoNoGoImportModule) Descriptor() ([]byte, []int) { + return fileDescriptor_873effbbb6b335c2, []int{5} +} +func (m *TestGogoNoGoImportModule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TestGogoNoGoImportModule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TestGogoNoGoImportModule.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TestGogoNoGoImportModule) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestGogoNoGoImportModule.Merge(m, src) +} +func (m *TestGogoNoGoImportModule) XXX_Size() int { + return m.Size() +} +func (m *TestGogoNoGoImportModule) XXX_DiscardUnknown() { + xxx_messageInfo_TestGogoNoGoImportModule.DiscardUnknown(m) +} + +var xxx_messageInfo_TestGogoNoGoImportModule proto.InternalMessageInfo + +func init() { + proto.RegisterType((*TestGogoRuntimeModule)(nil), "testpb.TestGogoRuntimeModule") + proto.RegisterType((*TestGogoModuleA)(nil), "testpb.TestGogoModuleA") + proto.RegisterType((*TestGogoModuleB)(nil), "testpb.TestGogoModuleB") + proto.RegisterType((*TestGogoUnregisteredModule)(nil), "testpb.TestGogoUnregisteredModule") + proto.RegisterType((*TestGogoNoModuleOptionModule)(nil), "testpb.TestGogoNoModuleOptionModule") + proto.RegisterType((*TestGogoNoGoImportModule)(nil), "testpb.TestGogoNoGoImportModule") +} + +func init() { proto.RegisterFile("testpb/test_gogo.proto", fileDescriptor_873effbbb6b335c2) } + +var fileDescriptor_873effbbb6b335c2 = []byte{ + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x49, 0x2d, 0x2e, + 0x29, 0x48, 0xd2, 0x07, 0x51, 0xf1, 0xe9, 0xf9, 0xe9, 0xf9, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, + 0x42, 0x6c, 0x10, 0x71, 0x29, 0x85, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xc4, 0x82, 0x02, + 0xfd, 0x32, 0xc3, 0xc4, 0x9c, 0x82, 0x8c, 0x44, 0x43, 0xfd, 0xdc, 0xfc, 0x94, 0xd2, 0x9c, 0x54, + 0x88, 0x4a, 0x25, 0x27, 0x2e, 0xd1, 0x90, 0xd4, 0xe2, 0x12, 0xf7, 0xfc, 0xf4, 0xfc, 0xa0, 0xd2, + 0xbc, 0x92, 0xcc, 0xdc, 0x54, 0x5f, 0xb0, 0xb4, 0x95, 0xe6, 0xae, 0x03, 0xd3, 0x6e, 0x31, 0x2a, + 0x73, 0x29, 0x42, 0x8c, 0x28, 0x4e, 0xc9, 0xd6, 0xcb, 0xcc, 0xd7, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, + 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0x87, 0xd8, 0xa2, 0x64, 0xc3, 0xc5, 0x0f, + 0x33, 0x03, 0xa2, 0xd9, 0x91, 0x22, 0xdd, 0x4e, 0xa4, 0xe8, 0x76, 0xe7, 0x92, 0x82, 0xe9, 0x0e, + 0xcd, 0x2b, 0x4a, 0x4d, 0xcf, 0x2c, 0x2e, 0x49, 0x2d, 0x4a, 0x4d, 0x21, 0xdd, 0x13, 0x72, 0x5c, + 0x32, 0x30, 0x83, 0xfc, 0xa0, 0x0e, 0xf1, 0x2f, 0x28, 0xc9, 0xcc, 0xcf, 0x83, 0xb0, 0x95, 0x94, + 0xb8, 0x24, 0x10, 0xf2, 0xee, 0xf9, 0x9e, 0xb9, 0x05, 0xf9, 0x45, 0x25, 0x50, 0x6b, 0xd8, 0xc0, + 0xd6, 0x30, 0x38, 0x4d, 0x66, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x06, 0x2e, + 0xae, 0xe4, 0xfc, 0x5c, 0x3d, 0x88, 0x55, 0x4e, 0xbc, 0x30, 0x83, 0x02, 0x40, 0x51, 0x10, 0xc0, + 0x18, 0xa5, 0x86, 0xe2, 0xbc, 0x94, 0xd4, 0x82, 0xcc, 0xbc, 0xac, 0xd4, 0xe4, 0x12, 0x74, 0x37, + 0x2e, 0x62, 0x62, 0x0e, 0x89, 0x88, 0x58, 0xc5, 0xc4, 0x16, 0x02, 0xe6, 0x9e, 0x82, 0x31, 0x1e, + 0x31, 0x09, 0x41, 0x18, 0x31, 0xee, 0x01, 0x4e, 0xbe, 0xa9, 0x25, 0x89, 0x29, 0x89, 0x25, 0x89, + 0xaf, 0x60, 0xb2, 0x49, 0x6c, 0xe0, 0x98, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x6e, + 0xa8, 0x7f, 0x2d, 0x02, 0x00, 0x00, +} + +func (m *TestGogoRuntimeModule) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoRuntimeModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoRuntimeModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TestGogoModuleA) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoModuleA) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoModuleA) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TestGogoModuleB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoModuleB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoModuleB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TestGogoUnregisteredModule) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoUnregisteredModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoUnregisteredModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TestGogoNoModuleOptionModule) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoNoModuleOptionModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoNoModuleOptionModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TestGogoNoGoImportModule) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TestGogoNoGoImportModule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TestGogoNoGoImportModule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTestGogo(dAtA []byte, offset int, v uint64) int { + offset -= sovTestGogo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TestGogoRuntimeModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TestGogoModuleA) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TestGogoModuleB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TestGogoUnregisteredModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TestGogoNoModuleOptionModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TestGogoNoGoImportModule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTestGogo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTestGogo(x uint64) (n int) { + return sovTestGogo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TestGogoRuntimeModule) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoRuntimeModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoRuntimeModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestGogoModuleA) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoModuleA: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoModuleA: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestGogoModuleB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoModuleB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoModuleB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestGogoUnregisteredModule) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoUnregisteredModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoUnregisteredModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestGogoNoModuleOptionModule) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoNoModuleOptionModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoNoModuleOptionModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TestGogoNoGoImportModule) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTestGogo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TestGogoNoGoImportModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TestGogoNoGoImportModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTestGogo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTestGogo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTestGogo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTestGogo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTestGogo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTestGogo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTestGogo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTestGogo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTestGogo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTestGogo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTestGogo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTestGogo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/depinject/internal/appconfig/testpb/test_gogo.proto b/depinject/internal/appconfig/testpb/test_gogo.proto new file mode 100644 index 000000000000..c5889d25b61d --- /dev/null +++ b/depinject/internal/appconfig/testpb/test_gogo.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package testpb; + +import "cosmos/app/v1alpha1/module.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/depinject/internal/appconfig/testgogo"; + +message TestGogoRuntimeModule { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestGogoModuleA { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestGogoModuleB { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestGogoUnregisteredModule { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestGogoNoModuleOptionModule {} + +message TestGogoNoGoImportModule { + option (cosmos.app.v1alpha1.module) = { + }; +} diff --git a/orm/go.mod b/orm/go.mod index 1420aed6c947..d64566f1a0d4 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -14,7 +14,7 @@ require ( github.com/iancoleman/strcase v0.3.0 github.com/regen-network/gocuke v1.1.1 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 + golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 google.golang.org/grpc v1.64.0 google.golang.org/protobuf v1.34.1 gotest.tools/v3 v3.5.1 @@ -22,6 +22,8 @@ require ( ) require ( + buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.1-20240312114316-c0d3497e35d6.1 // indirect + buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.1-20240130113600-88ef6483f90f.1 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect @@ -49,7 +51,7 @@ require ( github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/onsi/gomega v1.20.0 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.1 // indirect github.com/prometheus/client_model v0.6.0 // indirect github.com/prometheus/common v0.53.0 // indirect @@ -57,6 +59,7 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect @@ -67,6 +70,7 @@ require ( ) replace ( + cosmossdk.io/api => ../api cosmossdk.io/core => ../core cosmossdk.io/depinject => ../depinject ) diff --git a/orm/go.sum b/orm/go.sum index 9e43a3668ca4..45077b251a92 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -1,5 +1,7 @@ -cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= -cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.1-20240312114316-c0d3497e35d6.1 h1:lBlYy54lX1iBjFhbkd13bWlH7dMnoiyENzZ0Wok1YH4= +buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.1-20240312114316-c0d3497e35d6.1/go.mod h1:fYP6DZCfO5Ex4U+Xq1PqQwB8NQQhW5Y+Qbyzd/7dw7o= +buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.1-20240130113600-88ef6483f90f.1 h1:MfK7sTqm7NFqM/GOuuKOOemQzW8P7z07YQIW0vsYr38= +buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.1-20240130113600-88ef6483f90f.1/go.mod h1:RigkrxrsA6FPZontmsidcr0WGWF8zNFYleIktv6XdLc= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= @@ -63,6 +65,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -82,6 +85,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ 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/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -119,8 +125,9 @@ github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTw 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/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= @@ -137,20 +144,23 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= 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/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= 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/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -167,12 +177,13 @@ golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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= @@ -213,6 +224,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T 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= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= diff --git a/proto/cosmos/app/v2/config.proto b/proto/cosmos/app/v2/config.proto new file mode 100644 index 000000000000..0740cf06c718 --- /dev/null +++ b/proto/cosmos/app/v2/config.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; + +package cosmos.app.v2; + +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/api/cosmos/app/v2"; + +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +message Config { + // modules are the module configurations for the app. + repeated ModuleConfig modules = 1; + + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + repeated GolangBinding golang_bindings = 2; +} + +// ModuleConfig is a module configuration for an app. +message ModuleConfig { + // name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + string name = 1; + + // config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + google.protobuf.Any config = 2; + + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + repeated GolangBinding golang_bindings = 3; +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +message GolangBinding { + // interface_type is the interface type which will be bound to a specific implementation type + string interface_type = 1; + + // implementation is the implementing type which will be supplied when an input of type interface is requested + string implementation = 2; +} \ No newline at end of file diff --git a/proto/cosmos/app/v2/module.proto b/proto/cosmos/app/v2/module.proto new file mode 100644 index 000000000000..9ce5d259f372 --- /dev/null +++ b/proto/cosmos/app/v2/module.proto @@ -0,0 +1,93 @@ +syntax = "proto3"; + +package cosmos.app.v2; + +import "google/protobuf/descriptor.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/api/cosmos/app/v2"; + +extend google.protobuf.MessageOptions { + // module indicates that this proto type is a config object for an app module + // and optionally provides other descriptive information about the module. + // It is recommended that a new module config object and go module is versioned + // for every state machine breaking version of a module. The recommended + // pattern for doing this is to put module config objects in a separate proto + // package from the API they expose. Ex: the cosmos.group.v1 API would be + // exposed by module configs cosmos.group.module.v1, cosmos.group.module.v2, etc. + ModuleDescriptor module = 57193490; +} + +// ModuleDescriptor describes an app module. +message ModuleDescriptor { + // go_import names the package that should be imported by an app to load the + // module in the runtime module registry. It is required to make debugging + // of configuration errors easier for users. + string go_import = 1; + + // use_package refers to a protobuf package that this module + // uses and exposes to the world. In an app, only one module should "use" + // or own a single protobuf package. It is assumed that the module uses + // all of the .proto files in a single package. + repeated PackageReference use_package = 2; + + // can_migrate_from defines which module versions this module can migrate + // state from. The framework will check that one module version is able to + // migrate from a previous module version before attempting to update its + // config. It is assumed that modules can transitively migrate from earlier + // versions. For instance if v3 declares it can migrate from v2, and v2 + // declares it can migrate from v1, the framework knows how to migrate + // from v1 to v3, assuming all 3 module versions are registered at runtime. + repeated MigrateFromInfo can_migrate_from = 3; +} + +// PackageReference is a reference to a protobuf package used by a module. +message PackageReference { + // name is the fully-qualified name of the package. + string name = 1; + + // revision is the optional revision of the package that is being used. + // Protobuf packages used in Cosmos should generally have a major version + // as the last part of the package name, ex. foo.bar.baz.v1. + // The revision of a package can be thought of as the minor version of a + // package which has additional backwards compatible definitions that weren't + // present in a previous version. + // + // A package should indicate its revision with a source code comment + // above the package declaration in one of its files containing the + // text "Revision N" where N is an integer revision. All packages start + // at revision 0 the first time they are released in a module. + // + // When a new version of a module is released and items are added to existing + // .proto files, these definitions should contain comments of the form + // "Since: Revision N" where N is an integer revision. + // + // When the module runtime starts up, it will check the pinned proto + // image and panic if there are runtime protobuf definitions that are not + // in the pinned descriptor which do not have + // a "Since Revision N" comment or have a "Since Revision N" comment where + // N is <= to the revision specified here. This indicates that the protobuf + // files have been updated, but the pinned file descriptor hasn't. + // + // If there are items in the pinned file descriptor with a revision + // greater than the value indicated here, this will also cause a panic + // as it may mean that the pinned descriptor for a legacy module has been + // improperly updated or that there is some other versioning discrepancy. + // Runtime protobuf definitions will also be checked for compatibility + // with pinned file descriptors to make sure there are no incompatible changes. + // + // This behavior ensures that: + // * pinned proto images are up-to-date + // * protobuf files are carefully annotated with revision comments which + // are important good client UX + // * protobuf files are changed in backwards and forwards compatible ways + uint32 revision = 2; +} + +// MigrateFromInfo is information on a module version that a newer module +// can migrate from. +message MigrateFromInfo { + + // module is the fully-qualified protobuf name of the module config object + // for the previous module version, ex: "cosmos.group.module.v1.Module". + string module = 1; +} diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 9840ca88316a..f33dc0b23e4b 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -81,6 +81,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/net v0.25.0 // indirect diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index a3a26f890ba6..791ea70bb530 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -77,6 +77,7 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -98,7 +99,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ 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/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -214,6 +218,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -245,6 +251,7 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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= @@ -293,6 +300,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T 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= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index c4bbd6d1dfde..6d289dcc57ad 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -24,6 +24,9 @@ for dir in $proto_dirs; do if [ -d "../cosmos" -a "$dir" != "./proto" ]; then cp -r ../cosmos $home/api rm -rf ../cosmos + + # remove /api/cosmos/app/v2 folder since v2 not support pulsar + rm -rf $home/api/cosmos/app/v2/*.pulsar.go fi fi