diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index b3ff8b16283ca..4266ad7459e65 100644 --- a/bin/node/runtime/src/lib.rs +++ b/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/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 48b54a8c8677e..8d504127245d0 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -141,8 +141,8 @@ impl ClassifyDispatch for WeightForCallCreate { } } -impl PaysFee for WeightForCallCreate { - fn pays_fee(&self) -> bool { +impl PaysFee for WeightForCallCreate { + fn pays_fee(&self, _: T) -> bool { true } } diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index 853674f6fd065..80569a1b57374 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -301,8 +301,8 @@ impl ClassifyDispatch<(&BalanceOf,)> for WeightFor } } -impl PaysFee for WeightForSetDummy { - fn pays_fee(&self) -> bool { +impl PaysFee<(&BalanceOf,)> for WeightForSetDummy { + fn pays_fee(&self, _target: (&BalanceOf,)) -> bool { true } } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 7d3750d9d4eaf..b2d7e6e1d409e 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1312,8 +1312,9 @@ macro_rules! decl_module { &$weight, ($( $param_name, )*) ); - let pays_fee = ::pays_fee( - &$weight + let pays_fee = >::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 = ::pays_fee( - &$crate::dispatch::SimpleDispatchInfo::default() + let pays_fee = >::pays_fee( + &$crate::dispatch::SimpleDispatchInfo::default(), + () ); $crate::dispatch::DispatchInfo { weight, class, pays_fee } diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index b4b70def1d312..f1092b500230b 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -78,8 +78,8 @@ pub trait WeighBlock { /// 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 { + fn pays_fee(&self, _target: T) -> bool { true } } @@ -208,8 +208,8 @@ impl ClassifyDispatch for SimpleDispatchInfo { } } -impl PaysFee for SimpleDispatchInfo { - fn pays_fee(&self) -> bool { +impl PaysFee for SimpleDispatchInfo { + fn pays_fee(&self, _: T) -> bool { match self { SimpleDispatchInfo::FixedNormal(_) => true, SimpleDispatchInfo::MaxNormal => true, diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 1f7e861373c84..9ab2975e29550 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -204,9 +204,9 @@ impl ClassifyDispatch<(&u16, &Box)> for Passthrough call.get_dispatch_info().class } } -impl PaysFee for Passthrough { - fn pays_fee(&self) -> bool { - true +impl PaysFee<(&u16, &Box)> for Passthrough { + fn pays_fee(&self, (_, call): (&u16, &Box)) -> bool { + call.get_dispatch_info().pays_fee } } @@ -226,13 +226,21 @@ impl WeighData<(&Vec,)> for BatchPassthrough } } impl ClassifyDispatch<(&Vec,)> for BatchPassthrough { - fn classify_dispatch(&self, (_,): (&Vec,)) -> DispatchClass { - DispatchClass::Normal + fn classify_dispatch(&self, (calls,): (&Vec,)) -> 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 PaysFee for BatchPassthrough { - fn pays_fee(&self) -> bool { - true +impl PaysFee<(&Vec,)> for BatchPassthrough { + fn pays_fee(&self, (calls,): (&Vec,)) -> bool { + calls.iter() + .any(|call| call.get_dispatch_info().pays_fee) } } @@ -254,16 +262,16 @@ for MultiPassthrough impl ClassifyDispatch<(&u16, &Vec, &Timepoint, &Box)> for MultiPassthrough { - fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec, &Timepoint, &Box)) + fn classify_dispatch(&self, (_, _, _, call): (&u16, &Vec, &Timepoint, &Box)) -> DispatchClass { - DispatchClass::Normal + call.get_dispatch_info().class } } -impl PaysFee +impl PaysFee<(&u16, &Vec, &Timepoint, &Box)> for MultiPassthrough { - fn pays_fee(&self) -> bool { + fn pays_fee(&self, _: (&u16, &Vec, &Timepoint, &Box)) -> bool { true } } @@ -286,16 +294,16 @@ for SigsLen impl ClassifyDispatch<(&u16, &Vec, &Timepoint, &[u8; 32])> for SigsLen { - fn classify_dispatch(&self, (_, _, _, _): (&u16, &Vec, &Timepoint, &[u8; 32])) + fn classify_dispatch(&self, _: (&u16, &Vec, &Timepoint, &[u8; 32])) -> DispatchClass { DispatchClass::Normal } } -impl PaysFee +impl PaysFee<(&u16, &Vec, &Timepoint, &[u8; 32])> for SigsLen { - fn pays_fee(&self) -> bool { + fn pays_fee(&self, _: (&u16, &Vec, &Timepoint, &[u8; 32])) -> bool { true } }