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

governance: let validator vote even if it doesn't have a self-bond #3874

Merged
merged 1 commit into from
Oct 3, 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
4 changes: 3 additions & 1 deletion crates/tx_prelude/src/proof_of_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use namada_proof_of_stake::{
claim_reward_tokens, deactivate_validator, reactivate_validator,
redelegate_tokens, unbond_tokens, unjail_validator, withdraw_tokens,
};
pub use namada_proof_of_stake::{parameters, storage, storage_key, types};
pub use namada_proof_of_stake::{
is_validator, parameters, storage, storage_key, types,
};
use namada_tx::action::{
Action, ClaimRewards, PosAction, Redelegation, Unbond, Withdraw, Write,
};
Expand Down
13 changes: 10 additions & 3 deletions wasm/tx_vote_proposal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! A tx to vote on a proposal

use namada_tx_prelude::action::{Action, GovAction, Write};
use namada_tx_prelude::proof_of_stake::find_delegation_validators;
use namada_tx_prelude::proof_of_stake::{
find_delegation_validators, is_validator,
};
use namada_tx_prelude::*;

#[transaction]
Expand All @@ -24,8 +26,13 @@ fn apply_tx(ctx: &mut Ctx, tx_data: BatchedTx) -> TxResult {
// vote will be counted based on the validator state will be determined
// when tallying the votes and executing the proposal.
let current_epoch = ctx.get_block_epoch()?;
let delegation_targets =
find_delegation_validators(ctx, &tx_data.voter, &current_epoch)?;

let is_validator = is_validator(ctx, &tx_data.voter).unwrap_or(false);
let delegation_targets = if !is_validator {
find_delegation_validators(ctx, &tx_data.voter, &current_epoch)?
} else {
[tx_data.voter.clone()].into()
};

governance::vote_proposal(ctx, tx_data, delegation_targets)
.wrap_err("Failed to vote on governance proposal")
Expand Down
Loading