mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Collator for the "adder" (formerly basic-add) parachain and various small fixes (#438)
* update basic_add wasm * wasm feature and collator feature * move test parachains around a little * fix wasm build for basic_add * move basic_add to adder, introduce README * minimal basic_add collator * ensure collator messages are sent in the right order * more logging * route consensus statements to all peers * minor bugfixes for parachains * genesis builder accounts for parachain heads * fix parachains tests * targets for txpool * tweak runtime + collator * fix version in adder-collator * consistency for overflowing * adjust comment * fix stable test run * remove dummy registration test * final grumbles
This commit is contained in:
committed by
GitHub
parent
f5aa4f6f79
commit
f4cd995558
@@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "adder-wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
adder = { path = ".." }
|
||||
polkadot-parachain = { path = "../../../parachain", default-features = false }
|
||||
wee_alloc = { version = "0.4.1" }
|
||||
pwasm-libc = { version = "0.2" }
|
||||
tiny-keccak = "1.4"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[target.release]
|
||||
panic = "abort"
|
||||
lto = true
|
||||
|
||||
[workspace]
|
||||
@@ -0,0 +1,73 @@
|
||||
// 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(
|
||||
alloc, core_intrinsics, lang_items, panic_implementation, core_panic_info,
|
||||
alloc_error_handler
|
||||
)]
|
||||
|
||||
extern crate alloc;
|
||||
extern crate wee_alloc;
|
||||
extern crate pwasm_libc;
|
||||
extern crate adder;
|
||||
extern crate polkadot_parachain as parachain;
|
||||
extern crate tiny_keccak;
|
||||
|
||||
// Define global allocator.
|
||||
#[global_allocator]
|
||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||
|
||||
use core::{intrinsics, panic};
|
||||
use parachain::ValidationResult;
|
||||
use parachain::codec::{Encode, Decode};
|
||||
use adder::{HeadData, BlockData};
|
||||
|
||||
#[panic_implementation]
|
||||
#[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(offset: usize, len: usize) -> usize {
|
||||
let params = unsafe { ::parachain::load_params(offset, 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[..]);
|
||||
|
||||
match ::adder::execute(parent_hash, parent_head, &block_data) {
|
||||
Ok(new_head) => parachain::write_result(ValidationResult { head_data: new_head.encode() }),
|
||||
Err(_) => panic!("execution failure"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user