Skip to content

Commit

Permalink
Merge branch 'feat/governance-snapshots' into governance-v2-merkle-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu authored Aug 7, 2023
2 parents 7948025 + 3a1e7a8 commit 2571f42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion energy-integration/governance-v2/src/configurable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MIN_VOTING_PERIOD: u64 = 14_400; // 24 Hours
const MAX_VOTING_PERIOD: u64 = 201_600; // 2 Weeks
const MIN_QUORUM: u64 = 1_000; // 10%
const MAX_QUORUM: u64 = 6_000; // 60%
const MIN_MIN_FEE_FOR_PROPOSE: u64 = 2_000_000;
const MIN_MIN_FEE_FOR_PROPOSE: u64 = 1;
const MAX_MIN_FEE_FOR_PROPOSE: u64 = 200_000_000_000;
const DECIMALS_CONST: u64 = 1_000_000_000_000_000_000;

Expand Down
2 changes: 1 addition & 1 deletion energy-integration/governance-v2/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub const INVALID_ROOT_HASH: &[u8] = b"Invalid root hash provided";
pub const PROPOSAL_NO_ACTION: &[u8] = b"Proposal has no actions";
pub const EXEEDED_MAX_ACTIONS: &[u8] = b"Exceeded max actions per proposal";
pub const ONLY_PROPOSER_CANCEL: &[u8] = b"Only original proposer may cancel a pending proposal";
pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may cancel a pending proposal";
pub const ONLY_PROPOSER_WITHDRAW: &[u8] = b"Only original proposer may withdraw a pending proposal";
pub const NO_PROPOSAL: &[u8] = b"Proposal does not exist";
pub const WITHDRAW_NOT_ALLOWED: &[u8] = b"You may not withdraw funds from this proposal!";
pub const INVALID_MERKLE_PROOF: &[u8] = b"Invalid merkle proof provided";
18 changes: 9 additions & 9 deletions energy-integration/governance-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub trait GovernanceV2:
let new_user = self.user_voted_proposals(&voter).insert(proposal_id);
require!(new_user, ALREADY_VOTED_ERR_MSG);

let voting_power = user_quorum.sqrt();
let voting_power = &user_quorum;

match self.get_root_hash(proposal_id) {
OptionalValue::None => {
Expand All @@ -178,31 +178,31 @@ pub trait GovernanceV2:
match vote {
VoteType::UpVote => {
self.proposal_votes(proposal_id).update(|proposal_votes| {
proposal_votes.up_votes += &voting_power.clone();
proposal_votes.up_votes += voting_power.clone();
proposal_votes.quorum += &user_quorum.clone();
});
self.up_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum);
self.up_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum);
}
VoteType::DownVote => {
self.proposal_votes(proposal_id).update(|proposal_votes| {
proposal_votes.down_votes += &voting_power.clone();
proposal_votes.down_votes += voting_power.clone();
proposal_votes.quorum += &user_quorum.clone();
});
self.down_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum);
self.down_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum);
}
VoteType::DownVetoVote => {
self.proposal_votes(proposal_id).update(|proposal_votes| {
proposal_votes.down_veto_votes += &voting_power.clone();
proposal_votes.down_veto_votes += voting_power.clone();
proposal_votes.quorum += &user_quorum.clone();
});
self.down_veto_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum);
self.down_veto_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum);
}
VoteType::AbstainVote => {
self.proposal_votes(proposal_id).update(|proposal_votes| {
proposal_votes.abstain_votes += &voting_power.clone();
proposal_votes.abstain_votes += voting_power.clone();
proposal_votes.quorum += &user_quorum.clone();
});
self.abstain_vote_cast_event(&voter, proposal_id, &voting_power, &user_quorum);
self.abstain_vote_cast_event(&voter, proposal_id, voting_power, &user_quorum);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions energy-integration/governance-v2/tests/gov_rust_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ fn gov_withdraw_defeated_proposal_test() {
// Other user (not proposer) try to withdraw the fee -> Fail
gov_setup
.withdraw_after_defeated(&third_user_addr, proposal_id)
.assert_error(4, "Only original proposer may cancel a pending proposal");
.assert_error(4, "Only original proposer may withdraw a pending proposal");

// Proposer withdraw
gov_setup
Expand Down Expand Up @@ -562,7 +562,7 @@ fn gov_modify_withdraw_defeated_proposal_test() {
// Other user (not proposer) try to withdraw the fee -> Fail
gov_setup
.withdraw_after_defeated(&third_user_addr, proposal_id)
.assert_error(4, "Only original proposer may cancel a pending proposal");
.assert_error(4, "Only original proposer may withdraw a pending proposal");

// Proposer withdraw
gov_setup
Expand Down Expand Up @@ -650,7 +650,7 @@ fn gov_withdraw_no_with_veto_defeated_proposal_test() {
// Other user (not proposer) try to withdraw the fee -> Fail
gov_setup
.withdraw_after_defeated(&third_user_addr, proposal_id)
.assert_error(4, "Only original proposer may cancel a pending proposal");
.assert_error(4, "Only original proposer may withdraw a pending proposal");

// Proposer withdraw
gov_setup
Expand Down

0 comments on commit 2571f42

Please sign in to comment.