From 7f838b0c354cedb51c9327c6023e743b6487ddfd Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 5 Apr 2020 14:27:58 +0200 Subject: [PATCH] Update for using Mandatory inherents (#967) * Update for using Mandatory inherents. * use --- polkadot/runtime/common/src/attestations.rs | 2 +- polkadot/runtime/common/src/parachains.rs | 2 +- polkadot/validation/src/block_production.rs | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/polkadot/runtime/common/src/attestations.rs b/polkadot/runtime/common/src/attestations.rs index b493c10cfc..58b90acce5 100644 --- a/polkadot/runtime/common/src/attestations.rs +++ b/polkadot/runtime/common/src/attestations.rs @@ -131,7 +131,7 @@ decl_module! { type Error = Error; /// Provide candidate receipts for parachains, in ascending order by id. - #[weight = frame_support::weights::SimpleDispatchInfo::default()] + #[weight = frame_support::weights::SimpleDispatchInfo::FixedMandatory(10_000)] fn more_attestations(origin, _more: MoreAttestations) -> DispatchResult { ensure_none(origin)?; ensure!(!DidUpdate::exists(), Error::::TooManyAttestations); diff --git a/polkadot/runtime/common/src/parachains.rs b/polkadot/runtime/common/src/parachains.rs index 11f1ac5e60..728277b5eb 100644 --- a/polkadot/runtime/common/src/parachains.rs +++ b/polkadot/runtime/common/src/parachains.rs @@ -399,7 +399,7 @@ decl_module! { type Error = Error; /// Provide candidate receipts for parachains, in ascending order by id. - #[weight = SimpleDispatchInfo::FixedNormal(1_000_000)] + #[weight = SimpleDispatchInfo::FixedMandatory(1_000_000)] pub fn set_heads(origin, heads: Vec) -> DispatchResult { ensure_none(origin)?; ensure!(!::exists(), Error::::TooManyHeadUpdates); diff --git a/polkadot/validation/src/block_production.rs b/polkadot/validation/src/block_production.rs index 2ba7881962..e8d6c85925 100644 --- a/polkadot/validation/src/block_production.rs +++ b/polkadot/validation/src/block_production.rs @@ -277,7 +277,16 @@ impl CreateProposalData where { let inherents = runtime_api.inherent_extrinsics(&self.parent_id, inherent_data)?; for inherent in inherents { - block_builder.push(inherent)?; + match block_builder.push(inherent) { + Err(sp_blockchain::Error::ApplyExtrinsicFailed(sp_blockchain::ApplyExtrinsicFailed::Validity(e))) + if e.exhausted_resources() => { + warn!("⚠️ Dropping non-mandatory inherent from overweight block."); + } + Err(e) => { + warn!("❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e); + } + Ok(_) => {} + } } let mut unqueue_invalid = Vec::new();