mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Add set custom header to Seedling Runtime (#846)
* before adding seedling client side * seedling runtime compiles * create seedling spec script added * seedling node & BaseCallFilter fixes * update AllPalets * formatting * CallFilter + SignedExtra + AccountData fix * XCM removed * cleanup * solo-to-para pallet added & before testing * fix runtime upgrade method * soloToPara pallet + set header * clean up * clean up 2 * signed extension check sudo added * fmt + cleanup * Refac code and fixes * fmt * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * small fixes * OnValidationData used * small changes * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update pallets/solo-to-para/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * OnValidationData replaced by OnSystemEvent * fmt + cargo fix * disable-default-bootnodes for seedling script Co-authored-by: Ricardo Rius <ricardo@parity.io> Co-authored-by: Ricardo Rius <9488369+riusricardo@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
use codec::Encode;
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain, AbridgedHostConfiguration, ChannelStatus, CollationInfo, DmpMessageHandler,
|
||||
GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, MessageSendError, OnValidationData,
|
||||
GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, MessageSendError,
|
||||
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
|
||||
XcmpMessageHandler, XcmpMessageSource,
|
||||
};
|
||||
@@ -105,7 +105,7 @@ pub mod pallet {
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Something which can be notified when the validation data is set.
|
||||
type OnValidationData: OnValidationData;
|
||||
type OnSystemEvent: OnSystemEvent;
|
||||
|
||||
/// Returns the parachain ID we are running with.
|
||||
type SelfParaId: Get<ParaId>;
|
||||
@@ -329,6 +329,7 @@ pub mod pallet {
|
||||
let validation_code = <PendingValidationCode<T>>::take();
|
||||
|
||||
Self::put_parachain_code(&validation_code);
|
||||
<T::OnSystemEvent as OnSystemEvent>::on_validation_code_applied();
|
||||
Self::deposit_event(Event::ValidationFunctionApplied(vfp.relay_parent_number));
|
||||
},
|
||||
Some(relay_chain::v1::UpgradeGoAhead::Abort) => {
|
||||
@@ -354,7 +355,7 @@ pub mod pallet {
|
||||
<RelevantMessagingState<T>>::put(relevant_messaging_state.clone());
|
||||
<HostConfiguration<T>>::put(host_config);
|
||||
|
||||
<T::OnValidationData as OnValidationData>::on_validation_data(&vfp);
|
||||
<T::OnSystemEvent as OnSystemEvent>::on_validation_data(&vfp);
|
||||
|
||||
// TODO: This is more than zero, but will need benchmarking to figure out what.
|
||||
let mut total_weight = 0;
|
||||
@@ -397,7 +398,7 @@ pub mod pallet {
|
||||
code: Vec<u8>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
Self::validate_authorized_upgrade(&code[..])?;
|
||||
Self::set_code_impl(code)?;
|
||||
Self::schedule_code_upgrade(code)?;
|
||||
AuthorizedUpgrade::<T>::kill();
|
||||
Ok(Pays::No.into())
|
||||
}
|
||||
@@ -883,7 +884,7 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
/// The implementation of the runtime upgrade functionality for parachains.
|
||||
fn set_code_impl(validation_function: Vec<u8>) -> DispatchResult {
|
||||
pub fn schedule_code_upgrade(validation_function: Vec<u8>) -> DispatchResult {
|
||||
// Ensure that `ValidationData` exists. We do not care about the validation data per se,
|
||||
// but we do care about the [`UpgradeRestrictionSignal`] which arrives with the same inherent.
|
||||
ensure!(<ValidationData<T>>::exists(), Error::<T>::ValidationDataNotAvailable,);
|
||||
@@ -949,7 +950,7 @@ pub struct ParachainSetCode<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Config> frame_system::SetCode<T> for ParachainSetCode<T> {
|
||||
fn set_code(code: Vec<u8>) -> DispatchResult {
|
||||
Pallet::<T>::set_code_impl(code)
|
||||
Pallet::<T>::schedule_code_upgrade(code)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1007,6 +1008,21 @@ pub trait CheckInherents<Block: BlockT> {
|
||||
) -> frame_support::inherent::CheckInherentsResult;
|
||||
}
|
||||
|
||||
/// Something that should be informed about system related events.
|
||||
///
|
||||
/// This includes events like [`on_validation_data`](Self::on_validation_data) that is being
|
||||
/// called when the parachain inherent is executed that contains the validation data.
|
||||
/// Or like [`on_validation_code_applied`](Self::on_validation_code_applied) that is called
|
||||
/// when the new validation is written to the state. This means that
|
||||
/// from the next block the runtime is being using this new code.
|
||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||
pub trait OnSystemEvent {
|
||||
/// Called in each blocks once when the validation data is set by the inherent.
|
||||
fn on_validation_data(data: &PersistedValidationData);
|
||||
/// Called when the validation code is being applied, aka from the next block on this is the new runtime.
|
||||
fn on_validation_code_applied();
|
||||
}
|
||||
|
||||
/// Implements [`BlockNumberProvider`] that returns relay chain block number fetched from
|
||||
/// validation data.
|
||||
/// NTOE: When validation data is not available (e.g. within on_initialize), 0 will be returned.
|
||||
|
||||
@@ -100,7 +100,7 @@ impl frame_system::Config for Test {
|
||||
}
|
||||
impl Config for Test {
|
||||
type Event = Event;
|
||||
type OnValidationData = ();
|
||||
type OnSystemEvent = ();
|
||||
type SelfParaId = ParachainId;
|
||||
type OutboundXcmpMessageSource = FromThreadLocal;
|
||||
type DmpMessageHandler = SaveIntoThreadLocal;
|
||||
|
||||
Reference in New Issue
Block a user