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

migrate pallet-elections-phragmen to attribute macros #8044

Merged
26 commits merged into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -58,7 +58,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
12 changes: 11 additions & 1 deletion frame/elections-phragmen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ 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
[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 <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -17,14 +17,15 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
serde = { version = "1.0.101", optional = true }
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 @@ -40,6 +41,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, impl_benchmark_test_suite};
use frame_support::traits::OnInitialize;
use frame_support::{dispatch::DispatchResultWithPostInfo, traits::OnInitialize};

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

const BALANCE_FACTOR: u32 = 250;
const MAX_VOTERS: u32 = 500;
Expand Down Expand Up @@ -95,11 +95,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