cumulus_pallet_parachain_system/validate_block/mod.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3// SPDX-License-Identifier: Apache-2.0
4
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17//! A module that enables a runtime to work as parachain.
18
19#[cfg(not(feature = "std"))]
20#[doc(hidden)]
21pub mod implementation;
22
23#[cfg(any(test, not(feature = "std")))]
24#[doc(hidden)]
25pub mod scheduling;
26
27#[cfg(test)]
28mod tests;
29
30#[cfg(not(feature = "std"))]
31#[doc(hidden)]
32pub mod trie_cache;
33
34#[cfg(any(test, not(feature = "std")))]
35#[doc(hidden)]
36pub mod trie_recorder;
37
38#[cfg(not(feature = "std"))]
39#[doc(hidden)]
40pub use alloc::{boxed::Box, slice};
41#[cfg(not(feature = "std"))]
42#[doc(hidden)]
43pub use bytes;
44#[cfg(not(feature = "std"))]
45#[doc(hidden)]
46pub use codec::decode_from_bytes;
47#[cfg(not(feature = "std"))]
48#[doc(hidden)]
49pub use polkadot_parachain_primitives;
50#[cfg(not(feature = "std"))]
51#[doc(hidden)]
52pub use sp_api;
53#[cfg(not(feature = "std"))]
54#[doc(hidden)]
55pub use sp_runtime::traits::GetRuntimeBlockType;
56#[cfg(not(feature = "std"))]
57#[doc(hidden)]
58pub use sp_std;
59
60/// Basically the same as
61/// [`ValidationParams`](polkadot_parachain_primitives::primitives::ValidationParams), but a little
62/// bit optimized for our use case here.
63///
64/// `block_data` and `head_data` are represented as [`bytes::Bytes`] to make them reuse
65/// the memory of the input parameter of the exported `validate_blocks` function.
66///
67/// The layout of this type must match exactly the layout of
68/// [`ValidationParams`](polkadot_parachain_primitives::primitives::ValidationParams) to have the
69/// same SCALE encoding, with the extension field at the end for V3+ candidates.
70#[derive(codec::Decode)]
71#[cfg_attr(feature = "std", derive(codec::Encode))]
72#[doc(hidden)]
73pub struct MemoryOptimizedValidationParams {
74 pub parent_head: bytes::Bytes,
75 pub block_data: bytes::Bytes,
76 pub relay_parent_number: cumulus_primitives_core::relay_chain::BlockNumber,
77 pub relay_parent_storage_root: cumulus_primitives_core::relay_chain::Hash,
78 /// V3+ extension containing relay_parent and scheduling_parent hashes.
79 /// None for V1/V2 candidates (no trailing bytes).
80 pub extension: polkadot_parachain_primitives::primitives::TrailingOption<
81 polkadot_parachain_primitives::primitives::ValidationParamsExtension,
82 >,
83}