Description
The Vote enum in contracts/governance/src/types.rs has four variants:
pub enum Vote {
Yes,
No,
Abstain,
Choice(u32), // ← multi-choice extension
}
However, the match vote { ... } block inside cast_vote in lib.rs only handles three of them:
match vote {
Vote::Yes => { ... }
Vote::No => { ... }
Vote::Abstain => { ... }
// Vote::Choice(n) is missing
}
Depending on whether Soroban's Rust target treats this as:
- A compile error (non-exhaustive pattern match — most likely with
#[derive(...)] and Clippy match-wildcard-for-single-variants), or
- A runtime panic (if a wildcard or default arm is implicitly present)
Either outcome is unacceptable. A caller who submits Vote::Choice(0) will either be rejected at compile time or trigger undefined behavior on-chain.
Root Cause
The Vote::Choice variant was added as part of the multi-choice voting extension (see also #390) but the cast_vote logic was never updated to handle it.
Acceptance Criteria
Dependencies
Priority
High
Estimated Effort
Small
Description
The
Voteenum incontracts/governance/src/types.rshas four variants:However, the
match vote { ... }block insidecast_voteinlib.rsonly handles three of them:Depending on whether Soroban's Rust target treats this as:
#[derive(...)]and Clippymatch-wildcard-for-single-variants), orEither outcome is unacceptable. A caller who submits
Vote::Choice(0)will either be rejected at compile time or trigger undefined behavior on-chain.Root Cause
The
Vote::Choicevariant was added as part of the multi-choice voting extension (see also #390) but thecast_votelogic was never updated to handle it.Acceptance Criteria
Vote::Choice(n)arm to thecast_votematch expressionErr(ContractError::InvalidVote)with a clear error message (if multi-choice is deferred — aligns with feat: add secret management docs and CI secret scan #390 Option B)_wildcard that silently swallows unknown variantsVote::Choiceon a standard Yes/No/Abstain proposal verifying it returnsInvalidVote(if Option B)cargo build -p cosmosvote-governancesucceeds (pending build(deps): bump actions/checkout from 4 to 7 #389 and feat: add secret management docs and CI secret scan #390 also being resolved)Dependencies
fn upgrade) for a clean buildPriority
High
Estimated Effort
Small