Skip to content

Commit

Permalink
Merge pull request #85 from agicommies/main
Browse files Browse the repository at this point in the history
fix: false `InsufficientStake` error (#207)
  • Loading branch information
functor-flow authored Aug 25, 2024
2 parents 5ee0099 + 7f38f9c commit f0426ca
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

spec version `121`

Fixing `InsufficientStake` bug in proposal voting

spec version `120`

Storages:
Expand Down
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 pallets/governance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-governance"
version = "1.1.0"
version = "1.1.1"
description = "FRAME pallet for runtime logic of Subspace Blockchain."
authors = ["Commune Community"]
homepage = "https://communeai.org/"
Expand Down
13 changes: 7 additions & 6 deletions pallets/governance/src/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ impl<T: Config> Pallet<T> {
Error::<T>::AlreadyVoted
);

let voter_stake = pallet_subspace::Pallet::<T>::get_delegated_stake(&key);
let voter_delegated_stake = pallet_subspace::Pallet::<T>::get_delegated_stake(&key);
let voter_owned_stake = pallet_subspace::Pallet::<T>::get_owned_stake(&key);

ensure!(voter_stake > 0, Error::<T>::InsufficientStake);
ensure!(
voter_delegated_stake > 0 || voter_owned_stake > 0,
Error::<T>::InsufficientStake
);

let stake_from_vector = pallet_subspace::Pallet::<T>::get_stake_from_vector(&key);
let has_stake_from =
|| stake_from_vector.iter().any(|(k, stakes)| k == &key && *stakes > 0);
if !NotDelegatingVotingPower::<T>::get().contains(&key) && !has_stake_from() {
if !NotDelegatingVotingPower::<T>::get().contains(&key) && voter_delegated_stake == 0 {
return Err(Error::<T>::VoterIsDelegatingVotingPower.into());
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 120,
spec_version: 121,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit f0426ca

Please sign in to comment.