polkadot_parachain_primitives/lib.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! Defines primitive types for creating or validating a parachain.
18//!
19//! When compiled with standard library support, this crate exports a `wasm`
20//! module that can be used to validate parachain WASM.
21//!
22//! ## Parachain WASM
23//!
24//! Polkadot parachain WASM is in the form of a module which imports a memory
25//! instance and exports a function `validate_block`.
26//!
27//! `validate` accepts as input two `i32` values, representing a pointer/length pair
28//! respectively, that encodes [`ValidationParams`](primitives::ValidationParams).
29//!
30//! `validate` returns an `u64` which is a pointer to an `u8` array and its length.
31//! The data in the array is expected to be a SCALE encoded
32//! [`ValidationResult`](primitives::ValidationResult).
33//!
34//! ASCII-diagram demonstrating the return data format:
35//!
36//! ```ignore
37//! [pointer][length]
38//! 32bit 32bit
39//! ^~~ returned pointer & length
40//! ```
41//!
42//! The wasm-api (enabled only when `std` feature is not enabled and `wasm-api` feature is enabled)
43//! provides utilities for setting up a parachain WASM module in Rust.
44
45#![cfg_attr(not(feature = "std"), no_std)]
46
47pub mod primitives;
48
49#[cfg(all(not(feature = "std"), feature = "wasm-api"))]
50mod wasm_api;
51
52#[cfg(all(not(feature = "std"), feature = "wasm-api"))]
53pub use wasm_api::*;
54
55extern crate alloc;