mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -22,7 +22,7 @@ pub mod currency {
|
||||
use node_primitives::Balance;
|
||||
|
||||
pub const MILLICENTS: Balance = 1_000_000_000;
|
||||
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
|
||||
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
|
||||
pub const DOLLARS: Balance = 100 * CENTS;
|
||||
|
||||
pub const fn deposit(items: u32, bytes: u32) -> Balance {
|
||||
@@ -32,7 +32,7 @@ pub mod currency {
|
||||
|
||||
/// Time.
|
||||
pub mod time {
|
||||
use node_primitives::{Moment, BlockNumber};
|
||||
use node_primitives::{BlockNumber, Moment};
|
||||
|
||||
/// Since BABE is probabilistic this is the average expected block time that
|
||||
/// we are targeting. Blocks will be produced at a minimum duration defined
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
//! Some configurable implementations as associated type for the substrate runtime.
|
||||
|
||||
use frame_support::traits::{OnUnbalanced, Currency};
|
||||
use crate::{Balances, Authorship, NegativeImbalance};
|
||||
use crate::{Authorship, Balances, NegativeImbalance};
|
||||
use frame_support::traits::{Currency, OnUnbalanced};
|
||||
|
||||
pub struct Author;
|
||||
impl OnUnbalanced<NegativeImbalance> for Author {
|
||||
@@ -29,19 +29,24 @@ impl OnUnbalanced<NegativeImbalance> for Author {
|
||||
|
||||
#[cfg(test)]
|
||||
mod multiplier_tests {
|
||||
use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::{Convert, One, Zero}};
|
||||
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
|
||||
use sp_runtime::{
|
||||
assert_eq_error_rate,
|
||||
traits::{Convert, One, Zero},
|
||||
FixedPointNumber,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
constants::{currency::*, time::*},
|
||||
TransactionPayment, Runtime, TargetBlockFullness,
|
||||
AdjustmentVariable, System, MinimumMultiplier,
|
||||
RuntimeBlockWeights as BlockWeights,
|
||||
AdjustmentVariable, MinimumMultiplier, Runtime, RuntimeBlockWeights as BlockWeights,
|
||||
System, TargetBlockFullness, TransactionPayment,
|
||||
};
|
||||
use frame_support::weights::{Weight, WeightToFeePolynomial, DispatchClass};
|
||||
use frame_support::weights::{DispatchClass, Weight, WeightToFeePolynomial};
|
||||
|
||||
fn max_normal() -> Weight {
|
||||
BlockWeights::get().get(DispatchClass::Normal).max_total
|
||||
BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.max_total
|
||||
.unwrap_or_else(|| BlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
@@ -64,7 +69,7 @@ mod multiplier_tests {
|
||||
}
|
||||
|
||||
// update based on reference impl.
|
||||
fn truth_value_update(block_weight: Weight, previous: Multiplier) -> Multiplier {
|
||||
fn truth_value_update(block_weight: Weight, previous: Multiplier) -> Multiplier {
|
||||
let accuracy = Multiplier::accuracy() as f64;
|
||||
let previous_float = previous.into_inner() as f64 / accuracy;
|
||||
// bump if it is zero.
|
||||
@@ -81,15 +86,20 @@ mod multiplier_tests {
|
||||
// Current saturation in terms of weight
|
||||
let s = block_weight;
|
||||
|
||||
let t1 = v * (s/m - ss/m);
|
||||
let t2 = v.powi(2) * (s/m - ss/m).powi(2) / 2.0;
|
||||
let t1 = v * (s / m - ss / m);
|
||||
let t2 = v.powi(2) * (s / m - ss / m).powi(2) / 2.0;
|
||||
let next_float = previous_float * (1.0 + t1 + t2);
|
||||
Multiplier::from_float(next_float)
|
||||
}
|
||||
|
||||
fn run_with_system_weight<F>(w: Weight, assertions: F) where F: Fn() -> () {
|
||||
let mut t: sp_io::TestExternalities =
|
||||
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||
fn run_with_system_weight<F>(w: Weight, assertions: F)
|
||||
where
|
||||
F: Fn() -> (),
|
||||
{
|
||||
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default()
|
||||
.build_storage::<Runtime>()
|
||||
.unwrap()
|
||||
.into();
|
||||
t.execute_with(|| {
|
||||
System::set_block_consumed_resources(w, 0);
|
||||
assertions()
|
||||
@@ -157,7 +167,9 @@ mod multiplier_tests {
|
||||
loop {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
fm = next;
|
||||
if fm == min_multiplier() { break; }
|
||||
if fm == min_multiplier() {
|
||||
break
|
||||
}
|
||||
iterations += 1;
|
||||
}
|
||||
assert!(iterations > 533_333);
|
||||
@@ -198,7 +210,9 @@ mod multiplier_tests {
|
||||
loop {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
// if no change, panic. This should never happen in this case.
|
||||
if fm == next { panic!("The fee should ever increase"); }
|
||||
if fm == next {
|
||||
panic!("The fee should ever increase");
|
||||
}
|
||||
fm = next;
|
||||
iterations += 1;
|
||||
let fee =
|
||||
@@ -225,7 +239,7 @@ mod multiplier_tests {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
assert_eq_error_rate!(
|
||||
next,
|
||||
truth_value_update(target() / 4 , fm),
|
||||
truth_value_update(target() / 4, fm),
|
||||
Multiplier::from_inner(100),
|
||||
);
|
||||
|
||||
@@ -237,12 +251,11 @@ mod multiplier_tests {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
assert_eq_error_rate!(
|
||||
next,
|
||||
truth_value_update(target() / 2 , fm),
|
||||
truth_value_update(target() / 2, fm),
|
||||
Multiplier::from_inner(100),
|
||||
);
|
||||
// Light block. Multiplier is reduced a little.
|
||||
assert!(next < fm);
|
||||
|
||||
});
|
||||
run_with_system_weight(target(), || {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
@@ -259,7 +272,7 @@ mod multiplier_tests {
|
||||
let next = runtime_multiplier_update(fm);
|
||||
assert_eq_error_rate!(
|
||||
next,
|
||||
truth_value_update(target() * 2 , fm),
|
||||
truth_value_update(target() * 2, fm),
|
||||
Multiplier::from_inner(100),
|
||||
);
|
||||
|
||||
@@ -326,28 +339,24 @@ mod multiplier_tests {
|
||||
BlockWeights::get().max_block,
|
||||
Weight::max_value() / 2,
|
||||
Weight::max_value(),
|
||||
].into_iter().for_each(|i| {
|
||||
]
|
||||
.into_iter()
|
||||
.for_each(|i| {
|
||||
run_with_system_weight(i, || {
|
||||
let next = runtime_multiplier_update(Multiplier::one());
|
||||
let truth = truth_value_update(i, Multiplier::one());
|
||||
assert_eq_error_rate!(
|
||||
truth,
|
||||
next,
|
||||
Multiplier::from_inner(50_000_000)
|
||||
);
|
||||
assert_eq_error_rate!(truth, next, Multiplier::from_inner(50_000_000));
|
||||
});
|
||||
});
|
||||
|
||||
// Some values that are all above the target and will cause an increase.
|
||||
let t = target();
|
||||
vec![t + 100, t * 2, t * 4]
|
||||
.into_iter()
|
||||
.for_each(|i| {
|
||||
run_with_system_weight(i, || {
|
||||
let fm = runtime_multiplier_update(max_fm);
|
||||
// won't grow. The convert saturates everything.
|
||||
assert_eq!(fm, max_fm);
|
||||
})
|
||||
});
|
||||
vec![t + 100, t * 2, t * 4].into_iter().for_each(|i| {
|
||||
run_with_system_weight(i, || {
|
||||
let fm = runtime_multiplier_update(max_fm);
|
||||
// won't grow. The convert saturates everything.
|
||||
assert_eq!(fm, max_fm);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,67 +22,67 @@
|
||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types, RuntimeDebug,
|
||||
weights::{
|
||||
Weight, IdentityFee,
|
||||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
DispatchClass,
|
||||
},
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
Currency, Imbalance, KeyOwnerProofSystem, OnUnbalanced, LockIdentifier,
|
||||
U128CurrencyToVote, AllowAll, DenyAll,
|
||||
AllowAll, Currency, DenyAll, Imbalance, InstanceFilter, KeyOwnerProofSystem,
|
||||
LockIdentifier, OnUnbalanced, U128CurrencyToVote,
|
||||
},
|
||||
weights::{
|
||||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
DispatchClass, IdentityFee, Weight,
|
||||
},
|
||||
PalletId, RuntimeDebug,
|
||||
};
|
||||
use frame_system::{
|
||||
EnsureRoot, EnsureOneOf,
|
||||
limits::{BlockWeights, BlockLength}
|
||||
limits::{BlockLength, BlockWeights},
|
||||
EnsureOneOf, EnsureRoot,
|
||||
};
|
||||
use frame_support::{traits::InstanceFilter, PalletId};
|
||||
use codec::{Encode, Decode, MaxEncodedLen};
|
||||
pub use node_primitives::{AccountId, Signature};
|
||||
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use pallet_contracts::weights::WeightInfo;
|
||||
use pallet_election_provider_multi_phase::FallbackStrategy;
|
||||
use pallet_grandpa::{
|
||||
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
|
||||
};
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_session::historical as pallet_session_historical;
|
||||
pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
|
||||
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_core::{
|
||||
crypto::KeyTypeId,
|
||||
u32_trait::{_1, _2, _3, _4, _5},
|
||||
OpaqueMetadata,
|
||||
};
|
||||
pub use node_primitives::{AccountId, Signature};
|
||||
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_inherents::{CheckInherentsResult, InherentData};
|
||||
use sp_runtime::{
|
||||
Permill, Perbill, Perquintill, Percent, ApplyExtrinsicResult, impl_opaque_keys, generic,
|
||||
create_runtime_str, FixedPointNumber,
|
||||
create_runtime_str,
|
||||
curve::PiecewiseLinear,
|
||||
generic, impl_opaque_keys,
|
||||
traits::{
|
||||
self, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys,
|
||||
SaturatedConversion, StaticLookup,
|
||||
},
|
||||
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
|
||||
ApplyExtrinsicResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill,
|
||||
};
|
||||
use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority};
|
||||
use sp_runtime::traits::{
|
||||
self, BlakeTwo256, Block as BlockT, StaticLookup, SaturatedConversion, ConvertInto, OpaqueKeys,
|
||||
NumberFor,
|
||||
};
|
||||
use sp_version::RuntimeVersion;
|
||||
use sp_std::prelude::*;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use sp_version::NativeVersion;
|
||||
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||
use pallet_grandpa::fg_primitives;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, CurrencyAdapter};
|
||||
use pallet_session::{historical as pallet_session_historical};
|
||||
use sp_inherents::{InherentData, CheckInherentsResult};
|
||||
use sp_version::RuntimeVersion;
|
||||
use static_assertions::const_assert;
|
||||
use pallet_contracts::weights::WeightInfo;
|
||||
use pallet_election_provider_multi_phase::FallbackStrategy;
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use frame_system::Call as SystemCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use pallet_staking::StakerStatus;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
|
||||
/// Implementations of some helper traits passed into runtime modules as associated types.
|
||||
pub mod impls;
|
||||
@@ -90,7 +90,7 @@ use impls::Author;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
use constants::{time::*, currency::*};
|
||||
use constants::{currency::*, time::*};
|
||||
use sp_runtime::generic::Era;
|
||||
|
||||
// Make the WASM binary available.
|
||||
@@ -100,9 +100,11 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn wasm_binary_unwrap() -> &'static [u8] {
|
||||
WASM_BINARY.expect("Development wasm binary is not available. This means the client is \
|
||||
WASM_BINARY.expect(
|
||||
"Development wasm binary is not available. This means the client is \
|
||||
built with `SKIP_WASM_BUILD` flag and it is only usable for \
|
||||
production chains. Please rebuild with the flag disabled.")
|
||||
production chains. Please rebuild with the flag disabled.",
|
||||
)
|
||||
}
|
||||
|
||||
/// Runtime version.
|
||||
@@ -125,23 +127,20 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
|
||||
sp_consensus_babe::BabeEpochConfiguration {
|
||||
c: PRIMARY_PROBABILITY,
|
||||
allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots
|
||||
allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots,
|
||||
};
|
||||
|
||||
/// Native version.
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub fn native_version() -> NativeVersion {
|
||||
NativeVersion {
|
||||
runtime_version: VERSION,
|
||||
can_author_with: Default::default(),
|
||||
}
|
||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||
}
|
||||
|
||||
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
|
||||
|
||||
pub struct DealWithFees;
|
||||
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
|
||||
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {
|
||||
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
|
||||
if let Some(fees) = fees_then_tips.next() {
|
||||
// for fees, 80% to treasury, 20% to author
|
||||
let mut split = fees.ration(80, 20);
|
||||
@@ -256,14 +255,20 @@ parameter_types! {
|
||||
}
|
||||
|
||||
/// The type used to represent the kinds of proxying allowed.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen)]
|
||||
#[derive(
|
||||
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
|
||||
)]
|
||||
pub enum ProxyType {
|
||||
Any,
|
||||
NonTransfer,
|
||||
Governance,
|
||||
Staking,
|
||||
}
|
||||
impl Default for ProxyType { fn default() -> Self { Self::Any } }
|
||||
impl Default for ProxyType {
|
||||
fn default() -> Self {
|
||||
Self::Any
|
||||
}
|
||||
}
|
||||
impl InstanceFilter<Call> for ProxyType {
|
||||
fn filter(&self, c: &Call) -> bool {
|
||||
match self {
|
||||
@@ -271,19 +276,16 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
ProxyType::NonTransfer => !matches!(
|
||||
c,
|
||||
Call::Balances(..) |
|
||||
Call::Assets(..) |
|
||||
Call::Uniques(..) |
|
||||
Call::Vesting(pallet_vesting::Call::vested_transfer(..)) |
|
||||
Call::Indices(pallet_indices::Call::transfer(..))
|
||||
Call::Assets(..) | Call::Uniques(..) |
|
||||
Call::Vesting(pallet_vesting::Call::vested_transfer(..)) |
|
||||
Call::Indices(pallet_indices::Call::transfer(..))
|
||||
),
|
||||
ProxyType::Governance => matches!(
|
||||
c,
|
||||
Call::Democracy(..) |
|
||||
Call::Council(..) |
|
||||
Call::Society(..) |
|
||||
Call::TechnicalCommittee(..) |
|
||||
Call::Elections(..) |
|
||||
Call::Treasury(..)
|
||||
Call::Council(..) | Call::Society(..) |
|
||||
Call::TechnicalCommittee(..) |
|
||||
Call::Elections(..) | Call::Treasury(..)
|
||||
),
|
||||
ProxyType::Staking => matches!(c, Call::Staking(..)),
|
||||
}
|
||||
@@ -500,15 +502,16 @@ impl pallet_staking::Config for Runtime {
|
||||
type SlashCancelOrigin = EnsureOneOf<
|
||||
AccountId,
|
||||
EnsureRoot<AccountId>,
|
||||
pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>
|
||||
pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>,
|
||||
>;
|
||||
type SessionInterface = Self;
|
||||
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
|
||||
type NextNewSession = Session;
|
||||
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
|
||||
type ElectionProvider = ElectionProviderMultiPhase;
|
||||
type GenesisElectionProvider =
|
||||
onchain::OnChainSequentialPhragmen<pallet_election_provider_multi_phase::OnChainConfig<Self>>;
|
||||
type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<
|
||||
pallet_election_provider_multi_phase::OnChainConfig<Self>,
|
||||
>;
|
||||
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
@@ -618,20 +621,26 @@ impl pallet_democracy::Config for Runtime {
|
||||
type VotingPeriod = VotingPeriod;
|
||||
type MinimumDeposit = MinimumDeposit;
|
||||
/// A straight majority of the council can decide what their next motion is.
|
||||
type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
|
||||
type ExternalOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
|
||||
/// A super-majority can have the next scheduled referendum be a straight majority-carries vote.
|
||||
type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
type ExternalMajorityOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
|
||||
/// A unanimous council can have the next scheduled referendum be a straight default-carries
|
||||
/// (NTB) vote.
|
||||
type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;
|
||||
type ExternalDefaultOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;
|
||||
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
|
||||
/// be tabled immediately and with a shorter voting/enactment period.
|
||||
type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
|
||||
type InstantOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>;
|
||||
type FastTrackOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
|
||||
type InstantOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>;
|
||||
type InstantAllowed = InstantAllowed;
|
||||
type FastTrackVotingPeriod = FastTrackVotingPeriod;
|
||||
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
|
||||
type CancellationOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
|
||||
type CancellationOrigin =
|
||||
pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
|
||||
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
|
||||
// Root must agree.
|
||||
type CancelProposalOrigin = EnsureOneOf<
|
||||
@@ -728,7 +737,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
|
||||
type EnsureRootOrHalfCouncil = EnsureOneOf<
|
||||
AccountId,
|
||||
EnsureRoot<AccountId>,
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>,
|
||||
>;
|
||||
impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
|
||||
type Event = Event;
|
||||
@@ -768,12 +777,12 @@ impl pallet_treasury::Config for Runtime {
|
||||
type ApproveOrigin = EnsureOneOf<
|
||||
AccountId,
|
||||
EnsureRoot<AccountId>,
|
||||
pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>
|
||||
pallet_collective::EnsureProportionAtLeast<_3, _5, AccountId, CouncilCollective>,
|
||||
>;
|
||||
type RejectOrigin = EnsureOneOf<
|
||||
AccountId,
|
||||
EnsureRoot<AccountId>,
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>,
|
||||
>;
|
||||
type Event = Event;
|
||||
type OnSlash = ();
|
||||
@@ -876,8 +885,8 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
|
||||
where
|
||||
Call: From<LocalCall>,
|
||||
where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
|
||||
call: Call,
|
||||
@@ -887,10 +896,8 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
) -> Option<(Call, <UncheckedExtrinsic as traits::Extrinsic>::SignaturePayload)> {
|
||||
let tip = 0;
|
||||
// take the biggest period possible.
|
||||
let period = BlockHashCount::get()
|
||||
.checked_next_power_of_two()
|
||||
.map(|c| c / 2)
|
||||
.unwrap_or(2) as u64;
|
||||
let period =
|
||||
BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
|
||||
let current_block = System::block_number()
|
||||
.saturated_into::<u64>()
|
||||
// The `System::block_number` is initialized with `n+1`,
|
||||
@@ -911,10 +918,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
log::warn!("Unable to create signed payload: {:?}", e);
|
||||
})
|
||||
.ok()?;
|
||||
let signature = raw_payload
|
||||
.using_encoded(|payload| {
|
||||
C::sign(payload, public)
|
||||
})?;
|
||||
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
|
||||
let address = Indices::unlookup(account);
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
Some((call, (address, signature.into(), extra)))
|
||||
@@ -926,7 +930,8 @@ impl frame_system::offchain::SigningTypes for Runtime {
|
||||
type Signature = Signature;
|
||||
}
|
||||
|
||||
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
|
||||
where
|
||||
Call: From<C>,
|
||||
{
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
@@ -965,8 +970,11 @@ impl pallet_grandpa::Config for Runtime {
|
||||
GrandpaId,
|
||||
)>>::IdentificationTuple;
|
||||
|
||||
type HandleEquivocation =
|
||||
pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
|
||||
type HandleEquivocation = pallet_grandpa::EquivocationHandler<
|
||||
Self::KeyOwnerIdentification,
|
||||
Offences,
|
||||
ReportLongevity,
|
||||
>;
|
||||
|
||||
type WeightInfo = ();
|
||||
}
|
||||
@@ -1036,7 +1044,8 @@ impl pallet_society::Config for Runtime {
|
||||
type MembershipChanged = ();
|
||||
type RotationPeriod = RotationPeriod;
|
||||
type MaxLockDuration = MaxLockDuration;
|
||||
type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type FounderSetOrigin =
|
||||
pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>;
|
||||
type SuspensionJudgementOrigin = pallet_society::EnsureFounder<Runtime>;
|
||||
type MaxCandidateIntake = MaxCandidateIntake;
|
||||
type ChallengePeriod = ChallengePeriod;
|
||||
@@ -1261,11 +1270,7 @@ mod mmr {
|
||||
use super::Runtime;
|
||||
pub use pallet_mmr::primitives::*;
|
||||
|
||||
pub type Leaf = <
|
||||
<Runtime as pallet_mmr::Config>::LeafData
|
||||
as
|
||||
LeafDataProvider
|
||||
>::LeafData;
|
||||
pub type Leaf = <<Runtime as pallet_mmr::Config>::LeafData as LeafDataProvider>::LeafData;
|
||||
pub type Hash = <Runtime as pallet_mmr::Config>::Hash;
|
||||
pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
|
||||
}
|
||||
@@ -1613,9 +1618,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn validate_transaction_submitter_bounds() {
|
||||
fn is_submit_signed_transaction<T>() where
|
||||
fn is_submit_signed_transaction<T>()
|
||||
where
|
||||
T: CreateSignedTransaction<Call>,
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
is_submit_signed_transaction::<Runtime>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user