mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Update to latest Substrate master (#320)
* Make `collator::Network` require `Send + Sync` to make it work * Update packages * Update to latest Substrate * Make it compile and make tests work * Use `polkadot-master` * Fix CI * Remove `build.sh` from readmes * Delete old stuff * Bring one back
This commit is contained in:
committed by
André Silva
parent
d99f721540
commit
c0b065837e
@@ -1,23 +0,0 @@
|
||||
[package]
|
||||
name = "adder-wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
adder = { path = ".." }
|
||||
parachain = { package = "polkadot-parachain", path = "../../../parachain", default-features = false, features = ["wasm-api"] }
|
||||
tiny-keccak = "1.4"
|
||||
dlmalloc = { version = "0.1.3", features = ["global"] }
|
||||
|
||||
# We need to make sure the global allocator is disabled until we have support of full substrate externalities
|
||||
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, features = [ "no_global_allocator" ] }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
|
||||
[workspace]
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright 2017 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! WASM validation for adder parachain.
|
||||
|
||||
#![no_std]
|
||||
|
||||
#![feature(core_intrinsics, lang_items, core_panic_info, alloc_error_handler)]
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
|
||||
|
||||
use core::{intrinsics, panic};
|
||||
use parachain::ValidationResult;
|
||||
use parachain::codec::{Encode, Decode};
|
||||
use adder::{HeadData, BlockData};
|
||||
|
||||
#[panic_handler]
|
||||
#[no_mangle]
|
||||
pub fn panic(_info: &panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
intrinsics::abort()
|
||||
}
|
||||
}
|
||||
|
||||
#[alloc_error_handler]
|
||||
#[no_mangle]
|
||||
pub fn oom(_: core::alloc::Layout) -> ! {
|
||||
unsafe {
|
||||
intrinsics::abort();
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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[..]);
|
||||
|
||||
// we also add based on incoming data from messages. ignoring unknown message
|
||||
// kinds.
|
||||
let from_messages = adder::process_messages(
|
||||
params.ingress.iter().map(|incoming| &incoming.data[..])
|
||||
);
|
||||
|
||||
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() }
|
||||
),
|
||||
Err(_) => panic!("execution failure"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user