Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d3af49f
Remove Default for AccountId
gavofyork Dec 2, 2021
f6827f1
More removals of default
gavofyork Dec 2, 2021
d397c5d
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
c446fff
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
19023db
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
80df1fb
Update frame/authorship/src/lib.rs
gavofyork Dec 2, 2021
2cbe13a
More work
gavofyork Dec 2, 2021
0930529
More work
gavofyork Dec 2, 2021
016a1ee
Remove old code
gavofyork Dec 2, 2021
594deb9
More work
gavofyork Dec 2, 2021
daa2942
pallet-asset-tx-payment
gavofyork Dec 2, 2021
0f270da
tips
gavofyork Dec 2, 2021
393ed87
sc-consensus-babe
gavofyork Dec 2, 2021
7169d84
sc-finality-grandpa
gavofyork Dec 2, 2021
a853bcc
sc-consensus-babe-rpc
gavofyork Dec 2, 2021
4cb42ff
sc-cli
gavofyork Dec 2, 2021
2a04445
make npos crates accept non-default account (#10420)
kianenigma Dec 4, 2021
452651c
more work
gavofyork Dec 4, 2021
227f360
more work
gavofyork Dec 4, 2021
345c87b
Tests build
gavofyork Dec 6, 2021
c12d8cf
Fix imonline tests
gavofyork Dec 7, 2021
2cfd1d0
Formatting
gavofyork Dec 7, 2021
b537356
Merge branch 'master' into gav-no-default-accountid
gavofyork Dec 7, 2021
f5758f1
Fixes
gavofyork Dec 7, 2021
9965af3
Merge branch 'gav-no-default-accountid' of github.com:paritytech/subs…
gavofyork Dec 7, 2021
3dc3969
Fixes
gavofyork Dec 7, 2021
b7fe115
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork Dec 9, 2021
c9c7ba7
Fix bench
kianenigma Dec 9, 2021
ea520fa
Fixes
gavofyork Dec 9, 2021
b694599
Fixes
gavofyork Dec 9, 2021
97ec65a
Fixes
gavofyork Dec 10, 2021
b9c1e17
Fixes
gavofyork Dec 10, 2021
ddfbfa9
Fixes
gavofyork Dec 10, 2021
2316103
Formatting
gavofyork Dec 10, 2021
d302551
Fixes
gavofyork Dec 10, 2021
915bf1c
Formatting
gavofyork Dec 10, 2021
cfb1418
Fixes
gavofyork Dec 10, 2021
ed72cad
Formatting
gavofyork Dec 10, 2021
6e1b9e7
Fixes
gavofyork Dec 10, 2021
5fab98c
Formatting
gavofyork Dec 10, 2021
8eccc1d
Merge remote-tracking branch 'origin/master' into gav-no-default-acco…
gavofyork Dec 11, 2021
67492d1
Fixes
gavofyork Dec 11, 2021
b465b2d
Formatting
gavofyork Dec 11, 2021
26053ee
Merge branch 'master' into gav-no-default-accountid
gavofyork Dec 11, 2021
87351bb
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
f7939bb
Update client/finality-grandpa/src/lib.rs
gavofyork Dec 12, 2021
5e157c9
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
3557e13
Update client/keystore/src/local.rs
gavofyork Dec 12, 2021
c147de9
Update frame/staking/src/lib.rs
gavofyork Dec 12, 2021
fa596c1
Update frame/staking/src/lib.rs
gavofyork Dec 12, 2021
aa7ac28
Update primitives/runtime/src/traits.rs
gavofyork Dec 12, 2021
175596a
Formatting
gavofyork Dec 13, 2021
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
Prev Previous commit
Next Next commit
Fixes
  • Loading branch information
gavofyork committed Dec 10, 2021
commit 6e1b9e7f56c0900e71b022195c81794b0c7e7313
10 changes: 10 additions & 0 deletions frame/examples/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,16 @@ where
Ok(())
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}

fn validate(
&self,
_who: &Self::AccountId,
Expand Down
12 changes: 11 additions & 1 deletion frame/system/src/extensions/check_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{Config, Pallet};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{SignedExtension, Zero},
traits::{SignedExtension, Zero, DispatchInfoOf},
transaction_validity::TransactionValidityError,
};

Expand Down Expand Up @@ -62,4 +62,14 @@ impl<T: Config + Send + Sync> SignedExtension for CheckGenesis<T> {
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(<Pallet<T>>::block_hash(T::BlockNumber::zero()))
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}
}
10 changes: 10 additions & 0 deletions frame/system/src/extensions/check_mortality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ impl<T: Config + Send + Sync> SignedExtension for CheckMortality<T> {
Ok(<Pallet<T>>::block_hash(n))
}
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}
}

#[cfg(test)]
Expand Down
10 changes: 10 additions & 0 deletions frame/system/src/extensions/check_non_zero_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ where
Ok(())
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}

fn validate(
&self,
who: &Self::AccountId,
Expand Down
13 changes: 12 additions & 1 deletion frame/system/src/extensions/check_spec_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use crate::{Config, Pallet};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{traits::SignedExtension, transaction_validity::TransactionValidityError};
use sp_runtime::traits::{SignedExtension, DispatchInfoOf};
use sp_runtime::transaction_validity::TransactionValidityError;

/// Ensure the runtime version registered in the transaction is the same as at present.
///
Expand Down Expand Up @@ -59,4 +60,14 @@ impl<T: Config + Send + Sync> SignedExtension for CheckSpecVersion<T> {
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(<Pallet<T>>::runtime_version().spec_version)
}

fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}
}
11 changes: 10 additions & 1 deletion frame/system/src/extensions/check_tx_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::{Config, Pallet};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::{traits::SignedExtension, transaction_validity::TransactionValidityError};
use sp_runtime::{traits::{SignedExtension, DispatchInfoOf}, transaction_validity::TransactionValidityError};

/// Ensure the transaction version registered in the transaction is the same as at present.
///
Expand Down Expand Up @@ -59,4 +59,13 @@ impl<T: Config + Send + Sync> SignedExtension for CheckTxVersion<T> {
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
Ok(<Pallet<T>>::runtime_version().transaction_version)
}
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
Ok(self.validate(who, call, info, len).map(|_| ())?)
}
}
6 changes: 3 additions & 3 deletions frame/system/src/extensions/check_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ where
}

fn post_dispatch(
_pre: Self::Pre,
_pre: Option<Self::Pre>,
info: &DispatchInfoOf<Self::Call>,
post_info: &PostDispatchInfoOf<Self::Call>,
_len: usize,
Expand Down Expand Up @@ -563,7 +563,7 @@ mod tests {
let pre = CheckWeight::<Test>(PhantomData).pre_dispatch(&1, CALL, &info, len).unwrap();
assert_eq!(BlockWeight::<Test>::get().total(), info.weight + 256);

assert_ok!(CheckWeight::<Test>::post_dispatch(pre, &info, &post_info, len, &Ok(())));
assert_ok!(CheckWeight::<Test>::post_dispatch(Some(pre), &info, &post_info, len, &Ok(())));
assert_eq!(BlockWeight::<Test>::get().total(), post_info.actual_weight.unwrap() + 256);
})
}
Expand All @@ -587,7 +587,7 @@ mod tests {
info.weight + 128 + block_weights().get(DispatchClass::Normal).base_extrinsic,
);

assert_ok!(CheckWeight::<Test>::post_dispatch(pre, &info, &post_info, len, &Ok(())));
assert_ok!(CheckWeight::<Test>::post_dispatch(Some(pre), &info, &post_info, len, &Ok(())));
assert_eq!(
BlockWeight::<Test>::get().total(),
info.weight + 128 + block_weights().get(DispatchClass::Normal).base_extrinsic,
Expand Down
71 changes: 35 additions & 36 deletions frame/transaction-payment/asset-tx-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ where
// tip
BalanceOf<T>,
// who paid the fee
Option<Self::AccountId>,
Self::AccountId,
// imbalance resulting from withdrawing the fee
InitialPayment<T>,
);
Expand Down Expand Up @@ -240,49 +240,48 @@ where
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
let (_fee, initial_payment) = self.withdraw_fee(who, call, info, len)?;
Ok((self.tip, Some(who.clone()), initial_payment))
Ok((self.tip, who.clone(), initial_payment))
}

fn post_dispatch(
pre: Self::Pre,
pre: Option<Self::Pre>,
info: &DispatchInfoOf<Self::Call>,
post_info: &PostDispatchInfoOf<Self::Call>,
len: usize,
result: &DispatchResult,
) -> Result<(), TransactionValidityError> {
let (tip, who, initial_payment) = pre;
match initial_payment {
InitialPayment::Native(already_withdrawn) => {
pallet_transaction_payment::ChargeTransactionPayment::<T>::post_dispatch(
(tip, who, already_withdrawn),
info,
post_info,
len,
result,
)?;
},
InitialPayment::Asset(already_withdrawn) => {
let actual_fee = pallet_transaction_payment::Pallet::<T>::compute_actual_fee(
len as u32, info, post_info, tip,
);
let who =
who.ok_or(TransactionValidityError::Invalid(InvalidTransaction::Custom(255)))?;
T::OnChargeAssetTransaction::correct_and_deposit_fee(
&who,
info,
post_info,
actual_fee.into(),
tip.into(),
already_withdrawn.into(),
)?;
},
InitialPayment::Nothing => {
// `actual_fee` should be zero here for any signed extrinsic. It would be non-zero
// here in case of unsigned extrinsics as they don't pay fees but
// `compute_actual_fee` is not aware of them. In both cases it's fine to just move
// ahead without adjusting the fee, though, so we do nothing.
debug_assert!(tip.is_zero(), "tip should be zero if initial fee was zero.");
},
if let Some((tip, who, initial_payment)) = pre {
match initial_payment {
InitialPayment::Native(already_withdrawn) => {
pallet_transaction_payment::ChargeTransactionPayment::<T>::post_dispatch(
Some((tip, who, already_withdrawn)),
info,
post_info,
len,
result,
)?;
},
InitialPayment::Asset(already_withdrawn) => {
let actual_fee = pallet_transaction_payment::Pallet::<T>::compute_actual_fee(
len as u32, info, post_info, tip,
);
T::OnChargeAssetTransaction::correct_and_deposit_fee(
&who,
info,
post_info,
actual_fee.into(),
tip.into(),
already_withdrawn.into(),
)?;
},
InitialPayment::Nothing => {
// `actual_fee` should be zero here for any signed extrinsic. It would be non-zero
// here in case of unsigned extrinsics as they don't pay fees but
// `compute_actual_fee` is not aware of them. In both cases it's fine to just move
// ahead without adjusting the fee, though, so we do nothing.
debug_assert!(tip.is_zero(), "tip should be zero if initial fee was zero.");
},
}
}

Ok(())
Expand Down
31 changes: 12 additions & 19 deletions frame/transaction-payment/asset-tx-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn transaction_payment_in_native_possible() {
assert_eq!(Balances::free_balance(1), initial_balance - 5 - 5 - 10);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(5),
&default_post_info(),
len,
Expand All @@ -320,7 +320,7 @@ fn transaction_payment_in_native_possible() {
assert_eq!(Balances::free_balance(2), initial_balance_for_2 - 5 - 10 - 100 - 5);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(100),
&post_info_from_weight(50),
len,
Expand Down Expand Up @@ -371,7 +371,7 @@ fn transaction_payment_in_asset_possible() {
assert_eq!(Assets::balance(asset_id, BLOCK_AUTHOR), 0);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(weight),
&default_post_info(),
len,
Expand Down Expand Up @@ -424,7 +424,7 @@ fn transaction_payment_without_fee() {
assert_eq!(Assets::balance(asset_id, BLOCK_AUTHOR), 0);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(weight),
&post_info_from_pays(Pays::No),
len,
Expand Down Expand Up @@ -476,7 +476,7 @@ fn asset_transaction_payment_with_tip_and_refund() {

let final_weight = 50;
assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(weight),
&post_info_from_weight(final_weight),
len,
Expand Down Expand Up @@ -529,7 +529,7 @@ fn payment_from_account_with_only_assets() {
assert_eq!(Assets::balance(asset_id, caller), balance - fee);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(weight),
&default_post_info(),
len,
Expand Down Expand Up @@ -613,7 +613,7 @@ fn converted_fee_is_never_zero_if_input_fee_is_not() {
assert_eq!(Assets::balance(asset_id, caller), balance);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_pays(Pays::No),
&post_info_from_pays(Pays::No),
len,
Expand All @@ -628,7 +628,7 @@ fn converted_fee_is_never_zero_if_input_fee_is_not() {
assert_eq!(Assets::balance(asset_id, caller), balance - 1);

assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_weight(weight),
&default_post_info(),
len,
Expand Down Expand Up @@ -685,7 +685,7 @@ fn post_dispatch_fee_is_zero_if_pre_dispatch_fee_is_zero() {
// `Pays::Yes` on post-dispatch does not mean we pay (we never charge more than the
// initial fee)
assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
Some(pre),
&info_from_pays(Pays::No),
&post_info_from_pays(Pays::Yes),
len,
Expand Down Expand Up @@ -722,25 +722,18 @@ fn post_dispatch_fee_is_zero_if_unsigned_pre_dispatch_fee_is_zero() {
assert_eq!(Assets::balance(asset_id, caller), balance);
let weight = 1;
let len = 1;
let pre = ChargeAssetTxPayment::<Runtime>::pre_dispatch_unsigned(
ChargeAssetTxPayment::<Runtime>::pre_dispatch_unsigned(
CALL,
&info_from_weight(weight),
len,
)
.unwrap();
).unwrap();

assert_eq!(Assets::balance(asset_id, caller), balance);
let (_tip, _who, initial_payment) = &pre;
let not_paying = match initial_payment {
&InitialPayment::Nothing => true,
_ => false,
};
assert!(not_paying, "initial payment is Nothing for unsigned extrinsics");

// `Pays::Yes` on post-dispatch does not mean we pay (we never charge more than the
// initial fee)
assert_ok!(ChargeAssetTxPayment::<Runtime>::post_dispatch(
pre,
None,
&info_from_weight(weight),
&post_info_from_pays(Pays::Yes),
len,
Expand Down
Loading