Files
pezkuwi-subxt/substrate/frame/support/test/tests/system.rs
T
Gavin Wood a6891951fb Referenda and Conviction Voting pallets (#10195)
* Initial draft of new referendum state machine.

* Docs

* Fixes

* Fixes

* Add conviction-voting pallet

* Basic build

* Building

* Some TODOs

* Tests building

* Add missing file

* Basic lifecycle test

* Add couple of tests

* Another test

* More tests

* Fixes

* Fixes

* Formatting

* Fixes

* Tests

* Fixes

* Fixes

* More tests

* Formatting

* First few benchmarks

* First few benchmarks

* Defered queue servicing

* More testing

* Benchmarks

* Fiddly benchmark

* Final nudge benchmarks

* Formatting

* Formatting

* Finished up benchmarks

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_referenda --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/referenda/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Events finished

* Missing file

* No GenesisConfig for Referenda

* Formatting

* Docs

* Docs

* Docs

* Per-class conviction voting

* New test & mock utils

* More tests

* Tests

* Tests finished 🎉

* Benchmarking stuff

* Fixes

* Test harness

* Test harness

* Benchmarks for Conviction=Voting

* Benchmarking pipeline complete

* Docs

* Formatting

* Remove unneeded warning

* Fix UI tests

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_conviction_voting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/conviction-voting/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Docs

* Update frame/conviction-voting/src/vote.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* update sp-runtime version

* MEL Fixes for Referenda and Conviction Voting (#10725)

* free maxencodedlen

* more maxencodedlen

* more MEL

* more mel

* disable storage info

* More Referenda Patches (#10760)

* basic fixes

* fix benchmarking

* fix license

* prevent panic in curve math

* fmt

* bump crate versions

* Update mock.rs

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2022-02-06 12:51:12 +01:00

82 lines
2.3 KiB
Rust

// This file is part of Substrate.
// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::{
codec::{Decode, Encode, EncodeLike},
traits::Get,
weights::RuntimeDbWeight,
};
pub trait Config: 'static + Eq + Clone {
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
+ From<RawOrigin<Self::AccountId>>;
type BaseCallFilter: frame_support::traits::Contains<Self::Call>;
type BlockNumber: Decode + Encode + EncodeLike + Clone + Default + scale_info::TypeInfo;
type Hash;
type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo;
type Call;
type Event: From<Event<Self>>;
type PalletInfo: frame_support::traits::PalletInfo;
type DbWeight: Get<RuntimeDbWeight>;
}
frame_support::decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
#[weight = 0]
fn noop(_origin) {}
}
}
impl<T: Config> Module<T> {
pub fn deposit_event(_event: impl Into<T::Event>) {}
}
frame_support::decl_event!(
pub enum Event<T>
where
BlockNumber = <T as Config>::BlockNumber,
{
ExtrinsicSuccess,
ExtrinsicFailed,
Ignore(BlockNumber),
}
);
frame_support::decl_error! {
pub enum Error for Module<T: Config> {
/// Test error documentation
TestError,
/// Error documentation
/// with multiple lines
AnotherError,
// Required by construct_runtime
CallFiltered,
}
}
pub use frame_support::dispatch::RawOrigin;
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
#[allow(dead_code)]
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
where
OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>,
{
o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin")
}