Bring support for calling check_inherents (#490)

* Start

* More work

* Add proc-macro for `validate_block`

* Make everything compile

* Add some test
This commit is contained in:
Bastian Köcher authored and GitHub committed 2021-06-12 20:21:46 +02:00
1 parent 2f88be0874
commit d54fdd788e
20 files changed
+684 -326

No files matched your search

+26 -1
View File
@@ -427,4 +427,29 @@ impl_runtime_apis! {
}
}
cumulus_pallet_parachain_system::register_validate_block!(Runtime, Executive);
struct CheckInherents;
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
_: &[UncheckedExtrinsic],
relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
if relay_state_proof.read_slot().expect("Reads slot") == 1337u64 {
let mut res = sp_inherents::CheckInherentsResult::new();
res.put_error(
[1u8; 8],
&sp_inherents::MakeFatalError::from("You are wrong"),
)
.expect("Puts error");
res
} else {
sp_inherents::CheckInherentsResult::new()
}
}
}
cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = Executive,
CheckInherents = CheckInherents,
}