Skip to content

Commit

Permalink
wasm tx: pass current delegations instead of those at proposal start
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Apr 30, 2024
1 parent d0f24f2 commit 9d0a862
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions wasm/tx_vote_proposal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! A tx to vote on a proposal
use namada_tx_prelude::action::{Action, GovAction, Write};
use namada_tx_prelude::gov_storage::keys::get_voting_start_epoch_key;
use namada_tx_prelude::proof_of_stake::find_delegation_validators;
use namada_tx_prelude::*;

Expand All @@ -23,22 +22,15 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult {
voter: tx_data.voter.clone(),
}))?;

let voting_start_epoch_key = get_voting_start_epoch_key(tx_data.id);
let proposal_start_epoch = ctx.read(&voting_start_epoch_key)?;
let proposal_start_epoch = if let Some(epoch) = proposal_start_epoch {
epoch
} else {
return Err(Error::new_alloc(format!(
"Proposal id {} doesn't have a start epoch",
tx_data.id
)));
};

debug_log!("apply_tx called to vote a governance proposal");

let delegations_targets =
find_delegation_validators(ctx, &tx_data.voter, &proposal_start_epoch)?;
// Pass in all target validators to the proposal vote. Whether or not the
// 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)?;

governance::vote_proposal(ctx, tx_data, active_delegations_targets)
governance::vote_proposal(ctx, tx_data, delegation_targets)
.wrap_err("Failed to vote on governance proposal")
}

0 comments on commit 9d0a862

Please sign in to comment.