mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Compile polkadot-runtime both for Wasm ad native, allowing for testing and direct usage.
This commit is contained in:
Generated
+11
@@ -499,6 +499,13 @@ dependencies = [
|
|||||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "native-runtime"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"runtime-support 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "net2"
|
name = "net2"
|
||||||
version = "0.2.31"
|
version = "0.2.31"
|
||||||
@@ -808,6 +815,10 @@ dependencies = [
|
|||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "runtime-support"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ members = [
|
|||||||
"primitives",
|
"primitives",
|
||||||
"rpc",
|
"rpc",
|
||||||
"rpc_servers",
|
"rpc_servers",
|
||||||
|
"native-runtime",
|
||||||
"serializer",
|
"serializer",
|
||||||
"state_machine",
|
"state_machine",
|
||||||
"validator",
|
"validator",
|
||||||
]
|
]
|
||||||
exclude = [
|
exclude = [
|
||||||
"runtime"
|
"wasm-runtime"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
|
|||||||
} else { 0 }
|
} else { 0 }
|
||||||
} else { 0 }
|
} else { 0 }
|
||||||
},
|
},
|
||||||
ext_deposit_log(_log_data: *const u8, _log_len: u32) {
|
ext_deposit_log(_log_data: *const u8, _log_len: u32) => {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
=> <'e, E: Externalities + 'e>
|
=> <'e, E: Externalities + 'e>
|
||||||
@@ -175,8 +175,8 @@ impl CodeExecutor for WasmExecutor {
|
|||||||
let returned = program
|
let returned = program
|
||||||
.params_with_external("env", &mut fec)
|
.params_with_external("env", &mut fec)
|
||||||
.map(|p| p
|
.map(|p| p
|
||||||
.add_argument(I32(offset as u32))
|
.add_argument(I32(offset as i32))
|
||||||
.add_argument(I32(size as u32)))
|
.add_argument(I32(size as i32)))
|
||||||
.and_then(|p| module.execute_export(method, p))
|
.and_then(|p| module.execute_export(method, p))
|
||||||
.map_err(|_| -> Error { ErrorKind::Runtime.into() })?;
|
.map_err(|_| -> Error { ErrorKind::Runtime.into() })?;
|
||||||
|
|
||||||
@@ -233,8 +233,8 @@ mod tests {
|
|||||||
let returned = program
|
let returned = program
|
||||||
.params_with_external("env", &mut fec)
|
.params_with_external("env", &mut fec)
|
||||||
.map(|p| p
|
.map(|p| p
|
||||||
.add_argument(I32(offset as u32))
|
.add_argument(I32(offset as i32))
|
||||||
.add_argument(I32(size as u32)))
|
.add_argument(I32(size as i32)))
|
||||||
.and_then(|p| module.execute_export("test_data_in", p))
|
.and_then(|p| module.execute_export("test_data_in", p))
|
||||||
.map_err(|_| -> Error { ErrorKind::Runtime.into() }).expect("function should be callable");
|
.map_err(|_| -> Error { ErrorKind::Runtime.into() }).expect("function should be callable");
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "native-runtime"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["with-std"]
|
||||||
|
with-std = []
|
||||||
|
without-std = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
runtime-support = { path = "./support", version = "0.1" }
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../wasm-runtime/polkadot/src
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "runtime-support"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
strict = []
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
pub use std::vec::Vec;
|
||||||
|
|
||||||
|
pub fn storage(_key: &[u8]) -> Vec<u8> { vec![] }
|
||||||
|
pub fn storage_into<T: Sized>(_key: &[u8]) -> Option<T> { None }
|
||||||
|
pub fn set_storage(_key: &[u8], _value: &[u8]) {}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! impl_stubs {
|
||||||
|
($( $name:ident ),*) => {}
|
||||||
|
}
|
||||||
@@ -8,3 +8,8 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
runtime-support = { path = "../support", version = "0.1" }
|
runtime-support = { path = "../support", version = "0.1" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["without-std"]
|
||||||
|
with-std = []
|
||||||
|
without-std = []
|
||||||
+14
-11
@@ -1,14 +1,9 @@
|
|||||||
#![no_std]
|
#![cfg_attr(feature = "without-std", no_std)]
|
||||||
#![feature(lang_items)]
|
|
||||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||||
|
|
||||||
#![feature(alloc)]
|
|
||||||
extern crate alloc;
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate runtime_support;
|
extern crate runtime_support;
|
||||||
use runtime_support::{set_storage, storage, storage_into};
|
use runtime_support::{set_storage, storage, storage_into, Vec};
|
||||||
|
|
||||||
/// The hash of an ECDSA pub key which is used to identify an external transactor.
|
/// The hash of an ECDSA pub key which is used to identify an external transactor.
|
||||||
pub type AccountID = [u8; 32];
|
pub type AccountID = [u8; 32];
|
||||||
@@ -116,12 +111,12 @@ fn get_environment() -> EnvironmentHolder {
|
|||||||
// TODO: include RLP implementation
|
// TODO: include RLP implementation
|
||||||
// TODO: add keccak256 (or some better hashing scheme) & ECDSA-recover (or some better sig scheme)
|
// TODO: add keccak256 (or some better hashing scheme) & ECDSA-recover (or some better sig scheme)
|
||||||
|
|
||||||
fn execute_block(_input: Vec<u8>) -> Vec<u8> {
|
pub fn execute_block(_input: Vec<u8>) -> Vec<u8> {
|
||||||
let block = Block::from_rlp(&_input);
|
let block = Block::from_rlp(&_input);
|
||||||
environment::execute_block(&block)
|
environment::execute_block(&block)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_transaction(_input: Vec<u8>) -> Vec<u8> {
|
pub fn execute_transaction(_input: Vec<u8>) -> Vec<u8> {
|
||||||
let tx = Transaction::from_rlp(&_input);
|
let tx = Transaction::from_rlp(&_input);
|
||||||
environment::execute_transaction(&tx)
|
environment::execute_transaction(&tx)
|
||||||
}
|
}
|
||||||
@@ -235,6 +230,11 @@ mod consensus {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The number of blocks in each session.
|
||||||
|
pub fn session_length() -> BlockNumber {
|
||||||
|
10
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the session key of `_validator` to `_session`. This doesn't take effect until the next
|
/// Sets the session key of `_validator` to `_session`. This doesn't take effect until the next
|
||||||
/// session.
|
/// session.
|
||||||
pub fn set_session_key(_validator: AccountID, _session: AccountID) {
|
pub fn set_session_key(_validator: AccountID, _session: AccountID) {
|
||||||
@@ -260,11 +260,14 @@ mod staking {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// The length of a staking era in blocks.
|
/// The length of a staking era in blocks.
|
||||||
fn era_length() -> BlockNumber { unimplemented!() }
|
pub fn era_length() -> BlockNumber { sessions_per_era() * consensus::session_length() }
|
||||||
|
|
||||||
|
/// The length of a staking era in sessions.
|
||||||
|
pub fn sessions_per_era() -> BlockNumber { 10 }
|
||||||
|
|
||||||
/// The era has changed - enact new staking set.
|
/// The era has changed - enact new staking set.
|
||||||
///
|
///
|
||||||
/// NOTE: This is always a session change.
|
/// NOTE: This always happens on a session change.
|
||||||
fn next_era() { unimplemented!() }
|
fn next_era() { unimplemented!() }
|
||||||
|
|
||||||
/// The balance of a given account.
|
/// The balance of a given account.
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
|
#![feature(alloc)]
|
||||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||||
|
|
||||||
#![feature(alloc)]
|
#![feature(alloc)]
|
||||||
|
//#[macro_use]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
use alloc::vec::Vec;
|
pub use alloc::vec::Vec;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
|
||||||
extern crate pwasm_libc;
|
extern crate pwasm_libc;
|
||||||
@@ -36,16 +38,17 @@ pub fn storage(key: &[u8]) -> Vec<u8> {
|
|||||||
pub fn storage_into<T: Sized>(key: &[u8]) -> Option<T> {
|
pub fn storage_into<T: Sized>(key: &[u8]) -> Option<T> {
|
||||||
let mut result: T;
|
let mut result: T;
|
||||||
let size = mem::size_of::<T>();
|
let size = mem::size_of::<T>();
|
||||||
let mut written;
|
let written;
|
||||||
unsafe {
|
unsafe {
|
||||||
result = mem::uninitialized();
|
result = mem::uninitialized();
|
||||||
let result_as_byte_blob = mem::transmute::<*mut T, *mut u8>(&mut result);
|
let result_as_byte_blob = mem::transmute::<*mut T, *mut u8>(&mut result);
|
||||||
written = ext_get_storage_into(&key[0], key.len() as u32, result_as_byte_blob, size as u32) as usize;
|
written = ext_get_storage_into(&key[0], key.len() as u32, result_as_byte_blob, size as u32) as usize;
|
||||||
}
|
}
|
||||||
// Only return a fully written value.
|
// Only return a fully written value.
|
||||||
match written {
|
if written == size {
|
||||||
size => Some(result),
|
Some(result)
|
||||||
_ => None,
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +99,7 @@ macro_rules! impl_stubs {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn $name(input_data: *mut u8, input_len: usize) -> u64 {
|
pub fn $name(input_data: *mut u8, input_len: usize) -> u64 {
|
||||||
let input = unsafe {
|
let input = unsafe {
|
||||||
super::alloc::vec::Vec::from_raw_parts(input_data, input_len, input_len)
|
$crate::Vec::from_raw_parts(input_data, input_len, input_len)
|
||||||
};
|
};
|
||||||
|
|
||||||
let output = super::$name(input);
|
let output = super::$name(input);
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
ba1707f874223553
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8291033049748019918,"features":"[]","target":14441046832906989149,"profile":731176819336294830,"deps":[],"local":[{"MtimeBased":[[1515500307,607755819],"/Users/gav/Core/polkadot/wasm-runtime/target/debug/.fingerprint/pwasm-libc-e72991cbfafd2b71/dep-lib-pwasm_libc-e72991cbfafd2b71"]}],"rustflags":[]}
|
||||||
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/debug/deps/pwasm_libc-b023388293df7da5: /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs
|
||||||
|
|
||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/debug/deps/pwasm_libc-b023388293df7da5.d: /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs
|
||||||
|
|
||||||
|
/Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs:
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
ee4d5b5400bf9619
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8294656847287967537,"features":"[]","target":1127969377865045195,"profile":42358739494345872,"deps":[["pwasm-libc v0.1.0 (file:///Users/gav/Core/polkadot/wasm-runtime/pwasm-libc)",6197225601014249845]],"local":[{"MtimeBased":[[1515500743,816953612],"/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/.fingerprint/pwasm-alloc-e37006629c0ab425/dep-lib-pwasm_alloc-e37006629c0ab425"]}],"rustflags":[]}
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
7539698dd9f70056
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8294656847287967537,"features":"[]","target":14441046832906989149,"profile":42358739494345872,"deps":[],"local":[{"MtimeBased":[[1515500743,598235760],"/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/.fingerprint/pwasm-libc-9375d1aea6d3c98f/dep-lib-pwasm_libc-9375d1aea6d3c98f"]}],"rustflags":[]}
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
d4940d6f62cf958e
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8294656847287967537,"features":"[\"default\", \"without-std\"]","target":15371597068611496627,"profile":42358739494345872,"deps":[["runtime-support v0.1.0 (file:///Users/gav/Core/polkadot/wasm-runtime/support)",2223771509741189442]],"local":[{"MtimeBased":[[1515501953,507863132],"/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/.fingerprint/runtime-polkadot-1e4c8740d04ba868/dep-lib-runtime_polkadot"]}],"rustflags":[]}
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
42f9c1f3676cdc1e
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8294656847287967537,"features":"[]","target":14982045766639954252,"profile":42358739494345872,"deps":[["pwasm-alloc v0.1.0 (file:///Users/gav/Core/polkadot/wasm-runtime/pwasm-alloc)",1843871105590971886],["pwasm-libc v0.1.0 (file:///Users/gav/Core/polkadot/wasm-runtime/pwasm-libc)",6197225601014249845]],"local":[{"MtimeBased":[[1515500954,752149165],"/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/.fingerprint/runtime-support-5482fb51bf4d410e/dep-lib-runtime_support-5482fb51bf4d410e"]}],"rustflags":[]}
|
||||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
|||||||
|
9cf830998a9aef5e
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"rustc":8294656847287967537,"features":"[]","target":11385551307513482501,"profile":42358739494345872,"deps":[["runtime-support v0.1.0 (file:///Users/gav/Core/polkadot/wasm-runtime/support)",2223771509741189442]],"local":[{"MtimeBased":[[1515500955,389693545],"/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/.fingerprint/runtime-test-0ee9f37942e84b82/dep-lib-runtime_test"]}],"rustflags":[]}
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/libpwasm_alloc.rlib: /Users/gav/Core/polkadot/wasm-runtime/pwasm-alloc/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/libpwasm_libc.rlib: /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/libruntime_support.rlib: /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/support/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/pwasm-alloc/src/lib.rs
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm: /Users/gav/Core/polkadot/wasm-runtime/pwasm-alloc/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/support/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/polkadot/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
/Users/gav/Core/polkadot/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_test.wasm: /Users/gav/Core/polkadot/wasm-runtime/pwasm-alloc/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/test/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/pwasm-libc/src/lib.rs /Users/gav/Core/polkadot/wasm-runtime/support/src/lib.rs
|
||||||
Binary file not shown.
Reference in New Issue
Block a user