Skip to content
Open
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
2 changes: 1 addition & 1 deletion pallets/committee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ pub mod pallet {
/// * `FirstVoteReject`, if `call` hasn't been proposed and `approve == false`.
/// * `NotAMember`, if the `origin` is not a member of this committee.
#[pallet::weight((<T as Config<I>>::WeightInfo::vote_or_propose_new_proposal()
.saturating_add(call.get_dispatch_info().total_weight()),
.saturating_add(call.get_dispatch_info().call_weight),
DispatchClass::Operational
))]
#[pallet::call_index(3)]
Expand Down
2 changes: 1 addition & 1 deletion pallets/contracts/src/chain_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ where

// Charge weight for the call.
let di = call.get_dispatch_info();
let charged_amount = env.charge_weight(di.total_weight())?;
let charged_amount = env.charge_weight(di.call_weight)?;

// Execute call requested by contract, with current DID set to the contract owner.
let addr = env.ext().address().clone();
Expand Down
6 changes: 3 additions & 3 deletions pallets/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub mod pallet {
#[pallet::weight({
<T as Config>::WeightInfo::create_proposal()
.saturating_add(<T as Config>::WeightInfo::execute_proposal())
.saturating_add(proposal.get_dispatch_info().total_weight())
.saturating_add(proposal.get_dispatch_info().call_weight)
})]
pub fn create_proposal(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1044,7 +1044,7 @@ impl<T: Config> Pallet<T> {
expiry: Option<T::Moment>,
) -> DispatchResultWithPostInfo {
Self::ensure_ms_signer(multisig, &signer)?;
let max_weight = proposal.get_dispatch_info().total_weight();
let max_weight = proposal.get_dispatch_info().call_weight;
let caller_did = Self::ensure_ms_get_did(multisig)?;
let proposal_id = NextProposalId::<T>::get(multisig);
Self::ensure_valid_expiry(&expiry)?;
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl<T: Config> Pallet<T> {
.ok_or_else(|| Error::<T>::ProposalMissing)?;

// Ensure `max_weight` was enough to cover the worst-case weight.
let proposal_weight = proposal.get_dispatch_info().total_weight();
let proposal_weight = proposal.get_dispatch_info().call_weight;
ensure!(
proposal_weight.all_lte(max_weight),
Error::<T>::MaxWeightTooLow
Expand Down
1 change: 0 additions & 1 deletion pallets/runtime/build_tool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub fn build() {
{
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.disable_runtime_version_section_check()
.export_heap_base()
.import_memory()
.build()
Expand Down
18 changes: 9 additions & 9 deletions pallets/runtime/tests/src/balances_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use frame_support::dispatch::DispatchInfo;
use frame_support::traits::Currency;
use frame_support::weights::Weight;
use sp_keyring::Sr25519Keyring;
use sp_runtime::traits::TransactionExtension;
use sp_runtime::traits::{TransactionExtension, TxBaseImplication};
use sp_runtime::transaction_validity::TransactionSource;

use pallet_balances::{self as balances, Event as BalancesRawEvent};
use pallet_identity as identity;
Expand Down Expand Up @@ -75,16 +76,15 @@ fn tipping_fails() {
.monied(true)
.build()
.execute_with(|| {
let charge_tx_payment = ChargeTransactionPayment::<TestStorage>::from(5);

let call = StorageRuntimeCall::System(frame_system::Call::remark { remark: vec![] });
assert!(charge_tx_payment
.prepare(
Val::NoCharge,
&Origin::signed(Sr25519Keyring::Alice.to_account_id()),
&call,
assert!(ChargeTransactionPayment::<TestStorage>::from(5)
.validate(
Origin::signed(Sr25519Keyring::Alice.to_account_id()),
&StorageRuntimeCall::System(frame_system::Call::remark { remark: vec![] }),
&info_from_weight(3),
10,
Default::default(),
&TxBaseImplication(()),
TransactionSource::InBlock,
)
.is_err());
});
Expand Down
57 changes: 52 additions & 5 deletions pallets/runtime/tests/src/relayer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ fn assert_invalid_subsidy_call(caller: &AccountId, call: &RuntimeCall) {
.unwrap_err();
assert_eq!(pre_err, expected_err);

let val_charge = Val::Charge {
tip: 0,
who: caller.clone(),
fee: 1,
subsidiser: None,
};
let pre_err = ChargeTransactionPayment::from(0)
.prepare(Val::NoCharge, &origin, call, &info_from_weight(5), 10)
.prepare(val_charge, &origin, call, &info_from_weight(5), 10)
.map(|_| ())
.unwrap_err();
assert_eq!(pre_err, expected_err);
Expand Down Expand Up @@ -450,9 +456,21 @@ fn do_user_remove_paying_key_transaction_fee_test() {
let transaction_fee = TransactionPayment::compute_fee(len as u32, &call_info, 0);

// 1. Call `pre_dispatch`.
let val = ChargeTransactionPayment::from(0)
.validate(
RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
len,
Default::default(),
&TxBaseImplication(()),
TransactionSource::InBlock,
)
.unwrap();

let pre = ChargeTransactionPayment::from(0)
.prepare(
Val::NoCharge,
val.1,
&RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
Expand Down Expand Up @@ -524,7 +542,12 @@ fn do_relayer_transaction_and_protocol_fees_test() {
// test `pre_dispatch`
let pre_err = ChargeTransactionPayment::from(0)
.prepare(
Val::NoCharge,
Val::Charge {
tip: 0,
who: bob.acc(),
fee: 1,
subsidiser: Some(alice.acc()),
},
&RuntimeOrigin::signed(bob.acc()),
&call_system_remark(42),
&info_from_weight(5),
Expand All @@ -550,9 +573,21 @@ fn do_relayer_transaction_and_protocol_fees_test() {
let total_fee = transaction_fee + protocol_fee;

// 1. Call `pre_dispatch`.
let val = ChargeTransactionPayment::from(0)
.validate(
RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
len,
Default::default(),
&TxBaseImplication(()),
TransactionSource::InBlock,
)
.unwrap();

let pre = ChargeTransactionPayment::from(0)
.prepare(
Val::NoCharge,
val.1,
&RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
Expand Down Expand Up @@ -661,9 +696,21 @@ fn do_relayer_batched_subsidy_calls_test() {
let total_fee = transaction_fee + protocol_fee;

// 1. Call `pre_dispatch`.
let val = ChargeTransactionPayment::from(0)
.validate(
RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
len,
Default::default(),
&TxBaseImplication(()),
TransactionSource::InBlock,
)
.unwrap();

let pre = ChargeTransactionPayment::from(0)
.prepare(
Val::NoCharge,
val.1,
&RuntimeOrigin::signed(bob.acc()),
&call,
&call_info,
Expand Down
Loading