diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index afd2631373..bad1ea4174 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -77,11 +77,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, // Per convention: if the runtime behavior changes, increment spec_version - // and set impl_version to equal spec_version. If only runtime + // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 207, - impl_version: 208, + spec_version: 208, + impl_version: 0, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/frame/executive/src/lib.rs b/substrate/frame/executive/src/lib.rs index 96c79c1073..cafb9fad27 100644 --- a/substrate/frame/executive/src/lib.rs +++ b/substrate/frame/executive/src/lib.rs @@ -385,7 +385,7 @@ mod tests { fn some_root_operation(origin) { let _ = frame_system::ensure_root(origin); } - #[weight = SimpleDispatchInfo::FreeNormal] + #[weight = SimpleDispatchInfo::InsecureFreeNormal] fn some_unsigned_message(origin) { let _ = frame_system::ensure_none(origin); } diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 0bcc33b217..631d77d0bf 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -842,7 +842,7 @@ decl_module! { /// - `S + 2` storage mutations. /// - One event. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn kill_identity(origin, target: ::Source) { T::ForceOrigin::try_origin(origin) .map(|_| ()) diff --git a/substrate/frame/nicks/src/lib.rs b/substrate/frame/nicks/src/lib.rs index 79365ff713..1067e9a5de 100644 --- a/substrate/frame/nicks/src/lib.rs +++ b/substrate/frame/nicks/src/lib.rs @@ -194,7 +194,7 @@ decl_module! { /// - One storage read/write. /// - One event. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(70_000)] fn kill_name(origin, target: ::Source) { T::ForceOrigin::try_origin(origin) .map(|_| ()) @@ -222,7 +222,7 @@ decl_module! { /// - One storage read/write. /// - One event. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(70_000)] fn force_name(origin, target: ::Source, name: Vec) { T::ForceOrigin::try_origin(origin) .map(|_| ()) diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs index 21ac24bc68..757f75bf0a 100644 --- a/substrate/frame/staking/src/lib.rs +++ b/substrate/frame/staking/src/lib.rs @@ -1150,7 +1150,7 @@ decl_module! { } /// The ideal number of validators. - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(5_000)] fn set_validator_count(origin, #[compact] new: u32) { ensure_root(origin)?; ValidatorCount::put(new); @@ -1163,7 +1163,7 @@ decl_module! { /// # /// - No arguments. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(5_000)] fn force_no_eras(origin) { ensure_root(origin)?; ForceEra::put(Forcing::ForceNone); @@ -1175,21 +1175,21 @@ decl_module! { /// # /// - No arguments. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(5_000)] fn force_new_era(origin) { ensure_root(origin)?; ForceEra::put(Forcing::ForceNew); } /// Set the validators who cannot be slashed (if any). - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(5_000)] fn set_invulnerables(origin, validators: Vec) { ensure_root(origin)?; >::put(validators); } /// Force a current staker to become completely unstaked, immediately. - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn force_unstake(origin, stash: T::AccountId) { ensure_root(origin)?; @@ -1204,7 +1204,7 @@ decl_module! { /// # /// - One storage write /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(5_000)] fn force_new_era_always(origin) { ensure_root(origin)?; ForceEra::put(Forcing::ForceAlways); @@ -1217,7 +1217,7 @@ decl_module! { /// # /// - One storage write. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(1_000_000)] fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec) { T::SlashCancelOrigin::try_origin(origin) .map(|_| ()) diff --git a/substrate/frame/sudo/src/lib.rs b/substrate/frame/sudo/src/lib.rs index ea436e2629..e69840e158 100644 --- a/substrate/frame/sudo/src/lib.rs +++ b/substrate/frame/sudo/src/lib.rs @@ -119,7 +119,7 @@ decl_module! { /// - One DB write (event). /// - Unknown weight of derivative `proposal` execution. /// # - #[weight = SimpleDispatchInfo::FreeOperational] + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] fn sudo(origin, proposal: Box) { // This is a public call, so we ensure that the origin is some signed account. let sender = ensure_signed(origin)?; diff --git a/substrate/frame/support/src/weights.rs b/substrate/frame/support/src/weights.rs index e44ab16458..34166c368c 100644 --- a/substrate/frame/support/src/weights.rs +++ b/substrate/frame/support/src/weights.rs @@ -127,11 +127,10 @@ impl From for DispatchClass { match tx { SimpleDispatchInfo::FixedOperational(_) => DispatchClass::Operational, SimpleDispatchInfo::MaxOperational => DispatchClass::Operational, - SimpleDispatchInfo::FreeOperational => DispatchClass::Operational, SimpleDispatchInfo::FixedNormal(_) => DispatchClass::Normal, SimpleDispatchInfo::MaxNormal => DispatchClass::Normal, - SimpleDispatchInfo::FreeNormal => DispatchClass::Normal, + SimpleDispatchInfo::InsecureFreeNormal => DispatchClass::Normal, } } } @@ -178,14 +177,12 @@ pub enum SimpleDispatchInfo { FixedNormal(Weight), /// A normal dispatch with the maximum weight. MaxNormal, - /// A normal dispatch with no weight. - FreeNormal, + /// A normal dispatch with no weight. Base and bytes fees still need to be paid. + InsecureFreeNormal, /// An operational dispatch with fixed weight. FixedOperational(Weight), /// An operational dispatch with the maximum weight. MaxOperational, - /// An operational dispatch with no weight. - FreeOperational, } impl WeighData for SimpleDispatchInfo { @@ -193,11 +190,10 @@ impl WeighData for SimpleDispatchInfo { match self { SimpleDispatchInfo::FixedNormal(w) => *w, SimpleDispatchInfo::MaxNormal => Bounded::max_value(), - SimpleDispatchInfo::FreeNormal => Bounded::min_value(), + SimpleDispatchInfo::InsecureFreeNormal => Bounded::min_value(), SimpleDispatchInfo::FixedOperational(w) => *w, SimpleDispatchInfo::MaxOperational => Bounded::max_value(), - SimpleDispatchInfo::FreeOperational => Bounded::min_value(), } } } @@ -213,11 +209,10 @@ impl PaysFee for SimpleDispatchInfo { match self { SimpleDispatchInfo::FixedNormal(_) => true, SimpleDispatchInfo::MaxNormal => true, - SimpleDispatchInfo::FreeNormal => true, + SimpleDispatchInfo::InsecureFreeNormal => true, SimpleDispatchInfo::FixedOperational(_) => true, SimpleDispatchInfo::MaxOperational => true, - SimpleDispatchInfo::FreeOperational => false, } } } diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 00dbf6bc66..370bd87b4c 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -477,7 +477,7 @@ mod tests { let len = 100; - // like a FreeOperational + // This is a completely free (and thus wholly insecure/DoS-ridden) transaction. let operational_transaction = DispatchInfo { weight: 0, class: DispatchClass::Operational, @@ -489,7 +489,7 @@ mod tests { .is_ok() ); - // like a FreeNormal + // like a InsecureFreeNormal let free_transaction = DispatchInfo { weight: 0, class: DispatchClass::Normal,