Interchain message-passing (#117)

* compute ingress and routing in polkadot runtime

* extract parent candidates from block when beginning consensus

* fetch incoming messages when validating

* fix consensus tests

* parachain wasm execution uses messages

* update parachain tests to check if messages are executed

* abstract out network service to make room for network tests

* skeleton for incoming data fetch

* collate ingress from consensus-gossip

* keep track of validated candidates in the shared-table

* add some shared_table tests for new behavior

* broadcast egress messages on gossip

* test compute_ingress

* move network tests to module folder

* dummy network for consensus-network tests

* make consensus network generic over executor

* test egress broadcast and ingress fetch

* fix test compilation

* address some grumbles

* address grumbles and fix parachain shuffle

* remove broadcast parameter from consensus network trait
This commit is contained in:
Robert Habermeier
2019-02-19 13:59:29 -03:00
committed by GitHub
parent da409f6c9e
commit f8af277006
26 changed files with 1733 additions and 368 deletions
@@ -6,9 +6,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
adder = { path = ".." }
polkadot-parachain = { path = "../../../parachain", default-features = false, features = ["wasm-api"] }
wee_alloc = { version = "0.4.1" }
pwasm-libc = { version = "0.2" }
tiny-keccak = "1.4"
dlmalloc = { version = "0.1.2", features = ["global"] }
[lib]
crate-type = ["cdylib"]
@@ -23,13 +23,13 @@
)]
extern crate alloc;
extern crate pwasm_libc;
extern crate adder;
extern crate polkadot_parachain as parachain;
extern crate tiny_keccak;
extern crate dlmalloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
use core::{intrinsics, panic};
use parachain::ValidationResult;
@@ -63,7 +63,13 @@ pub extern fn validate(offset: usize, len: usize) -> usize {
let parent_hash = ::tiny_keccak::keccak256(&params.parent_head[..]);
match ::adder::execute(parent_hash, parent_head, &block_data) {
// 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() }
),