mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Do not use rely on the block initialization when calling runtime APIs (#2123)
* Don't initialize block when calling runtime APIs * Adapt check_validation_outputs We split the code path for the inclusion and for the commitments checking. * Slap #[skip_initialize_block] on safe runtime APIs That is, those that should not be affected by this attribute * Make `Scheduled` not ephemeral So that it is persisted in the storage and ready to be inspected by the runtime APIs. This is in contrast to what was before, where we would remove the storage entry and then rely on the scheduling performed by `on_initialize` again. * Add a big fat comment * Typos Co-authored-by: Robert Habermeier <rphmeier@gmail.com> * Move session change to the end of the current block Previously, it was the beginning of the next block. This allows us to put #[skip_initialize_block] * Update tests * Fix a test in paras registrar Also refactor it a bit so the next time there are more chances this kind of issue is diagnosed quicker. * Add for_runtime_api to inclusion's check_validation_outputs Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -193,12 +193,13 @@ pub fn full_validation_data<T: initializer::Config>(
|
||||
)
|
||||
-> Option<ValidationData<T::BlockNumber>>
|
||||
{
|
||||
let relay_parent_number = <frame_system::Module<T>>::block_number();
|
||||
with_assumption::<T, _, _>(
|
||||
para_id,
|
||||
assumption,
|
||||
|| Some(ValidationData {
|
||||
persisted: crate::util::make_persisted_validation_data::<T>(para_id)?,
|
||||
transient: crate::util::make_transient_validation_data::<T>(para_id)?,
|
||||
persisted: crate::util::make_persisted_validation_data::<T>(para_id, relay_parent_number)?,
|
||||
transient: crate::util::make_transient_validation_data::<T>(para_id, relay_parent_number)?,
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -208,10 +209,11 @@ pub fn persisted_validation_data<T: initializer::Config>(
|
||||
para_id: ParaId,
|
||||
assumption: OccupiedCoreAssumption,
|
||||
) -> Option<PersistedValidationData<T::BlockNumber>> {
|
||||
let relay_parent_number = <frame_system::Module<T>>::block_number();
|
||||
with_assumption::<T, _, _>(
|
||||
para_id,
|
||||
assumption,
|
||||
|| crate::util::make_persisted_validation_data::<T>(para_id),
|
||||
|| crate::util::make_persisted_validation_data::<T>(para_id, relay_parent_number),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -220,7 +222,7 @@ pub fn check_validation_outputs<T: initializer::Config>(
|
||||
para_id: ParaId,
|
||||
outputs: primitives::v1::CandidateCommitments,
|
||||
) -> bool {
|
||||
<inclusion::Module<T>>::check_validation_outputs(para_id, outputs)
|
||||
<inclusion::Module<T>>::check_validation_outputs_for_runtime_api(para_id, outputs)
|
||||
}
|
||||
|
||||
/// Implementation for the `session_index_for_child` function of the runtime API.
|
||||
|
||||
Reference in New Issue
Block a user