1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: GPL-3.0
//! Relay chain storage mocking for block building.
//!
//! This module provides utilities for mocking relay chain-specific storage
//! that is required for block finalization. On relay chains, the `ParaInherent`
//! pallet requires that `Included` storage is set every block.
//!
//! # How It Works
//!
//! The relay chain runtime's `ParaInherent` pallet has an `on_finalize` hook that
//! panics if `Included` storage is not set:
//!
//! ```ignore
//! fn on_finalize(_: BlockNumberFor<T>) {
//! if Included::<T>::take().is_none() {
//! panic!("Bitfields and heads must be included every block");
//! }
//! }
//! ```
//!
//! Instead of constructing a complex `paras_inherent.enter` extrinsic with proper
//! bitfields and candidates, we simply mock the `Included` storage directly.
//! The runtime only checks for existence, not validity.
//!
//! # Usage
//!
//! This is handled automatically by `BlockBuilder::apply_inherents()` when it
//! detects a relay chain runtime (one with `ParaInherent` pallet).
use craterelay as strings;
/// Pallet name for ParaInherent (relay chain parachains inherent).
pub const PARA_INHERENT_PALLET: &str = PARA_INHERENT_PALLET;
/// Compute the storage key for `ParaInherent::Included`.
///
/// The key is constructed as: `twox_128("ParaInherent") ++ twox_128("Included")`
///
/// This storage value is checked in `on_finalize` to ensure the paras inherent
/// was "included" in the block. By setting this directly, we bypass the need
/// for a valid `paras_inherent.enter` extrinsic.
///
/// # Returns
///
/// A 32-byte storage key.