mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Make polkadot-parachain call validate_block instead of validate (#297)
* Make `polkadot-parachain` call `validate_block` instead of `validate` Also switch to rust 2018 in the crate * Use `rstd` * Make `load_params` a pointer
This commit is contained in:
@@ -18,9 +18,7 @@
|
||||
|
||||
#![no_std]
|
||||
|
||||
#![feature(
|
||||
alloc, core_intrinsics, lang_items, core_panic_info, alloc_error_handler
|
||||
)]
|
||||
#![feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)]
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
|
||||
@@ -40,30 +38,30 @@ pub fn panic(_info: &panic::PanicInfo) -> ! {
|
||||
|
||||
#[alloc_error_handler]
|
||||
#[no_mangle]
|
||||
pub fn oom(_: ::core::alloc::Layout) -> ! {
|
||||
pub fn oom(_: core::alloc::Layout) -> ! {
|
||||
unsafe {
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn validate(offset: usize, len: usize) -> usize {
|
||||
let params = unsafe { ::parachain::wasm_api::load_params(offset, len) };
|
||||
pub extern fn validate_block(params: *const u8, len: usize) -> usize {
|
||||
let params = unsafe { parachain::wasm_api::load_params(params, len) };
|
||||
let parent_head = HeadData::decode(&mut ¶ms.parent_head[..])
|
||||
.expect("invalid parent head format.");
|
||||
|
||||
let block_data = BlockData::decode(&mut ¶ms.block_data[..])
|
||||
.expect("invalid block data format.");
|
||||
|
||||
let parent_hash = ::tiny_keccak::keccak256(¶ms.parent_head[..]);
|
||||
let parent_hash = tiny_keccak::keccak256(¶ms.parent_head[..]);
|
||||
|
||||
// we also add based on incoming data from messages. ignoring unknown message
|
||||
// kinds.
|
||||
let from_messages = ::adder::process_messages(
|
||||
let from_messages = adder::process_messages(
|
||||
params.ingress.iter().map(|incoming| &incoming.data[..])
|
||||
);
|
||||
|
||||
match ::adder::execute(parent_hash, parent_head, &block_data, from_messages) {
|
||||
match adder::execute(parent_hash, parent_head, &block_data, from_messages) {
|
||||
Ok(new_head) => parachain::wasm_api::write_result(
|
||||
ValidationResult { head_data: new_head.encode() }
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user