Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
migrate pallet-elections-phragmen to attribute macros (#8044)
Browse files Browse the repository at this point in the history
* All done

* Fix benchmarks

* Apply suggestions from code review

Co-authored-by: Guillaume Thiolliere <[email protected]>

* Fix metadata.

* Fix build

* Add migrations

* Fix

* Update frame/elections-phragmen/src/migrations/v4.rs

* Better migeation test

* More test

* Fix warn

* Update frame/elections-phragmen/src/lib.rs

Co-authored-by: Guillaume Thiolliere <[email protected]>

* Fix test

* early exit

* Fix

* Fix build

Co-authored-by: Guillaume Thiolliere <[email protected]>
  • Loading branch information
kianenigma and gui1117 authored Apr 23, 2021
1 parent 4551b3c commit 20b1a0e
Show file tree
Hide file tree
Showing 9 changed files with 477 additions and 275 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 bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pallet-contracts-primitives = { version = "3.0.0", default-features = false, pat
pallet-contracts-rpc-runtime-api = { version = "3.0.0", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" }
pallet-democracy = { version = "3.0.0", default-features = false, path = "../../../frame/democracy" }
pallet-election-provider-multi-phase = { version = "3.0.0", default-features = false, path = "../../../frame/election-provider-multi-phase" }
pallet-elections-phragmen = { version = "3.0.0", default-features = false, path = "../../../frame/elections-phragmen" }
pallet-elections-phragmen = { version = "4.0.0", default-features = false, path = "../../../frame/elections-phragmen" }
pallet-gilt = { version = "3.0.0", default-features = false, path = "../../../frame/gilt" }
pallet-grandpa = { version = "3.0.0", default-features = false, path = "../../../frame/grandpa" }
pallet-im-online = { version = "3.0.0", default-features = false, path = "../../../frame/im-online" }
Expand Down
13 changes: 12 additions & 1 deletion frame/elections-phragmen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ All notable changes to this crate will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this crate adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - UNRELEASED
## [4.0.0] - UNRELEASED

### Added

### Changed
\[**Needs Migration**\] [migrate pallet-elections-phragmen to attribute macros](https://github.com/paritytech/substrate/pull/8044)

### Fixed

### Security

## [3.0.0]

### Added
[Add slashing events to elections-phragmen](https://github.com/paritytech/substrate/pull/7543)
Expand Down
7 changes: 5 additions & 2 deletions frame/elections-phragmen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-elections-phragmen"
version = "3.0.0"
version = "4.0.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -16,14 +16,15 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-runtime = { version = "3.0.0", default-features = false, path = "../../primitives/runtime" }
sp-npos-elections = { version = "3.0.0", default-features = false, path = "../../primitives/npos-elections" }
sp-io = { version = "3.0.0", default-features = false, path = "../../primitives/io" }
frame-support = { version = "3.0.0", default-features = false, path = "../support" }
frame-system = { version = "3.0.0", default-features = false, path = "../system" }
sp-std = { version = "3.0.0", default-features = false, path = "../../primitives/std" }
sp-core = { version = "3.0.0", default-features = false, path = "../../primitives/core" }
frame-benchmarking = { version = "3.1.0", default-features = false, path = "../benchmarking", optional = true }
log = { version = "0.4.14", default-features = false }

[dev-dependencies]
sp-io = { version = "3.0.0", path = "../../primitives/io" }
hex-literal = "0.3.1"
pallet-balances = { version = "3.0.0", path = "../balances" }
sp-core = { version = "3.0.0", path = "../../primitives/core" }
Expand All @@ -38,6 +39,8 @@ std = [
"sp-npos-elections/std",
"frame-system/std",
"sp-std/std",
"sp-io/std",
"sp-core/std",
"log/std",
]
runtime-benchmarks = [
Expand Down
13 changes: 7 additions & 6 deletions frame/elections-phragmen/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use super::*;

use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, account, whitelist, impl_benchmark_test_suite};
use frame_support::traits::OnInitialize;
use frame_support::{traits::OnInitialize, dispatch::DispatchResultWithPostInfo};

use crate::Module as Elections;
use crate::Pallet as Elections;

const BALANCE_FACTOR: u32 = 250;
const MAX_VOTERS: u32 = 500;
Expand Down Expand Up @@ -87,11 +87,12 @@ fn submit_candidates_with_self_vote<T: Config>(c: u32, prefix: &'static str)
Ok(candidates)
}


/// Submit one voter.
fn submit_voter<T: Config>(caller: T::AccountId, votes: Vec<T::AccountId>, stake: BalanceOf<T>)
-> frame_support::dispatch::DispatchResult
{
fn submit_voter<T: Config>(
caller: T::AccountId,
votes: Vec<T::AccountId>,
stake: BalanceOf<T>,
) -> DispatchResultWithPostInfo {
<Elections<T>>::vote(RawOrigin::Signed(caller).into(), votes, stake)
}

Expand Down
Loading

0 comments on commit 20b1a0e

Please sign in to comment.