mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Check that we have set the validation data inherent (#451)
This commit is contained in:
@@ -28,20 +28,19 @@
|
|||||||
//! Users must ensure that they register this pallet as an inherent provider.
|
//! Users must ensure that they register this pallet as an inherent provider.
|
||||||
|
|
||||||
use cumulus_primitives_core::{
|
use cumulus_primitives_core::{
|
||||||
relay_chain, CollationInfo,
|
relay_chain, AbridgedHostConfiguration, ChannelStatus, CollationInfo, DmpMessageHandler,
|
||||||
AbridgedHostConfiguration, ChannelStatus, DmpMessageHandler, GetChannelInfo,
|
GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, MessageSendError, OnValidationData,
|
||||||
InboundDownwardMessage, InboundHrmpMessage, MessageSendError, OnValidationData,
|
|
||||||
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
|
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
|
||||||
XcmpMessageHandler, XcmpMessageSource,
|
XcmpMessageHandler, XcmpMessageSource,
|
||||||
};
|
};
|
||||||
use cumulus_primitives_parachain_inherent::ParachainInherentData;
|
use cumulus_primitives_parachain_inherent::ParachainInherentData;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
ensure,
|
|
||||||
dispatch::{DispatchError, DispatchResult},
|
dispatch::{DispatchError, DispatchResult},
|
||||||
|
ensure,
|
||||||
|
inherent::{InherentData, InherentIdentifier, ProvideInherent},
|
||||||
storage,
|
storage,
|
||||||
traits::Get,
|
traits::Get,
|
||||||
weights::{PostDispatchInfo, Weight, Pays},
|
weights::{Pays, PostDispatchInfo, Weight},
|
||||||
inherent::{InherentData, InherentIdentifier, ProvideInherent},
|
|
||||||
};
|
};
|
||||||
use frame_system::{ensure_none, ensure_root};
|
use frame_system::{ensure_none, ensure_root};
|
||||||
use polkadot_parachain::primitives::RelayChainBlockNumber;
|
use polkadot_parachain::primitives::RelayChainBlockNumber;
|
||||||
@@ -108,6 +107,11 @@ pub mod pallet {
|
|||||||
fn on_finalize(_: T::BlockNumber) {
|
fn on_finalize(_: T::BlockNumber) {
|
||||||
<DidSetValidationCode<T>>::kill();
|
<DidSetValidationCode<T>>::kill();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
<ValidationData<T>>::exists(),
|
||||||
|
"set_validation_data inherent needs to be present in every block!"
|
||||||
|
);
|
||||||
|
|
||||||
let host_config = match Self::host_configuration() {
|
let host_config = match Self::host_configuration() {
|
||||||
Some(ok) => ok,
|
Some(ok) => ok,
|
||||||
None => {
|
None => {
|
||||||
@@ -118,18 +122,17 @@ pub mod pallet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let relevant_messaging_state =
|
let relevant_messaging_state = match Self::relevant_messaging_state() {
|
||||||
match Self::relevant_messaging_state() {
|
Some(ok) => ok,
|
||||||
Some(ok) => ok,
|
None => {
|
||||||
None => {
|
debug_assert!(
|
||||||
debug_assert!(
|
false,
|
||||||
false,
|
"relevant messaging state is promised to be set until `on_finalize`; \
|
||||||
"relevant messaging state is promised to be set until `on_finalize`; \
|
|
||||||
qed",
|
qed",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
<PendingUpwardMessages<T>>::mutate(|up| {
|
<PendingUpwardMessages<T>>::mutate(|up| {
|
||||||
let (count, size) = relevant_messaging_state.relay_dispatch_queue_size;
|
let (count, size) = relevant_messaging_state.relay_dispatch_queue_size;
|
||||||
@@ -181,10 +184,8 @@ pub mod pallet {
|
|||||||
let outbound_messages =
|
let outbound_messages =
|
||||||
T::OutboundXcmpMessageSource::take_outbound_messages(maximum_channels)
|
T::OutboundXcmpMessageSource::take_outbound_messages(maximum_channels)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(recipient, data)| OutboundHrmpMessage {
|
.map(|(recipient, data)| OutboundHrmpMessage { recipient, data })
|
||||||
recipient,
|
.collect::<Vec<_>>();
|
||||||
data,
|
|
||||||
}).collect::<Vec<_>>();
|
|
||||||
|
|
||||||
HrmpOutboundMessages::<T>::put(outbound_messages);
|
HrmpOutboundMessages::<T>::put(outbound_messages);
|
||||||
}
|
}
|
||||||
@@ -681,8 +682,8 @@ impl<T: Config> Pallet<T> {
|
|||||||
let mut weight_used = 0;
|
let mut weight_used = 0;
|
||||||
if dm_count != 0 {
|
if dm_count != 0 {
|
||||||
Self::deposit_event(Event::DownwardMessagesReceived(dm_count));
|
Self::deposit_event(Event::DownwardMessagesReceived(dm_count));
|
||||||
let max_weight = <ReservedDmpWeightOverride<T>>::get()
|
let max_weight =
|
||||||
.unwrap_or_else(T::ReservedDmpWeight::get);
|
<ReservedDmpWeightOverride<T>>::get().unwrap_or_else(T::ReservedDmpWeight::get);
|
||||||
|
|
||||||
let message_iter = downward_messages
|
let message_iter = downward_messages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -728,11 +729,9 @@ impl<T: Config> Pallet<T> {
|
|||||||
// A violation of the assertion below indicates that one of the messages submitted
|
// A violation of the assertion below indicates that one of the messages submitted
|
||||||
// by the collator was sent from a sender that doesn't have a channel opened to
|
// by the collator was sent from a sender that doesn't have a channel opened to
|
||||||
// this parachain, according to the relay-parent state.
|
// this parachain, according to the relay-parent state.
|
||||||
assert!(
|
assert!(ingress_channels
|
||||||
ingress_channels
|
.binary_search_by_key(sender, |&(s, _)| s)
|
||||||
.binary_search_by_key(sender, |&(s, _)| s)
|
.is_ok(),);
|
||||||
.is_ok(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second, prepare horizontal messages for a more convenient processing:
|
// Second, prepare horizontal messages for a more convenient processing:
|
||||||
@@ -863,8 +862,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
Error::<T>::OverlappingUpgrades
|
Error::<T>::OverlappingUpgrades
|
||||||
);
|
);
|
||||||
let vfp = Self::validation_data().ok_or(Error::<T>::ValidationDataNotAvailable)?;
|
let vfp = Self::validation_data().ok_or(Error::<T>::ValidationDataNotAvailable)?;
|
||||||
let cfg =
|
let cfg = Self::host_configuration().ok_or(Error::<T>::HostConfigurationNotAvailable)?;
|
||||||
Self::host_configuration().ok_or(Error::<T>::HostConfigurationNotAvailable)?;
|
|
||||||
ensure!(
|
ensure!(
|
||||||
validation_function.len() <= cfg.max_code_size as usize,
|
validation_function.len() <= cfg.max_code_size as usize,
|
||||||
Error::<T>::TooBig
|
Error::<T>::TooBig
|
||||||
|
|||||||
Reference in New Issue
Block a user