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

Use explicit call indices #6449

Merged
merged 2 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
360 changes: 180 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
// TODO: Benchmark this
/// Assign a permanent parachain slot and immediately create a lease for it.
#[pallet::call_index(0)]
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
pub fn assign_perm_parachain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
T::AssignSlotOrigin::ensure_origin(origin)?;
Expand Down Expand Up @@ -258,6 +259,7 @@ pub mod pallet {
/// Assign a temporary parachain slot. The function tries to create a lease for it
/// immediately if `SlotLeasePeriodStart::Current` is specified, and if the number
/// of currently active temporary slots is below `MaxTemporarySlotPerLeasePeriod`.
#[pallet::call_index(1)]
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
pub fn assign_temp_parachain_slot(
origin: OriginFor<T>,
Expand Down Expand Up @@ -341,6 +343,7 @@ pub mod pallet {

// TODO: Benchmark this
/// Unassign a permanent or temporary parachain slot
#[pallet::call_index(2)]
#[pallet::weight(((MAXIMUM_BLOCK_WEIGHT / 10) as Weight, DispatchClass::Operational))]
pub fn unassign_parachain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
T::AssignSlotOrigin::ensure_origin(origin.clone())?;
Expand Down
3 changes: 3 additions & 0 deletions runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub mod pallet {
/// 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.
#[pallet::call_index(0)]
#[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))]
pub fn new_auction(
origin: OriginFor<T>,
Expand All @@ -279,6 +280,7 @@ pub mod pallet {
/// 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.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::bid())]
pub fn bid(
origin: OriginFor<T>,
Expand All @@ -296,6 +298,7 @@ pub mod pallet {
/// Cancel an in-progress auction.
///
/// Can only be called by Root origin.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::cancel_auction())]
pub fn cancel_auction(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
Expand Down
5 changes: 5 additions & 0 deletions runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::claim())]
pub fn claim(
origin: OriginFor<T>,
Expand Down Expand Up @@ -337,6 +338,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::mint_claim())]
pub fn mint_claim(
origin: OriginFor<T>,
Expand Down Expand Up @@ -384,6 +386,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::claim_attest())]
pub fn claim_attest(
origin: OriginFor<T>,
Expand Down Expand Up @@ -420,6 +423,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(3)]
#[pallet::weight((
T::WeightInfo::attest(),
DispatchClass::Normal,
Expand All @@ -436,6 +440,7 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::move_claim())]
pub fn move_claim(
origin: OriginFor<T>,
Expand Down
9 changes: 9 additions & 0 deletions runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ pub mod pallet {
///
/// This applies a lock to your parachain configuration, ensuring that it cannot be changed
/// by the parachain manager.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::create())]
pub fn create(
origin: OriginFor<T>,
Expand Down Expand Up @@ -449,6 +450,7 @@ pub mod pallet {

/// Contribute to a crowd sale. This will transfer some balance over to fund a parachain
/// slot. It will be withdrawable when the crowdloan has ended and the funds are unused.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::contribute())]
pub fn contribute(
origin: OriginFor<T>,
Expand Down Expand Up @@ -477,6 +479,7 @@ pub mod pallet {
///
/// - `who`: The account whose contribution should be withdrawn.
/// - `index`: The parachain to whose crowdloan the contribution was made.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::withdraw())]
pub fn withdraw(
origin: OriginFor<T>,
Expand Down Expand Up @@ -510,6 +513,7 @@ pub mod pallet {
/// times to fully refund all users. We will refund `RemoveKeysLimit` users at a time.
///
/// Origin must be signed, but can come from anyone.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::refund(T::RemoveKeysLimit::get()))]
pub fn refund(
origin: OriginFor<T>,
Expand Down Expand Up @@ -555,6 +559,7 @@ pub mod pallet {
}

/// Remove a fund after the retirement period has ended and all funds have been returned.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::dissolve())]
pub fn dissolve(origin: OriginFor<T>, #[pallet::compact] index: ParaId) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand Down Expand Up @@ -582,6 +587,7 @@ pub mod pallet {
/// Edit the configuration for an in-progress crowdloan.
///
/// Can only be called by Root origin.
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::edit())]
pub fn edit(
origin: OriginFor<T>,
Expand Down Expand Up @@ -619,6 +625,7 @@ pub mod pallet {
/// Add an optional memo to an existing crowdloan contribution.
///
/// Origin must be Signed, and the user must have contributed to the crowdloan.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::add_memo())]
pub fn add_memo(origin: OriginFor<T>, index: ParaId, memo: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand All @@ -637,6 +644,7 @@ pub mod pallet {
/// Poke the fund into `NewRaise`
///
/// Origin must be Signed, and the fund has non-zero raise.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::poke())]
pub fn poke(origin: OriginFor<T>, index: ParaId) -> DispatchResult {
ensure_signed(origin)?;
Expand All @@ -650,6 +658,7 @@ pub mod pallet {

/// Contribute your entire balance to a crowd sale. This will transfer the entire balance of a user over to fund a parachain
/// slot. It will be withdrawable when the crowdloan has ended and the funds are unused.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::contribute())]
pub fn contribute_all(
origin: OriginFor<T>,
Expand Down
9 changes: 9 additions & 0 deletions runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub mod pallet {
///
/// ## Events
/// The `Registered` event is emitted in case of success.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::register())]
pub fn register(
origin: OriginFor<T>,
Expand All @@ -246,6 +247,7 @@ pub mod pallet {
///
/// The deposit taken can be specified for this registration. Any `ParaId`
/// can be registered, including sub-1000 IDs which are System Parachains.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::force_register())]
pub fn force_register(
origin: OriginFor<T>,
Expand All @@ -262,6 +264,7 @@ pub mod pallet {
/// Deregister a Para Id, freeing all data and returning any deposit.
///
/// The caller must be Root, the `para` owner, or the `para` itself. The para must be a parathread.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::deregister())]
pub fn deregister(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
Expand All @@ -279,6 +282,7 @@ pub mod pallet {
/// `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.
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::swap())]
pub fn swap(origin: OriginFor<T>, id: ParaId, other: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
Expand Down Expand Up @@ -328,6 +332,7 @@ pub mod pallet {
/// previously locked para to deregister or swap a para without using governance.
///
/// Can only be called by the Root origin or the parachain.
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn remove_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_or_para(origin, para)?;
Expand All @@ -349,6 +354,7 @@ pub mod pallet {
///
/// ## Events
/// The `Reserved` event is emitted in case of success, which provides the ID reserved for use.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::reserve())]
pub fn reserve(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand All @@ -362,6 +368,7 @@ pub mod pallet {
/// para to deregister or swap a para.
///
/// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked.
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn add_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, para)?;
Expand All @@ -372,6 +379,7 @@ pub mod pallet {
/// Schedule a parachain upgrade.
///
/// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked.
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))]
pub fn schedule_code_upgrade(
origin: OriginFor<T>,
Expand All @@ -386,6 +394,7 @@ pub mod pallet {
/// Set the parachain's current head.
///
/// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked.
#[pallet::call_index(8)]
#[pallet::weight(<T as Config>::WeightInfo::set_current_head(new_head.0.len() as u32))]
pub fn set_current_head(
origin: OriginFor<T>,
Expand Down
6 changes: 6 additions & 0 deletions runtime/common/src/paras_sudo_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Schedule a para to be initialized at the start of the next session.
#[pallet::call_index(0)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_initialize(
origin: OriginFor<T>,
Expand All @@ -83,6 +84,7 @@ pub mod pallet {
}

/// Schedule a para to be cleaned up at the start of the next session.
#[pallet::call_index(1)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_cleanup(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
ensure_root(origin)?;
Expand All @@ -92,6 +94,7 @@ pub mod pallet {
}

/// Upgrade a parathread to a parachain
#[pallet::call_index(2)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_parathread_upgrade(
origin: OriginFor<T>,
Expand All @@ -109,6 +112,7 @@ pub mod pallet {
}

/// Downgrade a parachain to a parathread
#[pallet::call_index(3)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_parachain_downgrade(
origin: OriginFor<T>,
Expand All @@ -129,6 +133,7 @@ pub mod pallet {
///
/// The given parachain should exist and the payload should not exceed the preconfigured size
/// `config.max_downward_message_size`.
#[pallet::call_index(4)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_queue_downward_xcm(
origin: OriginFor<T>,
Expand All @@ -149,6 +154,7 @@ pub mod pallet {
///
/// This is equivalent to sending an `Hrmp::hrmp_init_open_channel` extrinsic followed by
/// `Hrmp::hrmp_accept_open_channel`.
#[pallet::call_index(5)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_establish_hrmp_channel(
origin: OriginFor<T>,
Expand Down
7 changes: 7 additions & 0 deletions runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ pub mod pallet {
/// We check that the account does not exist at this stage.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(Weight::from_ref_time(200_000_000) + T::DbWeight::get().reads_writes(4, 1))]
pub fn create_account(
origin: OriginFor<T>,
Expand Down Expand Up @@ -232,6 +233,7 @@ pub mod pallet {
/// We check that the account exists at this stage, but has not completed the process.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn update_validity_status(
origin: OriginFor<T>,
Expand Down Expand Up @@ -260,6 +262,7 @@ pub mod pallet {
/// We check that the account is valid for a balance transfer at this point.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(2)]
#[pallet::weight(T::DbWeight::get().reads_writes(2, 1))]
pub fn update_balance(
origin: OriginFor<T>,
Expand Down Expand Up @@ -297,6 +300,7 @@ pub mod pallet {
///
/// Origin must match the configured `PaymentAccount` (if it is not configured then this
/// will always fail with `BadOrigin`).
#[pallet::call_index(3)]
#[pallet::weight(T::DbWeight::get().reads_writes(4, 2))]
pub fn payout(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
// Payments must be made directly by the `PaymentAccount`.
Expand Down Expand Up @@ -366,6 +370,7 @@ pub mod pallet {
/// Set the account that will be used to payout users in the DOT purchase process.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_payment_account(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
Expand All @@ -378,6 +383,7 @@ pub mod pallet {
/// Set the statement that must be signed for a user to participate on the DOT sale.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(5)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_statement(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
Expand All @@ -394,6 +400,7 @@ pub mod pallet {
/// Set the block where locked DOTs will become unlocked.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_unlock_block(
origin: OriginFor<T>,
Expand Down
3 changes: 3 additions & 0 deletions runtime/common/src/slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub mod pallet {
/// independently of any other on-chain mechanism to use it.
///
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::force_lease())]
pub fn force_lease(
origin: OriginFor<T>,
Expand All @@ -183,6 +184,7 @@ pub mod pallet {
/// Clear all leases for a Para Id, refunding any deposits back to the original owners.
///
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::clear_all_leases())]
pub fn clear_all_leases(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
T::ForceOrigin::ensure_origin(origin)?;
Expand All @@ -205,6 +207,7 @@ pub mod pallet {
/// let them onboard from here.
///
/// Origin must be signed, but can be called by anyone.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::trigger_onboard())]
pub fn trigger_onboard(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
let _ = ensure_signed(origin)?;
Expand Down
Loading