First step for generating host externals out of the function definition in sr-io (#3567)

* Adds new wrapper traits for wasm executor

* Add new crate `substrate-wasm-interface`

Thew new crate holds types and traits for the communicating between the
wasm runtime and the host.

* Rewrite externals with new macro etc

* Fix vec initialization

* Make executor tests working

* Remove unused code + warnings

* Introduce `Pointer` and `WordSize` for working with wasm

* Fix tests and compilation

* Fix compilation

* Apply suggestions from code review

Co-Authored-By: Sergei Pepyakin <sergei@parity.io>

* Review feedback

* Remove unused conversions

* Make each host function its own struct

`HostFunctions` now just returns these function structs. Each function
can be executed by using one of the function structs. The inherent host
functions are now moved to the "normal" host functions.

* Remove byteorder

* Add floating point types

* Make pointer interface more safe

* Add type alias for wasm-interface Result

* More review comments
This commit is contained in:
Bastian Köcher
2019-09-10 16:07:25 +02:00
committed by GitHub
parent 86b3f2e1a7
commit 1450719acc
20 changed files with 1815 additions and 1462 deletions
+3 -4
View File
@@ -47,7 +47,7 @@ pub fn panic(info: &PanicInfo) -> ! {
#[cfg(not(feature = "no_oom"))]
#[alloc_error_handler]
pub extern fn oom(_: ::core::alloc::Layout) -> ! {
pub extern fn oom(_: core::alloc::Layout) -> ! {
static OOM_MSG: &str = "Runtime memory exhausted. Aborting";
unsafe {
@@ -980,10 +980,9 @@ impl OffchainApi for () {
unsafe { ext_is_validator.get()() == 1 }
}
fn submit_transaction<T: codec::Encode>(data: &T) -> Result<(), ()> {
let encoded_data = codec::Encode::encode(data);
fn submit_transaction(data: Vec<u8>) -> Result<(), ()> {
let ret = unsafe {
ext_submit_transaction.get()(encoded_data.as_ptr(), encoded_data.len() as u32)
ext_submit_transaction.get()(data.as_ptr(), data.len() as u32)
};
if ret == 0 {