Companion for substrate/5686 (#1008)

* Companion for substrate/5686

* Update substrate
This commit is contained in:
Kian Paimani
2020-04-22 09:51:55 +02:00
committed by GitHub
parent ed9c8ce662
commit 97fed89079
8 changed files with 184 additions and 186 deletions
+152 -153
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -25,7 +25,7 @@ use frame_support::{
decl_storage, decl_module, decl_error, ensure, decl_storage, decl_module, decl_error, ensure,
dispatch::DispatchResult, dispatch::DispatchResult,
traits::Get, traits::Get,
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo}, weights::{MINIMUM_WEIGHT, DispatchClass},
}; };
use primitives::{Hash, parachain::{AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId}}; use primitives::{Hash, parachain::{AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId}};
@@ -134,7 +134,7 @@ decl_module! {
type Error = Error<T>; type Error = Error<T>;
/// Provide candidate receipts for parachains, in ascending order by id. /// Provide candidate receipts for parachains, in ascending order by id.
#[weight = SimpleDispatchInfo::FixedMandatory(MINIMUM_WEIGHT)] #[weight = (MINIMUM_WEIGHT, DispatchClass::Mandatory)]
fn more_attestations(origin, _more: MoreAttestations) -> DispatchResult { fn more_attestations(origin, _more: MoreAttestations) -> DispatchResult {
ensure_none(origin)?; ensure_none(origin)?;
ensure!(!DidUpdate::exists(), Error::<T>::TooManyAttestations); ensure!(!DidUpdate::exists(), Error::<T>::TooManyAttestations);
+2 -3
View File
@@ -19,7 +19,6 @@
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover}; use sp_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover};
use frame_support::{decl_event, decl_storage, decl_module, decl_error}; use frame_support::{decl_event, decl_storage, decl_module, decl_error};
use frame_support::weights::SimpleDispatchInfo;
use frame_support::traits::{Currency, Get, VestingSchedule}; use frame_support::traits::{Currency, Get, VestingSchedule};
use system::{ensure_root, ensure_none}; use system::{ensure_root, ensure_none};
use codec::{Encode, Decode}; use codec::{Encode, Decode};
@@ -184,7 +183,7 @@ decl_module! {
/// ///
/// Total Complexity: O(1) /// Total Complexity: O(1)
/// </weight> /// </weight>
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)] #[weight = 1_000_000_000]
fn claim(origin, dest: T::AccountId, ethereum_signature: EcdsaSignature) { fn claim(origin, dest: T::AccountId, ethereum_signature: EcdsaSignature) {
ensure_none(origin)?; ensure_none(origin)?;
@@ -231,7 +230,7 @@ decl_module! {
/// ///
/// Total Complexity: O(1) /// Total Complexity: O(1)
/// </weight> /// </weight>
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)] #[weight = 30_000_000]
fn mint_claim(origin, fn mint_claim(origin,
who: EthereumAddress, who: EthereumAddress,
value: BalanceOf<T>, value: BalanceOf<T>,
+8 -8
View File
@@ -71,7 +71,7 @@ use frame_support::{
traits::{ traits::{
Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement::AllowDeath Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement::AllowDeath
}, },
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo}, weights::MINIMUM_WEIGHT,
}; };
use system::ensure_signed; use system::ensure_signed;
use sp_runtime::{ModuleId, use sp_runtime::{ModuleId,
@@ -250,7 +250,7 @@ decl_module! {
fn deposit_event() = default; fn deposit_event() = default;
/// Create a new crowdfunding campaign for a parachain slot deposit for the current auction. /// Create a new crowdfunding campaign for a parachain slot deposit for the current auction.
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)] #[weight = 100_000_000]
fn create(origin, fn create(origin,
#[compact] cap: BalanceOf<T>, #[compact] cap: BalanceOf<T>,
#[compact] first_slot: T::BlockNumber, #[compact] first_slot: T::BlockNumber,
@@ -294,7 +294,7 @@ decl_module! {
/// Contribute to a crowd sale. This will transfer some balance over to fund a parachain /// Contribute to a crowd sale. This will transfer some balance over to fund a parachain
/// slot. It will be withdrawable in two instances: the parachain becomes retired; or the /// slot. It will be withdrawable in two instances: the parachain becomes retired; or the
/// slot is unable to be purchased and the timeout expires. /// slot is unable to be purchased and the timeout expires.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn contribute(origin, #[compact] index: FundIndex, #[compact] value: BalanceOf<T>) { fn contribute(origin, #[compact] index: FundIndex, #[compact] value: BalanceOf<T>) {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
@@ -353,7 +353,7 @@ decl_module! {
/// - `index` is the fund index that `origin` owns and whose deploy data will be set. /// - `index` is the fund index that `origin` owns and whose deploy data will be set.
/// - `code_hash` is the hash of the parachain's Wasm validation function. /// - `code_hash` is the hash of the parachain's Wasm validation function.
/// - `initial_head_data` is the parachain's initial head data. /// - `initial_head_data` is the parachain's initial head data.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn fix_deploy_data(origin, fn fix_deploy_data(origin,
#[compact] index: FundIndex, #[compact] index: FundIndex,
code_hash: T::Hash, code_hash: T::Hash,
@@ -379,7 +379,7 @@ decl_module! {
/// ///
/// - `index` is the fund index that `origin` owns and whose deploy data will be set. /// - `index` is the fund index that `origin` owns and whose deploy data will be set.
/// - `para_id` is the parachain index that this fund won. /// - `para_id` is the parachain index that this fund won.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn onboard(origin, fn onboard(origin,
#[compact] index: FundIndex, #[compact] index: FundIndex,
#[compact] para_id: ParaId #[compact] para_id: ParaId
@@ -408,7 +408,7 @@ decl_module! {
} }
/// Note that a successful fund has lost its parachain slot, and place it into retirement. /// Note that a successful fund has lost its parachain slot, and place it into retirement.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn begin_retirement(origin, #[compact] index: FundIndex) { fn begin_retirement(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?; let _ = ensure_signed(origin)?;
@@ -430,7 +430,7 @@ decl_module! {
} }
/// Withdraw full balance of a contributor to an unsuccessful or off-boarded fund. /// Withdraw full balance of a contributor to an unsuccessful or off-boarded fund.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn withdraw(origin, #[compact] index: FundIndex) { fn withdraw(origin, #[compact] index: FundIndex) {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
@@ -461,7 +461,7 @@ decl_module! {
/// Remove a fund after either: it was unsuccessful and it timed out; or it was successful /// Remove a fund after either: it was unsuccessful and it timed out; or it was successful
/// but it has been retired from its parachain slot. This places any deposits that were not /// but it has been retired from its parachain slot. This places any deposits that were not
/// withdrawn into the treasury. /// withdrawn into the treasury.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn dissolve(origin, #[compact] index: FundIndex) { fn dissolve(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?; let _ = ensure_signed(origin)?;
+4 -4
View File
@@ -35,8 +35,8 @@ use sp_staking::{
}; };
use frame_support::{ use frame_support::{
traits::KeyOwnerProofSystem, traits::KeyOwnerProofSystem,
dispatch::IsSubType, dispatch::{IsSubType},
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT}, weights::{DispatchClass, Weight, MINIMUM_WEIGHT},
}; };
use primitives::{ use primitives::{
Balance, Balance,
@@ -571,7 +571,7 @@ decl_module! {
} }
/// Provide candidate receipts for parachains, in ascending order by id. /// Provide candidate receipts for parachains, in ascending order by id.
#[weight = SimpleDispatchInfo::FixedMandatory(1_000_000_000)] #[weight = (1_000_000_000, DispatchClass::Mandatory)]
pub fn set_heads(origin, heads: Vec<AttestedCandidate>) -> DispatchResult { pub fn set_heads(origin, heads: Vec<AttestedCandidate>) -> DispatchResult {
ensure_none(origin)?; ensure_none(origin)?;
ensure!(!<DidUpdate>::exists(), Error::<T>::TooManyHeadUpdates); ensure!(!<DidUpdate>::exists(), Error::<T>::TooManyHeadUpdates);
@@ -651,7 +651,7 @@ decl_module! {
/// ///
/// The weight is 0; in order to avoid DoS a `SignedExtension` validation /// The weight is 0; in order to avoid DoS a `SignedExtension` validation
/// is implemented. /// is implemented.
#[weight = SimpleDispatchInfo::FixedNormal(0)] #[weight = 0]
pub fn report_double_vote( pub fn report_double_vote(
origin, origin,
report: DoubleVoteReport< report: DoubleVoteReport<
+8 -8
View File
@@ -31,7 +31,7 @@ use sp_runtime::{
use frame_support::{ use frame_support::{
decl_storage, decl_module, decl_event, decl_error, ensure, decl_storage, decl_module, decl_event, decl_error, ensure,
dispatch::{DispatchResult, IsSubType}, traits::{Get, Currency, ReservableCurrency}, dispatch::{DispatchResult, IsSubType}, traits::{Get, Currency, ReservableCurrency},
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT}, weights::{DispatchClass, Weight, MINIMUM_WEIGHT},
}; };
use system::{self, ensure_root, ensure_signed}; use system::{self, ensure_root, ensure_signed};
use primitives::parachain::{ use primitives::parachain::{
@@ -264,7 +264,7 @@ decl_module! {
/// ///
/// Unlike the `Registrar` trait function of the same name, this /// Unlike the `Registrar` trait function of the same name, this
/// checks the code and head data against size limits. /// checks the code and head data against size limits.
#[weight = SimpleDispatchInfo::FixedOperational(5_000_000_000)] #[weight = (5_000_000_000, DispatchClass::Operational)]
pub fn register_para(origin, pub fn register_para(origin,
#[compact] id: ParaId, #[compact] id: ParaId,
info: ParaInfo, info: ParaInfo,
@@ -289,7 +289,7 @@ decl_module! {
} }
/// Deregister a parachain with given id /// Deregister a parachain with given id
#[weight = SimpleDispatchInfo::FixedOperational(10_000_000)] #[weight = (10_000_000, DispatchClass::Operational)]
pub fn deregister_para(origin, #[compact] id: ParaId) -> DispatchResult { pub fn deregister_para(origin, #[compact] id: ParaId) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
<Self as Registrar<T::AccountId>>::deregister_para(id) <Self as Registrar<T::AccountId>>::deregister_para(id)
@@ -300,7 +300,7 @@ decl_module! {
/// - `count`: The number of parathreads. /// - `count`: The number of parathreads.
/// ///
/// Must be called from Root origin. /// Must be called from Root origin.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn set_thread_count(origin, count: u32) { fn set_thread_count(origin, count: u32) {
ensure_root(origin)?; ensure_root(origin)?;
ThreadCount::put(count); ThreadCount::put(count);
@@ -314,7 +314,7 @@ decl_module! {
/// Unlike `register_para`, this function does check that the maximum code size /// Unlike `register_para`, this function does check that the maximum code size
/// and head data size are respected, as parathread registration is an atomic /// and head data size are respected, as parathread registration is an atomic
/// action. /// action.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn register_parathread(origin, fn register_parathread(origin,
code: ValidationCode, code: ValidationCode,
initial_head_data: HeadData, initial_head_data: HeadData,
@@ -354,7 +354,7 @@ decl_module! {
/// This is a kind of special transaction that should be heavily prioritized in the /// This is a kind of special transaction that should be heavily prioritized in the
/// transaction pool according to the `value`; only `ThreadCount` of them may be presented /// transaction pool according to the `value`; only `ThreadCount` of them may be presented
/// in any single block. /// in any single block.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn select_parathread(origin, fn select_parathread(origin,
#[compact] _id: ParaId, #[compact] _id: ParaId,
_collator: CollatorId, _collator: CollatorId,
@@ -371,7 +371,7 @@ decl_module! {
/// Ensure that before calling this that any funds you want emptied from the parathread's /// Ensure that before calling this that any funds you want emptied from the parathread's
/// account is moved out; after this it will be impossible to retrieve them (without /// account is moved out; after this it will be impossible to retrieve them (without
/// governance intervention). /// governance intervention).
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn deregister_parathread(origin) { fn deregister_parathread(origin) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?; let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;
@@ -395,7 +395,7 @@ decl_module! {
/// `ParaId` to be a long-term identifier of a notional "parachain". However, their /// `ParaId` to be a long-term identifier of a notional "parachain". However, their
/// scheduling info (i.e. whether they're a parathread or parachain), auction information /// scheduling info (i.e. whether they're a parathread or parachain), auction information
/// and the auction deposit are switched. /// and the auction deposit are switched.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)] #[weight = MINIMUM_WEIGHT]
fn swap(origin, #[compact] other: ParaId) { fn swap(origin, #[compact] other: ParaId) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?; let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;
+7 -7
View File
@@ -26,7 +26,7 @@ use codec::{Encode, Decode, Codec};
use frame_support::{ use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, dispatch::DispatchResult, decl_module, decl_storage, decl_event, decl_error, ensure, dispatch::DispatchResult,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness}, traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo, Weight}, weights::{MINIMUM_WEIGHT, DispatchClass, Weight},
}; };
use primitives::parachain::{ use primitives::parachain::{
SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData, SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData,
@@ -309,7 +309,7 @@ decl_module! {
/// This can only happen when there isn't already an auction in progress and may only be /// This can only happen when there isn't already an auction in progress and may only be
/// called by the root origin. Accepts the `duration` of this auction and the /// called by the root origin. Accepts the `duration` of this auction and the
/// `lease_period_index` of the initial lease period of the four that are to be auctioned. /// `lease_period_index` of the initial lease period of the four that are to be auctioned.
#[weight = SimpleDispatchInfo::FixedOperational(100_000_000)] #[weight = (100_000_000, DispatchClass::Operational)]
pub fn new_auction(origin, pub fn new_auction(origin,
#[compact] duration: T::BlockNumber, #[compact] duration: T::BlockNumber,
#[compact] lease_period_index: LeasePeriodOf<T> #[compact] lease_period_index: LeasePeriodOf<T>
@@ -344,7 +344,7 @@ decl_module! {
/// absolute lease period index value, not an auction-specific offset. /// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the parachain should the /// - `amount` is the amount to bid to be held as deposit for the parachain should the
/// bid win. This amount is held throughout the range. /// bid win. This amount is held throughout the range.
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)] #[weight = 500_000_000]
pub fn bid(origin, pub fn bid(origin,
#[compact] sub: SubId, #[compact] sub: SubId,
#[compact] auction_index: AuctionIndex, #[compact] auction_index: AuctionIndex,
@@ -372,7 +372,7 @@ decl_module! {
/// absolute lease period index value, not an auction-specific offset. /// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the parachain should the /// - `amount` is the amount to bid to be held as deposit for the parachain should the
/// bid win. This amount is held throughout the range. /// bid win. This amount is held throughout the range.
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)] #[weight = 500_000_000]
fn bid_renew(origin, fn bid_renew(origin,
#[compact] auction_index: AuctionIndex, #[compact] auction_index: AuctionIndex,
#[compact] first_slot: LeasePeriodOf<T>, #[compact] first_slot: LeasePeriodOf<T>,
@@ -391,7 +391,7 @@ decl_module! {
/// The origin *must* be a parachain account. /// The origin *must* be a parachain account.
/// ///
/// - `dest` is the destination account to receive the parachain's deposit. /// - `dest` is the destination account to receive the parachain's deposit.
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)] #[weight = 1_000_000_000]
pub fn set_offboarding(origin, dest: <T::Lookup as StaticLookup>::Source) { pub fn set_offboarding(origin, dest: <T::Lookup as StaticLookup>::Source) {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?; let dest = T::Lookup::lookup(dest)?;
@@ -407,7 +407,7 @@ decl_module! {
/// - `para_id` is the parachain ID allotted to the winning bidder. /// - `para_id` is the parachain ID allotted to the winning bidder.
/// - `code_hash` is the hash of the parachain's Wasm validation function. /// - `code_hash` is the hash of the parachain's Wasm validation function.
/// - `initial_head_data` is the parachain's initial head data. /// - `initial_head_data` is the parachain's initial head data.
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)] #[weight = 500_000_000]
pub fn fix_deploy_data(origin, pub fn fix_deploy_data(origin,
#[compact] sub: SubId, #[compact] sub: SubId,
#[compact] para_id: ParaId, #[compact] para_id: ParaId,
@@ -449,7 +449,7 @@ decl_module! {
/// - `_origin` is irrelevant. /// - `_origin` is irrelevant.
/// - `para_id` is the parachain ID whose code will be elaborated. /// - `para_id` is the parachain ID whose code will be elaborated.
/// - `code` is the preimage of the registered `code_hash` of `para_id`. /// - `code` is the preimage of the registered `code_hash` of `para_id`.
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)] #[weight = 5_000_000_000]
pub fn elaborate_deploy_data( pub fn elaborate_deploy_data(
_origin, _origin,
#[compact] para_id: ParaId, #[compact] para_id: ParaId,
+1 -1
View File
@@ -41,7 +41,7 @@ use sp_runtime::{
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{ traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup, BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup,
DispatchInfoOf, StaticLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]