Skip to content

Commit

Permalink
Aldebaran 1.1.4 (#514)
Browse files Browse the repository at this point in the history
Fix for vote counting for negative votes on PIPs
Update previous vote counts to correct above bug
  • Loading branch information
adamdossa authored Aug 6, 2020
1 parent 9157660 commit 0047b25
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polymesh"
version = "2.0.0"
version = "2.0.9"
authors = ["Anonymous"]
build = "build.rs"
edition = "2018"
Expand Down
35 changes: 32 additions & 3 deletions pallets/pips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use frame_support::{
weights::SimpleDispatchInfo,
Parameter,
};
use frame_system::{self as system, ensure_signed};
use frame_system::{self as system, ensure_root, ensure_signed};
use pallet_identity as identity;
use pallet_treasury::TreasuryTrait;
use polymesh_common_utilities::{
Expand Down Expand Up @@ -470,6 +470,35 @@ decl_module! {

fn deposit_event() = default;

#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
fn update_vote_tally(origin) {
ensure_root(origin)?;
let last_pip_id = <PipIdSequence>::get();
// Iterate over all pips
for pip_id in 0..=last_pip_id {
// Skip pruned pips
if <ProposalResult<T>>::contains_key(pip_id) {
// Recalculate result
let mut stats = VotingResult::default();
for vote in <ProposalVotes<T>>::iter_prefix(pip_id) {
match vote {
Vote::None => {},
Vote::Yes(deposit) => {
stats.ayes_count += 1;
stats.ayes_stake += deposit;
}
Vote::No(deposit) => {
stats.nays_count += 1;
stats.nays_stake += deposit;
}
}
}
// Update result
<ProposalResult<T>>::insert(pip_id, stats);
}
}
}

/// Change whether completed PIPs are pruned. Can only be called by governance council
///
/// # Arguments
Expand Down Expand Up @@ -1351,11 +1380,11 @@ impl<T: Trait> Module<T> {
.ok_or_else(|| Error::<T>::StakeAmountOfVotesExceeded)?;
}
Vote::No(deposit) => {
stats.nays_count += stats
stats.nays_count = stats
.nays_count
.checked_add(1)
.ok_or_else(|| Error::<T>::NumberOfVotesExceeded)?;
stats.nays_stake += stats
stats.nays_stake = stats
.nays_stake
.checked_add(&deposit)
.ok_or_else(|| Error::<T>::StakeAmountOfVotesExceeded)?;
Expand Down
4 changes: 2 additions & 2 deletions pallets/runtime/develop/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polymesh"),
impl_name: create_runtime_str!("polymath-polymesh"),
authoring_version: 1,
spec_version: 1008,
impl_version: 1008,
spec_version: 1009,
impl_version: 1009,
apis: RUNTIME_API_VERSIONS,
};

Expand Down
4 changes: 2 additions & 2 deletions pallets/runtime/testnet-v1/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polymesh"),
impl_name: create_runtime_str!("polymath-polymesh"),
authoring_version: 1,
spec_version: 1008,
impl_version: 1008,
spec_version: 1009,
impl_version: 1009,
apis: RUNTIME_API_VERSIONS,
};

Expand Down

0 comments on commit 0047b25

Please sign in to comment.