Switch parachain interface to new runtime_interface macro (#665)

* Make use of `runtime_interface` for parachain externalities

This also changes the encoding of the `ValidationResult` return value to
match the default encoding used in Substrate.

* Fix compilation for web

* Update `Cargo.lock`

* Include feedback

* Move proc macro

* Update parachain/src/lib.rs

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Bastian Köcher
2020-01-08 20:44:50 +01:00
committed by GitHub
parent 10f1f3a381
commit 06386558ae
16 changed files with 468 additions and 609 deletions
+1 -31
View File
@@ -35,7 +35,7 @@ use application_crypto::KeyTypeId;
use trie::TrieConfiguration;
pub use polkadot_parachain::{
Id, ParachainDispatchOrigin, LOWEST_USER_ID, UpwardMessage,
Id, ParachainDispatchOrigin, LOWEST_USER_ID, UpwardMessage, TargetedMessage,
};
/// The key type ID for a collator key.
@@ -164,36 +164,6 @@ pub struct DutyRoster {
pub validator_duty: Vec<Chain>,
}
/// A message targeted to a specific parachain.
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub struct TargetedMessage {
/// The target parachain.
pub target: Id,
/// The message data.
pub data: Vec<u8>,
}
impl AsRef<[u8]> for TargetedMessage {
fn as_ref(&self) -> &[u8] {
&self.data[..]
}
}
impl PartialOrd for TargetedMessage {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.target.cmp(&other.target))
}
}
impl Ord for TargetedMessage {
fn cmp(&self, other: &Self) -> Ordering {
self.target.cmp(&other.target)
}
}
/// Outgoing message data for a parachain candidate.
///
/// This is data produced by evaluating the candidate. It contains