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

Add threshold to cw3 flex #180

Merged
merged 28 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e4ff708
Integrate Threshold into msg/state
ethanfrey Dec 14, 2020
185b6ab
cw3-flex compiles with threshold
ethanfrey Dec 14, 2020
09aff63
Existing tests updated and pass
ethanfrey Dec 14, 2020
b1e05c1
Test cases on message validation
ethanfrey Dec 14, 2020
4e1ec11
All message logic tested
ethanfrey Dec 14, 2020
a41b125
Properly calculate passing for Quorum - different if voting open/closed
ethanfrey Dec 14, 2020
011f27f
Test vote/tally logic, fix rounding issue
ethanfrey Dec 14, 2020
f798ddc
Extensive tests and fixes on threshold quorum
ethanfrey Dec 14, 2020
7dc1c75
Add test coverage to list/reverse proposals
ethanfrey Dec 15, 2020
31607dc
Test threshold, vote detail queries
ethanfrey Dec 15, 2020
65a7ee8
Scenario test with absolute percentage and dynamic group
ethanfrey Dec 15, 2020
01a77e7
Add scenario tests for percentage and quorum threshold variants
ethanfrey Dec 15, 2020
478fc3c
Update typos, rename some fields
ethanfrey Dec 15, 2020
3f3b379
Properly handle missing quorum and hitting threshold edge case
ethanfrey Dec 15, 2020
94af010
Extensive rustdoc on ThresholdResponse in cw3 spec
ethanfrey Dec 15, 2020
df6c9d3
cw3: Update query data types and more rustdoc
ethanfrey Dec 15, 2020
23de1be
Update cw3-fixed to match updated cw3 spec
ethanfrey Dec 15, 2020
09e9163
Update cw3-flex to new cw3 spec
ethanfrey Dec 15, 2020
0719092
Merge pull request #188 from CosmWasm/update-cw3-spec
maurolacy Dec 16, 2020
382cbf1
Format / fix cw3 spec details
maurolacy Dec 16, 2020
8a190f1
Update schemas
maurolacy Dec 16, 2020
8290c57
Update contracts/cw3-flex-multisig/src/state.rs
ethanfrey Dec 16, 2020
0fd5a88
Consider abstained votes when computing AbsoluteThreshold passing weight
maurolacy Dec 16, 2020
5ae15c6
Simplify branches in ThresholdQuora is_passed
ethanfrey Dec 16, 2020
526b0ff
Rename ThresholdQuora to ThresholdQuorum
ethanfrey Dec 16, 2020
e574ff7
Pull out PRECISION_FACTOR as mod level const
ethanfrey Dec 16, 2020
d87e498
Add one test for AbsolutePercentage and abstain, cargo schema
ethanfrey Dec 16, 2020
f33e3aa
Remove duplicate descriptions
maurolacy Dec 16, 2020
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
2 changes: 1 addition & 1 deletion contracts/cw3-fixed-multisig/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
fn query_threshold(deps: Deps) -> StdResult<ThresholdResponse> {
let cfg = CONFIG.load(deps.storage)?;
Ok(ThresholdResponse::AbsoluteCount {
weight_needed: cfg.required_weight,
weight: cfg.required_weight,
total_weight: cfg.total_weight,
})
}
Expand Down
82 changes: 77 additions & 5 deletions contracts/cw3-flex-multisig/schema/init_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"required": [
"group_addr",
"max_voting_period",
"required_weight"
"threshold"
],
"properties": {
"group_addr": {
Expand All @@ -14,13 +14,15 @@
"max_voting_period": {
"$ref": "#/definitions/Duration"
},
"required_weight": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
"threshold": {
"$ref": "#/definitions/Threshold"
}
},
"definitions": {
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"type": "string"
},
"Duration": {
"description": "Duration is a delta of time. You can add it to a BlockInfo or Expiration to move that further in the future. Note that an height-based Duration and a time-based Expiration cannot be combined",
"anyOf": [
Expand Down Expand Up @@ -54,6 +56,76 @@
},
"HumanAddr": {
"type": "string"
},
"Threshold": {
"anyOf": [
{
"description": "Declares a total weight needed to pass This usually implies that weight_needed is stable, even if total_weight changes eg. 3 of 5 multisig -> 3 of 6 multisig",
"type": "object",
"required": [
"absolute_count"
],
"properties": {
"absolute_count": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
}
},
{
"description": "Declares a percentage of the total weight needed to pass This implies the percentage is stable, when total_weight changes eg. at 50.1%, we go from needing 51/100 to needing 101/200\n\nNote: percentage_needed = 60% is different than threshold = 60%, quora = 100% as the first will pass with 60% yes votes and 10% no votes, while the second will require the others to vote anything (no, abstain...) to pass",
"type": "object",
"required": [
"absolute_percentage"
],
"properties": {
"absolute_percentage": {
"type": "object",
"required": [
"percentage"
],
"properties": {
"percentage": {
"$ref": "#/definitions/Decimal"
}
}
}
}
},
{
"description": "Declares a threshold (minimum percentage of votes that must approve) and a quorum (minimum percentage of voter weight that must vote). This allows eg. 20.04% of the total weight yes votes to pass, if we have a quorum of 40% and threshold of 51%, and most of the people sit out the election.\n\nThis is more common in general elections, where participation is expected to be low.",
"type": "object",
"required": [
"threshold_quora"
],
"properties": {
"threshold_quora": {
"type": "object",
"required": [
"quorum",
"threshold"
],
"properties": {
"quorum": {
"$ref": "#/definitions/Decimal"
},
"threshold": {
"$ref": "#/definitions/Decimal"
}
}
}
}
}
]
}
}
}
Loading