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): add yes_quorum parameter #19167

Merged
merged 23 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
294 changes: 226 additions & 68 deletions api/cosmos/gov/v1/gov.pulsar.go

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions client/v2/internal/offchain/msgSignArbitraryData.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "amino/amino.proto";

// MsgSignArbitraryData defines an arbitrary, general-purpose, off-chain message
message MsgSignArbitraryData {
option (amino.name) = "offchain/MsgSignArbitraryData";
option (amino.name) = "offchain/MsgSignArbitraryData";
option (cosmos.msg.v1.signer) = "signer";
// AppDomain is the application requesting off-chain message signing
string app_domain = 1;
Expand All @@ -17,4 +17,3 @@ message MsgSignArbitraryData {
// Data represents the raw bytes of the content that is signed (text, json, etc)
string data = 3;
}

3 changes: 2 additions & 1 deletion collections/lookup_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package collections_test
import (
"testing"

"github.com/stretchr/testify/require"

"cosmossdk.io/collections"
"cosmossdk.io/collections/colltest"
"github.com/stretchr/testify/require"
)

func TestLookupMap(t *testing.T) {
Expand Down
18 changes: 13 additions & 5 deletions proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ message Params {
//
// Since: x/gov v1.0.0
string optimistic_rejected_threshold = 19 [(cosmos_proto.scalar) = "cosmos.Dec"];

// yes_quorum defines the minimum percentage of Yes votes in quroum for proposal to pass.
// Default value: 0 (disabled).
//
// Since: x/gov v1.0.0
string yes_quorum = 20 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

// MessageBasedParams defines the parameters of specific messages in a proposal.
Expand All @@ -361,14 +367,16 @@ message MessageBasedParams {
// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];

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

// Minimum proportion of Yes votes for proposal to pass.
// yes_quorum defines the minimum percentage of Yes votes in quroum for proposal to pass.
// If zero then the yes_quorum is disabled.
string yes_quorum = 20 [(cosmos_proto.scalar) = "cosmos.Dec"];

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

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed.
// Minimum value of Veto votes to Total votes ratio for proposal to be vetoed.
string veto_threshold = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
3 changes: 2 additions & 1 deletion store/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"fmt"
"testing"

"cosmossdk.io/store/v2"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"cosmossdk.io/store/v2"
)

type DBTestSuite struct {
Expand Down
8 changes: 4 additions & 4 deletions store/db/goleveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type GoLevelDB struct {

var _ store.RawDB = (*GoLevelDB)(nil)

func NewGoLevelDB(name string, dir string, opts store.Options) (*GoLevelDB, error) {
func NewGoLevelDB(name, dir string, opts store.Options) (*GoLevelDB, error) {
defaultOpts := &opt.Options{
Filter: filter.NewBloomFilter(10), // by default, goleveldb doesn't use a bloom filter.
}
Expand All @@ -39,7 +39,7 @@ func NewGoLevelDB(name string, dir string, opts store.Options) (*GoLevelDB, erro
return NewGoLevelDBWithOpts(name, dir, defaultOpts)
}

func NewGoLevelDBWithOpts(name string, dir string, o *opt.Options) (*GoLevelDB, error) {
func NewGoLevelDBWithOpts(name, dir string, o *opt.Options) (*GoLevelDB, error) {
dbPath := filepath.Join(dir, name+".db")
db, err := leveldb.OpenFile(dbPath, o)
if err != nil {
Expand Down Expand Up @@ -76,7 +76,7 @@ func (db *GoLevelDB) Has(key []byte) (bool, error) {
}

// Set implements RawDB.
func (db *GoLevelDB) Set(key []byte, value []byte) error {
func (db *GoLevelDB) Set(key, value []byte) error {
if len(key) == 0 {
return store.ErrKeyEmpty
}
Expand All @@ -90,7 +90,7 @@ func (db *GoLevelDB) Set(key []byte, value []byte) error {
}

// SetSync implements RawDB.
func (db *GoLevelDB) SetSync(key []byte, value []byte) error {
func (db *GoLevelDB) SetSync(key, value []byte) error {
if len(key) == 0 {
return store.ErrKeyEmpty
}
Expand Down
10 changes: 5 additions & 5 deletions store/db/memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (db *MemDB) Has(key []byte) (bool, error) {
}

// Set implements DB.
func (db *MemDB) Set(key []byte, value []byte) error {
func (db *MemDB) Set(key, value []byte) error {
if len(key) == 0 {
return store.ErrKeyEmpty
}
Expand All @@ -103,12 +103,12 @@ func (db *MemDB) Set(key []byte, value []byte) error {
}

// set sets a value without locking the mutex.
func (db *MemDB) set(key []byte, value []byte) {
func (db *MemDB) set(key, value []byte) {
db.btree.ReplaceOrInsert(newPair(key, value))
}

// SetSync implements DB.
func (db *MemDB) SetSync(key []byte, value []byte) error {
func (db *MemDB) SetSync(key, value []byte) error {
return db.Set(key, value)
}

Expand Down Expand Up @@ -231,11 +231,11 @@ type memDBIterator struct {
var _ corestore.Iterator = (*memDBIterator)(nil)

// newMemDBIterator creates a new memDBIterator.
func newMemDBIterator(db *MemDB, start []byte, end []byte, reverse bool) *memDBIterator {
func newMemDBIterator(db *MemDB, start, end []byte, reverse bool) *memDBIterator {
return newMemDBIteratorMtxChoice(db, start, end, reverse, true)
}

func newMemDBIteratorMtxChoice(db *MemDB, start []byte, end []byte, reverse bool, useMtx bool) *memDBIterator {
func newMemDBIteratorMtxChoice(db *MemDB, start, end []byte, reverse, useMtx bool) *memDBIterator {
ctx, cancel := context.WithCancel(context.Background())
ch := make(chan *item, chBufferSize)
iter := &memDBIterator{
Expand Down
2 changes: 1 addition & 1 deletion store/db/prefixdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func newPrefixIterator(prefix, start, end []byte, source corestore.Iterator) (*p
}

// Domain implements Iterator.
func (itr *prefixDBIterator) Domain() (start []byte, end []byte) {
func (itr *prefixDBIterator) Domain() (start, end []byte) {
return itr.start, itr.end
}

Expand Down
4 changes: 2 additions & 2 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,9 @@ require (
replace (
cosmossdk.io/api => ../api
cosmossdk.io/client/v2 => ../client/v2
cosmossdk.io/depinject => ../depinject
cosmossdk.io/core => ../core
cosmossdk.io/depinject => ../depinject
cosmossdk.io/x/accounts => ../x/accounts
cosmossdk.io/x/tx => ../x/tx
cosmossdk.io/x/auth => ../x/auth
cosmossdk.io/x/authz => ../x/authz
cosmossdk.io/x/bank => ../x/bank
Expand All @@ -244,6 +243,7 @@ replace (
cosmossdk.io/x/protocolpool => ../x/protocolpool
cosmossdk.io/x/slashing => ../x/slashing
cosmossdk.io/x/staking => ../x/staking
cosmossdk.io/x/tx => ../x/tx
cosmossdk.io/x/upgrade => ../x/upgrade
)

Expand Down
Loading
Loading