Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/cli/src/params/shared_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ pub struct SharedParams {
#[arg(long, short = 'd', value_name = "PATH")]
pub base_path: Option<PathBuf>,

/// Sets a custom logging filter. Syntax is <target>=<level>, e.g. -lsync=debug.
/// Sets a custom logging filter. Syntax is `<target>=<level>`, e.g. -lsync=debug.
///
/// Log levels (least to most verbose) are error, warn, info, debug, and trace.
/// By default, all targets log `info`. The global log level can be set with -l<level>.
/// By default, all targets log `info`. The global log level can be set with `-l<level>`.
#[arg(short = 'l', long, value_name = "LOG_PATTERN", num_args = 1..)]
pub log: Vec<String>,

Expand All @@ -71,7 +71,7 @@ pub struct SharedParams {
#[arg(long)]
pub enable_log_reloading: bool,

/// Sets a custom profiling filter. Syntax is the same as for logging: <target>=<level>
/// Sets a custom profiling filter. Syntax is the same as for logging: `<target>=<level>`.
#[arg(long, value_name = "TARGETS")]
pub tracing_targets: Option<String>,

Expand Down
146 changes: 122 additions & 24 deletions primitives/runtime-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,132 @@
//! The following table documents how values of types are passed between the wasm and
//! the host side and how they are converted into the corresponding type.
//!
//! | Type | FFI type | Conversion |
//! |----|----|----|
//! | `u8` | `u32` | zero-extended to 32-bits |
//! | `u16` | `u32` | zero-extended to 32-bits |
//! | `u32` | `u32` | `Identity` |
//! | `u64` | `u64` | `Identity` |
//! | `i128` | `u32` | `v.as_ptr()` (pointer to a 16 byte array) |
//! | `i8` | `i32` | sign-extended to 32-bits |
//! | `i16` | `i32` | sign-extended to 32-bits |
//! | `i32` | `i32` | `Identity` |
//! | `i64` | `i64` | `Identity` |
//! | `u128` | `u32` | `v.as_ptr()` (pointer to a 16 byte array) |
//! | `bool` | `u32` | `if v { 1 } else { 0 }` |
//! | `&str` | `u64` | <code>v.len() 32bit << 32 &#124; v.as_ptr() 32bit</code> |
//! | `&[u8]` | `u64` | <code>v.len() 32bit << 32 &#124; v.as_ptr() 32bit</code> |
//! | `Vec<u8>` | `u64` | <code>v.len() 32bit << 32 &#124; v.as_ptr() 32bit</code> |
//! | `Vec<T> where T: Encode` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32
//! &#124; e.as_ptr() 32bit</code> | | `&[T] where T: Encode` | `u64` | `let e =
//! v.encode();`<br><br><code>e.len() 32bit << 32 &#124; e.as_ptr() 32bit</code> | | `[u8; N]` |
//! `u32` | `v.as_ptr()` | | `*const T` | `u32` | `Identity` |
//! | `Option<T>` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 &#124; e.as_ptr()
//! 32bit</code> | | [`T where T: PassBy<PassBy=Inner>`](./pass_by#Inner) | Depends on inner |
//! Depends on inner | | [`T where T: PassBy<PassBy=Codec>`](./pass_by#Codec)|`u64`|<code>v.len()
//! 32bit << 32 &#124;v.as_ptr() 32bit</code>|
//! <table>
//! <thread>
//! <tr>
//! <th>Type</th>
//! <th>FFI Type</th>
//! <th>Conversion</th>
//! </tr>
//! </thread>
//! <tbody>
//! <tr>
//! <td><code>u8</code></td>
//! <td><code>u32</code></td>
//! <td>zero-extended to 32-bits</td>
//! </tr>
//! <tr>
//! <td><code>u16</code></td>
//! <td><code>u32</code></td>
//! <td>zero-extended to 32-bits</td>
//! </tr>
//! <tr>
//! <td><code>u32</code></td>
//! <td><code>u32</code></td>
//! <td><code>Identity</code></td>
//! </tr>
//! <tr>
//! <td><code>u64</code></td>
//! <td><code>u64</code></td>
//! <td><code>Identity</code></td>
//! </tr>
//! <tr>
//! <td><code>i128</code></td>
//! <td><code>u32</code></td>
//! <td><code>v.as_ptr()</code>(pointer to a 16 byte array)</td>
//! </tr>
//! <tr>
//! <td><code>i8</code></td>
//! <td><code>i32</code></td>
//! <td>sign-extended to 32-bits</td>
//! </tr>
//! <tr>
//! <td><code>i16</code></td>
//! <td><code>i32</code></td>
//! <td>sign-extended to 32-bits</td>
//! </tr>
//! <tr>
//! <td><code>i32</code></td>
//! <td><code>i32</code></td>
//! <td><code>Identity</code></td>
//! </tr>
//! <tr>
//! <td><code>i64</code></td>
//! <td><code>i64</code></td>
//! <td><code>Identity</code></td>
//! </tr>
//! <tr>
//! <td><code>u128</code></td>
//! <td><code>u32</code></td>
//! <td><code>v.as_ptr()</code>(pointer to a 16 byte array)</td>
//! </tr>
//! <tr>
//! <td><code>bool</code></td>
//! <td><code>u32</code></td>
//! <td><code>if v { 1 } else { 0 }</code></td>
//! </tr>
//! <tr>
//! <td><code>&str</code></td>
//! <td><code>u64</code></td>
//! <td><code>v.len() 32bit<< 32 &#124; v.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><code>&[u8]</code></td>
//! <td><code>u64</code></td>
//! <td><code>v.len() 32bit<< 32 &#124; v.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><code>Vec<u8></code></td>
//! <td><code>u64</code></td>
//! <td><code>v.len() 32bit<< 32 &#124; v.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><code>Vec<T>where T: Encode</code></td>
//! <td><code>u64</code></td>
//! <td><code>let e = v.encode();</code><br>
//! <code>e.len() 32bit<< 32 &#124; e.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><code>&[T] where T: Encode</code></td>
//! <td><code>u64</code></td>
//! <td><code>let e = v.encode();</code><br>
//! <code>e.len() 32bit<< 32 &#124; e.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><code>[u8; N]</code></td>
//! <td><code>u32</code></td>
//! <td><code>v.as_ptr()</code></td>
//! </tr>
//! <tr>
//! <td><code>*const T</code></td>
//! <td><code>u32</code></td>
//! <td><code>Identity</code></td>
//! </tr>
//! <tr>
//! <td><code>Option<T><code></td>
//! <td><code>u64</code></td>
//! <td><code>let e = v.encode();</code><br>
//! <code>e.len() 32bit<< 32 &#124; e.as_ptr() 32bit</code></td>
//! </tr>
//! <tr>
//! <td><a href="./pass_by/index.html#Inner"><code>T where T: PassBy<PassBy=Inner></code></a></td>
//! <td>Depends on inner</td>
//! <td>Depends on inner</td>
//! </tr>
//! <tr>
//! <td><a href="./pass_by/index.html#Codec"><code>T where T: PassBy<PassBy=Codec></code></a></td>
//! <td><code>u64</code></td>
//! <td><code>v.len() 32bit<< 32 &#124; v.as_ptr() 32bit</code></td>
//! </tr>
//! </tbody>
//! </table>
//!
//! `Identity` means that the value is converted directly into the corresponding FFI type.
#![cfg_attr(not(feature = "std"), no_std)]
// `cargo doc` doc thinks that `Vec<u8>` has an invalid `u8` HTML tag which cannot be fixed by
// backticks...
#![allow(rustdoc::invalid_html_tags)]

extern crate self as sp_runtime_interface;

Expand Down
2 changes: 1 addition & 1 deletion primitives/runtime-interface/test-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait TestApi {
/// # Note
///
/// We return a `Vec<u32>` because this will use the code path that uses SCALE
/// to pass the data between native/wasm. (Vec<u8> is passed without encoding the
/// to pass the data between native/wasm. (`Vec<u8>` is passed without encoding the
/// data)
fn return_16kb() -> Vec<u32> {
vec![0; 4 * 1024]
Expand Down