polkadot_parachain/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#![warn(unused_crate_dependencies)]
18
19//! Defines primitive types for creating or validating a parachain.
20//!
21//! When compiled with standard library support, this crate exports a `wasm`
22//! module that can be used to validate parachain WASM.
23//!
24//! ## Parachain WASM
25//!
26//! Polkadot parachain WASM is in the form of a module which imports a memory
27//! instance and exports a function `validate_block`.
28//!
29//! `validate` accepts as input two `i32` values, representing a pointer/length pair
30//! respectively, that encodes [`ValidationParams`].
31//!
32//! `validate` returns an `u64` which is a pointer to an `u8` array and its length.
33//! The data in the array is expected to be a SCALE encoded [`ValidationResult`].
34//!
35//! ASCII-diagram demonstrating the return data format:
36//!
37//! ```ignore
38//! [pointer][length]
39//! 32bit 32bit
40//! ^~~ returned pointer & length
41//! ```
42//!
43//! The wasm-api (enabled only when `std` feature is not enabled and `wasm-api` feature is enabled)
44//! provides utilities for setting up a parachain WASM module in Rust.
45
46#![cfg_attr(not(feature = "std"), no_std)]
47
48pub mod primitives;
49
50#[cfg(all(not(feature = "std"), feature = "wasm-api"))]
51mod wasm_api;
52
53#[cfg(all(not(feature = "std"), feature = "wasm-api"))]
54pub use wasm_api::*;