mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 02:57:57 +00:00
Adds support for checking the timestamp inherent while validating a block (#494)
* Adds support for checking the timestamp inherent while validating a block This adds support for checking the timestamp inherent while validating a block. This will use the relay chain slot number * relay chain slot duration to calculate a timestamp. This timestamp is used to check the timestamp in the timestamp inherent. * Update polkadot-parachains/rococo-runtime/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update polkadot-parachains/statemine-runtime/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update primitives/timestamp/src/lib.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Fix warnings Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
+21
-18
@@ -18,22 +18,21 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::{RuntimeDebug, traits::Block as BlockT};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::weights::Weight;
|
||||
use sp_runtime::{traits::Block as BlockT, RuntimeDebug};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub use polkadot_core_primitives::InboundDownwardMessage;
|
||||
pub use polkadot_parachain::primitives::{Id as ParaId, UpwardMessage, ValidationParams};
|
||||
pub use polkadot_primitives::v1::{
|
||||
PersistedValidationData, AbridgedHostConfiguration, AbridgedHrmpChannel,
|
||||
AbridgedHostConfiguration, AbridgedHrmpChannel, PersistedValidationData,
|
||||
};
|
||||
|
||||
/// A module that re-exports relevant relay chain definitions.
|
||||
pub mod relay_chain {
|
||||
pub use polkadot_core_primitives::*;
|
||||
pub use polkadot_primitives::v1;
|
||||
pub use polkadot_primitives::v1::well_known_keys;
|
||||
pub use polkadot_primitives::{v1, v1::well_known_keys};
|
||||
}
|
||||
use relay_chain::BlockNumber as RelayBlockNumber;
|
||||
|
||||
@@ -95,13 +94,13 @@ pub trait DmpMessageHandler {
|
||||
///
|
||||
/// Also, process messages up to some `max_weight`.
|
||||
fn handle_dmp_messages(
|
||||
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>,
|
||||
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
|
||||
max_weight: Weight,
|
||||
) -> Weight;
|
||||
}
|
||||
impl DmpMessageHandler for () {
|
||||
fn handle_dmp_messages(
|
||||
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>,
|
||||
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
|
||||
_max_weight: Weight,
|
||||
) -> Weight {
|
||||
iter.for_each(drop);
|
||||
@@ -115,13 +114,13 @@ pub trait XcmpMessageHandler {
|
||||
/// messages).
|
||||
///
|
||||
/// Also, process messages up to some `max_weight`.
|
||||
fn handle_xcmp_messages<'a, I: Iterator<Item=(ParaId, RelayBlockNumber, &'a [u8])>>(
|
||||
fn handle_xcmp_messages<'a, I: Iterator<Item = (ParaId, RelayBlockNumber, &'a [u8])>>(
|
||||
iter: I,
|
||||
max_weight: Weight,
|
||||
) -> Weight;
|
||||
}
|
||||
impl XcmpMessageHandler for () {
|
||||
fn handle_xcmp_messages<'a, I: Iterator<Item=(ParaId, RelayBlockNumber, &'a [u8])>>(
|
||||
fn handle_xcmp_messages<'a, I: Iterator<Item = (ParaId, RelayBlockNumber, &'a [u8])>>(
|
||||
iter: I,
|
||||
_max_weight: Weight,
|
||||
) -> Weight {
|
||||
@@ -158,15 +157,13 @@ pub enum ChannelStatus {
|
||||
/// A means of figuring out what outbound XCMP messages should be being sent.
|
||||
pub trait XcmpMessageSource {
|
||||
/// Take a single XCMP message from the queue for the given `dest`, if one exists.
|
||||
fn take_outbound_messages(
|
||||
maximum_channels: usize,
|
||||
) -> Vec<(ParaId, Vec<u8>)>;
|
||||
fn take_outbound_messages(maximum_channels: usize) -> Vec<(ParaId, Vec<u8>)>;
|
||||
}
|
||||
|
||||
impl XcmpMessageSource for () {
|
||||
fn take_outbound_messages(
|
||||
_maximum_channels: usize,
|
||||
) -> Vec<(ParaId, Vec<u8>)> { vec![] }
|
||||
fn take_outbound_messages(_maximum_channels: usize) -> Vec<(ParaId, Vec<u8>)> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
/// The "quality of service" considerations for message sending.
|
||||
@@ -191,7 +188,7 @@ pub trait OnValidationData {
|
||||
///
|
||||
/// This is send as PoV (proof of validity block) to the relay-chain validators. There it will be
|
||||
/// passed to the parachain validation Wasm blob to be validated.
|
||||
#[derive(codec::Encode, codec::Decode)]
|
||||
#[derive(codec::Encode, codec::Decode, Clone)]
|
||||
pub struct ParachainBlockData<B: BlockT> {
|
||||
/// The header of the parachain block.
|
||||
header: B::Header,
|
||||
@@ -241,7 +238,13 @@ impl<B: BlockT> ParachainBlockData<B> {
|
||||
}
|
||||
|
||||
/// Deconstruct into the inner parts.
|
||||
pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec<B::Extrinsic>, sp_trie::CompactProof) {
|
||||
pub fn deconstruct(
|
||||
self,
|
||||
) -> (
|
||||
B::Header,
|
||||
sp_std::vec::Vec<B::Extrinsic>,
|
||||
sp_trie::CompactProof,
|
||||
) {
|
||||
(self.header, self.extrinsics, self.storage_proof)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user