Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/gov): dynamic deposit throttler #69

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d516277
prototype `GetCurrentMinDeposit`
giunatale Dec 2, 2024
4f6b7a7
move prototype to separate file
giunatale Dec 2, 2024
383396d
draft implementation, still missing pieces
giunatale Dec 3, 2024
a305b76
add ways to activate proposals when deposit decreases
giunatale Dec 3, 2024
e43d85a
make deposit stay stable when at target
giunatale Dec 3, 2024
c0ba785
improve GetMinDeposit
giunatale Dec 4, 2024
48ae048
add mindeposit query
giunatale Dec 4, 2024
f21be70
add params validation
giunatale Dec 4, 2024
ec45133
params
giunatale Dec 4, 2024
47fdc95
genesis
giunatale Dec 4, 2024
55fa158
move out code from keeper.SetParams
giunatale Dec 10, 2024
2a0f376
fix sign of percChange
giunatale Dec 10, 2024
0fc050c
fix tests
giunatale Dec 13, 2024
2b95d87
fix e2e tests
giunatale Dec 16, 2024
95b6028
fix formula for min deposit
giunatale Dec 16, 2024
5b8f2be
test(gov): GetMinDeposit()
tbruyelle Dec 16, 2024
5bc6c02
update proto description
giunatale Dec 17, 2024
4b2b5b3
move throttler params into a struct
giunatale Dec 19, 2024
d891a69
fix(gov): default genesis state is not valid
tbruyelle Dec 20, 2024
56931a9
test(gov): handle when lastMinDeposit has other coins than minDeposit…
tbruyelle Dec 20, 2024
cadfb64
fix(x/gov): α must be strictly between 0 and 1 (#70)
tbruyelle Dec 20, 2024
2664360
test(x/gov): assert ActivateVotingPeriod increments ActiveProposalNumber
tbruyelle Dec 20, 2024
9c45704
test(x/gov): assert EndBlocker decrements ActiveProposalNumber
tbruyelle Dec 20, 2024
85ec4c0
docs(x/gov): min_deposit deprecation details
tbruyelle Dec 20, 2024
fb05dca
feat(x/gov): add dynamic min initial deposit (#72)
giunatale Jan 14, 2025
1d88928
use common variables
giunatale Jan 14, 2025
354908f
docs(x/gov): update documentation to include dynamic deposits (#75)
giunatale Jan 16, 2025
b96f037
remove double space
giunatale Jan 16, 2025
454b99b
Update adr-003 to "implemented"
giunatale Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## **Status[](https://docs.cosmos.network/main/architecture/adr-template#status)**

DRAFT
Implemented (https://github.com/atomone-hub/atomone/pull/69)

## **Abstract[](https://docs.cosmos.network/main/architecture/adr-template#abstract)**

Expand Down
6 changes: 6 additions & 0 deletions proto/atomone/gov/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ message GenesisState {
//
// Since: cosmos-sdk 0.48
string constitution = 9;

// last updated value for the dynamic min deposit
LastMinDeposit last_min_deposit = 10;

// last updated value for the dynamic min initial deposit
LastMinDeposit last_min_initial_deposit = 11;
}
78 changes: 76 additions & 2 deletions proto/atomone/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ message Deposit {
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// LastMinDeposit is a record of the last time the minimum deposit
// was updated in the store, both its value and a timestamp
message LastMinDeposit {
// value is the value of the minimum deposit
repeated cosmos.base.v1beta1.Coin value = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// time is the time the minimum deposit was last updated
google.protobuf.Timestamp time = 2 [ (gogoproto.stdtime) = true ];
}

// Proposal defines the core field members of a governance proposal.
message Proposal {
// id defines the unique id of the proposal.
Expand Down Expand Up @@ -208,13 +219,72 @@ message TallyParams {
string law_threshold = 6 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

message MinDepositThrottler {
// Floor value for the minimum deposit required for a proposal to enter the voting period.
repeated cosmos.base.v1beta1.Coin floor_value = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// Duration that dictates after how long the dynamic minimum deposit should be recalculated
// for time-based updates.
google.protobuf.Duration update_period = 2 [(gogoproto.stdduration) = true];

// The number of active proposals the dynamic minimum deposit should target.
uint64 target_active_proposals = 3;

// The ratio of increase for the minimum deposit when the number of active proposals
// exceeds the target by 1.
string increase_ratio = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];

// The ratio of decrease for the minimum deposit when the number of active proposals
// is 1 less than the target.
string decrease_ratio = 5 [(cosmos_proto.scalar) = "cosmos.Dec"];

// A positive integer representing the sensitivity of the dynamic minimum deposit
// increase/decrease to the distance from the target number of active proposals.
// The higher the number, the lower the sensitivity. A value of 1 represents the
// highest sensitivity.
uint64 sensitivity_target_distance = 6;
}

message MinInitialDepositThrottler {
// Floor value for the minimum initial deposit required for a proposal to enter the deposit period.
repeated cosmos.base.v1beta1.Coin floor_value = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// Duration that dictates after how long the dynamic minimum deposit should be recalculated
// for time-based updates.
google.protobuf.Duration update_period = 2 [(gogoproto.stdduration) = true];

// The number of proposals in deposit period the dynamic minimum initial deposit should target.
uint64 target_proposals = 3;

// The ratio of increase for the minimum initial deposit when the number of proposals
// in deposit period exceeds the target by 1.
string increase_ratio = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];

// The ratio of decrease for the minimum initial deposit when the number of proposals
// in deposit period is 1 less than the target.
string decrease_ratio = 5 [(cosmos_proto.scalar) = "cosmos.Dec"];

// A positive integer representing the sensitivity of the dynamic minimum initial
// deposit increase/decrease to the distance from the target number of proposals
// in deposit period. The higher the number, the lower the sensitivity. A value
// of 1 represents the highest sensitivity.
uint64 sensitivity_target_distance = 6;
}

// Params defines the parameters for the x/gov module.
//
// Since: cosmos-sdk 0.47
message Params {
// Minimum deposit for a proposal to enter voting period.
// Deprecated: a dynamic system now determines the minimum deposit,
// see the other params inside the min_deposit_throttler field.
// While setting this value returns an error, when queried it is set to the
// value of the current minimum deposit value as determined by the dynamic
// system for backward compatibility.
repeated cosmos.base.v1beta1.Coin min_deposit = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true, deprecated = true ];

// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
Expand All @@ -232,7 +302,7 @@ message Params {
string threshold = 5 [(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"];
string min_initial_deposit_ratio = 7 [(cosmos_proto.scalar) = "cosmos.Dec", deprecated = true ];

// burn deposits if a proposal does not meet quorum
bool burn_vote_quorum = 13;
Expand Down Expand Up @@ -272,4 +342,8 @@ message Params {
// Number of times a proposal should be checked for quorum after the quorum timeout
// has elapsed. Used to compute the amount of time in between quorum checks.
uint64 quorum_check_count = 22;

MinDepositThrottler min_deposit_throttler = 23;

MinInitialDepositThrottler min_initial_deposit_throttler = 24;
}
32 changes: 32 additions & 0 deletions proto/atomone/gov/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
syntax = "proto3";
package atomone.gov.v1;

import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "atomone/gov/v1/gov.proto";
Expand Down Expand Up @@ -61,6 +63,18 @@ service Query {
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/tally";
}

// MinDeposit queries the minimum deposit currently
// required for a proposal to enter voting period.
rpc MinDeposit(QueryMinDepositRequest) returns (QueryMinDepositResponse) {
option (google.api.http).get = "/atomone/gov/v1/mindeposit";
}

// MinInitialDeposit queries the minimum initial deposit
// currently required for a proposal to be submitted.
rpc MinInitialDeposit(QueryMinInitialDepositRequest) returns (QueryMinInitialDepositResponse) {
option (google.api.http).get = "/atomone/gov/v1/mininitialdeposit";
}
}

// QueryConstitutionRequest is the request type for the Query/Constitution RPC method
Expand Down Expand Up @@ -209,3 +223,21 @@ message QueryTallyResultResponse {
// tally defines the requested tally.
TallyResult tally = 1;
}

// QueryMinDepositRequest is the request type for the Query/MinDeposit RPC method.
message QueryMinDepositRequest {}

// QueryMinDepositResponse is the response type for the Query/MinDeposit RPC method.
message QueryMinDepositResponse {
// min_deposit defines the minimum deposit required for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [ (gogoproto.nullable) = false];
}

// QueryMinInitialDepositRequest is the request type for the Query/MinInitialDeposit RPC method.
message QueryMinInitialDepositRequest {}

// QueryMinInitialDepositResponse is the response type for the Query/MinInitialDeposit RPC method.
message QueryMinInitialDepositResponse {
// min_initial_deposit defines the minimum initial deposit required for a proposal to be submitted.
repeated cosmos.base.v1beta1.Coin min_initial_deposit = 1 [ (gogoproto.nullable) = false];
}
11 changes: 9 additions & 2 deletions tests/e2e/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,20 @@ func modifyGenesis(path, moniker, amountStr string, addrAll []sdk.AccAddress, de

govGenState := govv1.NewGenesisState(1,
govv1.NewParams(
sdk.NewCoins(depositAmount), maxDepositPeriod,
// sdk.NewCoins(sdk.NewCoin(denom, depositAmount.Amount)),
maxDepositPeriod,
votingPeriod,
quorum.String(), threshold.String(),
amendmentsQuorum.String(), amendmentsThreshold.String(), lawQuorum.String(), lawThreshold.String(),
sdk.ZeroDec().String(),
// sdk.ZeroDec().String(),
false, false, govv1.DefaultMinDepositRatio.String(),
govv1.DefaultQuorumTimeout, govv1.DefaultMaxVotingPeriodExtension, govv1.DefaultQuorumCheckCount,
sdk.NewCoins(sdk.NewCoin(denom, depositAmount.Amount)), govv1.DefaultMinDepositUpdatePeriod,
govv1.DefaultMinDepositSensitivityTargetDistance,
govv1.DefaultMinDepositIncreaseRatio.String(), govv1.DefaultMinDepositDecreaseRatio.String(),
govv1.DefaultTargetActiveProposals, sdk.NewCoins(sdk.NewCoin(denom, initialDepositAmount.Amount)), govv1.DefaultMinInitialDepositUpdatePeriod,
govv1.DefaultMinInitialDepositSensitivityTargetDistance, govv1.DefaultMinInitialDepositIncreaseRatio.String(),
govv1.DefaultMinInitialDepositDecreaseRatio.String(), govv1.DefaultTargetProposalsInDepositPeriod,
),
)
govGenState.Constitution = "This is a test constitution"
Expand Down
Loading
Loading