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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// SPDX-License-Identifier: GPL-3.0
//! Inherent extrinsic providers for block building.
//!
//! This module defines the [`InherentProvider`] trait and provides implementations
//! for generating inherent extrinsics during block construction.
//!
//! # What are Inherents?
//!
//! Inherent are special transactions that:
//! - Are unsigned (no signature required)
//! - Are mandatory (block is invalid without them)
//! - Are applied before regular extrinsics
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ InherentProvider Trait │
//! └─────────────────────────────────────────────────────────────────┘
//! │
//! ┌─────────────────────┼─────────────────────┐
//! ▼ ▼ ▼
//! ┌──────────┐ ┌──────────┐ ┌──────────┐
//! │Timestamp │ │Parachain │ │RelayChain│
//! │ Inherent │ │ Inherent │ │ Inherent │
//! └──────────┘ └──────────┘ └──────────┘
//! ```
//!
//! # Implementing a Provider
//!
//! ```ignore
//! use pop_fork::{InherentProvider, Block, BlockBuilderError, RuntimeExecutor};
//! use async_trait::async_trait;
//!
//! pub struct TimestampInherent {
//! slot_duration_ms: u64,
//! }
//!
//! #[async_trait]
//! impl InherentProvider for TimestampInherent {
//! fn identifier(&self) -> &'static str {
//! "Timestamp"
//! }
//!
//! async fn provide(
//! &self,
//! parent: &Block,
//! executor: &RuntimeExecutor,
//! ) -> Result<Vec<Vec<u8>>, BlockBuilderError> {
//! // Read current timestamp, add slot_duration, encode call
//! Ok(vec![encoded_timestamp_set_call])
//! }
//! }
//! ```
pub use ParachainInherent;
pub use ;
pub use ;
pub use ;
pub use TimestampInherent;
use crate::;
use async_trait;
/// Trait for creating inherent extrinsics during block building.
///
/// Inherent providers generate the "inherent" extrinsics that are automatically
/// included in each block (timestamp, parachain validation data, etc.).
///
/// # Implementing
///
/// Implementations should return an empty `Vec` if the inherent doesn't apply
/// to the current chain (e.g., parachain inherents on a relay chain).
/// Create default inherent providers for block building.
///
/// This factory function creates a standard set of inherent providers
/// suitable for most chains.
///
/// # Arguments
///
/// * `is_parachain` - Whether the chain is a parachain (affects slot duration and adds parachain
/// inherent provider)
///
/// # Slot Duration
///
/// The timestamp inherent provider uses default slot durations:
/// - Relay chains: 6 seconds (6000ms)
/// - Parachains: 12 seconds (12000ms)
///
/// The actual slot duration will be detected from the runtime at block-building time,
/// with these values serving as fallbacks.
///
/// # Returns
///
/// A vector of boxed inherent providers ready for use with `BlockBuilder`.
///
/// # Example
///
/// ```ignore
/// use pop_fork::inherent::default_providers;
///
/// // For a relay chain
/// let providers = default_providers(false);
///
/// // For a parachain
/// let providers = default_providers(true);
/// ```