mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
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:
@@ -49,64 +49,3 @@ pub(crate) fn with_validation_params<R>(f: impl FnOnce(&ValidationParams) -> R)
|
||||
fn set_and_run_with_validation_params<R>(mut params: ValidationParams, f: impl FnOnce() -> R) -> R {
|
||||
VALIDATION_PARAMS::using(&mut params, f)
|
||||
}
|
||||
|
||||
/// Register the `validate_block` function that is used by parachains to validate blocks on a
|
||||
/// validator.
|
||||
///
|
||||
/// Does *nothing* when `std` feature is enabled.
|
||||
///
|
||||
/// Expects as parameters the runtime and a block executor.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// struct BlockExecutor;
|
||||
/// struct Runtime;
|
||||
///
|
||||
/// cumulus_pallet_parachain_system::register_validate_block!(Runtime, BlockExecutor);
|
||||
///
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! register_validate_block {
|
||||
($runtime:ty, $block_executor:ty $( , )? ) => {
|
||||
$crate::register_validate_block_impl!($runtime, $block_executor);
|
||||
};
|
||||
}
|
||||
|
||||
/// The actual implementation of `register_validate_block` for `no_std`.
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! register_validate_block_impl {
|
||||
($runtime:ty, $block_executor:ty) => {
|
||||
#[doc(hidden)]
|
||||
mod parachain_validate_block {
|
||||
use super::*;
|
||||
|
||||
#[no_mangle]
|
||||
unsafe fn validate_block(arguments: *const u8, arguments_len: usize) -> u64 {
|
||||
let params = $crate::validate_block::polkadot_parachain::load_params(
|
||||
arguments,
|
||||
arguments_len,
|
||||
);
|
||||
|
||||
let res = $crate::validate_block::implementation::validate_block::<
|
||||
<$runtime as $crate::validate_block::GetRuntimeBlockType>::RuntimeBlock,
|
||||
$block_executor,
|
||||
$runtime,
|
||||
>(params);
|
||||
|
||||
$crate::validate_block::polkadot_parachain::write_result(&res)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The actual implementation of `register_validate_block` for `std`.
|
||||
#[cfg(feature = "std")]
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! register_validate_block_impl {
|
||||
($runtime:ty, $block_executor:ty) => {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user