mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Runtime dispatch calls return Result (#192)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic * Update wasm. * consensus, session and staking all panic-safe. * Democracy doesn't panic in apply. * Fix tests. * Extra helper macro, council depanicked. * Fix one test. * Fix up all council tests. No panics! * Council voting depanicked. * Dispatch returns result. * session & staking tests updated * Fix democracy tests. * Fix council tests. * Fix up polkadot parachains in runtime * Fix borked merge
This commit is contained in:
@@ -26,6 +26,7 @@ use polkadot_primitives::parachain::{Id, Chain, DutyRoster, CandidateReceipt};
|
|||||||
use {system, session};
|
use {system, session};
|
||||||
|
|
||||||
use runtime_support::{StorageValue, StorageMap};
|
use runtime_support::{StorageValue, StorageMap};
|
||||||
|
use runtime_support::dispatch::Result;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
use rstd::marker::PhantomData;
|
use rstd::marker::PhantomData;
|
||||||
@@ -44,7 +45,7 @@ decl_module! {
|
|||||||
pub struct Module<T: Trait>;
|
pub struct Module<T: Trait>;
|
||||||
pub enum Call where aux: <T as Trait>::PublicAux {
|
pub enum Call where aux: <T as Trait>::PublicAux {
|
||||||
// provide candidate receipts for parachains, in ascending order by id.
|
// provide candidate receipts for parachains, in ascending order by id.
|
||||||
fn set_heads(aux, heads: Vec<CandidateReceipt>) = 0;
|
fn set_heads(aux, heads: Vec<CandidateReceipt>) -> Result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,13 +138,13 @@ impl<T: Trait> Module<T> {
|
|||||||
<Parachains<T>>::put(parachains);
|
<Parachains<T>>::put(parachains);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_heads(aux: &<T as Trait>::PublicAux, heads: Vec<CandidateReceipt>) {
|
fn set_heads(aux: &<T as Trait>::PublicAux, heads: Vec<CandidateReceipt>) -> Result {
|
||||||
assert!(aux.is_empty());
|
ensure!(aux.is_empty(), "set_heads must not be signed");
|
||||||
assert!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
|
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
|
||||||
assert!(
|
ensure!(
|
||||||
<system::Module<T>>::extrinsic_index() == T::SET_POSITION,
|
<system::Module<T>>::extrinsic_index() == T::SET_POSITION,
|
||||||
"Parachain heads update extrinsic must be at position {} in the block",
|
"Parachain heads update extrinsic must be at position {} in the block"
|
||||||
T::SET_POSITION
|
// , T::SET_POSITION
|
||||||
);
|
);
|
||||||
|
|
||||||
let active_parachains = Self::active_parachains();
|
let active_parachains = Self::active_parachains();
|
||||||
@@ -151,10 +152,10 @@ impl<T: Trait> Module<T> {
|
|||||||
|
|
||||||
// perform this check before writing to storage.
|
// perform this check before writing to storage.
|
||||||
for head in &heads {
|
for head in &heads {
|
||||||
assert!(
|
ensure!(
|
||||||
iter.find(|&p| p == &head.parachain_index).is_some(),
|
iter.find(|&p| p == &head.parachain_index).is_some(),
|
||||||
"Submitted candidate for unregistered or out-of-order parachain {}",
|
"Submitted candidate for unregistered or out-of-order parachain {}"
|
||||||
head.parachain_index.into_inner()
|
// , head.parachain_index.into_inner()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +165,8 @@ impl<T: Trait> Module<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<DidUpdate<T>>::put(true);
|
<DidUpdate<T>>::put(true);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user