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): min amount per deposit #13

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ docker-build-debug:
### Linting ###
###############################################################################
golangci_lint_cmd=golangci-lint
golangci_version=v1.53.3
golangci_version=v1.56.0 # note: needed to bump from v1.53.3 bc go.tmz.dev/musttag (A dep of golangci-lint) was no longer resolving

lint:
@echo "--> Running linter"
Expand All @@ -242,6 +242,31 @@ format:
$(golangci_lint_cmd) run --fix
.PHONY: format

# Get a list of all directories containing Go files, excluding vendor and other paths
GO_DIRS=$(shell find . -name '*.go' -not -path "./vendor*" -not -path "*.git*" \
-not -path "./client/docs/statik/statik.go" \
-not -path "./tests/mocks/*" \
-not -path "./crypto/keys/secp256k1/*" \
-not -name "*.pb.go" \
-not -name "*.pb.gw.go" \
-not -name "*.pulsar.go" | xargs -n1 dirname | sort -u)

format-batch:
@go install mvdan.cc/gofumpt@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)

# Run gofumpt in a loop over each directory
@for dir in $(GO_DIRS); do \
echo "Running gofumpt on $$dir"; \
find $$dir -name '*.go' -type f -print0 | xargs -0 gofumpt -w -l; \
done

# Run golangci-lint separately for each directory
@for dir in $(GO_DIRS); do \
$(golangci_lint_cmd) run --fix $$dir || exit 1; \
done
.PHONY: format-batch

###############################################################################
### Localnet ###
###############################################################################
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d
cosmossdk.io/tools/rosetta v0.2.1
github.com/chzyer/readline v1.5.1
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft-db v0.10.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
Expand All @@ -19,6 +20,7 @@ require (
github.com/golang/mock v1.6.0
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.1
github.com/manifoldco/promptui v0.9.0
github.com/ory/dockertest/v3 v3.10.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.6.0
Expand Down Expand Up @@ -66,7 +68,6 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/errors v1.10.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
Expand Down Expand Up @@ -145,7 +146,6 @@ require (
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.11 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand Down Expand Up @@ -221,4 +221,7 @@ replace (

// following versions might cause unexpected behavior
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

// replace broken cosmos-sdk dep
nhooyr.io/websocket => github.com/coder/websocket v1.8.6
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ github.com/cockroachdb/pebble v1.0.0/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7Hpx
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coder/websocket v1.8.6 h1:OmNKdwUvLj7VvHnl5o8skaVghSPLjWdHGCnFbkWqs9w=
github.com/coder/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI=
github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA=
github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M=
Expand Down Expand Up @@ -1953,8 +1955,6 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
7 changes: 4 additions & 3 deletions proto/atomone/gov/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import "cosmos/app/v1alpha1/module.proto";
// Module is the config object of the gov module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/atomone-hub/atomone/x/gov"
go_import : "github.com/atomone-hub/atomone/x/gov"
};

// max_metadata_len defines the maximum proposal metadata length.
// max_metadata_len defines the maximum proposal metadata length.
// Defaults to 255 if not explicitly set.
uint64 max_metadata_len = 1;

// authority defines the custom module authority. If not set, defaults to the governance module.
// authority defines the custom module authority. If not set, defaults to the
// governance module.
string authority = 2;
}
6 changes: 3 additions & 3 deletions proto/atomone/gov/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
108 changes: 64 additions & 44 deletions proto/atomone/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,60 @@ enum VoteOption {

// WeightedVoteOption defines a unit of vote for vote split.
message WeightedVoteOption {
// option defines the valid vote options, it must not contain duplicate vote options.
// option defines the valid vote options, it must not contain duplicate vote
// options.
VoteOption option = 1;

// weight is the vote weight associated with the vote option.
string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
string weight = 2 [ (cosmos_proto.scalar) = "cosmos.Dec" ];
}

// Deposit defines an amount deposited by an account address to an active
// proposal.
message Deposit {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
uint64 proposal_id = 1;

// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string depositor = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// amount to be deposited by depositor.
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
repeated cosmos.base.v1beta1.Coin amount = 3
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// Proposal defines the core field members of a governance proposal.
message Proposal {
// id defines the unique id of the proposal.
uint64 id = 1;
uint64 id = 1;

// messages are the arbitrary messages to be executed if the proposal passes.
repeated google.protobuf.Any messages = 2;

// status defines the proposal status.
ProposalStatus status = 3;
ProposalStatus status = 3;

// final_tally_result is the final tally result of the proposal. When
// querying a proposal via gRPC, this field is not populated until the
// proposal's voting period has ended.
TallyResult final_tally_result = 4;
TallyResult final_tally_result = 4;

// submit_time is the time of proposal submission.
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp submit_time = 5 [ (gogoproto.stdtime) = true ];

// deposit_end_time is the end time for deposition.
google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp deposit_end_time = 6 [ (gogoproto.stdtime) = true ];

// total_deposit is the total deposit on the proposal.
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

repeated cosmos.base.v1beta1.Coin total_deposit = 7
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// voting_start_time is the starting time to vote on a proposal.
google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true];

google.protobuf.Timestamp voting_start_time = 8
[ (gogoproto.stdtime) = true ];

// voting_end_time is the end time of voting on a proposal.
google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true];
google.protobuf.Timestamp voting_end_time = 9 [ (gogoproto.stdtime) = true ];

// metadata is any arbitrary metadata attached to the proposal.
string metadata = 10;
Expand All @@ -95,7 +99,7 @@ message Proposal {
// Proposer is the address of the proposal sumbitter
//
// Since: cosmos-sdk 0.47
string proposer = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string proposer = 13 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// ProposalStatus enumerates the valid statuses of a proposal.
Expand All @@ -122,13 +126,13 @@ enum ProposalStatus {
// TallyResult defines a standard tally for a governance proposal.
message TallyResult {
// yes_count is the number of yes votes on a proposal.
string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"];
string yes_count = 1 [ (cosmos_proto.scalar) = "cosmos.Int" ];
// abstain_count is the number of abstain votes on a proposal.
string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"];
string abstain_count = 2 [ (cosmos_proto.scalar) = "cosmos.Int" ];
// no_count is the number of no votes on a proposal.
string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"];
string no_count = 3 [ (cosmos_proto.scalar) = "cosmos.Int" ];
// no_with_veto_count is the number of no with veto votes on a proposal.
string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"];
string no_with_veto_count = 4 [ (cosmos_proto.scalar) = "cosmos.Int" ];
}

// Vote defines a vote on a governance proposal.
Expand All @@ -138,8 +142,8 @@ message Vote {
uint64 proposal_id = 1;

// voter is the voter address of the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string voter = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

reserved 3;

// options is the weighted vote options.
Expand All @@ -152,69 +156,85 @@ message Vote {
// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "min_deposit,omitempty"];
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "min_deposit,omitempty"
];

// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
google.protobuf.Duration max_deposit_period = 2
[(gogoproto.stdduration) = true, (gogoproto.jsontag) = "max_deposit_period,omitempty"];
google.protobuf.Duration max_deposit_period = 2 [
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "max_deposit_period,omitempty"
];
}

// VotingParams defines the params for voting on governance proposals.
message VotingParams {
// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];
google.protobuf.Duration voting_period = 1 [ (gogoproto.stdduration) = true ];
}

// TallyParams defines the params for tallying votes on governance proposals.
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];
string quorum = 1 [ (cosmos_proto.scalar) = "cosmos.Dec" ];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
string threshold = 2 [ (cosmos_proto.scalar) = "cosmos.Dec" ];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
string veto_threshold = 3 [ (cosmos_proto.scalar) = "cosmos.Dec" ];
}

// 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.
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
repeated cosmos.base.v1beta1.Coin min_deposit = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
google.protobuf.Duration max_deposit_period = 2 [(gogoproto.stdduration) = true];
google.protobuf.Duration max_deposit_period = 2
[ (gogoproto.stdduration) = true ];

// Duration of the voting period.
google.protobuf.Duration voting_period = 3 [(gogoproto.stdduration) = true];
google.protobuf.Duration voting_period = 3 [ (gogoproto.stdduration) = true ];

// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
string quorum = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];
string quorum = 4 [ (cosmos_proto.scalar) = "cosmos.Dec" ];

// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
string threshold = 5 [(cosmos_proto.scalar) = "cosmos.Dec"];
string threshold = 5 [ (cosmos_proto.scalar) = "cosmos.Dec" ];

// 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"];
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"];
// 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" ];

// burn deposits if a proposal does not meet quorum
bool burn_vote_quorum = 13;

// burn deposits if the proposal does not enter voting period
bool burn_proposal_deposit_prevote = 14;

// burn deposits if quorum with vote type no_veto is met
bool burn_vote_veto = 15;

// The ratio representing the proportion of the deposit value minimum that
// must be met when making a deposit. Default value: 0.01. Meaning that for a
// chain with a min_deposit of 100stake, a deposit of 1stake would be
// required.
//
// Since: cosmos-sdk 0.50
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/18146)
string min_deposit_ratio = 16 [ (cosmos_proto.scalar) = "cosmos.Dec" ];
}
Loading
Loading