feat!: initial deposit requirement for proposals (#12771)

* feat!: initial deposit requirement for proposals

* changelog

* fix genesis sim tests

* msg server test and err check

* fix e2e gov tests

* fix param tests

* fix sim and migration tests

* remove redundant check

* uncomment tests and revert the consensus version change

* migrations comment

* fix comment in simulation genesis

* restore zero ratio check

* remove gogoproto tag from new param

* upgrading.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Roman 2022-08-02 11:40:00 -07:00 committed by GitHub
parent 0f7e56c6f9
commit 07f7035f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 584 additions and 171 deletions

View File

@ -66,6 +66,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/gov) [#12631](https://github.com/cosmos/cosmos-sdk/pull/12631) Migrate `x/gov` to self-managed parameters and deprecate it's usage of `x/params`.
* (x/staking) [#12409](https://github.com/cosmos/cosmos-sdk/pull/12409) Migrate `x/staking` to self-managed parameters and deprecate it's usage of `x/params`.
* (x/bank) [#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly.
* (x/gov) [#12771](https://github.com/cosmos/cosmos-sdk/pull/12771) Initial deposit requirement for proposals at submission time.
### API Breaking Changes

View File

@ -30,7 +30,9 @@ This means you can replace your usage of `simapp.MakeTestEncodingConfig` in test
### Client Changes
### `x/gov` v1
### `x/gov`
#### `types/v1`
The `gov` module has been greatly improved. The previous API has been moved to `v1beta1` while the new implementation is called `v1`.
@ -38,6 +40,16 @@ In order to submit a proposal with `submit-proposal` you now need to pass a `pro
You can still use the old way by using `submit-legacy-proposal`. This is not recommended.
More information can be found in the gov module [client documentation](https://docs.cosmos.network/v0.46/modules/gov/07_client.html).
#### Minimum Proposal Deposit At Time of Submission
The `gov` module has been updated to support a minimum proposal deposit at submission time. It is determined by a new
parameter called `MinInitialDepositRatio`. When multiplied by the existing `MinDeposit` parameter, it produces
the necessary proportion of coins needed at the proposal submission time. The motivation for this change is to prevent proposal spamming.
By default, the new `MinInitialDepositRatio` parameter is set to zero during migration. The value of zero signifies that this
feature is disabled. If chains wish to utilize the minimum proposal deposits at time of submission, the migration logic needs to be
modified to set the new parameter to the desired value.
### Keyring
The keyring has been refactored in v0.46.

View File

@ -7015,7 +7015,7 @@ func (x *CommunityPoolSpendProposal) GetAmount() []*v1beta1.Coin {
// staking token, and the creation height (to check later on if any slashes have
// occurred). NOTE: Even though validators are slashed to whole staking tokens,
// the delegators within the validator may be left with less than a full token,
// thus math.LegacyDec is used.
// thus sdk.Dec is used.
type DelegatorStartingInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache

View File

@ -5169,13 +5169,14 @@ func (x *_Params_1_list) IsValid() bool {
}
var (
md_Params protoreflect.MessageDescriptor
fd_Params_min_deposit protoreflect.FieldDescriptor
fd_Params_max_deposit_period protoreflect.FieldDescriptor
fd_Params_voting_period protoreflect.FieldDescriptor
fd_Params_quorum protoreflect.FieldDescriptor
fd_Params_threshold protoreflect.FieldDescriptor
fd_Params_veto_threshold protoreflect.FieldDescriptor
md_Params protoreflect.MessageDescriptor
fd_Params_min_deposit protoreflect.FieldDescriptor
fd_Params_max_deposit_period protoreflect.FieldDescriptor
fd_Params_voting_period protoreflect.FieldDescriptor
fd_Params_quorum protoreflect.FieldDescriptor
fd_Params_threshold protoreflect.FieldDescriptor
fd_Params_veto_threshold protoreflect.FieldDescriptor
fd_Params_min_initial_deposit_ratio protoreflect.FieldDescriptor
)
func init() {
@ -5187,6 +5188,7 @@ func init() {
fd_Params_quorum = md_Params.Fields().ByName("quorum")
fd_Params_threshold = md_Params.Fields().ByName("threshold")
fd_Params_veto_threshold = md_Params.Fields().ByName("veto_threshold")
fd_Params_min_initial_deposit_ratio = md_Params.Fields().ByName("min_initial_deposit_ratio")
}
var _ protoreflect.Message = (*fastReflection_Params)(nil)
@ -5290,6 +5292,12 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto
return
}
}
if x.MinInitialDepositRatio != "" {
value := protoreflect.ValueOfString(x.MinInitialDepositRatio)
if !f(fd_Params_min_initial_deposit_ratio, value) {
return
}
}
}
// Has reports whether a field is populated.
@ -5317,6 +5325,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool {
return x.Threshold != ""
case "cosmos.gov.v1.Params.veto_threshold":
return x.VetoThreshold != ""
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
return x.MinInitialDepositRatio != ""
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5345,6 +5355,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) {
x.Threshold = ""
case "cosmos.gov.v1.Params.veto_threshold":
x.VetoThreshold = ""
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
x.MinInitialDepositRatio = ""
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5382,6 +5394,9 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro
case "cosmos.gov.v1.Params.veto_threshold":
value := x.VetoThreshold
return protoreflect.ValueOfString(value)
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
value := x.MinInitialDepositRatio
return protoreflect.ValueOfString(value)
default:
if descriptor.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5416,6 +5431,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto
x.Threshold = value.Interface().(string)
case "cosmos.gov.v1.Params.veto_threshold":
x.VetoThreshold = value.Interface().(string)
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
x.MinInitialDepositRatio = value.Interface().(string)
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5458,6 +5475,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore
panic(fmt.Errorf("field threshold of message cosmos.gov.v1.Params is not mutable"))
case "cosmos.gov.v1.Params.veto_threshold":
panic(fmt.Errorf("field veto_threshold of message cosmos.gov.v1.Params is not mutable"))
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
panic(fmt.Errorf("field min_initial_deposit_ratio of message cosmos.gov.v1.Params is not mutable"))
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5486,6 +5505,8 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor
return protoreflect.ValueOfString("")
case "cosmos.gov.v1.Params.veto_threshold":
return protoreflect.ValueOfString("")
case "cosmos.gov.v1.Params.min_initial_deposit_ratio":
return protoreflect.ValueOfString("")
default:
if fd.IsExtension() {
panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.gov.v1.Params"))
@ -5581,6 +5602,10 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods {
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l))
}
l = len(x.MinInitialDepositRatio)
if l > 0 {
n += 1 + l + runtime.Sov(uint64(l))
}
if x.unknownFields != nil {
n += len(x.unknownFields)
}
@ -5610,6 +5635,13 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods {
i -= len(x.unknownFields)
copy(dAtA[i:], x.unknownFields)
}
if len(x.MinInitialDepositRatio) > 0 {
i -= len(x.MinInitialDepositRatio)
copy(dAtA[i:], x.MinInitialDepositRatio)
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MinInitialDepositRatio)))
i--
dAtA[i] = 0x3a
}
if len(x.VetoThreshold) > 0 {
i -= len(x.VetoThreshold)
copy(dAtA[i:], x.VetoThreshold)
@ -5926,6 +5958,38 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods {
}
x.VetoThreshold = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 7:
if wireType != 2 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinInitialDepositRatio", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
}
if iNdEx >= l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
}
if postIndex > l {
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
}
x.MinInitialDepositRatio = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := runtime.Skip(dAtA[iNdEx:])
@ -6602,6 +6666,8 @@ type Params struct {
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
VetoThreshold string `protobuf:"bytes,6,opt,name=veto_threshold,json=vetoThreshold,proto3" json:"veto_threshold,omitempty"`
// The ratio representing the proportion of the deposit value that must be paid at proposal submission.
MinInitialDepositRatio string `protobuf:"bytes,7,opt,name=min_initial_deposit_ratio,json=minInitialDepositRatio,proto3" json:"min_initial_deposit_ratio,omitempty"`
}
func (x *Params) Reset() {
@ -6666,6 +6732,13 @@ func (x *Params) GetVetoThreshold() string {
return ""
}
func (x *Params) GetMinInitialDepositRatio() string {
if x != nil {
return x.MinInitialDepositRatio
}
return ""
}
var File_cosmos_gov_v1_gov_proto protoreflect.FileDescriptor
var file_cosmos_gov_v1_gov_proto_rawDesc = []byte{
@ -6795,7 +6868,7 @@ var file_cosmos_gov_v1_gov_proto_rawDesc = []byte{
0x18, 0x76, 0x65, 0x74, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x2c,
0x6f, 0x6d, 0x69, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x79, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73,
0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x0d, 0x76, 0x65, 0x74, 0x6f, 0x54, 0x68, 0x72,
0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0xec, 0x02, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0xb7, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x73, 0x12, 0x40, 0x0a, 0x0b, 0x6d, 0x69, 0x6e, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e,
0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69,
@ -6818,39 +6891,44 @@ var file_cosmos_gov_v1_gov_proto_rawDesc = []byte{
0x0a, 0x0e, 0x76, 0x65, 0x74, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64,
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d,
0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x0d, 0x76, 0x65, 0x74, 0x6f, 0x54, 0x68, 0x72, 0x65,
0x73, 0x68, 0x6f, 0x6c, 0x64, 0x2a, 0x89, 0x01, 0x0a, 0x0a, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54,
0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10,
0x00, 0x12, 0x13, 0x0a, 0x0f, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e,
0x5f, 0x59, 0x45, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f,
0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x42, 0x53, 0x54, 0x41, 0x49, 0x4e, 0x10, 0x02, 0x12,
0x12, 0x0a, 0x0e, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e,
0x4f, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49,
0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x56, 0x45, 0x54, 0x4f, 0x10,
0x04, 0x2a, 0xce, 0x01, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c,
0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x22, 0x0a, 0x1e, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41,
0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x44, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54,
0x5f, 0x50, 0x45, 0x52, 0x49, 0x4f, 0x44, 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x52, 0x4f,
0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x56, 0x4f, 0x54,
0x49, 0x4e, 0x47, 0x5f, 0x50, 0x45, 0x52, 0x49, 0x4f, 0x44, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16,
0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f,
0x50, 0x41, 0x53, 0x53, 0x45, 0x44, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x52, 0x4f, 0x50,
0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45,
0x43, 0x54, 0x45, 0x44, 0x10, 0x04, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53,
0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44,
0x10, 0x05, 0x42, 0x99, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x47, 0x6f, 0x76, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e,
0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f,
0x76, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58,
0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31,
0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, 0x31,
0xe2, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, 0x31,
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x43,
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x6f, 0x76, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x49, 0x0a, 0x19, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x69,
0x74, 0x69, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x16, 0x6d, 0x69, 0x6e, 0x49, 0x6e, 0x69,
0x74, 0x69, 0x61, 0x6c, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x61, 0x74, 0x69, 0x6f,
0x2a, 0x89, 0x01, 0x0a, 0x0a, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x1b, 0x0a, 0x17, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55,
0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f,
0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x59, 0x45, 0x53, 0x10,
0x01, 0x12, 0x17, 0x0a, 0x13, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e,
0x5f, 0x41, 0x42, 0x53, 0x54, 0x41, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x56, 0x4f,
0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x10, 0x03, 0x12, 0x1c,
0x0a, 0x18, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f,
0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x56, 0x45, 0x54, 0x4f, 0x10, 0x04, 0x2a, 0xce, 0x01, 0x0a,
0x0e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x1f, 0x0a, 0x1b, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54,
0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,
0x12, 0x22, 0x0a, 0x1e, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41,
0x54, 0x55, 0x53, 0x5f, 0x44, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x5f, 0x50, 0x45, 0x52, 0x49,
0x4f, 0x44, 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c,
0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x56, 0x4f, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x50,
0x45, 0x52, 0x49, 0x4f, 0x44, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x52, 0x4f, 0x50, 0x4f,
0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x41, 0x53, 0x53, 0x45,
0x44, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f,
0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10,
0x04, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54,
0x41, 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x05, 0x42, 0x99, 0x01,
0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76,
0x2e, 0x76, 0x31, 0x42, 0x08, 0x47, 0x6f, 0x76, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a,
0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x3b,
0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x19, 0x43, 0x6f,
0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73,
0x3a, 0x3a, 0x47, 0x6f, 0x76, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (

2
go.sum
View File

@ -76,8 +76,6 @@ cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM=
cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4=
cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a h1:3lmQIAF6ScBJ8kW5ZNejcBUJpwWhE2y57qEUI+OBESU=
cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=

View File

@ -17,8 +17,8 @@ message SendAuthorization {
repeated cosmos.base.v1beta1.Coin spend_limit = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// allow_list specifies an optional list of addresses to whom the grantee can send tokens on behalf of the
// granter. If omitted, any recipient is allowed.
// allow_list specifies an optional list of addresses to whom the grantee can send tokens on behalf of the
// granter. If omitted, any recipient is allowed.
//
// Since: cosmos-sdk 0.47
repeated string allow_list = 2;

View File

@ -19,13 +19,13 @@ message GenesisState {
repeated Proposal proposals = 4;
// Deprecated: Prefer to use `params` instead.
// deposit_params defines all the paramaters of related to deposit.
DepositParams deposit_params = 5 [deprecated=true];
DepositParams deposit_params = 5 [deprecated = true];
// Deprecated: Prefer to use `params` instead.
// voting_params defines all the paramaters of related to voting.
VotingParams voting_params = 6 [deprecated=true];
VotingParams voting_params = 6 [deprecated = true];
// Deprecated: Prefer to use `params` instead.
// tally_params defines all the paramaters of related to tally.
TallyParams tally_params = 7 [deprecated=true];
TallyParams tally_params = 7 [deprecated = true];
// params defines all the paramaters of x/gov module.
//
// Since: cosmos-sdk 0.47

View File

@ -155,4 +155,7 @@ message Params {
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
string veto_threshold = 6 [(cosmos_proto.scalar) = "cosmos.Dec"];
// The ratio representing the proportion of the deposit value that must be paid at proposal submission.
string min_initial_deposit_ratio = 7 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

View File

@ -132,13 +132,13 @@ message QueryParamsRequest {
message QueryParamsResponse {
// Deprecated: Prefer to use `params` instead.
// voting_params defines the parameters related to voting.
VotingParams voting_params = 1 [deprecated=true];
VotingParams voting_params = 1 [deprecated = true];
// Deprecated: Prefer to use `params` instead.
// deposit_params defines the parameters related to deposit.
DepositParams deposit_params = 2 [deprecated=true];
DepositParams deposit_params = 2 [deprecated = true];
// Deprecated: Prefer to use `params` instead.
// tally_params defines the parameters related to tally.
TallyParams tally_params = 3 [deprecated=true];
TallyParams tally_params = 3 [deprecated = true];
// params defines all the paramaters of x/gov module.
//
// Since: cosmos-sdk 0.47

View File

@ -469,7 +469,7 @@ var xxx_messageInfo_CommunityPoolSpendProposal proto.InternalMessageInfo
// staking token, and the creation height (to check later on if any slashes have
// occurred). NOTE: Even though validators are slashed to whole staking tokens,
// the delegators within the validator may be left with less than a full token,
// thus math.LegacyDec is used.
// thus sdk.Dec is used.
type DelegatorStartingInfo struct {
PreviousPeriod uint64 `protobuf:"varint,1,opt,name=previous_period,json=previousPeriod,proto3" json:"previous_period,omitempty"`
Stake github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=stake,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake"`

View File

@ -24,7 +24,7 @@ func (s *IntegrationTestSuite) TestCmdParams() {
{
"json output",
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"}}`,
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000"}}`,
},
{
"text output",
@ -40,6 +40,7 @@ params:
min_deposit:
- amount: "10000000"
denom: stake
min_initial_deposit_ratio: "0.000000000000000000"
quorum: "0.334000000000000000"
threshold: "0.500000000000000000"
veto_threshold: "0.334000000000000000"

View File

@ -165,18 +165,18 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() {
val := s.network.Validators[0]
invalidProp := `{
"title": "",
"description": "Where is the title!?",
"type": "Text",
"deposit": "-324foocoin"
}`
"title": "",
"description": "Where is the title!?",
"type": "Text",
"deposit": "-324foocoin"
}`
invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp)
validProp := fmt.Sprintf(`{
"title": "Text Proposal",
"description": "Hello, World!",
"type": "Text",
"deposit": "%s"
}`, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
"title": "Text Proposal",
"description": "Hello, World!",
"type": "Text",
"deposit": "%s"
}`, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
validPropFile := testutil.WriteToNewTempFile(s.T(), validProp)
testCases := []struct {
name string

View File

@ -178,3 +178,25 @@ func (keeper Keeper) RefundAndDeleteDeposits(ctx sdk.Context, proposalID uint64)
return false
})
}
// validateInitialDeposit validates if initial deposit is greater than or equal to the minimum
// required at the time of proposal submission. This threshold amount is determined by
// the deposit parameters. Returns nil on success, error otherwise.
func (keeper Keeper) validateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins) error {
params := keeper.GetParams(ctx)
minInitialDepositRatio, err := sdk.NewDecFromStr(params.MinInitialDepositRatio)
if err != nil {
return err
}
if minInitialDepositRatio.IsZero() {
return nil
}
minDepositCoins := params.MinDeposit
for i := range minDepositCoins {
minDepositCoins[i].Amount = sdk.NewDecFromInt(minDepositCoins[i].Amount).Mul(minInitialDepositRatio).RoundInt()
}
if !initialDeposit.IsAllGTE(minDepositCoins) {
return sdkerrors.Wrapf(types.ErrMinDepositTooSmall, "was (%s), need (%s)", initialDeposit, minDepositCoins)
}
return nil
}

View File

@ -8,6 +8,12 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
const (
baseDepositTestAmount = 100
baseDepositTestPercent = 25
)
func TestDeposits(t *testing.T) {
@ -111,3 +117,102 @@ func TestDeposits(t *testing.T) {
require.Len(t, deposits, 0)
require.Equal(t, addr0Initial.Sub(fourStake...), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0]))
}
func TestValidateInitialDeposit(t *testing.T) {
testcases := map[string]struct {
minDeposit sdk.Coins
minInitialDepositPercent int64
initialDeposit sdk.Coins
expectError bool
}{
"min deposit * initial percent == initial deposit: success": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))),
},
"min deposit * initial percent < initial deposit: success": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100+1))),
},
"min deposit * initial percent > initial deposit: error": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100-1))),
expectError: true,
},
"min deposit * initial percent == initial deposit (non-base values and denom): success": {
minDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(56912))),
minInitialDepositPercent: 50,
initialDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(56912/2+10))),
},
"min deposit * initial percent == initial deposit but different denoms: error": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))),
expectError: true,
},
"min deposit * initial percent == initial deposit (multiple coins): success": {
minDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount)),
sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)),
sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2*baseDepositTestPercent/100)),
),
},
"min deposit * initial percent > initial deposit (multiple coins): error": {
minDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount)),
sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)),
sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*2*baseDepositTestPercent/100-1)),
),
expectError: true,
},
"min deposit * initial percent < initial deposit (multiple coins - coin not required by min deposit): success": {
minDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: baseDepositTestPercent,
initialDeposit: sdk.NewCoins(
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100)),
sdk.NewCoin("uosmo", sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100-1)),
),
},
"0 initial percent: success": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositPercent: 0,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount*baseDepositTestPercent/100))),
},
}
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
govKeeper := app.GovKeeper
params := v1.DefaultParams()
params.MinDeposit = tc.minDeposit
params.MinInitialDepositRatio = sdk.NewDec(tc.minInitialDepositPercent).Quo(sdk.NewDec(100)).String()
govKeeper.SetParams(ctx, params)
err := govKeeper.ValidateInitialDeposit(ctx, tc.initialDeposit)
if tc.expectError {
require.Error(t, err)
return
}
require.NoError(t, err)
})
}
}

View File

@ -0,0 +1,7 @@
package keeper
import sdk "github.com/cosmos/cosmos-sdk/types"
func (k Keeper) ValidateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins) error {
return k.validateInitialDeposit(ctx, initialDeposit)
}

View File

@ -33,11 +33,16 @@ var _ v1.MsgServer = msgServer{}
func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitProposal) (*v1.MsgSubmitProposalResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
initialDeposit := msg.GetInitialDeposit()
if err := k.validateInitialDeposit(ctx, initialDeposit); err != nil {
return nil, err
}
proposalMsgs, err := msg.GetMsgs()
if err != nil {
return nil, err
}
proposal, err := k.Keeper.SubmitProposal(ctx, proposalMsgs, msg.Metadata)
if err != nil {
return nil, err

View File

@ -4,11 +4,16 @@ import (
"strings"
"time"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
func (suite *KeeperTestSuite) TestSubmitProposalReq() {
@ -1007,3 +1012,83 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
})
}
}
func (suite *KeeperTestSuite) TestSubmitProposal_InitialDeposit() {
const meetsDepositValue = baseDepositTestAmount * baseDepositTestPercent / 100
var baseDepositRatioDec = sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100))
testcases := map[string]struct {
minDeposit sdk.Coins
minInitialDepositRatio sdk.Dec
initialDeposit sdk.Coins
accountBalance sdk.Coins
expectError bool
}{
"meets initial deposit, enough balance - success": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositRatio: baseDepositRatioDec,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))),
accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))),
},
"does not meet initial deposit, enough balance - error": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositRatio: baseDepositRatioDec,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))),
accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))),
expectError: true,
},
"meets initial deposit, not enough balance - error": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositRatio: baseDepositRatioDec,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue))),
accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))),
expectError: true,
},
"does not meet initial deposit and not enough balance - error": {
minDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseDepositTestAmount))),
minInitialDepositRatio: baseDepositRatioDec,
initialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))),
accountBalance: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(meetsDepositValue-1))),
expectError: true,
},
}
for name, tc := range testcases {
suite.Run(name, func() {
// Setup
privateKey := secp256k1.GenPrivKey()
address := sdk.AccAddress(privateKey.PubKey().Address())
acc := &authtypes.BaseAccount{
Address: address.String(),
}
genAccs := []authtypes.GenesisAccount{acc}
app := simapp.SetupWithGenesisAccounts(suite.T(), genAccs, banktypes.Balance{Address: acc.Address, Coins: tc.accountBalance})
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
govKeeper := app.GovKeeper
msgServer := keeper.NewMsgServerImpl(govKeeper)
params := v1.DefaultParams()
params.MinDeposit = tc.minDeposit
params.MinInitialDepositRatio = tc.minInitialDepositRatio.String()
govKeeper.SetParams(ctx, params)
msg, err := v1.NewMsgSubmitProposal(TestProposal, tc.initialDeposit, address.String(), "test")
suite.Require().NoError(err)
// System under test
_, err = msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), msg)
// Assertions
if tc.expectError {
suite.Require().Error(err)
return
}
suite.Require().NoError(err)
})
}
}

View File

@ -84,6 +84,7 @@ func TestMigrateJSON(t *testing.T) {
"denom": "stake"
}
],
"min_initial_deposit_ratio": "",
"quorum": "0.334000000000000000",
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000",

View File

@ -25,6 +25,7 @@ func migrateParams(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace
tp.Quorum,
tp.Threshold,
tp.VetoThreshold,
sdk.ZeroDec().String(),
)
bz, err := cdc.Marshal(&params)
@ -41,6 +42,7 @@ func migrateParams(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace
// migration includes:
//
// Params migrations from x/params to gov
// Addition of the new min initial deposit ratio parameter that is set to 0 by default.
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace exported.ParamSubspace, cdc codec.BinaryCodec) error {
return migrateParams(ctx, storeKey, legacySubspace, cdc)
}

View File

@ -69,4 +69,5 @@ func TestMigrateStore(t *testing.T) {
require.Equal(t, legacySubspace.tp.Quorum, params.Quorum)
require.Equal(t, legacySubspace.tp.Threshold, params.Threshold)
require.Equal(t, legacySubspace.tp.VetoThreshold, params.VetoThreshold)
require.Equal(t, sdk.ZeroDec().String(), params.MinInitialDepositRatio)
}

View File

@ -289,7 +289,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4)
if err != nil {
panic(err)

View File

@ -20,6 +20,7 @@ import (
const (
DepositParamsMinDeposit = "deposit_params_min_deposit"
DepositParamsDepositPeriod = "deposit_params_deposit_period"
DepositMinInitialRatio = "deposit_params_min_initial_ratio"
VotingParamsVotingPeriod = "voting_params_voting_period"
TallyParamsQuorum = "tally_params_quorum"
TallyParamsThreshold = "tally_params_threshold"
@ -36,6 +37,11 @@ func GenDepositParamsMinDeposit(r *rand.Rand) sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(simulation.RandIntBetween(r, 1, 1e3))))
}
// GenDepositMinInitialRatio randomized DepositMinInitialRatio
func GenDepositMinInitialDepositRatio(r *rand.Rand) sdk.Dec {
return sdk.NewDec(int64(simulation.RandIntBetween(r, 0, 99))).Quo(sdk.NewDec(100))
}
// GenVotingParamsVotingPeriod randomized VotingParamsVotingPeriod
func GenVotingParamsVotingPeriod(r *rand.Rand) time.Duration {
return time.Duration(simulation.RandIntBetween(r, 1, 2*60*60*24*2)) * time.Second
@ -72,6 +78,12 @@ func RandomizedGenState(simState *module.SimulationState) {
func(r *rand.Rand) { depositPeriod = GenDepositParamsDepositPeriod(r) },
)
var minInitialDepositRatio sdk.Dec
simState.AppParams.GetOrGenerate(
simState.Cdc, DepositMinInitialRatio, &minInitialDepositRatio, simState.Rand,
func(r *rand.Rand) { minInitialDepositRatio = GenDepositMinInitialDepositRatio(r) },
)
var votingPeriod time.Duration
simState.AppParams.GetOrGenerate(
simState.Cdc, VotingParamsVotingPeriod, &votingPeriod, simState.Rand,
@ -98,7 +110,7 @@ func RandomizedGenState(simState *module.SimulationState) {
govGenesis := v1.NewGenesisState(
startingProposalID,
v1.NewParams(minDeposit, depositPeriod, votingPeriod, quorum.String(), threshold.String(), veto.String()),
v1.NewParams(minDeposit, depositPeriod, votingPeriod, quorum.String(), threshold.String(), veto.String(), minInitialDepositRatio.String()),
)
bz, err := json.MarshalIndent(&govGenesis, "", " ")

View File

@ -10,7 +10,6 @@ import (
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
@ -42,16 +41,19 @@ func TestRandomizedGenState(t *testing.T) {
var govGenesis v1.GenesisState
simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &govGenesis)
dec1, _ := sdk.NewDecFromStr("0.361000000000000000")
dec2, _ := sdk.NewDecFromStr("0.512000000000000000")
dec3, _ := sdk.NewDecFromStr("0.267000000000000000")
const (
tallyQuorum = "0.400000000000000000"
tallyThreshold = "0.539000000000000000"
tallyVetoThreshold = "0.314000000000000000"
minInitialDepositDec = "0.590000000000000000"
)
require.Equal(t, "905stake", govGenesis.Params.MinDeposit[0].String())
require.Equal(t, "77h26m10s", govGenesis.Params.MaxDepositPeriod.String())
require.Equal(t, float64(148296), govGenesis.Params.VotingPeriod.Seconds())
require.Equal(t, dec1.String(), govGenesis.Params.Quorum)
require.Equal(t, dec2.String(), govGenesis.Params.Threshold)
require.Equal(t, dec3.String(), govGenesis.Params.VetoThreshold)
require.Equal(t, float64(275567), govGenesis.Params.VotingPeriod.Seconds())
require.Equal(t, tallyQuorum, govGenesis.Params.Quorum)
require.Equal(t, tallyThreshold, govGenesis.Params.Threshold)
require.Equal(t, tallyVetoThreshold, govGenesis.Params.VetoThreshold)
require.Equal(t, uint64(0x28), govGenesis.StartingProposalId)
require.Equal(t, []*v1.Deposit{}, govGenesis.Deposits)
require.Equal(t, []*v1.Vote{}, govGenesis.Votes)

View File

@ -133,7 +133,7 @@ func SimulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k
}
simAccount, _ := simtypes.RandomAcc(r, accs)
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address)
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, true)
switch {
case skip:
return simtypes.NoOpMsg(types.ModuleName, TypeMsgSubmitProposal, "skip deposit"), nil, nil
@ -230,7 +230,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.K
return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "unable to generate proposalID"), nil, nil
}
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address)
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false)
switch {
case skip:
return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "skip deposit"), nil, nil
@ -377,7 +377,15 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe
// deposit amount between (0, min(balance, minDepositAmount))
// This is to simulate multiple users depositing to get the
// proposal above the minimum deposit amount
func randomDeposit(r *rand.Rand, ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, addr sdk.AccAddress) (deposit sdk.Coins, skip bool, err error) {
func randomDeposit(
r *rand.Rand,
ctx sdk.Context,
ak types.AccountKeeper,
bk types.BankKeeper,
k *keeper.Keeper,
addr sdk.AccAddress,
useMinAmount bool,
) (deposit sdk.Coins, skip bool, err error) {
account := ak.GetAccount(ctx, addr)
spendable := bk.SpendableCoins(ctx, account.GetAddress())
@ -385,24 +393,37 @@ func randomDeposit(r *rand.Rand, ctx sdk.Context, ak types.AccountKeeper, bk typ
return nil, true, nil // skip
}
minDeposit := k.GetParams(ctx).MinDeposit
params := k.GetParams(ctx)
minDeposit := params.MinDeposit
denomIndex := r.Intn(len(minDeposit))
denom := minDeposit[denomIndex].Denom
depositCoins := spendable.AmountOf(denom)
if depositCoins.IsZero() {
spendableBalance := spendable.AmountOf(denom)
if spendableBalance.IsZero() {
return nil, true, nil
}
maxAmt := depositCoins
if maxAmt.GT(minDeposit[denomIndex].Amount) {
maxAmt = minDeposit[denomIndex].Amount
minDepositAmount := minDeposit[denomIndex].Amount
minAmount := sdk.ZeroInt()
if useMinAmount {
minDepositPercent, err := sdk.NewDecFromStr(params.MinInitialDepositRatio)
if err != nil {
return nil, false, err
}
minAmount = sdk.NewDecFromInt(minDepositAmount).Mul(minDepositPercent).RoundInt()
}
amount, err := simtypes.RandPositiveInt(r, maxAmt)
amount, err := simtypes.RandPositiveInt(r, minDepositAmount.Sub(minAmount))
if err != nil {
return nil, false, err
}
amount = amount.Add(minAmount)
if amount.GT(spendableBalance) {
return nil, true, nil
}
return sdk.Coins{sdk.NewCoin(denom, amount)}, false, nil
}

View File

@ -21,4 +21,5 @@ var (
ErrInvalidSigner = sdkerrors.Register(ModuleName, 13, "expected gov account as only signer for proposal message")
ErrInvalidSignalMsg = sdkerrors.Register(ModuleName, 14, "signal message is invalid")
ErrMetadataTooLong = sdkerrors.Register(ModuleName, 15, "metadata too long")
ErrMinDepositTooSmall = sdkerrors.Register(ModuleName, 16, "minimum deposit is too small")
)

View File

@ -683,6 +683,8 @@ type Params struct {
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
VetoThreshold string `protobuf:"bytes,6,opt,name=veto_threshold,json=vetoThreshold,proto3" json:"veto_threshold,omitempty"`
// The ratio representing the proportion of the deposit value that must be paid at proposal submission.
MinInitialDepositRatio string `protobuf:"bytes,7,opt,name=min_initial_deposit_ratio,json=minInitialDepositRatio,proto3" json:"min_initial_deposit_ratio,omitempty"`
}
func (m *Params) Reset() { *m = Params{} }
@ -760,6 +762,13 @@ func (m *Params) GetVetoThreshold() string {
return ""
}
func (m *Params) GetMinInitialDepositRatio() string {
if m != nil {
return m.MinInitialDepositRatio
}
return ""
}
func init() {
proto.RegisterEnum("cosmos.gov.v1.VoteOption", VoteOption_name, VoteOption_value)
proto.RegisterEnum("cosmos.gov.v1.ProposalStatus", ProposalStatus_name, ProposalStatus_value)
@ -777,80 +786,82 @@ func init() {
func init() { proto.RegisterFile("cosmos/gov/v1/gov.proto", fileDescriptor_e05cb1c0d030febb) }
var fileDescriptor_e05cb1c0d030febb = []byte{
// 1166 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0xdb, 0x46,
0x17, 0x35, 0x25, 0x5a, 0x96, 0xaf, 0x2c, 0x85, 0xdf, 0x24, 0x5f, 0xc3, 0x38, 0xb1, 0xe4, 0x08,
0x6d, 0xe1, 0x3a, 0xb1, 0x54, 0x27, 0x48, 0x0b, 0x34, 0x9b, 0x4a, 0x16, 0x53, 0xcb, 0x70, 0x2d,
0x95, 0x64, 0x64, 0xa4, 0x1b, 0x82, 0x32, 0x19, 0x89, 0xa8, 0xc8, 0x51, 0x39, 0x23, 0xc5, 0x7a,
0x84, 0xee, 0xb2, 0x2c, 0xd0, 0xd7, 0x08, 0xfa, 0x0c, 0x59, 0x15, 0x41, 0x16, 0xfd, 0xd9, 0xa8,
0xad, 0xbd, 0x33, 0xfa, 0x10, 0x05, 0x87, 0x43, 0x4b, 0xa2, 0x15, 0xd8, 0xcd, 0x8a, 0xe4, 0xbd,
0xe7, 0xdc, 0x7b, 0x67, 0xce, 0xe1, 0x90, 0x70, 0xf3, 0x08, 0x13, 0x17, 0x93, 0x72, 0x07, 0x0f,
0xcb, 0xc3, 0xed, 0xe0, 0x52, 0xea, 0xfb, 0x98, 0x62, 0x94, 0x0d, 0x13, 0xa5, 0x20, 0x32, 0xdc,
0x5e, 0xcd, 0x73, 0x5c, 0xdb, 0x24, 0x76, 0x79, 0xb8, 0xdd, 0xb6, 0xa9, 0xb9, 0x5d, 0x3e, 0xc2,
0x8e, 0x17, 0xc2, 0x57, 0x6f, 0x74, 0x70, 0x07, 0xb3, 0xdb, 0x72, 0x70, 0xc7, 0xa3, 0x85, 0x0e,
0xc6, 0x9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bd,
0xf7, 0xf6, 0xbd, 0x9f, 0x76, 0x17, 0x2e, 0x1c, 0x10, 0xea, 0x13, 0x5a, 0xed, 0x92, 0x51, 0x75,
0xb4, 0x1b, 0x3d, 0x2a, 0x83, 0x90, 0x30, 0x82, 0xf2, 0xb1, 0xa3, 0x12, 0x59, 0x46, 0xbb, 0x5b,
0x45, 0x81, 0xeb, 0x38, 0xd4, 0xab, 0x8e, 0x76, 0x3b, 0x1e, 0x73, 0x76, 0xab, 0x07, 0x04, 0x07,
0x31, 0x7c, 0xeb, 0x5c, 0x97, 0x74, 0x09, 0x7f, 0xad, 0x46, 0x6f, 0xc2, 0x5a, 0xea, 0x12, 0xd2,
0xed, 0x7b, 0x55, 0xfe, 0xd5, 0x19, 0x3e, 0xa9, 0x32, 0xec, 0x7b, 0x94, 0x39, 0xfe, 0x40, 0x00,
0x36, 0xd3, 0x00, 0x27, 0x18, 0x0b, 0x57, 0x31, 0xed, 0x72, 0x87, 0xa1, 0xc3, 0x30, 0x49, 0x32,
0x6e, 0xc6, 0x15, 0xd9, 0x71, 0x52, 0x51, 0x2d, 0xff, 0x28, 0x13, 0x40, 0x8f, 0x3c, 0xdc, 0xed,
0x31, 0xcf, 0x6d, 0x13, 0xe6, 0x35, 0x07, 0x11, 0x0d, 0xed, 0x42, 0x8e, 0xf0, 0x37, 0x55, 0xda,
0x96, 0x76, 0x0a, 0x37, 0x37, 0x2b, 0x73, 0x4b, 0xac, 0x4c, 0xa1, 0x86, 0x00, 0xa2, 0x4f, 0x20,
0xf7, 0x94, 0x07, 0x52, 0x33, 0xdb, 0xd2, 0xce, 0x5a, 0xbd, 0xf0, 0xfa, 0xc5, 0x0d, 0x10, 0xac,
0x86, 0x77, 0x60, 0x08, 0x6f, 0xf9, 0x67, 0x09, 0x56, 0x1a, 0xde, 0x80, 0x50, 0xcc, 0x50, 0x09,
0xd6, 0x07, 0x21, 0x19, 0x10, 0xea, 0xf4, 0x6d, 0xec, 0xf2, 0x5c, 0xb2, 0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b, 0x76, 0x5b, 0xb3, 0x9a, 0x8a, 0x7c, 0xf5, 0x37, 0x09, 0x0a, 0xf3, 0x87,
0x3b, 0x2a, 0xc1, 0xc5, 0x96, 0xd1, 0x6c, 0x35, 0xcd, 0xda, 0x03, 0xdb, 0xb4, 0x6a, 0xd6, 0x43,
0x33, 0x55, 0x53, 0x19, 0x8a, 0x69, 0x40, 0x43, 0x6b, 0x35, 0x4d, 0xdd, 0xb2, 0x5b, 0x9a, 0xa1,
0x37, 0x1b, 0x8a, 0x84, 0xae, 0xc0, 0xe5, 0x34, 0xa6, 0xdd, 0xb4, 0xf4, 0xfd, 0xaf, 0x13, 0x48,
0x06, 0x6d, 0xc1, 0xf9, 0x34, 0xa4, 0x55, 0x33, 0x4d, 0xad, 0x11, 0x17, 0x9d, 0xf6, 0x19, 0xda,
0x7d, 0x6d, 0xcf, 0xd2, 0x1a, 0x8a, 0xbc, 0x88, 0x79, 0xb7, 0xa6, 0x3f, 0xd0, 0x1a, 0xca, 0x72,
0x5d, 0x7b, 0xf9, 0xa6, 0x28, 0xbd, 0x7a, 0x53, 0x94, 0xfe, 0x79, 0x53, 0x94, 0x9e, 0xbf, 0x2d,
0x2e, 0xbd, 0x7a, 0x5b, 0x5c, 0xfa, 0xf3, 0x6d, 0x71, 0xe9, 0xbb, 0x6b, 0x5d, 0xcc, 0x7a, 0xc3,
0x4e, 0xe5, 0x80, 0xf8, 0xe2, 0x6a, 0x29, 0x1e, 0x37, 0xa8, 0xfb, 0x7d, 0xf5, 0x19, 0xbf, 0x2e,
0xb3, 0xf1, 0xc0, 0xa3, 0xd1, 0x5d, 0x38, 0xc7, 0x25, 0x7a, 0xeb, 0xbf, 0x00, 0x00, 0x00, 0xff,
0xff, 0xde, 0xdf, 0xa6, 0x05, 0x4c, 0x0b, 0x00, 0x00,
}
func (m *WeightedVoteOption) Marshal() (dAtA []byte, err error) {
@ -1308,6 +1319,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.MinInitialDepositRatio) > 0 {
i -= len(m.MinInitialDepositRatio)
copy(dAtA[i:], m.MinInitialDepositRatio)
i = encodeVarintGov(dAtA, i, uint64(len(m.MinInitialDepositRatio)))
i--
dAtA[i] = 0x3a
}
if len(m.VetoThreshold) > 0 {
i -= len(m.VetoThreshold)
copy(dAtA[i:], m.VetoThreshold)
@ -1602,6 +1620,10 @@ func (m *Params) Size() (n int) {
if l > 0 {
n += 1 + l + sovGov(uint64(l))
}
l = len(m.MinInitialDepositRatio)
if l > 0 {
n += 1 + l + sovGov(uint64(l))
}
return n
}
@ -3143,6 +3165,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
m.VetoThreshold = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field MinInitialDepositRatio", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGov
}
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 ErrInvalidLengthGov
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGov
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.MinInitialDepositRatio = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGov(dAtA[iNdEx:])

View File

@ -15,10 +15,11 @@ const (
// Default governance params
var (
DefaultMinDepositTokens = sdk.NewInt(10000000)
DefaultQuorum = sdk.NewDecWithPrec(334, 3)
DefaultThreshold = sdk.NewDecWithPrec(5, 1)
DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3)
DefaultMinDepositTokens = sdk.NewInt(10000000)
DefaultQuorum = sdk.NewDecWithPrec(334, 3)
DefaultThreshold = sdk.NewDecWithPrec(5, 1)
DefaultVetoThreshold = sdk.NewDecWithPrec(334, 3)
DefaultMinInitialDepositRatio = sdk.ZeroDec()
)
// Deprecated: NewDepositParams creates a new DepositParams object
@ -47,15 +48,16 @@ func NewVotingParams(votingPeriod *time.Duration) VotingParams {
func NewParams(
minDeposit sdk.Coins, maxDepositPeriod time.Duration, votingPeriod time.Duration,
quorum string, threshold string, vetoThreshold string,
quorum string, threshold string, vetoThreshold string, minInitialDepositRatio string,
) Params {
return Params{
MinDeposit: minDeposit,
MaxDepositPeriod: &maxDepositPeriod,
VotingPeriod: &votingPeriod,
Quorum: quorum,
Threshold: threshold,
VetoThreshold: vetoThreshold,
MinDeposit: minDeposit,
MaxDepositPeriod: &maxDepositPeriod,
VotingPeriod: &votingPeriod,
Quorum: quorum,
Threshold: threshold,
VetoThreshold: vetoThreshold,
MinInitialDepositRatio: minInitialDepositRatio,
}
}
@ -68,6 +70,7 @@ func DefaultParams() Params {
DefaultQuorum.String(),
DefaultThreshold.String(),
DefaultVetoThreshold.String(),
DefaultMinInitialDepositRatio.String(),
)
}