diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index b3ff8b16283ca83e2b8928cefee139ccc9da402a..4266ad7459e656f4894883953b19f334da1ad3f8 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -80,8 +80,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 202, - impl_version: 202, + spec_version: 203, + impl_version: 203, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/frame/evm/src/lib.rs b/substrate/frame/evm/src/lib.rs index 48b54a8c8677e1eae20509085655e709620c495a..8d504127245d0b18d9b14cf35e649dcd20daa2aa 100644 --- a/substrate/frame/evm/src/lib.rs +++ b/substrate/frame/evm/src/lib.rs @@ -141,8 +141,8 @@ impl<T> ClassifyDispatch<T> for WeightForCallCreate { } } -impl PaysFee for WeightForCallCreate { - fn pays_fee(&self) -> bool { +impl<T> PaysFee<T> for WeightForCallCreate { + fn pays_fee(&self, _: T) -> bool { true } } diff --git a/substrate/frame/example/src/lib.rs b/substrate/frame/example/src/lib.rs index 853674f6fd0659d237376d33822cb09aad51286d..80569a1b573747d0748abb20c244c8778b28ec8e 100644 --- a/substrate/frame/example/src/lib.rs +++ b/substrate/frame/example/src/lib.rs @@ -301,8 +301,8 @@ impl<T: pallet_balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightFor } } -impl<T: pallet_balances::Trait> PaysFee for WeightForSetDummy<T> { - fn pays_fee(&self) -> bool { +impl<T: pallet_balances::Trait> PaysFee<(&BalanceOf<T>,)> for WeightForSetDummy<T> { + fn pays_fee(&self, _target: (&BalanceOf<T>,)) -> bool { true } } diff --git a/substrate/frame/support/src/dispatch.rs b/substrate/frame/support/src/dispatch.rs index 7d3750d9d4eaf81fd4f402be182ae0d5697e5a67..b2d7e6e1d409e232335672cdc3b1894cc8633443 100644 --- a/substrate/frame/support/src/dispatch.rs +++ b/substrate/frame/support/src/dispatch.rs @@ -1312,8 +1312,9 @@ macro_rules! decl_module { &$weight, ($( $param_name, )*) ); - let pays_fee = <dyn $crate::dispatch::PaysFee>::pays_fee( - &$weight + let pays_fee = <dyn $crate::dispatch::PaysFee<( $( & $param, )* )>>::pays_fee( + &$weight, + ($( $param_name, )*) ); return $crate::dispatch::DispatchInfo { weight, class, pays_fee }; } @@ -1331,8 +1332,9 @@ macro_rules! decl_module { &$crate::dispatch::SimpleDispatchInfo::default(), () ); - let pays_fee = <dyn $crate::dispatch::PaysFee>::pays_fee( - &$crate::dispatch::SimpleDispatchInfo::default() + let pays_fee = <dyn $crate::dispatch::PaysFee<_>>::pays_fee( + &$crate::dispatch::SimpleDispatchInfo::default(), + () ); $crate::dispatch::DispatchInfo { weight, class, pays_fee } diff --git a/substrate/frame/support/src/weights.rs b/substrate/frame/support/src/weights.rs index b4b70def1d312749129d3ab941d788c48aba2416..f1092b500230b5888385f0e14427ede776c3d2ce 100644 --- a/substrate/frame/support/src/weights.rs +++ b/substrate/frame/support/src/weights.rs @@ -78,8 +78,8 @@ pub trait WeighBlock<BlockNumber> { /// Indicates if dispatch function should pay fees or not. /// If set to false, the block resource limits are applied, yet no fee is deducted. -pub trait PaysFee { - fn pays_fee(&self) -> bool { +pub trait PaysFee<T> { + fn pays_fee(&self, _target: T) -> bool { true } } @@ -208,8 +208,8 @@ impl<T> ClassifyDispatch<T> for SimpleDispatchInfo { } } -impl PaysFee for SimpleDispatchInfo { - fn pays_fee(&self) -> bool { +impl<T> PaysFee<T> for SimpleDispatchInfo { + fn pays_fee(&self, _: T) -> bool { match self { SimpleDispatchInfo::FixedNormal(_) => true, SimpleDispatchInfo::MaxNormal => true, diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 1f7e861373c841d8f283e51e6b227d909361aa17..9ab2975e2955016c8450f1ef677afc489ae9414b 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -204,9 +204,9 @@ impl<Call: GetDispatchInfo> ClassifyDispatch<(&u16, &Box<Call>)> for Passthrough call.get_dispatch_info().class } } -impl<Call: GetDispatchInfo> PaysFee for Passthrough<Call> { - fn pays_fee(&self) -> bool { - true +impl<Call: GetDispatchInfo> PaysFee<(&u16, &Box<Call>)> for Passthrough<Call> { + fn pays_fee(&self, (_, call): (&u16, &Box<Call>)) -> bool { + call.get_dispatch_info().pays_fee } } @@ -226,13 +226,21 @@ impl<Call: GetDispatchInfo> WeighData<(&Vec<Call>,)> for BatchPassthrough<Call> } } impl<Call: GetDispatchInfo> ClassifyDispatch<(&Vec<Call>,)> for BatchPassthrough<Call> { - fn classify_dispatch(&self, (_,): (&Vec<Call>,)) -> DispatchClass { - DispatchClass::Normal + fn classify_dispatch(&self, (calls,): (&Vec<Call>,)) -> DispatchClass { + let all_operational = calls.iter() + .map(|call| call.get_dispatch_info().class) + .all(|class| class == DispatchClass::Operational); + if all_operational { + DispatchClass::Operational + } else { + DispatchClass::Normal + } } } -impl<Call: GetDispatchInfo> PaysFee for BatchPassthrough<Call> { - fn pays_fee(&self) -> bool { - true +impl<Call: GetDispatchInfo> PaysFee<(&Vec<Call>,)> for BatchPassthrough<Call> { + fn pays_fee(&self, (calls,): (&Vec<Call>,)) -> bool { + calls.iter() + .any(|call| call.get_dispatch_info().pays_fee) } } @@ -254,16 +262,16 @@ for MultiPassthrough<Call, AccountId, Timepoint> impl<Call: GetDispatchInfo, AccountId, Timepoint> ClassifyDispatch<(&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)> for MultiPassthrough<Call, AccountId, Timepoint> { - fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)) + fn classify_dispatch(&self, (_, _, _, call): (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)) -> DispatchClass { - DispatchClass::Normal + call.get_dispatch_info().class } } -impl<Call: GetDispatchInfo, AccountId, Timepoint> PaysFee +impl<Call: GetDispatchInfo, AccountId, Timepoint> PaysFee<(&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)> for MultiPassthrough<Call, AccountId, Timepoint> { - fn pays_fee(&self) -> bool { + fn pays_fee(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &Box<Call>)) -> bool { true } } @@ -286,16 +294,16 @@ for SigsLen<AccountId, Timepoint> impl<AccountId, Timepoint> ClassifyDispatch<(&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])> for SigsLen<AccountId, Timepoint> { - fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])) + fn classify_dispatch(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])) -> DispatchClass { DispatchClass::Normal } } -impl<AccountId, Timepoint> PaysFee +impl<AccountId, Timepoint> PaysFee<(&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])> for SigsLen<AccountId, Timepoint> { - fn pays_fee(&self) -> bool { + fn pays_fee(&self, _: (&u16, &Vec<AccountId>, &Timepoint, &[u8; 32])) -> bool { true } }