chore: re-add IntProto and DecProto and deprecate msg (#22925)

This commit is contained in:
Julien Robert 2024-12-17 15:57:03 +01:00 committed by GitHub
parent 5799c15b90
commit 0a8917802c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 2133 additions and 783 deletions

View File

@ -164,7 +164,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### API Breaking Changes
* (baseapp) [#16244](https://github.com/cosmos/cosmos-sdk/pull/16244) `SetProtocolVersion` has been renamed to `SetAppVersion`. It now updates the consensus params in baseapp's `ParamStore`.
* (types) [#16918](https://github.com/cosmos/cosmos-sdk/pull/16918) Remove `IntProto` and `DecProto`. Instead, `math.Int` and `math.LegacyDec` should be used respectively. Both types support `Marshal` and `Unmarshal` which should be used for binary marshaling.
* (types) [#16918](https://github.com/cosmos/cosmos-sdk/pull/16918), [#22925](https://github.com/cosmos/cosmos-sdk/pull/22925) Deprecate `IntProto` and `DecProto`. Instead, `math.Int` and `math.LegacyDec` should be used respectively. Both types support `Marshal` and `Unmarshal` which should be used for binary marshaling.
* (client) [#17215](https://github.com/cosmos/cosmos-sdk/pull/17215) `server.StartCmd`,`server.ExportCmd`,`server.NewRollbackCmd`,`pruning.Cmd`,`genutilcli.InitCmd`,`genutilcli.GenTxCmd`,`genutilcli.CollectGenTxsCmd`,`genutilcli.AddGenesisAccountCmd`, do not take a home directory anymore. It is inferred from the root command.
* (client) [#17259](https://github.com/cosmos/cosmos-sdk/pull/17259) Remove deprecated `clientCtx.PrintObjectLegacy`. Use `clientCtx.PrintProto` or `clientCtx.PrintRaw` instead.
* (types) [#17348](https://github.com/cosmos/cosmos-sdk/pull/17348) Remove the `WrapServiceResult` function.

File diff suppressed because it is too large Load Diff

View File

@ -1361,16 +1361,27 @@ type GeneratorParams struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Seed uint64 `protobuf:"varint,1,opt,name=seed,proto3" json:"seed,omitempty"`
BucketCount uint64 `protobuf:"varint,2,opt,name=bucket_count,json=bucketCount,proto3" json:"bucket_count,omitempty"`
KeyMean uint64 `protobuf:"varint,3,opt,name=key_mean,json=keyMean,proto3" json:"key_mean,omitempty"`
KeyStdDev uint64 `protobuf:"varint,4,opt,name=key_std_dev,json=keyStdDev,proto3" json:"key_std_dev,omitempty"`
ValueMean uint64 `protobuf:"varint,6,opt,name=value_mean,json=valueMean,proto3" json:"value_mean,omitempty"`
ValueStdDev uint64 `protobuf:"varint,7,opt,name=value_std_dev,json=valueStdDev,proto3" json:"value_std_dev,omitempty"`
GenesisCount uint64 `protobuf:"varint,8,opt,name=genesis_count,json=genesisCount,proto3" json:"genesis_count,omitempty"`
// seed is the seed for the random number generator.
Seed uint64 `protobuf:"varint,1,opt,name=seed,proto3" json:"seed,omitempty"`
// bucket_count is the number of store keys to uniformly distribute genesis_count keys across.
BucketCount uint64 `protobuf:"varint,2,opt,name=bucket_count,json=bucketCount,proto3" json:"bucket_count,omitempty"`
// key_mean is the mean size (in normal distribution) of keys in each bucket.
KeyMean uint64 `protobuf:"varint,3,opt,name=key_mean,json=keyMean,proto3" json:"key_mean,omitempty"`
// key_std_dev is the standard deviation of key sizes in each bucket.
KeyStdDev uint64 `protobuf:"varint,4,opt,name=key_std_dev,json=keyStdDev,proto3" json:"key_std_dev,omitempty"`
// value_mean is the mean size (in normal distribution) of values in each bucket.
ValueMean uint64 `protobuf:"varint,6,opt,name=value_mean,json=valueMean,proto3" json:"value_mean,omitempty"`
// value_std_dev is the standard deviation of value sizes in each bucket.
ValueStdDev uint64 `protobuf:"varint,7,opt,name=value_std_dev,json=valueStdDev,proto3" json:"value_std_dev,omitempty"`
// genesis_count is the number of keys to insert in the store, distributed across all buckets.
GenesisCount uint64 `protobuf:"varint,8,opt,name=genesis_count,json=genesisCount,proto3" json:"genesis_count,omitempty"`
// insert_weight is the weight of insert operations.
InsertWeight float32 `protobuf:"fixed32,9,opt,name=insert_weight,json=insertWeight,proto3" json:"insert_weight,omitempty"`
// update_weight is the weight of update operations.
UpdateWeight float32 `protobuf:"fixed32,10,opt,name=update_weight,json=updateWeight,proto3" json:"update_weight,omitempty"`
GetWeight float32 `protobuf:"fixed32,12,opt,name=get_weight,json=getWeight,proto3" json:"get_weight,omitempty"`
// get_weight is the weight of get operations.
GetWeight float32 `protobuf:"fixed32,12,opt,name=get_weight,json=getWeight,proto3" json:"get_weight,omitempty"`
// delete_weight is the weight of delete operations.
DeleteWeight float32 `protobuf:"fixed32,11,opt,name=delete_weight,json=deleteWeight,proto3" json:"delete_weight,omitempty"`
}

View File

@ -35,3 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
# Changelog
## [Unreleased]
## [v0.1.0](https://github.com/cosmos/cosmos-sdk/releases/tag/indexer/postgres/v0.1.0)
Initial tag.

View File

@ -39,3 +39,27 @@ message DecCoin {
(gogoproto.nullable) = false
];
}
// IntProto defines a Protobuf wrapper around an Int object.
// Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
message IntProto {
option deprecated = true;
string int = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
}
// DecProto defines a Protobuf wrapper around a Dec object.
// Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
message DecProto {
option deprecated = true;
string dec = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

View File

@ -16,16 +16,16 @@ message Module {
// GenesisParams defines the genesis parameters for the benchmark module.
message GeneratorParams {
// seed is the seed for the random number generator.
uint64 seed = 1;
uint64 seed = 1;
// bucket_count is the number of store keys to uniformly distribute genesis_count keys across.
uint64 bucket_count = 2;
// key_mean is the mean size (in normal distribution) of keys in each bucket.
uint64 key_mean = 3;
uint64 key_mean = 3;
// key_std_dev is the standard deviation of key sizes in each bucket.
uint64 key_std_dev = 4;
uint64 key_std_dev = 4;
// value_mean is the mean size (in normal distribution) of values in each bucket.
uint64 value_mean = 6;
uint64 value_mean = 6;
// value_std_dev is the standard deviation of value sizes in each bucket.
uint64 value_std_dev = 7;
@ -37,7 +37,7 @@ message GeneratorParams {
// update_weight is the weight of update operations.
float update_weight = 10;
// get_weight is the weight of get operations.
float get_weight = 12;
float get_weight = 12;
// delete_weight is the weight of delete operations.
float delete_weight = 11;
}

View File

@ -955,3 +955,15 @@ func NormalizeCoins(coins []DecCoin) Coins {
return result
}
// ----------------------------------------------------------------------------
// Deprecated: Use math.Int instead.
func (ip IntProto) String() string {
return ip.Int.String()
}
// Deprecated: Use math.LegacyDec instead.
func (dp DecProto) String() string {
return dp.Dec.String()
}

View File

@ -122,15 +122,97 @@ func (m *DecCoin) GetDenom() string {
return ""
}
// IntProto defines a Protobuf wrapper around an Int object.
// Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
//
// Deprecated: Do not use.
type IntProto struct {
Int cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=int,proto3,customtype=cosmossdk.io/math.Int" json:"int"`
}
func (m *IntProto) Reset() { *m = IntProto{} }
func (*IntProto) ProtoMessage() {}
func (*IntProto) Descriptor() ([]byte, []int) {
return fileDescriptor_189a96714eafc2df, []int{2}
}
func (m *IntProto) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *IntProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_IntProto.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 *IntProto) XXX_Merge(src proto.Message) {
xxx_messageInfo_IntProto.Merge(m, src)
}
func (m *IntProto) XXX_Size() int {
return m.Size()
}
func (m *IntProto) XXX_DiscardUnknown() {
xxx_messageInfo_IntProto.DiscardUnknown(m)
}
var xxx_messageInfo_IntProto proto.InternalMessageInfo
// DecProto defines a Protobuf wrapper around a Dec object.
// Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
//
// Deprecated: Do not use.
type DecProto struct {
Dec cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=dec,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"dec"`
}
func (m *DecProto) Reset() { *m = DecProto{} }
func (*DecProto) ProtoMessage() {}
func (*DecProto) Descriptor() ([]byte, []int) {
return fileDescriptor_189a96714eafc2df, []int{3}
}
func (m *DecProto) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *DecProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_DecProto.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 *DecProto) XXX_Merge(src proto.Message) {
xxx_messageInfo_DecProto.Merge(m, src)
}
func (m *DecProto) XXX_Size() int {
return m.Size()
}
func (m *DecProto) XXX_DiscardUnknown() {
xxx_messageInfo_DecProto.DiscardUnknown(m)
}
var xxx_messageInfo_DecProto proto.InternalMessageInfo
func init() {
proto.RegisterType((*Coin)(nil), "cosmos.base.v1beta1.Coin")
proto.RegisterType((*DecCoin)(nil), "cosmos.base.v1beta1.DecCoin")
proto.RegisterType((*IntProto)(nil), "cosmos.base.v1beta1.IntProto")
proto.RegisterType((*DecProto)(nil), "cosmos.base.v1beta1.DecProto")
}
func init() { proto.RegisterFile("cosmos/base/v1beta1/coin.proto", fileDescriptor_189a96714eafc2df) }
var fileDescriptor_189a96714eafc2df = []byte{
// 294 bytes of a gzipped FileDescriptorProto
// 347 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0x2f, 0xce,
0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0x2c, 0x4e, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4,
0x4f, 0xce, 0xcf, 0xcc, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xeb, 0x81,
@ -144,12 +226,15 @@ var fileDescriptor_189a96714eafc2df = []byte{
0x99, 0x57, 0xb2, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x7e, 0x2b, 0x96, 0x17, 0x0b, 0xe4,
0x19, 0x95, 0x0a, 0xb8, 0xd8, 0x5d, 0x52, 0x93, 0xf1, 0x58, 0xe8, 0x89, 0x66, 0xa1, 0x21, 0xd4,
0x42, 0x69, 0x4c, 0x0b, 0x7d, 0x52, 0xd3, 0x13, 0x93, 0x2b, 0x5d, 0x52, 0x93, 0x91, 0xac, 0x75,
0x49, 0x4d, 0x46, 0xb5, 0xd1, 0xc9, 0xe5, 0xc6, 0x43, 0x39, 0x86, 0x86, 0x47, 0x72, 0x0c, 0x27,
0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c,
0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a,
0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x0d, 0x2d, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x52, 0x59,
0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x2c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3a, 0xd8,
0xb7, 0xd2, 0xa7, 0x01, 0x00, 0x00,
0x49, 0x4d, 0x46, 0xb3, 0xd1, 0x97, 0x8b, 0xc3, 0x33, 0xaf, 0x24, 0x00, 0x1c, 0x88, 0xb6, 0x5c,
0xcc, 0x99, 0x79, 0x25, 0x10, 0x0b, 0x9d, 0xb4, 0x49, 0xf0, 0x4a, 0x10, 0x48, 0x9f, 0x15, 0x93,
0x04, 0xa3, 0x52, 0x30, 0x17, 0x87, 0x4b, 0x6a, 0x32, 0xc4, 0x38, 0x67, 0x2e, 0xe6, 0x94, 0xd4,
0x64, 0xa8, 0x71, 0x64, 0x38, 0x14, 0xa4, 0x1b, 0x64, 0xa8, 0x93, 0xcb, 0x8d, 0x87, 0x72, 0x0c,
0x0d, 0x8f, 0xe4, 0x18, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39,
0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x29,
0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0xa3, 0x50, 0x4a, 0xb7, 0x38,
0x25, 0x5b, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xa1, 0xc6, 0x80, 0x00, 0x00,
0x00, 0xff, 0xff, 0x83, 0xaa, 0x36, 0x79, 0x4b, 0x02, 0x00, 0x00,
}
func (this *Coin) Equal(that interface{}) bool {
@ -286,6 +371,72 @@ func (m *DecCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *IntProto) 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 *IntProto) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *IntProto) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size := m.Int.Size()
i -= size
if _, err := m.Int.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintCoin(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func (m *DecProto) 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 *DecProto) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *DecProto) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size := m.Dec.Size()
i -= size
if _, err := m.Dec.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
i = encodeVarintCoin(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
return len(dAtA) - i, nil
}
func encodeVarintCoin(dAtA []byte, offset int, v uint64) int {
offset -= sovCoin(v)
base := offset
@ -327,6 +478,28 @@ func (m *DecCoin) Size() (n int) {
return n
}
func (m *IntProto) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = m.Int.Size()
n += 1 + l + sovCoin(uint64(l))
return n
}
func (m *DecProto) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = m.Dec.Size()
n += 1 + l + sovCoin(uint64(l))
return n
}
func sovCoin(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -565,6 +738,174 @@ func (m *DecCoin) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *IntProto) 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 ErrIntOverflowCoin
}
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: IntProto: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: IntProto: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Int", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCoin
}
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 ErrInvalidLengthCoin
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthCoin
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Int.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCoin(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthCoin
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *DecProto) 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 ErrIntOverflowCoin
}
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: DecProto: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DecProto: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Dec", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCoin
}
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 ErrInvalidLengthCoin
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthCoin
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Dec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCoin(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthCoin
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCoin(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

File diff suppressed because it is too large Load Diff