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

Commit

Permalink
Companion for substrate/5686 (#1008)
Browse files Browse the repository at this point in the history
* Companion for substrate/5686

* Update substrate
  • Loading branch information
kianenigma committed Apr 22, 2020
1 parent a8e9240 commit 31a62f2
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 186 deletions.
305 changes: 152 additions & 153 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions runtime/common/src/attestations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
decl_storage, decl_module, decl_error, ensure,
dispatch::DispatchResult,
traits::Get,
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo},
weights::{MINIMUM_WEIGHT, DispatchClass},
};

use primitives::{Hash, parachain::{AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId}};
Expand Down Expand Up @@ -134,7 +134,7 @@ decl_module! {
type Error = Error<T>;

/// 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 {
ensure_none(origin)?;
ensure!(!DidUpdate::exists(), Error::<T>::TooManyAttestations);
Expand Down
5 changes: 2 additions & 3 deletions runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use sp_std::prelude::*;
use sp_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover};
use frame_support::{decl_event, decl_storage, decl_module, decl_error};
use frame_support::weights::SimpleDispatchInfo;
use frame_support::traits::{Currency, Get, VestingSchedule};
use system::{ensure_root, ensure_none};
use codec::{Encode, Decode};
Expand Down Expand Up @@ -184,7 +183,7 @@ decl_module! {
///
/// Total Complexity: O(1)
/// </weight>
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)]
#[weight = 1_000_000_000]
fn claim(origin, dest: T::AccountId, ethereum_signature: EcdsaSignature) {
ensure_none(origin)?;

Expand Down Expand Up @@ -231,7 +230,7 @@ decl_module! {
///
/// Total Complexity: O(1)
/// </weight>
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
#[weight = 30_000_000]
fn mint_claim(origin,
who: EthereumAddress,
value: BalanceOf<T>,
Expand Down
16 changes: 8 additions & 8 deletions runtime/common/src/crowdfund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use frame_support::{
traits::{
Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement::AllowDeath
},
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo},
weights::MINIMUM_WEIGHT,
};
use system::ensure_signed;
use sp_runtime::{ModuleId,
Expand Down Expand Up @@ -250,7 +250,7 @@ decl_module! {
fn deposit_event() = default;

/// 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,
#[compact] cap: BalanceOf<T>,
#[compact] first_slot: T::BlockNumber,
Expand Down Expand Up @@ -294,7 +294,7 @@ decl_module! {
/// 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 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>) {
let who = ensure_signed(origin)?;

Expand Down Expand Up @@ -353,7 +353,7 @@ decl_module! {
/// - `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.
/// - `initial_head_data` is the parachain's initial head data.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn fix_deploy_data(origin,
#[compact] index: FundIndex,
code_hash: T::Hash,
Expand All @@ -379,7 +379,7 @@ decl_module! {
///
/// - `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.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn onboard(origin,
#[compact] index: FundIndex,
#[compact] para_id: ParaId
Expand Down Expand Up @@ -408,7 +408,7 @@ decl_module! {
}

/// 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) {
let _ = ensure_signed(origin)?;

Expand All @@ -430,7 +430,7 @@ decl_module! {
}

/// 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) {
let who = ensure_signed(origin)?;

Expand Down Expand Up @@ -461,7 +461,7 @@ decl_module! {
/// 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
/// withdrawn into the treasury.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn dissolve(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?;

Expand Down
8 changes: 4 additions & 4 deletions runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use sp_staking::{
};
use frame_support::{
traits::KeyOwnerProofSystem,
dispatch::IsSubType,
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT},
dispatch::{IsSubType},
weights::{DispatchClass, Weight, MINIMUM_WEIGHT},
};
use primitives::{
Balance,
Expand Down Expand Up @@ -571,7 +571,7 @@ decl_module! {
}

/// 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 {
ensure_none(origin)?;
ensure!(!<DidUpdate>::exists(), Error::<T>::TooManyHeadUpdates);
Expand Down Expand Up @@ -651,7 +651,7 @@ decl_module! {
///
/// The weight is 0; in order to avoid DoS a `SignedExtension` validation
/// is implemented.
#[weight = SimpleDispatchInfo::FixedNormal(0)]
#[weight = 0]
pub fn report_double_vote(
origin,
report: DoubleVoteReport<
Expand Down
16 changes: 8 additions & 8 deletions runtime/common/src/registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_runtime::{
use frame_support::{
decl_storage, decl_module, decl_event, decl_error, ensure,
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 primitives::parachain::{
Expand Down Expand Up @@ -264,7 +264,7 @@ decl_module! {
///
/// Unlike the `Registrar` trait function of the same name, this
/// 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,
#[compact] id: ParaId,
info: ParaInfo,
Expand All @@ -289,7 +289,7 @@ decl_module! {
}

/// 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 {
ensure_root(origin)?;
<Self as Registrar<T::AccountId>>::deregister_para(id)
Expand All @@ -300,7 +300,7 @@ decl_module! {
/// - `count`: The number of parathreads.
///
/// Must be called from Root origin.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn set_thread_count(origin, count: u32) {
ensure_root(origin)?;
ThreadCount::put(count);
Expand All @@ -314,7 +314,7 @@ decl_module! {
/// Unlike `register_para`, this function does check that the maximum code size
/// and head data size are respected, as parathread registration is an atomic
/// action.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn register_parathread(origin,
code: ValidationCode,
initial_head_data: HeadData,
Expand Down Expand Up @@ -354,7 +354,7 @@ decl_module! {
/// 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
/// in any single block.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn select_parathread(origin,
#[compact] _id: ParaId,
_collator: CollatorId,
Expand All @@ -371,7 +371,7 @@ decl_module! {
/// 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
/// governance intervention).
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn deregister_parathread(origin) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;

Expand All @@ -395,7 +395,7 @@ decl_module! {
/// `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
/// and the auction deposit are switched.
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
#[weight = MINIMUM_WEIGHT]
fn swap(origin, #[compact] other: ParaId) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;

Expand Down
14 changes: 7 additions & 7 deletions runtime/common/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use codec::{Encode, Decode, Codec};
use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, dispatch::DispatchResult,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
weights::{MINIMUM_WEIGHT, SimpleDispatchInfo, Weight},
weights::{MINIMUM_WEIGHT, DispatchClass, Weight},
};
use primitives::parachain::{
SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData,
Expand Down Expand Up @@ -309,7 +309,7 @@ decl_module! {
/// 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
/// `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,
#[compact] duration: T::BlockNumber,
#[compact] lease_period_index: LeasePeriodOf<T>
Expand Down Expand Up @@ -344,7 +344,7 @@ decl_module! {
/// 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
/// bid win. This amount is held throughout the range.
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
#[weight = 500_000_000]
pub fn bid(origin,
#[compact] sub: SubId,
#[compact] auction_index: AuctionIndex,
Expand Down Expand Up @@ -372,7 +372,7 @@ decl_module! {
/// 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
/// bid win. This amount is held throughout the range.
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
#[weight = 500_000_000]
fn bid_renew(origin,
#[compact] auction_index: AuctionIndex,
#[compact] first_slot: LeasePeriodOf<T>,
Expand All @@ -391,7 +391,7 @@ decl_module! {
/// The origin *must* be a parachain account.
///
/// - `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) {
let who = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
Expand All @@ -407,7 +407,7 @@ decl_module! {
/// - `para_id` is the parachain ID allotted to the winning bidder.
/// - `code_hash` is the hash of the parachain's Wasm validation function.
/// - `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,
#[compact] sub: SubId,
#[compact] para_id: ParaId,
Expand Down Expand Up @@ -449,7 +449,7 @@ decl_module! {
/// - `_origin` is irrelevant.
/// - `para_id` is the parachain ID whose code will be elaborated.
/// - `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(
_origin,
#[compact] para_id: ParaId,
Expand Down
2 changes: 1 addition & 1 deletion runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use sp_runtime::{
curve::PiecewiseLinear,
traits::{
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")]
Expand Down

0 comments on commit 31a62f2

Please sign in to comment.