mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Switch parachain interface to new runtime_interface macro (#665)
* Make use of `runtime_interface` for parachain externalities This also changes the encoding of the `ValidationResult` return value to match the default encoding used in Substrate. * Fix compilation for web * Update `Cargo.lock` * Include feedback * Move proc macro * Update parachain/src/lib.rs Co-Authored-By: Robert Habermeier <rphmeier@gmail.com> Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -20,6 +20,6 @@ fn main() {
|
||||
build_current_project_with_rustflags(
|
||||
"wasm_binary.rs",
|
||||
WasmBuilderSource::Crates("1.0.7"),
|
||||
"-C link-arg=--import-memory",
|
||||
"-C link-arg=--export=__heap_base",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ primitives = { package = "polkadot-primitives", path = "../../../primitives" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
client = { package = "sc-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
client-api = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
parking_lot = "0.9.0"
|
||||
parking_lot = "0.10.0"
|
||||
codec = { package = "parity-scale-codec", version = "1.1.0" }
|
||||
ctrlc = { version = "3.1.3", features = ["termination"] }
|
||||
futures = "0.3.1"
|
||||
exit-future = "0.2.0"
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::sync::Arc;
|
||||
|
||||
use adder::{HeadData as AdderHead, BlockData as AdderBody};
|
||||
use sp_core::{Pair, Blake2Hasher};
|
||||
use parachain::codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{
|
||||
Hash, Block,
|
||||
parachain::{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use crate::{HeadData, BlockData};
|
||||
use core::{intrinsics, panic};
|
||||
use parachain::ValidationResult;
|
||||
use parachain::codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
#[panic_handler]
|
||||
#[no_mangle]
|
||||
@@ -38,8 +38,8 @@ pub fn oom(_: core::alloc::Layout) -> ! {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn validate_block(params: *const u8, len: usize) -> usize {
|
||||
let params = unsafe { parachain::wasm_api::load_params(params, len) };
|
||||
pub extern fn validate_block(params: *const u8, len: usize) -> u64 {
|
||||
let params = unsafe { parachain::load_params(params, len) };
|
||||
let parent_head = HeadData::decode(&mut ¶ms.parent_head[..])
|
||||
.expect("invalid parent head format.");
|
||||
|
||||
@@ -55,9 +55,9 @@ pub extern fn validate_block(params: *const u8, len: usize) -> usize {
|
||||
);
|
||||
|
||||
match crate::execute(parent_hash, parent_head, &block_data, from_messages) {
|
||||
Ok(new_head) => parachain::wasm_api::write_result(
|
||||
ValidationResult { head_data: new_head.encode() }
|
||||
Ok(new_head) => parachain::write_result(
|
||||
&ValidationResult { head_data: new_head.encode() }
|
||||
),
|
||||
Err(_) => panic!("execution failure"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ fn main() {
|
||||
build_current_project_with_rustflags(
|
||||
"wasm_binary.rs",
|
||||
WasmBuilderSource::Crates("1.0.7"),
|
||||
"-C link-arg=--import-memory",
|
||||
"-C link-arg=--export=__heap_base",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user