1c0e57d984
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
94 lines
3.2 KiB
Rust
94 lines
3.2 KiB
Rust
// This file is part of Bizinikiwi.
|
|
|
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! Benchmarks for Transaction Payment Pallet's transaction extension
|
|
|
|
extern crate alloc;
|
|
|
|
use super::*;
|
|
use crate::Pallet;
|
|
use pezframe_benchmarking::v2::*;
|
|
use pezframe_support::dispatch::{DispatchInfo, PostDispatchInfo};
|
|
use pezframe_system::{EventRecord, RawOrigin};
|
|
use pezsp_runtime::traits::{AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable};
|
|
|
|
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
|
|
let events = pezframe_system::Pallet::<T>::events();
|
|
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
|
|
// compare to the last event record
|
|
let EventRecord { event, .. } = &events[events.len() - 1];
|
|
assert_eq!(event, &system_event);
|
|
}
|
|
|
|
#[benchmarks(where
|
|
T: Config,
|
|
T::RuntimeOrigin: AsTransactionAuthorizedOrigin,
|
|
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
|
)]
|
|
mod benchmarks {
|
|
use super::*;
|
|
|
|
#[benchmark]
|
|
fn charge_transaction_payment() {
|
|
let caller: T::AccountId = account("caller", 0, 0);
|
|
let existential_deposit =
|
|
<T::OnChargeTransaction as OnChargeTransaction<T>>::minimum_balance();
|
|
|
|
let (amount_to_endow, tip) = if existential_deposit.is_zero() {
|
|
let min_tip: <<T as pallet::Config>::OnChargeTransaction as payment::OnChargeTransaction<T>>::Balance = 1_000_000_000u32.into();
|
|
(min_tip * 1000u32.into(), min_tip)
|
|
} else {
|
|
(existential_deposit * 1000u32.into(), existential_deposit)
|
|
};
|
|
|
|
<T::OnChargeTransaction as OnChargeTransaction<T>>::endow_account(&caller, amount_to_endow);
|
|
|
|
let ext: ChargeTransactionPayment<T> = ChargeTransactionPayment::from(tip);
|
|
let inner = pezframe_system::Call::remark { remark: alloc::vec![] };
|
|
let call = T::RuntimeCall::from(inner);
|
|
let extension_weight = ext.weight(&call);
|
|
let info = DispatchInfo {
|
|
call_weight: Weight::from_parts(100, 0),
|
|
extension_weight,
|
|
class: DispatchClass::Operational,
|
|
pays_fee: Pays::Yes,
|
|
};
|
|
let mut post_info = PostDispatchInfo {
|
|
actual_weight: Some(Weight::from_parts(10, 0)),
|
|
pays_fee: Pays::Yes,
|
|
};
|
|
|
|
#[block]
|
|
{
|
|
assert!(ext
|
|
.test_run(RawOrigin::Signed(caller.clone()).into(), &call, &info, 10, 0, |_| Ok(
|
|
post_info
|
|
))
|
|
.unwrap()
|
|
.is_ok());
|
|
}
|
|
|
|
post_info.actual_weight.as_mut().map(|w| w.saturating_accrue(extension_weight));
|
|
let actual_fee = Pallet::<T>::compute_actual_fee(10, &info, &post_info, tip);
|
|
assert_last_event::<T>(
|
|
Event::<T>::TransactionFeePaid { who: caller, actual_fee, tip }.into(),
|
|
);
|
|
}
|
|
|
|
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
|
}
|