From c19b6f2d16570b8747ea569a0af4ea43a7fac7cb Mon Sep 17 00:00:00 2001 From: cr4pt0 Date: Thu, 4 May 2023 13:42:44 +0100 Subject: [PATCH 1/2] use call_index to fix warning and CI step build-all-benchmarks-packages --- code/parachain/frame/assets/src/lib.rs | 10 ++++++++++ code/parachain/frame/bonded-finance/src/lib.rs | 3 +++ code/parachain/frame/crowdloan-rewards/src/lib.rs | 7 +++++++ code/parachain/frame/currency-factory/src/lib.rs | 2 ++ code/parachain/frame/governance-registry/src/lib.rs | 3 +++ code/parachain/frame/pablo/src/lib.rs | 6 ++++++ .../transaction-payment/asset-tx-payment/src/lib.rs | 1 + code/parachain/frame/vault/src/lib.rs | 10 +++++++++- code/parachain/frame/vault/src/mocks/strategy.rs | 3 +++ 9 files changed, 44 insertions(+), 1 deletion(-) diff --git a/code/parachain/frame/assets/src/lib.rs b/code/parachain/frame/assets/src/lib.rs index 312480f9bbb..f2df6503bf3 100644 --- a/code/parachain/frame/assets/src/lib.rs +++ b/code/parachain/frame/assets/src/lib.rs @@ -153,6 +153,7 @@ pub mod pallet { /// - If the account has insufficient free balance to make the transfer, or if `keep_alive` /// cannot be respected. /// - If the `dest` cannot be looked up. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::transfer())] pub fn transfer( origin: OriginFor, @@ -175,6 +176,7 @@ pub mod pallet { /// - If the account has insufficient free balance to make the transfer, or if `keep_alive` /// cannot be respected. /// - If the `dest` cannot be looked up. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::transfer_native())] pub fn transfer_native( origin: OriginFor, @@ -195,6 +197,7 @@ pub mod pallet { /// - If the account has insufficient free balance to make the transfer, or if `keep_alive` /// cannot be respected. /// - If the `dest` cannot be looked up. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::force_transfer())] pub fn force_transfer( origin: OriginFor, @@ -219,6 +222,7 @@ pub mod pallet { /// cannot be respected. /// - If the `dest` cannot be looked up. #[pallet::weight(T::WeightInfo::force_transfer_native())] + #[pallet::call_index(3)] pub fn force_transfer_native( origin: OriginFor, source: ::Source, @@ -239,6 +243,7 @@ pub mod pallet { /// - When `origin` is not signed. /// - If the `dest` cannot be looked up. #[pallet::weight(T::WeightInfo::transfer_all())] + #[pallet::call_index(4)] pub fn transfer_all( origin: OriginFor, asset: T::AssetId, @@ -265,6 +270,7 @@ pub mod pallet { /// - When `origin` is not signed. /// - If the `dest` cannot be looked up. #[pallet::weight(T::WeightInfo::transfer_all_native())] + #[pallet::call_index(5)] pub fn transfer_all_native( origin: OriginFor, dest: ::Source, @@ -286,6 +292,7 @@ pub mod pallet { /// Creates a new asset, minting `amount` of funds into the `dest` account. Intended to be /// used for creating wrapped assets, not associated with any project. #[pallet::weight(T::WeightInfo::mint_initialize())] + #[pallet::call_index(6)] pub fn mint_initialize( origin: OriginFor, #[pallet::compact] amount: T::Balance, @@ -302,6 +309,7 @@ pub mod pallet { /// account can use the democracy pallet to mint further assets, or if the governance_origin /// is set to an owned account, using signed transactions. In general the /// `governance_origin` should be generated from the pallet id. + #[pallet::call_index(7)] #[pallet::weight(T::WeightInfo::mint_initialize())] pub fn mint_initialize_with_governance( origin: OriginFor, @@ -319,6 +327,7 @@ pub mod pallet { } /// Mints `amount` of `asset_id` into the `dest` account. + #[pallet::call_index(8)] #[pallet::weight(T::WeightInfo::mint_into())] pub fn mint_into( origin: OriginFor, @@ -333,6 +342,7 @@ pub mod pallet { } /// Burns `amount` of `asset_id` into the `dest` account. + #[pallet::call_index(9)] #[pallet::weight(T::WeightInfo::burn_from())] pub fn burn_from( origin: OriginFor, diff --git a/code/parachain/frame/bonded-finance/src/lib.rs b/code/parachain/frame/bonded-finance/src/lib.rs index 65440ec2cf1..cde8d1af825 100644 --- a/code/parachain/frame/bonded-finance/src/lib.rs +++ b/code/parachain/frame/bonded-finance/src/lib.rs @@ -203,6 +203,7 @@ pub mod pallet { /// parameter. /// /// Emits a `NewOffer`. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::offer())] pub fn offer( origin: OriginFor, @@ -231,6 +232,7 @@ pub mod pallet { /// /// Emits a `NewBond`. /// Possibly Emits a `OfferCompleted`. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::bond())] pub fn bond( origin: OriginFor, @@ -251,6 +253,7 @@ pub mod pallet { /// The dispatch origin for this call must be _Signed_ and the sender must be `AdminOrigin` /// /// Emits a `OfferCancelled`. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::cancel())] #[transactional] pub fn cancel(origin: OriginFor, offer_id: T::BondOfferId) -> DispatchResult { diff --git a/code/parachain/frame/crowdloan-rewards/src/lib.rs b/code/parachain/frame/crowdloan-rewards/src/lib.rs index 5bd5c9c7734..b8fae08d0fa 100644 --- a/code/parachain/frame/crowdloan-rewards/src/lib.rs +++ b/code/parachain/frame/crowdloan-rewards/src/lib.rs @@ -267,6 +267,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Initialize the pallet at the current timestamp. + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::initialize(TotalContributors::::get()))] pub fn initialize(origin: OriginFor) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; @@ -275,6 +276,7 @@ pub mod pallet { } /// Initialize the pallet at the given timestamp. + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::initialize(TotalContributors::::get()))] pub fn initialize_at(origin: OriginFor, at: MomentOf) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; @@ -290,6 +292,7 @@ pub mod pallet { /// already has a reward, it will be replaced by the new reward value. /// /// Can only be called before `initialize`. + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::populate(rewards.len() as _))] pub fn populate( origin: OriginFor, @@ -308,6 +311,7 @@ pub mod pallet { /// ```haskell /// proof = sign (concat prefix (hex reward_account)) /// ``` + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::associate(TotalContributors::::get()))] pub fn associate( origin: OriginFor, @@ -321,6 +325,7 @@ pub mod pallet { /// Claim a reward from the associated reward account. /// A previous call to `associate` should have been made. /// If logic gate pass, no fees are applied. + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::claim(TotalContributors::::get()))] pub fn claim(origin: OriginFor) -> DispatchResultWithPostInfo { let reward_account = ensure_signed(origin)?; @@ -331,6 +336,7 @@ pub mod pallet { Ok(Pays::No.into()) } + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::unlock_rewards_for(reward_accounts.len() as _))] pub fn unlock_rewards_for( origin: OriginFor, @@ -343,6 +349,7 @@ pub mod pallet { /// Adds all accounts in the `additions` vector. Add may be called even if the pallet has /// been initialized. + #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::populate(additions.len() as _))] pub fn add( origin: OriginFor, diff --git a/code/parachain/frame/currency-factory/src/lib.rs b/code/parachain/frame/currency-factory/src/lib.rs index d8065786ffe..d3d334c1d2f 100644 --- a/code/parachain/frame/currency-factory/src/lib.rs +++ b/code/parachain/frame/currency-factory/src/lib.rs @@ -133,6 +133,7 @@ pub mod pallet { #[pallet::call] impl Pallet { + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::add_range())] pub fn add_range(origin: OriginFor, length: u64) -> DispatchResultWithPostInfo { T::AddOrigin::ensure_origin(origin)?; @@ -149,6 +150,7 @@ pub mod pallet { } /// Sets metadata + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::set_metadata())] pub fn set_metadata( origin: OriginFor, diff --git a/code/parachain/frame/governance-registry/src/lib.rs b/code/parachain/frame/governance-registry/src/lib.rs index de88a54dba5..63a80c7257a 100644 --- a/code/parachain/frame/governance-registry/src/lib.rs +++ b/code/parachain/frame/governance-registry/src/lib.rs @@ -74,6 +74,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Sets the value of an `asset_id` to the signed account id. Only callable by root. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::set())] pub fn set( origin: OriginFor, @@ -87,6 +88,7 @@ pub mod pallet { } /// Sets the value of an `asset_id` to root. Only callable by root. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::grant_root())] pub fn grant_root( origin: OriginFor, @@ -99,6 +101,7 @@ pub mod pallet { } /// Removes mapping of an `asset_id`. Only callable by root. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::remove())] pub fn remove(origin: OriginFor, asset_id: T::AssetId) -> DispatchResultWithPostInfo { ensure_root(origin)?; diff --git a/code/parachain/frame/pablo/src/lib.rs b/code/parachain/frame/pablo/src/lib.rs index 42fb3a78746..c18c68f5aa2 100644 --- a/code/parachain/frame/pablo/src/lib.rs +++ b/code/parachain/frame/pablo/src/lib.rs @@ -345,6 +345,7 @@ pub mod pallet { /// assets already exists in the runtime. /// /// Emits `PoolCreated` event when successful. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::create())] pub fn create(origin: OriginFor, pool: PoolInitConfigurationOf) -> DispatchResult { T::PoolCreationOrigin::ensure_origin(origin)?; @@ -355,6 +356,7 @@ pub mod pallet { /// Execute a buy order on pool. /// /// Emits `Swapped` event when successful. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::buy())] pub fn buy( origin: OriginFor, @@ -373,6 +375,7 @@ pub mod pallet { /// The `quote_amount` is always the quote asset amount (A/B => B), (B/A => A). /// /// Emits `Swapped` event when successful. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::swap())] pub fn swap( origin: OriginFor, @@ -389,6 +392,7 @@ pub mod pallet { /// Add liquidity to the given pool. /// /// Emits `LiquidityAdded` event when successful. + #[pallet::call_index(3)] #[pallet::weight(T::WeightInfo::add_liquidity())] pub fn add_liquidity( origin: OriginFor, @@ -405,6 +409,7 @@ pub mod pallet { /// Remove liquidity from the given pool. /// /// Emits `LiquidityRemoved` event when successful. + #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::remove_liquidity())] pub fn remove_liquidity( origin: OriginFor, @@ -417,6 +422,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(5)] #[pallet::weight(10_000)] #[transactional] pub fn enable_twap(origin: OriginFor, pool_id: T::PoolId) -> DispatchResult { diff --git a/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs b/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs index 59f581da6f5..674ddc9c4a7 100644 --- a/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -192,6 +192,7 @@ pub mod pallet { /// /// If `asset_id` is `None`, then native asset is used. /// Else new asset is configured and ED is on hold. + #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::set_payment_asset())] pub fn set_payment_asset( origin: OriginFor, diff --git a/code/parachain/frame/vault/src/lib.rs b/code/parachain/frame/vault/src/lib.rs index d8657d1e02a..cd59a85f57f 100644 --- a/code/parachain/frame/vault/src/lib.rs +++ b/code/parachain/frame/vault/src/lib.rs @@ -380,6 +380,7 @@ pub mod pallet { /// - When the origin is not signed. /// - When `deposit < CreationDeposit`. /// - Origin has insufficient funds to lock the deposit. + #[pallet::call_index(0)] #[transactional] #[pallet::weight(::WeightInfo::create())] pub fn create( @@ -422,6 +423,7 @@ pub mod pallet { /// /// A tombstoned vault still allows for withdrawals but blocks deposits, and requests all /// strategies to return their funds. + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::claim_surcharge())] pub fn claim_surcharge( origin: OriginFor, @@ -469,7 +471,7 @@ pub mod pallet { } }) } - + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::add_surcharge())] pub fn add_surcharge( origin: OriginFor, @@ -495,6 +497,7 @@ pub mod pallet { }) } + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::delete_tombstoned())] pub fn delete_tombstoned( origin: OriginFor, @@ -542,6 +545,7 @@ pub mod pallet { /// # Errors /// - When the origin is not signed. /// - When `deposit < MinimumDeposit`. + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::deposit())] pub fn deposit( origin: OriginFor, @@ -563,6 +567,7 @@ pub mod pallet { /// - When the origin is not signed. /// - When `lp_amount < MinimumWithdrawal`. /// - When the vault has insufficient amounts reserved. + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::withdraw())] pub fn withdraw( origin: OriginFor, @@ -583,6 +588,7 @@ pub mod pallet { /// # Errors /// - When the origin is not root. /// - When `vault` does not exist. + #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::emergency_shutdown())] pub fn emergency_shutdown( origin: OriginFor, @@ -602,6 +608,7 @@ pub mod pallet { /// # Errors /// - When the origin is not root. /// - When `vault` does not exist. + #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::start_())] pub fn start(origin: OriginFor, vault: T::VaultId) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -618,6 +625,7 @@ pub mod pallet { /// /// # Emits /// - Event::LiquidateStrategy + #[pallet::call_index(8)] #[pallet::weight(10_000)] pub fn liquidate_strategy( origin: OriginFor, diff --git a/code/parachain/frame/vault/src/mocks/strategy.rs b/code/parachain/frame/vault/src/mocks/strategy.rs index ecea98b1140..0b8733d8e15 100644 --- a/code/parachain/frame/vault/src/mocks/strategy.rs +++ b/code/parachain/frame/vault/src/mocks/strategy.rs @@ -67,6 +67,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Mints new tokens and sends them to self, mocking the generating of revenue through DeFi. + #[pallet::call_index(0)] #[pallet::weight(10_000)] pub fn generate_revenue( origin: OriginFor, @@ -81,6 +82,7 @@ pub mod pallet { } /// Reports the current balance to the vault. + #[pallet::call_index(1)] #[pallet::weight(10_000)] pub fn report(origin: OriginFor, vault: VaultIdOf) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -92,6 +94,7 @@ pub mod pallet { } /// Queries the vault for the current re-balance strategy and executes it. + #[pallet::call_index(2)] #[pallet::weight(10_000)] pub fn rebalance(origin: OriginFor, vault: VaultIdOf) -> DispatchResultWithPostInfo { ensure_root(origin)?; From 3d250df20a7a3d336d9ba225f78bfec51506889c Mon Sep 17 00:00:00 2001 From: cr4pt0 Date: Thu, 4 May 2023 13:47:02 +0100 Subject: [PATCH 2/2] use #[pallet::call_index(0)] --- .../frame/transaction-payment/asset-tx-payment/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs b/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs index 674ddc9c4a7..2adf99218a5 100644 --- a/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/code/parachain/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -192,7 +192,7 @@ pub mod pallet { /// /// If `asset_id` is `None`, then native asset is used. /// Else new asset is configured and ED is on hold. - #[pallet::call_index(1)] + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::set_payment_asset())] pub fn set_payment_asset( origin: OriginFor,