diff --git a/proto/greenfield/virtualgroup/params.proto b/proto/greenfield/virtualgroup/params.proto index 00c5ce0af..9565dfeea 100644 --- a/proto/greenfield/virtualgroup/params.proto +++ b/proto/greenfield/virtualgroup/params.proto @@ -20,11 +20,10 @@ message Params { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - - // min_deposit defines the minimum deposit amount for storage providers. - string min_deposit = 3 [ - (cosmos_proto.scalar) = "cosmos.Int", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; + // the max number of lvg which allowed in a bucket + uint32 max_local_virtual_group_num_per_bucket = 3; + // the max number of gvg which can exist in a family + uint32 max_global_virtual_group_num_per_family = 4; + // if the store size reach the exceed, the family is not allowed to sever more buckets + uint64 max_store_size_per_family = 5; } diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 4b3e6a6f2..548a5cf63 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -446,8 +446,9 @@ func (k Keeper) CreateObject( if !found { return sdkmath.ZeroUint(), types.ErrNoSuchBucket } - if bucketInfo.BucketStatus == types.BUCKET_STATUS_DISCONTINUED { - return sdkmath.ZeroUint(), types.ErrBucketDiscontinued + err := bucketInfo.CheckBucketStatus() + if err != nil { + return sdkmath.ZeroUint(), err } // verify permission @@ -856,6 +857,11 @@ func (k Keeper) CopyObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrNoSuchBucket, "dst bucket name (%s)", dstBucketName) } + err := dstBucketInfo.CheckBucketStatus() + if err != nil { + return sdkmath.ZeroUint(), err + } + srcObjectInfo, found := k.GetObjectInfo(ctx, srcBucketName, srcObjectName) if !found { return sdkmath.ZeroUint(), errors.Wrapf(types.ErrNoSuchObject, "src object name (%s)", srcObjectName) diff --git a/x/storage/types/errors.go b/x/storage/types/errors.go index a6a63c89f..6f88bcd84 100644 --- a/x/storage/types/errors.go +++ b/x/storage/types/errors.go @@ -36,13 +36,13 @@ var ( ErrInvalidOperationType = errors.Register(ModuleName, 3002, "invalid operation type") ErrInvalidId = errors.Register(ModuleName, 3003, "id is invalid") - ErrInvalidObjectIds = errors.Register(ModuleName, 3101, "object ids are invalid") - ErrInvalidReason = errors.Register(ModuleName, 3102, "reason is invalid") - ErrNoMoreDiscontinue = errors.Register(ModuleName, 3103, "no more discontinue requests") - ErrBucketDiscontinued = errors.Register(ModuleName, 3104, "the bucket is discontinued") - ErrInvalidObjectStatus = errors.Register(ModuleName, 3105, "invalid object status") - ErrInvalidBucketStatus = errors.Register(ModuleName, 3106, "invalid bucket status") - + ErrInvalidObjectIds = errors.Register(ModuleName, 3101, "object ids are invalid") + ErrInvalidReason = errors.Register(ModuleName, 3102, "reason is invalid") + ErrNoMoreDiscontinue = errors.Register(ModuleName, 3103, "no more discontinue requests") + ErrBucketDiscontinued = errors.Register(ModuleName, 3104, "the bucket is discontinued") + ErrInvalidObjectStatus = errors.Register(ModuleName, 3105, "invalid object status") + ErrInvalidBucketStatus = errors.Register(ModuleName, 3106, "invalid bucket status") + ErrBucketMigrating = errors.Register(ModuleName, 3107, "the bucket is migrating") ErrInvalidResource = errors.Register(ModuleName, 3201, "invalid resource type") ErrMigtationBucketFailed = errors.Register(ModuleName, 3202, "migrate bucket failed.") ) diff --git a/x/storage/types/types.go b/x/storage/types/types.go index c5b0f7469..e9a833862 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -40,6 +40,15 @@ func (m *BucketInfo) ToNFTMetadata() *BucketMetaData { } } +func (m *BucketInfo) CheckBucketStatus() error { + if m.BucketStatus == BUCKET_STATUS_DISCONTINUED { + return ErrBucketDiscontinued + } else if m.BucketStatus == BUCKET_STATUS_MIGRATING { + return ErrBucketMigrating + } + return nil +} + func (m *ObjectInfo) ToNFTMetadata() *ObjectMetaData { return &ObjectMetaData{ ObjectName: m.ObjectName, diff --git a/x/virtualgroup/keeper/keeper.go b/x/virtualgroup/keeper/keeper.go index 631762389..bcf39b3c0 100644 --- a/x/virtualgroup/keeper/keeper.go +++ b/x/virtualgroup/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "encoding/binary" "fmt" + "github.com/prysmaticlabs/prysm/crypto/bls" "cosmossdk.io/errors" @@ -231,6 +232,11 @@ func (k Keeper) GetOrCreateEmptyGVGFamily(ctx sdk.Context, familyID uint32, spID return nil, types.ErrGVGFamilyNotExist } k.cdc.MustUnmarshal(bz, &gvgFamily) + + storeSize := k.GetStoreSizeOfFamily(ctx, gvgFamily) + if storeSize > k.MaxStoreSizePerFamily(ctx) { + return nil, types.ErrStoreSizeExceed.Wrapf("A family only allow to store %ld, now: %ld", k.MaxStoreSizePerFamily(ctx), storeSize) + } return &gvgFamily, nil } } @@ -623,3 +629,18 @@ func (k Keeper) VerifyGVGSecondarySPsBlsSignature(ctx sdk.Context, gvgId uint32, } return types2.VerifyBlsAggSignature(secondarySpBlsPubKeys, signBz, signature) } + +// GetStoreSizeOfFamily Rather than calculating the stored size of a Global Virtual Group Family (GVGF) in real-time, +// it is preferable to calculate it once during the creation of a Global Virtual Group (GVG). This approach is favored +// because GVG creation is infrequent and occurs with low frequency. +func (k Keeper) GetStoreSizeOfFamily(ctx sdk.Context, gvgFamily types.GlobalVirtualGroupFamily) uint64 { + var totalStoreSize uint64 + for _, gvgID := range gvgFamily.GlobalVirtualGroupIds { + gvg, found := k.GetGVG(ctx, gvgID) + if !found { + panic("gvg not found when get store size of family") + } + totalStoreSize += gvg.StoredSize + } + return totalStoreSize +} diff --git a/x/virtualgroup/keeper/msg_server.go b/x/virtualgroup/keeper/msg_server.go index 51b61fd47..d2df17231 100644 --- a/x/virtualgroup/keeper/msg_server.go +++ b/x/virtualgroup/keeper/msg_server.go @@ -61,7 +61,6 @@ func (k msgServer) CreateGlobalVirtualGroup(goCtx context.Context, req *types.Ms // TODO(fynn): add some limit for gvgs in a family gvgFamily, err := k.GetOrCreateEmptyGVGFamily(ctx, req.FamilyId, sp.Id) - if err != nil { return nil, err } diff --git a/x/virtualgroup/keeper/params.go b/x/virtualgroup/keeper/params.go index 56131a95f..9395177d1 100644 --- a/x/virtualgroup/keeper/params.go +++ b/x/virtualgroup/keeper/params.go @@ -1,7 +1,6 @@ package keeper import ( - "cosmossdk.io/math" "github.com/bnb-chain/greenfield/x/virtualgroup/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -11,14 +10,24 @@ func (k Keeper) DepositDenomForGVG(ctx sdk.Context) (res string) { return params.DepositDenom } -func (k Keeper) MinDeposit(ctx sdk.Context) (res math.Int) { +func (k Keeper) GVGStakingPrice(ctx sdk.Context) (res sdk.Dec) { params := k.GetParams(ctx) - return params.MinDeposit + return params.GvgStakingPrice } -func (k Keeper) GVGStakingPrice(ctx sdk.Context) (res sdk.Dec) { +func (k Keeper) MaxLocalVirtualGroupNumPerBucket(ctx sdk.Context) (res uint32) { params := k.GetParams(ctx) - return params.GvgStakingPrice + return params.MaxLocalVirtualGroupNumPerBucket +} + +func (k Keeper) MaxGlobalVirtualGroupNumPerFamily(ctx sdk.Context) (res uint32) { + params := k.GetParams(ctx) + return params.MaxGlobalVirtualGroupNumPerFamily +} + +func (k Keeper) MaxStoreSizePerFamily(ctx sdk.Context) (res uint64) { + params := k.GetParams(ctx) + return params.MaxStoreSizePerFamily } // GetParams returns the current sp module parameters. diff --git a/x/virtualgroup/types/errors.go b/x/virtualgroup/types/errors.go index d4682717e..d07e137a7 100644 --- a/x/virtualgroup/types/errors.go +++ b/x/virtualgroup/types/errors.go @@ -19,6 +19,7 @@ var ( ErrInvalidGVGCount = errors.Register(ModuleName, 1120, "the count of global virtual group ids is invalid.") ErrMigrationBucketFailed = errors.Register(ModuleName, 1121, "fail to migration bucket.") ErrInvalidBlsPubKey = errors.Register(ModuleName, 1122, "invalid bls public key") + ErrStoreSizeExceed = errors.Register(ModuleName, 1123, "store size exceed.") ErrInvalidDenom = errors.Register(ModuleName, 2000, "Invalid denom.") ) diff --git a/x/virtualgroup/types/params.go b/x/virtualgroup/types/params.go index 85c1747b9..110f8c3cb 100644 --- a/x/virtualgroup/types/params.go +++ b/x/virtualgroup/types/params.go @@ -3,10 +3,8 @@ package types import ( "errors" "fmt" - "math/big" "strings" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -19,16 +17,18 @@ const ( ) var ( - // DefaultMinDeposit defines the minimum deposit amount for all storage provider - DefaultMinDeposit = math.NewIntFromBigInt(new(big.Int).Mul(big.NewInt(10000), big.NewInt(1e18))) - // DefaultGVGStakingPrice defines the default gvg staking price // TODO: Set a reasonable value. - DefaultGVGStakingPrice = sdk.NewDecFromIntWithPrec(sdk.NewInt(2), 18) - - KeyDepositDenom = []byte("DepositDenom") - KeyMinDeposit = []byte("MinDeposit") - KeyGVGStakingPrice = []byte("GVGStakingPrice") + DefaultGVGStakingPrice = sdk.NewDecFromIntWithPrec(sdk.NewInt(2), 18) + DefaultMaxLocalVirtualGroupNumPerBucket = uint32(10) + DefaultMaxGlocakVirtualGroupNumPerFamily = uint32(10) + DefaultMaxStoreSizePerFamily = uint64(64) * 1024 * 1024 * 1024 //64T + + KeyDepositDenom = []byte("DepositDenom") + KeyGVGStakingPrice = []byte("GVGStakingPrice") + KeyMaxLocalVirtualGroupNumPerBucket = []byte("MaxLocalVirtualGroupNumPerBucket") + KeyMaxGlobalVirtualGroupNumPerFamily = []byte("MaxGlobalVirtualGroupNumPerFamily") + KeyMaxStoreSizePerFamily = []byte("MaxStoreSizePerFamily") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -39,25 +39,30 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams(depositDenom string, minDeposit math.Int, baseGVGStorageStakingPrice sdk.Dec) Params { +func NewParams(depositDenom string, gvgStakingPrice sdk.Dec, maxLocalVirtualGroupNumPerBucket, maxGlobalVirtualGroupPerFamily uint32, + maxStoreSizePerFamily uint64) Params { return Params{ - DepositDenom: depositDenom, - GvgStakingPrice: baseGVGStorageStakingPrice, - MinDeposit: minDeposit, + DepositDenom: depositDenom, + GvgStakingPrice: gvgStakingPrice, + MaxLocalVirtualGroupNumPerBucket: maxLocalVirtualGroupNumPerBucket, + MaxGlobalVirtualGroupNumPerFamily: maxGlobalVirtualGroupPerFamily, + MaxStoreSizePerFamily: maxStoreSizePerFamily, } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams(DefaultDepositDenom, DefaultMinDeposit, DefaultGVGStakingPrice) + return NewParams(DefaultDepositDenom, DefaultGVGStakingPrice, DefaultMaxLocalVirtualGroupNumPerBucket, DefaultMaxGlocakVirtualGroupNumPerFamily, DefaultMaxStoreSizePerFamily) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyMinDeposit, &p.MinDeposit, validateMinDeposit), paramtypes.NewParamSetPair(KeyDepositDenom, &p.DepositDenom, validateDepositDenom), paramtypes.NewParamSetPair(KeyGVGStakingPrice, &p.GvgStakingPrice, validateGVGStakingPrice), + paramtypes.NewParamSetPair(KeyMaxLocalVirtualGroupNumPerBucket, &p.MaxLocalVirtualGroupNumPerBucket, validateMaxLocalVirtualGroupNumPerBucket), + paramtypes.NewParamSetPair(KeyMaxGlobalVirtualGroupNumPerFamily, &p.MaxGlobalVirtualGroupNumPerFamily, validateMaxGlobalVirtualGroupNumPerFamily), + paramtypes.NewParamSetPair(KeyMaxStoreSizePerFamily, &p.MaxStoreSizePerFamily, validateMaxStoreSizePerFamily), } } @@ -89,30 +94,52 @@ func validateDepositDenom(i interface{}) error { return nil } -func validateMinDeposit(i interface{}) error { - v, ok := i.(math.Int) +func validateGVGStakingPrice(i interface{}) error { + v, ok := i.(sdk.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } + if v.IsNil() || !v.IsPositive() || v.GT(sdk.OneDec()) { + return fmt.Errorf("invalid secondary sp store price ratio") + } + return nil +} - if v.IsNil() { - return fmt.Errorf("minimum deposit amount cannot be nil") +func validateMaxLocalVirtualGroupNumPerBucket(i interface{}) error { + v, ok := i.(uint32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) } - if v.IsNegative() { - return fmt.Errorf("minimum deposit amount cannot be lower than 0") + if v == 0 { + return fmt.Errorf("max buckets per account must be positive: %d", v) } return nil } -func validateGVGStakingPrice(i interface{}) error { - v, ok := i.(sdk.Dec) +func validateMaxGlobalVirtualGroupNumPerFamily(i interface{}) error { + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if v.IsNil() || !v.IsPositive() || v.GT(sdk.OneDec()) { - return fmt.Errorf("invalid secondary sp store price ratio") + + if v == 0 { + return fmt.Errorf("max buckets per account must be positive: %d", v) } + + return nil +} + +func validateMaxStoreSizePerFamily(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("max buckets per account must be positive: %d", v) + } + return nil } diff --git a/x/virtualgroup/types/params.pb.go b/x/virtualgroup/types/params.pb.go index 914533ab8..7185edc72 100644 --- a/x/virtualgroup/types/params.pb.go +++ b/x/virtualgroup/types/params.pb.go @@ -31,8 +31,12 @@ type Params struct { DepositDenom string `protobuf:"bytes,1,opt,name=deposit_denom,json=depositDenom,proto3" json:"deposit_denom,omitempty"` // store price, in bnb wei per charge byte GvgStakingPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=gvg_staking_price,json=gvgStakingPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"gvg_staking_price"` - // min_deposit defines the minimum deposit amount for storage providers. - MinDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_deposit,json=minDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_deposit"` + // the max number of lvg which allowed in a bucket + MaxLocalVirtualGroupNumPerBucket uint32 `protobuf:"varint,3,opt,name=max_local_virtual_group_num_per_bucket,json=maxLocalVirtualGroupNumPerBucket,proto3" json:"max_local_virtual_group_num_per_bucket,omitempty"` + // the max number of gvg which can exist in a family + MaxGlobalVirtualGroupNumPerFamily uint32 `protobuf:"varint,4,opt,name=max_global_virtual_group_num_per_family,json=maxGlobalVirtualGroupNumPerFamily,proto3" json:"max_global_virtual_group_num_per_family,omitempty"` + // if the store size reach the exceed, the family is not allowed to sever more buckets + MaxStoreSizePerFamily uint64 `protobuf:"varint,5,opt,name=max_store_size_per_family,json=maxStoreSizePerFamily,proto3" json:"max_store_size_per_family,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -74,6 +78,27 @@ func (m *Params) GetDepositDenom() string { return "" } +func (m *Params) GetMaxLocalVirtualGroupNumPerBucket() uint32 { + if m != nil { + return m.MaxLocalVirtualGroupNumPerBucket + } + return 0 +} + +func (m *Params) GetMaxGlobalVirtualGroupNumPerFamily() uint32 { + if m != nil { + return m.MaxGlobalVirtualGroupNumPerFamily + } + return 0 +} + +func (m *Params) GetMaxStoreSizePerFamily() uint64 { + if m != nil { + return m.MaxStoreSizePerFamily + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.virtualgroup.Params") } @@ -83,27 +108,33 @@ func init() { } var fileDescriptor_d8ecf89dd5128885 = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0x2f, 0x4a, 0x4d, - 0xcd, 0x4b, 0xcb, 0x4c, 0xcd, 0x49, 0xd1, 0x2f, 0xcb, 0x2c, 0x2a, 0x29, 0x4d, 0xcc, 0x49, 0x2f, - 0xca, 0x2f, 0x2d, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x47, 0xa8, 0xd2, 0x43, 0x56, 0x25, 0x25,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x05, - 0xf2, 0x0c, 0x2f, 0x16, 0xc8, 0x33, 0x3a, 0xf9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, - 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, - 0x1c, 0x43, 0x94, 0x09, 0x92, 0x2d, 0x49, 0x79, 0x49, 0xba, 0xc9, 0x19, 0x89, 0x99, 0x79, 0xfa, - 0x48, 0x31, 0x54, 0x81, 0x1a, 0x47, 0x60, 0x7b, 0x93, 0xd8, 0xc0, 0x21, 0x6b, 0x0c, 0x08, 0x00, - 0x00, 0xff, 0xff, 0x80, 0x19, 0x82, 0x31, 0xcb, 0x01, 0x00, 0x00, + // 412 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x3f, 0x6f, 0xd4, 0x30, + 0x18, 0x87, 0x63, 0x5a, 0x2a, 0xb0, 0xa8, 0x10, 0x11, 0x88, 0xb4, 0x43, 0x12, 0xfe, 0xa8, 0xdc, + 0x72, 0xc9, 0x00, 0x03, 0x42, 0x4c, 0xa7, 0x13, 0x5d, 0x50, 0x15, 0xe5, 0x24, 0x06, 0x16, 0xcb, + 0x71, 0x5c, 0x9f, 0x75, 0x71, 0x1c, 0xd9, 0xce, 0x29, 0xed, 0xc6, 0x37, 0x60, 0x64, 0xec, 0x87, + 0xe0, 0x43, 0x74, 0xac, 0x98, 0x10, 0x43, 0x85, 0xee, 0x16, 0x3e, 0x06, 0xb2, 0x13, 0x41, 0x10, + 0xea, 0x94, 0xe4, 0x97, 0xc7, 0x8f, 0xde, 0xf7, 0xf5, 0x0b, 0x9f, 0x33, 0x45, 0x69, 0x7d, 0xca, + 0x69, 0x55, 0xa6, 0x6b, 0xae, 0x4c, 0x8b, 0x2b, 0xa6, 0x64, 0xdb, 0xa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0x64, 0x71, 0xa3, 0xf2, 0x14, 0x0b, 0x5e, 0x9d, 0x05, 0xbb, 0x4e, 0xf9, 0x44, + 0xe0, 0xee, 0xd8, 0xd1, 0xff, 0x3b, 0xdf, 0x39, 0xd0, 0x7f, 0x0d, 0x0f, 0xac, 0x53, 0x1b, 0xa9, + 0x28, 0xd2, 0xfc, 0x9c, 0x8e, 0x2d, 0xb7, 0x63, 0x30, 0xd9, 0xcd, 0x1f, 0x09, 0xdc, 0x2d, 0xec, + 0xff, 0x05, 0x3f, 0xa7, 0x7f, 0x4e, 0xbe, 0xb9, 0xf3, 0xe5, 0x22, 0xf2, 0x7e, 0x5d, 0x44, 0x60, + 0x76, 0x72, 0xb9, 0x09, 0xc1, 0xd5, 0x26, 0x04, 0x3f, 0x37, 0x21, 0xf8, 0xbc, 0x0d, 0xbd, 0xab, + 0x6d, 0xe8, 0x7d, 0xdf, 0x86, 0xde, 0xc7, 0x57, 0xa3, 0x51, 0x16, 0x75, 0x31, 0x25, 0x4b, 0xcc, + 0xeb, 0x74, 0xb4, 0x22, 0xdd, 0xbf, 0x4b, 0xe2, 0x86, 0x5b, 0xec, 0xb9, 0xab, 0x7d, 0xf9, 0x3b, + 0x00, 0x00, 0xff, 0xff, 0xaf, 0xf7, 0x62, 0x8e, 0x4c, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -131,7 +162,13 @@ func (this *Params) Equal(that interface{}) bool { if !this.GvgStakingPrice.Equal(that1.GvgStakingPrice) { return false } - if !this.MinDeposit.Equal(that1.MinDeposit) { + if this.MaxLocalVirtualGroupNumPerBucket != that1.MaxLocalVirtualGroupNumPerBucket { + return false + } + if this.MaxGlobalVirtualGroupNumPerFamily != that1.MaxGlobalVirtualGroupNumPerFamily { + return false + } + if this.MaxStoreSizePerFamily != that1.MaxStoreSizePerFamily { return false } return true @@ -156,16 +193,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.MinDeposit.Size() - i -= size - if _, err := m.MinDeposit.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) + if m.MaxStoreSizePerFamily != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxStoreSizePerFamily)) + i-- + dAtA[i] = 0x28 + } + if m.MaxGlobalVirtualGroupNumPerFamily != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxGlobalVirtualGroupNumPerFamily)) + i-- + dAtA[i] = 0x20 + } + if m.MaxLocalVirtualGroupNumPerBucket != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxLocalVirtualGroupNumPerBucket)) + i-- + dAtA[i] = 0x18 } - i-- - dAtA[i] = 0x1a { size := m.GvgStakingPrice.Size() i -= size @@ -209,8 +251,15 @@ func (m *Params) Size() (n int) { } l = m.GvgStakingPrice.Size() n += 1 + l + sovParams(uint64(l)) - l = m.MinDeposit.Size() - n += 1 + l + sovParams(uint64(l)) + if m.MaxLocalVirtualGroupNumPerBucket != 0 { + n += 1 + sovParams(uint64(m.MaxLocalVirtualGroupNumPerBucket)) + } + if m.MaxGlobalVirtualGroupNumPerFamily != 0 { + n += 1 + sovParams(uint64(m.MaxGlobalVirtualGroupNumPerFamily)) + } + if m.MaxStoreSizePerFamily != 0 { + n += 1 + sovParams(uint64(m.MaxStoreSizePerFamily)) + } return n } @@ -316,10 +365,10 @@ func (m *Params) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinDeposit", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxLocalVirtualGroupNumPerBucket", wireType) } - var stringLen uint64 + m.MaxLocalVirtualGroupNumPerBucket = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -329,26 +378,49 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MaxLocalVirtualGroupNumPerBucket |= uint32(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxGlobalVirtualGroupNumPerFamily", wireType) } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams + m.MaxGlobalVirtualGroupNumPerFamily = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxGlobalVirtualGroupNumPerFamily |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - if postIndex > l { - return io.ErrUnexpectedEOF + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxStoreSizePerFamily", wireType) } - if err := m.MinDeposit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.MaxStoreSizePerFamily = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxStoreSizePerFamily |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])