diff --git a/polkadot/runtime/src/parachains.rs b/polkadot/runtime/src/parachains.rs index 1a6a77d7fe..50da4306cb 100644 --- a/polkadot/runtime/src/parachains.rs +++ b/polkadot/runtime/src/parachains.rs @@ -26,6 +26,7 @@ use polkadot_primitives::parachain::{Id, Chain, DutyRoster, CandidateReceipt}; use {system, session}; use runtime_support::{StorageValue, StorageMap}; +use runtime_support::dispatch::Result; #[cfg(any(feature = "std", test))] use rstd::marker::PhantomData; @@ -44,7 +45,7 @@ decl_module! { pub struct Module; pub enum Call where aux: ::PublicAux { // provide candidate receipts for parachains, in ascending order by id. - fn set_heads(aux, heads: Vec) = 0; + fn set_heads(aux, heads: Vec) -> Result = 0; } } @@ -137,13 +138,13 @@ impl Module { >::put(parachains); } - fn set_heads(aux: &::PublicAux, heads: Vec) { - assert!(aux.is_empty()); - assert!(!>::exists(), "Parachain heads must be updated only once in the block"); - assert!( + fn set_heads(aux: &::PublicAux, heads: Vec) -> Result { + ensure!(aux.is_empty(), "set_heads must not be signed"); + ensure!(!>::exists(), "Parachain heads must be updated only once in the block"); + ensure!( >::extrinsic_index() == T::SET_POSITION, - "Parachain heads update extrinsic must be at position {} in the block", - T::SET_POSITION + "Parachain heads update extrinsic must be at position {} in the block" +// , T::SET_POSITION ); let active_parachains = Self::active_parachains(); @@ -151,10 +152,10 @@ impl Module { // perform this check before writing to storage. for head in &heads { - assert!( + ensure!( iter.find(|&p| p == &head.parachain_index).is_some(), - "Submitted candidate for unregistered or out-of-order parachain {}", - head.parachain_index.into_inner() + "Submitted candidate for unregistered or out-of-order parachain {}" +// , head.parachain_index.into_inner() ); } @@ -164,6 +165,8 @@ impl Module { } >::put(true); + + Ok(()) } }