From 8028ef364784b7fdbd04f7db3dca0cc83429fec2 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 9 Dec 2019 15:26:41 +0100 Subject: [PATCH 1/3] Propagate Substrate#4284 to Polkadot --- Cargo.lock | 651 ++++++++++++++++++++++++++++++ network/Cargo.toml | 2 + network/src/gossip.rs | 137 ++++--- network/src/gossip/attestation.rs | 2 +- network/src/lib.rs | 83 +--- network/src/router.rs | 22 +- network/src/tests/validation.rs | 20 +- network/src/validation.rs | 57 ++- service/src/lib.rs | 7 +- 9 files changed, 791 insertions(+), 190 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8df1def39541..47859e7127a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1077,6 +1077,14 @@ name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fork-tree" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fork-tree" version = "2.0.0" @@ -1561,6 +1569,11 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "hashbrown" version = "0.6.3" @@ -2500,6 +2513,14 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lru" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lru" version = "0.4.0" @@ -3579,6 +3600,7 @@ dependencies = [ "polkadot-validation 0.7.9", "sc-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-network 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "sc-network-gossip 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", "sp-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sp-blockchain 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sp-core 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", @@ -4300,6 +4322,18 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-application-crypto" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-io 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sc-application-crypto" version = "2.0.0" @@ -4336,6 +4370,20 @@ dependencies = [ "sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sc-block-builder" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sc-block-builder" version = "2.0.0" @@ -4411,6 +4459,39 @@ dependencies = [ "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-client" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-client-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-executor 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-telemetry 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-keyring 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-client" version = "2.0.0" @@ -4444,6 +4525,38 @@ dependencies = [ "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-client-api" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-executor 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-telemetry 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-keyring 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-transaction-pool-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sc-client-api" version = "2.0.0" @@ -4541,6 +4654,25 @@ dependencies = [ "sp-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sc-consensus-slots" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-telemetry 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sc-consensus-slots" version = "2.0.0" @@ -4574,6 +4706,30 @@ dependencies = [ "sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sc-executor" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-io 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-panic-handler 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-serializer 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-wasm-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-executor" version = "2.0.0" @@ -4651,6 +4807,51 @@ dependencies = [ "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-network" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fork-tree 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-client 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-client-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-peerset 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus-babe 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-network" version = "2.0.0" @@ -4696,6 +4897,22 @@ dependencies = [ "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-network-gossip" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-network 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sc-offchain" version = "2.0.0" @@ -4723,6 +4940,17 @@ dependencies = [ "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-peerset" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-peerset" version = "2.0.0" @@ -4859,6 +5087,28 @@ dependencies = [ "sp-core 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sc-telemetry" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", + "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-telemetry" version = "2.0.0" @@ -5204,6 +5454,20 @@ name = "sourcefile" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "sp-api" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api-proc-macro 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-api" version = "2.0.0" @@ -5218,6 +5482,18 @@ dependencies = [ "sp-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-api-proc-macro" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-api-proc-macro" version = "2.0.0" @@ -5230,6 +5506,19 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-arithmetic" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-arithmetic" version = "2.0.0" @@ -5265,6 +5554,18 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-block-builder" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-block-builder" version = "2.0.0" @@ -5277,6 +5578,22 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-blockchain" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-blockchain" version = "2.0.0" @@ -5293,6 +5610,25 @@ dependencies = [ "sp-state-machine 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-consensus" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-consensus" version = "2.0.0" @@ -5312,6 +5648,22 @@ dependencies = [ "sp-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-consensus-babe" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sc-consensus-slots 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-timestamp 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-consensus-babe" version = "2.0.0" @@ -5328,6 +5680,45 @@ dependencies = [ "sp-timestamp 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-core" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-storage 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-debug-derive 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-core" version = "2.0.0" @@ -5367,6 +5758,17 @@ dependencies = [ "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-core-storage" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-core-storage" version = "2.0.0" @@ -5378,6 +5780,16 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-debug-derive" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-debug-derive" version = "2.0.0" @@ -5388,6 +5800,16 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-externalities" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-storage 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-externalities" version = "2.0.0" @@ -5421,6 +5843,18 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-inherents" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-inherents" version = "2.0.0" @@ -5433,6 +5867,23 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-io" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-io" version = "2.0.0" @@ -5450,6 +5901,17 @@ dependencies = [ "sp-trie 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-keyring" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-keyring" version = "2.0.0" @@ -5470,6 +5932,15 @@ dependencies = [ "sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-panic-handler" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-panic-handler" version = "2.0.0" @@ -5498,6 +5969,25 @@ dependencies = [ "sp-core 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-runtime" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-io 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-runtime" version = "2.0.0" @@ -5517,6 +6007,21 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-runtime-interface" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime-interface-proc-macro 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-wasm-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-runtime-interface" version = "2.0.0" @@ -5532,6 +6037,18 @@ dependencies = [ "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-runtime-interface-proc-macro" version = "2.0.0" @@ -5544,6 +6061,15 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-serializer" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-serializer" version = "2.0.0" @@ -5573,6 +6099,25 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-state-machine" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-panic-handler 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-state-machine" version = "2.0.0" @@ -5592,11 +6137,29 @@ dependencies = [ "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-std" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" + [[package]] name = "sp-std" version = "2.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#665304397ff7e60d7cda177a0623a571e5909a2c" +[[package]] +name = "sp-timestamp" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-timestamp" version = "2.0.0" @@ -5610,6 +6173,20 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-transaction-pool-api" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-transaction-pool-api" version = "2.0.0" @@ -5634,6 +6211,20 @@ dependencies = [ "sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-trie" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-trie" version = "2.0.0" @@ -5648,6 +6239,18 @@ dependencies = [ "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-version" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", + "sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)", +] + [[package]] name = "sp-version" version = "2.0.0" @@ -5660,6 +6263,15 @@ dependencies = [ "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", ] +[[package]] +name = "sp-wasm-interface" +version = "2.0.0" +source = "git+https://github.com/tomaka/polkadot?branch=extract-gossip#e6a06adae4e4f9dccfb4a361e2abb91a673a5a5e" +dependencies = [ + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sp-wasm-interface" version = "2.0.0" @@ -7011,6 +7623,7 @@ dependencies = [ "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fork-tree 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum fork-tree 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum frame-executive 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum frame-metadata 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum frame-support 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" @@ -7058,6 +7671,7 @@ dependencies = [ "checksum hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" "checksum hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" @@ -7137,6 +7751,7 @@ dependencies = [ "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum lru 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5d8f669d42c72d18514dfca8115689c5f6370a17d980cb5bd777a67f404594c8" "checksum lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26b0dca4ac5b5083c5169ab12205e6473df1c7659940e4978b94f363c6b54b22" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" @@ -7286,29 +7901,39 @@ dependencies = [ "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum sc-application-crypto 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-application-crypto 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-block-builder 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-chain-spec 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-chain-spec-derive 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-cli 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-client 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-client-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-client-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-client-db 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-consensus-babe 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-consensus-slots 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-consensus-slots 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-consensus-uncles 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-executor 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-executor 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-finality-grandpa 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-keystore 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-network 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-network 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" +"checksum sc-network-gossip 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-offchain 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-peerset 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-peerset 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-rpc 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-rpc-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-rpc-server 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-service 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-state-db 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-telemetry 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sc-telemetry 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sc-tracing 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-transaction-graph 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sc-transaction-pool 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" @@ -7343,41 +7968,67 @@ dependencies = [ "checksum soketto 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bceb1a3a15232d013d9a3b7cac9e5ce8e2313f348f01d4bc1097e5e53aa07095" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum sp-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-api-proc-macro 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-api-proc-macro 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-arithmetic 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-arithmetic 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-authorship 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-block-builder 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-block-builder 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-blockchain 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-blockchain 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-consensus 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-consensus 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-consensus-babe 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-consensus-babe 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-core 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-core 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-core-storage 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-core-storage 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-debug-derive 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-debug-derive 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-externalities 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-externalities 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-finality-grandpa 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-finality-tracker 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-inherents 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-inherents 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-io 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-io 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-keyring 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-keyring 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-offchain 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-panic-handler 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-panic-handler 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-phragmen 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-rpc 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-runtime 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-runtime-interface 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-runtime-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-runtime-interface-proc-macro 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-runtime-interface-proc-macro 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-serializer 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-serializer 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-session 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-staking 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-state-machine 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-state-machine 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-std 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-timestamp 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-timestamp 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-transaction-pool-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-transaction-pool-api 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-transaction-pool-runtime-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum sp-trie 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-trie 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-version 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-version 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum sp-wasm-interface 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum sp-wasm-interface 2.0.0 (git+https://github.com/tomaka/polkadot?branch=extract-gossip)" = "" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" diff --git a/network/Cargo.toml b/network/Cargo.toml index 0cf3b16edbe7..730317b8f4d0 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -14,6 +14,8 @@ polkadot-primitives = { path = "../primitives" } polkadot-erasure-coding = { path = "../erasure-coding" } codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = ["derive"] } sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } +# TODO: change git repo before merging +sc-network-gossip = { git = "https://github.com/tomaka/polkadot", branch = "extract-gossip" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } futures = "0.1" diff --git a/network/src/gossip.rs b/network/src/gossip.rs index 77d964e2a91a..13a41ee7d99e 100644 --- a/network/src/gossip.rs +++ b/network/src/gossip.rs @@ -51,10 +51,10 @@ use sp_runtime::{generic::BlockId, traits::{ProvideRuntimeApi, BlakeTwo256, Hash as HashT}}; use sp_blockchain::Error as ClientError; -use sc_network::{config::Roles, PeerId, ReputationChange}; -use sc_network::consensus_gossip::{ - self as network_gossip, ValidationResult as GossipValidationResult, - ValidatorContext, MessageIntent, ConsensusMessage, +use sc_network::{config::Roles, Context, PeerId, ReputationChange}; +use sc_network_gossip::{ + ValidationResult as GossipValidationResult, + ValidatorContext, MessageIntent, }; use polkadot_validation::{SignedStatement}; use polkadot_primitives::{Block, Hash}; @@ -68,11 +68,12 @@ use std::collections::HashMap; use std::sync::Arc; use arrayvec::ArrayVec; +use futures03::{prelude::*, compat::Compat}; use parking_lot::RwLock; use log::warn; use super::PolkadotNetworkService; -use crate::router::attestation_topic; +use crate::{GossipMessageStream, NetworkService, PolkadotProtocol, router::attestation_topic}; use attestation::{View as AttestationView, PeerData as AttestationPeerData}; use message_routing::{View as MessageRoutingView}; @@ -133,7 +134,7 @@ mod cost { } /// A gossip message. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub enum GossipMessage { /// A packet sent to a neighbor but not relayed. #[codec(index = "1")] @@ -151,15 +152,6 @@ pub enum GossipMessage { ErasureChunk(ErasureChunkMessage), } -impl GossipMessage { - fn to_consensus_message(&self) -> ConsensusMessage { - ConsensusMessage { - data: self.encode(), - engine_id: POLKADOT_ENGINE_ID, - } - } -} - impl From for GossipMessage { fn from(packet: NeighborPacket) -> Self { GossipMessage::Neighbor(VersionedNeighborPacket::V1(packet)) @@ -179,7 +171,7 @@ impl From for GossipMessage { } /// A gossip message containing a statement. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub struct GossipStatement { /// The block hash of the relay chain being referred to. In context, this should /// be a leaf. @@ -200,7 +192,7 @@ impl GossipStatement { /// A gossip message containing one erasure chunk of a candidate block. /// For each chunk of block erasure encoding one of this messages is constructed. -#[derive(Encode, Decode, Clone, Debug)] +#[derive(Encode, Decode, Clone, Debug, PartialEq)] pub struct ErasureChunkMessage { /// The chunk itself. pub chunk: PrimitiveChunk, @@ -221,7 +213,7 @@ impl From for GossipMessage { /// These are all the messages posted from one parachain to another during the /// execution of a single parachain block. Since this parachain block may have been /// included in many forks of the relay chain, there is no relay-chain leaf parameter. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub struct GossipParachainMessages { /// The root of the message queue. pub queue_root: Hash, @@ -241,7 +233,7 @@ impl GossipParachainMessages { } /// A versioned neighbor message. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub enum VersionedNeighborPacket { #[codec(index = "1")] V1(NeighborPacket), @@ -249,13 +241,13 @@ pub enum VersionedNeighborPacket { /// Contains information on which chain heads the peer is /// accepting messages for. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub struct NeighborPacket { chain_heads: Vec, } /// whether a block is known. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub enum Known { /// The block is a known leaf. Leaf, @@ -318,6 +310,7 @@ impl ChainContext for (F, P) where pub fn register_validator( service: Arc, chain: C, + executor: &impl futures03::task::Spawn, ) -> RegisteredMessageValidator { let s = service.clone(); @@ -338,19 +331,26 @@ pub fn register_validator( }); let gossip_side = validator.clone(); - service.with_gossip(|gossip, ctx| - gossip.register_validator(ctx, POLKADOT_ENGINE_ID, gossip_side) + let gossip_engine = sc_network_gossip::GossipEngine::new( + service.clone(), + executor, + POLKADOT_ENGINE_ID, + gossip_side ); - RegisteredMessageValidator { inner: validator as _ } + RegisteredMessageValidator { + inner: validator as _, + service, + gossip_engine + } } #[derive(PartialEq)] enum NewLeafAction { // (who, message) - TargetedMessage(PeerId, ConsensusMessage), + TargetedMessage(PeerId, GossipMessage), // (topic, message) - Multicast(Hash, ConsensusMessage), + Multicast(Hash, GossipMessage), } /// Actions to take after noting a new block-DAG leaf. @@ -365,15 +365,14 @@ impl NewLeafActions { /// Perform the queued actions, feeding into gossip. pub fn perform( self, - gossip: &mut dyn crate::GossipService, - ctx: &mut dyn sc_network::Context, + gossip: &dyn crate::NetworkService, ) { for action in self.actions { match action { NewLeafAction::TargetedMessage(who, message) - => gossip.send_message(ctx, &who, message), + => gossip.send_message(who, message), NewLeafAction::Multicast(topic, message) - => gossip.multicast(ctx, &topic, message), + => gossip.gossip_message(topic, message), } } } @@ -385,6 +384,8 @@ impl NewLeafActions { #[derive(Clone)] pub struct RegisteredMessageValidator { inner: Arc>, + service: Arc, + gossip_engine: sc_network_gossip::GossipEngine, } impl RegisteredMessageValidator { @@ -395,7 +396,10 @@ impl RegisteredMessageValidator { ) -> Self { let validator = Arc::new(MessageValidator::new_test(chain, report_handle)); - RegisteredMessageValidator { inner: validator as _ } + /*RegisteredMessageValidator { + inner: validator as _ + }*/ + unimplemented!() // FIXME: } pub fn register_availability_store(&mut self, availability_store: av_store::Store) { @@ -449,7 +453,7 @@ impl RegisteredMessageValidator { let message = GossipMessage::from(GossipParachainMessages { queue_root: *queue_root, messages, - }).to_consensus_message(); + }); actions.push(NewLeafAction::Multicast(*topic, message)); @@ -463,6 +467,31 @@ impl RegisteredMessageValidator { } } +impl NetworkService for RegisteredMessageValidator { + fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream { + let topic_stream = self.gossip_engine.messages_for(topic); + GossipMessageStream::new(Box::new(Compat::new(topic_stream.map(Ok)))) + } + + fn gossip_message(&self, topic: Hash, message: GossipMessage) { + self.gossip_engine.gossip_message( + topic, + message.encode(), + false, + ); + } + + fn send_message(&self, who: PeerId, message: GossipMessage) { + self.gossip_engine.send_message(vec![who], message.encode()); + } + + fn with_spec(&self, with: F) + where F: FnOnce(&mut PolkadotProtocol, &mut dyn Context) + { + self.service.with_spec(with) + } +} + /// The data needed for validating gossip messages. #[derive(Default)] pub(crate) struct MessageValidationData { @@ -585,13 +614,13 @@ impl Inner { } } - fn multicast_neighbor_packet( + fn multicast_neighbor_packet( &self, mut send_neighbor_packet: F, ) { let neighbor_packet = GossipMessage::from(NeighborPacket { chain_heads: self.attestation_view.neighbor_info().collect(), - }).to_consensus_message(); + }); for peer in self.peers.keys() { send_neighbor_packet(peer, neighbor_packet.clone()) @@ -628,7 +657,7 @@ impl MessageValidator { } } -impl network_gossip::Validator for MessageValidator { +impl sc_network_gossip::Validator for MessageValidator { fn new_peer(&self, _context: &mut dyn ValidatorContext, who: &PeerId, _roles: Roles) { let mut inner = self.inner.write(); inner.peers.insert(who.clone(), PeerData::default()); @@ -746,7 +775,7 @@ impl network_gossip::Validator for MessageValid #[cfg(test)] mod tests { use super::*; - use sc_network::consensus_gossip::Validator as ValidatorT; + use sc_network_gossip::Validator as ValidatorT; use std::sync::mpsc; use parking_lot::Mutex; use polkadot_primitives::parachain::{CandidateReceipt, HeadData}; @@ -776,7 +805,7 @@ mod tests { } } - impl network_gossip::ValidatorContext for MockValidatorContext { + impl sc_network_gossip::ValidatorContext for MockValidatorContext { fn broadcast_topic(&mut self, topic: Hash, force: bool) { self.events.push(ContextEvent::BroadcastTopic(topic, force)); } @@ -792,12 +821,12 @@ mod tests { } impl NewLeafActions { - fn has_message(&self, who: PeerId, message: ConsensusMessage) -> bool { + fn has_message(&self, who: PeerId, message: GossipMessage) -> bool { let x = NewLeafAction::TargetedMessage(who, message); self.actions.iter().find(|&m| m == &x).is_some() } - fn has_multicast(&self, topic: Hash, message: ConsensusMessage) -> bool { + fn has_multicast(&self, topic: Hash, message: GossipMessage) -> bool { let x = NewLeafAction::Multicast(topic, message); self.actions.iter().find(|&m| m == &x).is_some() } @@ -1082,12 +1111,12 @@ mod tests { assert!(actions.has_message(peer_a.clone(), GossipMessage::from(NeighborPacket { chain_heads: vec![hash_a], - }).to_consensus_message())); + }))); assert!(actions.has_multicast(root_a_topic, GossipMessage::from(GossipParachainMessages { queue_root: root_a, messages: root_a_messages.clone(), - }).to_consensus_message())); + }))); } // ensure that we are allowed to multicast to a peer with same chain head, @@ -1154,12 +1183,12 @@ mod tests { assert!(actions.has_message(peer_a.clone(), GossipMessage::from(NeighborPacket { chain_heads: vec![hash_a], - }).to_consensus_message())); + }))); assert!(actions.has_multicast(root_a_topic, GossipMessage::from(GossipParachainMessages { queue_root: root_a, messages: root_a_messages.clone(), - }).to_consensus_message())); + }))); } // ensure that we are not allowed to multicast to either peer, as they @@ -1168,12 +1197,12 @@ mod tests { let message = GossipMessage::from(GossipParachainMessages { queue_root: root_a, messages: root_a_messages.clone(), - }).encode(); + }); let mut allowed = validator.inner.message_allowed(); let intent = MessageIntent::Broadcast; - assert!(!allowed(&peer_a, intent, &root_a_topic, &message[..])); - assert!(!allowed(&peer_b, intent, &root_a_topic, &message[..])); + assert!(!allowed(&peer_a, intent, &root_a_topic, &message.encode())); + assert!(!allowed(&peer_b, intent, &root_a_topic, &message.encode())); } // peer A gets updated to the chain head. now we'll attempt to broadcast @@ -1259,17 +1288,17 @@ mod tests { let queue_messages = GossipMessage::from(GossipParachainMessages { queue_root: root_a, messages: root_a_messages.clone(), - }).to_consensus_message(); + }); let not_queue_messages = GossipMessage::from(GossipParachainMessages { queue_root: root_a, messages: not_root_a_messages.clone(), - }).encode(); + }); let queue_messages_wrong_root = GossipMessage::from(GossipParachainMessages { queue_root: not_root_a, messages: root_a_messages.clone(), - }).encode(); + }); // ensure that we attempt to multicast all relevant queues after noting a leaf. { @@ -1281,7 +1310,7 @@ mod tests { assert!(actions.has_message(peer_a.clone(), GossipMessage::from(NeighborPacket { chain_heads: vec![hash_a], - }).to_consensus_message())); + }))); // we don't know this queue! no broadcast :( assert!(!actions.has_multicast(root_a_topic, queue_messages.clone())); @@ -1292,7 +1321,7 @@ mod tests { let res = validator.inner.validate( &mut validator_context, &peer_a, - &queue_messages_wrong_root[..], + &queue_messages_wrong_root.encode(), ); match res { @@ -1308,7 +1337,7 @@ mod tests { let res = validator.inner.validate( &mut validator_context, &peer_a, - ¬_queue_messages[..], + ¬_queue_messages.encode(), ); match res { @@ -1324,7 +1353,7 @@ mod tests { let res = validator.inner.validate( &mut validator_context, &peer_a, - &queue_messages.data[..], + &queue_messages.encode(), ); match res { @@ -1333,7 +1362,7 @@ mod tests { } assert_eq!(validator_context.events, vec![ - ContextEvent::BroadcastMessage(root_a_topic, queue_messages.data.clone(), false), + ContextEvent::BroadcastMessage(root_a_topic, queue_messages.encode(), false), ]); } } diff --git a/network/src/gossip/attestation.rs b/network/src/gossip/attestation.rs index 677bfe1e0bd8..d8fc4c50a1fc 100644 --- a/network/src/gossip/attestation.rs +++ b/network/src/gossip/attestation.rs @@ -30,7 +30,7 @@ //! a `Candidate` we are aware of. Otherwise, it is possible we could be forced to //! consider an infinite amount of attestations produced by a misbehaving validator. -use sc_network::consensus_gossip::{ValidationResult as GossipValidationResult}; +use sc_network_gossip::{ValidationResult as GossipValidationResult}; use sc_network::ReputationChange; use polkadot_validation::GenericStatement; use polkadot_primitives::Hash; diff --git a/network/src/lib.rs b/network/src/lib.rs index f73dae2e7c5d..dbd032c49e62 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -29,7 +29,7 @@ use codec::{Decode, Encode}; use futures::sync::oneshot; use futures::future::Either; use futures::prelude::*; -use futures03::{channel::mpsc, compat::{Compat, Stream01CompatExt}, FutureExt, StreamExt, TryFutureExt}; +use futures03::{compat::Stream01CompatExt, FutureExt, StreamExt, TryFutureExt}; use polkadot_primitives::{Block, Hash, Header}; use polkadot_primitives::parachain::{ Id as ParaId, CollatorId, CandidateReceipt, Collation, PoVBlock, @@ -39,9 +39,7 @@ use sc_network::{ PeerId, RequestId, Context, StatusMessage as GenericFullStatus, specialization::NetworkSpecialization as Specialization, }; -use sc_network::consensus_gossip::{ - self, TopicNotification, MessageRecipient as GossipMessageRecipient, ConsensusMessage, -}; +use sc_network_gossip::TopicNotification; use self::validation::{LiveValidationLeaves, RecentValidatorIds, InsertedRecentKey}; use self::collator_pool::{CollatorPool, Role, Action}; use self::local_collations::LocalCollations; @@ -49,7 +47,7 @@ use log::{trace, debug, warn}; use std::collections::{HashMap, HashSet}; -use crate::gossip::{POLKADOT_ENGINE_ID, GossipMessage, ErasureChunkMessage}; +use crate::gossip::{GossipMessage, ErasureChunkMessage, RegisteredMessageValidator}; #[cfg(test)] mod tests; @@ -90,13 +88,12 @@ pub trait NetworkService: Send + Sync + 'static { /// Gossip a message on given topic. fn gossip_message(&self, topic: Hash, message: GossipMessage); - /// Execute a closure with the gossip service. - fn with_gossip(&self, with: F) - where F: FnOnce(&mut dyn GossipService, &mut dyn Context); + /// Send a message to a specific peer we're connected to. + fn send_message(&self, who: PeerId, message: GossipMessage); /// Execute a closure with the polkadot protocol. fn with_spec(&self, with: F) - where F: FnOnce(&mut PolkadotProtocol, &mut dyn Context); + where Self: Sized, F: FnOnce(&mut PolkadotProtocol, &mut dyn Context); } /// This is a newtype that implements a [`ProvideGossipMessages`] shim trait. @@ -106,11 +103,10 @@ pub trait NetworkService: Send + Sync + 'static { /// /// [`NetworkService`]: ./trait.NetworkService.html /// [`ProvideGossipMessages`]: ../polkadot_availability_store/trait.ProvideGossipMessages.html -pub struct AvailabilityNetworkShim(pub std::sync::Arc); +#[derive(Clone)] +pub struct AvailabilityNetworkShim(pub RegisteredMessageValidator); -impl av_store::ProvideGossipMessages for AvailabilityNetworkShim - where T: NetworkService -{ +impl av_store::ProvideGossipMessages for AvailabilityNetworkShim { fn gossip_messages_for(&self, topic: Hash) -> Box + Unpin + Send> { @@ -150,67 +146,6 @@ impl av_store::ProvideGossipMessages for AvailabilityNetworkShim } } -impl Clone for AvailabilityNetworkShim { - fn clone(&self) -> Self { - AvailabilityNetworkShim(self.0.clone()) - } -} - -impl NetworkService for PolkadotNetworkService { - fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream { - let (tx, rx) = std::sync::mpsc::channel(); - - PolkadotNetworkService::with_gossip(self, move |gossip, _| { - let inner_rx = gossip.messages_for(POLKADOT_ENGINE_ID, topic); - let _ = tx.send(inner_rx); - }); - - let topic_stream = match rx.recv() { - Ok(rx) => rx, - Err(_) => mpsc::unbounded().1, // return empty channel. - }; - - GossipMessageStream::new(Box::new(Compat::new(topic_stream.map(Ok)))) - } - - fn gossip_message(&self, topic: Hash, message: GossipMessage) { - self.gossip_consensus_message( - topic, - POLKADOT_ENGINE_ID, - message.encode(), - GossipMessageRecipient::BroadcastToAll, - ); - } - - fn with_gossip(&self, with: F) - where F: FnOnce(&mut dyn GossipService, &mut dyn Context) - { - PolkadotNetworkService::with_gossip(self, move |gossip, ctx| with(gossip, ctx)) - } - - fn with_spec(&self, with: F) - where F: FnOnce(&mut PolkadotProtocol, &mut dyn Context) - { - PolkadotNetworkService::with_spec(self, with) - } -} - -/// A gossip network subservice. -pub trait GossipService { - fn send_message(&mut self, ctx: &mut dyn Context, who: &PeerId, message: ConsensusMessage); - fn multicast(&mut self, ctx: &mut dyn Context, topic: &Hash, message: ConsensusMessage); -} - -impl GossipService for consensus_gossip::ConsensusGossip { - fn send_message(&mut self, ctx: &mut dyn Context, who: &PeerId, message: ConsensusMessage) { - consensus_gossip::ConsensusGossip::send_message(self, ctx, who, message) - } - - fn multicast(&mut self, ctx: &mut dyn Context, topic: &Hash, message: ConsensusMessage) { - consensus_gossip::ConsensusGossip::multicast(self, ctx, *topic, message, false) - } -} - /// A stream of gossip messages and an optional sender for a topic. pub struct GossipMessageStream { topic_stream: Box + Send>, diff --git a/network/src/router.rs b/network/src/router.rs index 79d6fffa9ef8..340d87cf78f5 100644 --- a/network/src/router.rs +++ b/network/src/router.rs @@ -71,18 +71,18 @@ pub(crate) fn checked_statements(network: &N, topic: Hash) -> } /// Table routing implementation. -pub struct Router { +pub struct Router { table: Arc, attestation_topic: Hash, - fetcher: LeafWorkDataFetcher, + fetcher: LeafWorkDataFetcher, deferred_statements: Arc>, message_validator: RegisteredMessageValidator, } -impl Router { +impl Router { pub(crate) fn new( table: Arc, - fetcher: LeafWorkDataFetcher, + fetcher: LeafWorkDataFetcher, message_validator: RegisteredMessageValidator, ) -> Self { let parent_hash = fetcher.parent_hash(); @@ -102,19 +102,19 @@ impl Router { /// dropped when it is not required anymore. Otherwise, it will stick around in memory /// infinitely. pub(crate) fn checked_statements(&self) -> impl Stream { - checked_statements(&**self.network(), self.attestation_topic) + checked_statements(&*self.network(), self.attestation_topic) } fn parent_hash(&self) -> Hash { self.fetcher.parent_hash() } - fn network(&self) -> &Arc { + fn network(&self) -> &RegisteredMessageValidator { self.fetcher.network() } } -impl Clone for Router { +impl Clone for Router { fn clone(&self) -> Self { Router { table: self.table.clone(), @@ -126,9 +126,8 @@ impl Clone for Router { } } -impl Router where +impl Router where P::Api: ParachainHost, - N: NetworkService, T: Clone + Executor + Send + 'static, E: futures03::Future + Clone + Send + Unpin + 'static, { @@ -221,9 +220,8 @@ impl Router w } } -impl TableRouter for Router where +impl TableRouter for Router where P::Api: ParachainHost, - N: NetworkService, T: Clone + Executor + Send + 'static, E: futures03::Future + Clone + Send + Unpin + 'static, { @@ -279,7 +277,7 @@ impl TableRouter for Router wh } } -impl Drop for Router { +impl Drop for Router { fn drop(&mut self) { let parent_hash = self.parent_hash(); self.network().with_spec(move |spec, _| { spec.remove_validation_session(parent_hash); }); diff --git a/network/src/tests/validation.rs b/network/src/tests/validation.rs index 9e5bc7e9370c..d495bffa8e73 100644 --- a/network/src/tests/validation.rs +++ b/network/src/tests/validation.rs @@ -19,11 +19,11 @@ #![allow(unused)] use crate::gossip::GossipMessage; -use sc_network::Context as NetContext; -use sc_network::consensus_gossip::TopicNotification; +use sc_network::{Context as NetContext, PeerId}; +use sc_network_gossip::TopicNotification; use sp_core::{NativeOrEncoded, ExecutionContext}; use sp_keyring::Sr25519Keyring; -use crate::{GossipService, PolkadotProtocol, NetworkService, GossipMessageStream}; +use crate::{PolkadotProtocol, NetworkService, GossipMessageStream}; use polkadot_validation::{SharedTable, Network}; use polkadot_primitives::{Block, BlockNumber, Hash, Header, BlockId}; @@ -151,17 +151,15 @@ impl NetworkService for TestNetwork { GossipMessageStream::new(Box::new(rx)) } + fn send_message(&self, _: PeerId, _: GossipMessage) { + unimplemented!() + } + fn gossip_message(&self, topic: Hash, message: GossipMessage) { let notification = TopicNotification { message: message.encode(), sender: None }; let _ = self.gossip.send_message.unbounded_send((topic, notification)); } - fn with_gossip(&self, with: F) - where F: FnOnce(&mut dyn GossipService, &mut dyn NetContext) - { - unimplemented!() - } - fn with_spec(&self, with: F) where F: FnOnce(&mut PolkadotProtocol, &mut dyn NetContext) { @@ -337,7 +335,6 @@ impl ParachainHost for RuntimeApi { type TestValidationNetwork = crate::validation::ValidationNetwork< TestApi, NeverExit, - TestNetwork, TaskExecutor, >; @@ -364,9 +361,8 @@ fn build_network(n: usize, executor: TaskExecutor) -> Built { ); TestValidationNetwork::new( - net, - NeverExit, message_val, + NeverExit, runtime_api.clone(), executor.clone(), ) diff --git a/network/src/validation.rs b/network/src/validation.rs index 25e87559f38d..8401f91b8d38 100644 --- a/network/src/validation.rs +++ b/network/src/validation.rs @@ -88,44 +88,40 @@ pub struct LeafWorkParams { } /// Wrapper around the network service -pub struct ValidationNetwork { - network: Arc, +pub struct ValidationNetwork { api: Arc

, executor: T, - message_validator: RegisteredMessageValidator, + network: RegisteredMessageValidator, exit: E, } -impl ValidationNetwork { +impl ValidationNetwork { /// Create a new consensus networking object. pub fn new( - network: Arc, + network: RegisteredMessageValidator, exit: E, - message_validator: RegisteredMessageValidator, api: Arc

, executor: T, ) -> Self { - ValidationNetwork { network, exit, message_validator, api, executor } + ValidationNetwork { network, exit, api, executor } } } -impl Clone for ValidationNetwork { +impl Clone for ValidationNetwork { fn clone(&self) -> Self { ValidationNetwork { network: self.network.clone(), exit: self.exit.clone(), api: self.api.clone(), executor: self.executor.clone(), - message_validator: self.message_validator.clone(), } } } -impl ValidationNetwork where +impl ValidationNetwork where P: ProvideRuntimeApi + Send + Sync + 'static, P::Api: ParachainHost, E: Clone + futures03::Future + Send + Sync + 'static, - N: NetworkService, T: Clone + Executor + Send + Sync + 'static, { /// Instantiate block-DAG leaf work @@ -143,27 +139,26 @@ impl ValidationNetwork where /// leaf-work instances safely, but they should all be coordinated on which session keys /// are being used. pub fn instantiate_leaf_work(&self, params: LeafWorkParams) - -> oneshot::Receiver> + -> oneshot::Receiver> { let parent_hash = params.parent_hash; let network = self.network.clone(); let api = self.api.clone(); let task_executor = self.executor.clone(); let exit = self.exit.clone(); - let message_validator = self.message_validator.clone(); let authorities = params.authorities.clone(); let (tx, rx) = oneshot::channel(); self.network.with_spec(move |spec, ctx| { - let actions = message_validator.new_local_leaf( + let actions = network.new_local_leaf( parent_hash, MessageValidationData { authorities }, |queue_root| spec.availability_store.as_ref() .and_then(|store| store.queue_by_root(queue_root)) ); - network.with_gossip(move |gossip, ctx| actions.perform(gossip, ctx)); + actions.perform(&network); let work = spec.new_validation_leaf_work(ctx, params); let _ = tx.send(LeafWorkDataFetcher { @@ -173,7 +168,6 @@ impl ValidationNetwork where parent_hash, knowledge: work.knowledge().clone(), exit, - message_validator, }); }); @@ -181,7 +175,7 @@ impl ValidationNetwork where } } -impl ValidationNetwork where N: NetworkService { +impl ValidationNetwork { /// Convert the given `CollatorId` to a `PeerId`. pub fn collator_id_to_peer_id(&self, collator_id: CollatorId) -> impl Future, Error=()> + Send @@ -199,20 +193,19 @@ impl ValidationNetwork where N: NetworkService { /// dropped when it is not required anymore. Otherwise, it will stick around in memory /// infinitely. pub fn checked_statements(&self, relay_parent: Hash) -> impl Stream { - crate::router::checked_statements(&*self.network, crate::router::attestation_topic(relay_parent)) + crate::router::checked_statements(&self.network, crate::router::attestation_topic(relay_parent)) } } /// A long-lived network which can create parachain statement routing processes on demand. -impl ParachainNetwork for ValidationNetwork where +impl ParachainNetwork for ValidationNetwork where P: ProvideRuntimeApi + Send + Sync + 'static, P::Api: ParachainHost, E: Clone + futures03::Future + Send + Sync + Unpin + 'static, - N: NetworkService, T: Clone + Executor + Send + Sync + 'static, { type Error = String; - type TableRouter = Router; + type TableRouter = Router; type BuildTableRouter = Box + Send>; fn communication_for( @@ -229,16 +222,16 @@ impl ParachainNetwork for ValidationNetwork where parent_hash, authorities: authorities.to_vec(), }); - let message_validator = self.message_validator.clone(); let executor = self.executor.clone(); + let network = self.network.clone(); let work = build_fetcher .map_err(|e| format!("{:?}", e)) .map(move |fetcher| { let table_router = Router::new( table, fetcher, - message_validator, + network, ); let table_router_clone = table_router.clone(); @@ -288,10 +281,9 @@ impl Future for AwaitingCollation { } } -impl Collators for ValidationNetwork where +impl Collators for ValidationNetwork where P: ProvideRuntimeApi + Send + Sync + 'static, P::Api: ParachainHost, - N: NetworkService, { type Error = NetworkDown; type Collation = AwaitingCollation; @@ -615,17 +607,16 @@ impl Future for PoVReceiver { } /// Can fetch data for a given validation leaf-work instance. -pub struct LeafWorkDataFetcher { - network: Arc, +pub struct LeafWorkDataFetcher { + network: RegisteredMessageValidator, api: Arc

, exit: E, task_executor: T, knowledge: Arc>, parent_hash: Hash, - message_validator: RegisteredMessageValidator, } -impl LeafWorkDataFetcher { +impl LeafWorkDataFetcher { /// Get the parent hash. pub(crate) fn parent_hash(&self) -> Hash { self.parent_hash @@ -642,7 +633,7 @@ impl LeafWorkDataFetcher { } /// Get the network service. - pub(crate) fn network(&self) -> &Arc { + pub(crate) fn network(&self) -> &RegisteredMessageValidator { &self.network } @@ -657,7 +648,7 @@ impl LeafWorkDataFetcher { } } -impl Clone for LeafWorkDataFetcher { +impl Clone for LeafWorkDataFetcher { fn clone(&self) -> Self { LeafWorkDataFetcher { network: self.network.clone(), @@ -666,14 +657,12 @@ impl Clone for LeafWorkDataFetcher LeafWorkDataFetcher where +impl LeafWorkDataFetcher where P::Api: ParachainHost, - N: NetworkService, T: Clone + Executor + Send + 'static, E: futures03::Future + Clone + Send + 'static, { diff --git a/service/src/lib.rs b/service/src/lib.rs index 935e87f2f57a..bf7369c6718d 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -228,6 +228,7 @@ pub fn new_full(config: Configuration) let mut gossip_validator = network_gossip::register_validator( service.network(), (is_known, client.clone()), + &service.spawn_task_handle(), ); if participates_in_consensus { @@ -241,7 +242,7 @@ pub fn new_full(config: Configuration) cache_size: None, path, }, - polkadot_network::AvailabilityNetworkShim(service.network()), + polkadot_network::AvailabilityNetworkShim(gossip_validator.clone()), )? }; @@ -259,9 +260,8 @@ pub fn new_full(config: Configuration) // collator connections and validation network both fulfilled by this let validation_network = ValidationNetwork::new( - service.network(), - service.on_exit(), gossip_validator, + service.on_exit(), service.client(), polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()), ); @@ -358,6 +358,7 @@ pub fn new_full(config: Configuration) on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + executor: service.spawn_task_handle(), }; service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?); } else { From e18795e36598573d3c2a0d986ecaedef1d732ae7 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 10 Dec 2019 15:03:43 +0100 Subject: [PATCH 2/3] Fix tests --- network/src/gossip.rs | 53 ++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/network/src/gossip.rs b/network/src/gossip.rs index 13a41ee7d99e..b135267071dc 100644 --- a/network/src/gossip.rs +++ b/network/src/gossip.rs @@ -340,8 +340,8 @@ pub fn register_validator( RegisteredMessageValidator { inner: validator as _, - service, - gossip_engine + service: Some(service), + gossip_engine: Some(gossip_engine), } } @@ -384,8 +384,10 @@ impl NewLeafActions { #[derive(Clone)] pub struct RegisteredMessageValidator { inner: Arc>, - service: Arc, - gossip_engine: sc_network_gossip::GossipEngine, + // Note: this is always `Some` in real code and `None` in tests. + service: Option>, + // Note: this is always `Some` in real code and `None` in tests. + gossip_engine: Option>, } impl RegisteredMessageValidator { @@ -396,10 +398,11 @@ impl RegisteredMessageValidator { ) -> Self { let validator = Arc::new(MessageValidator::new_test(chain, report_handle)); - /*RegisteredMessageValidator { - inner: validator as _ - }*/ - unimplemented!() // FIXME: + RegisteredMessageValidator { + inner: validator as _, + service: None, + gossip_engine: None, + } } pub fn register_availability_store(&mut self, availability_store: av_store::Store) { @@ -469,26 +472,44 @@ impl RegisteredMessageValidator { impl NetworkService for RegisteredMessageValidator { fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream { - let topic_stream = self.gossip_engine.messages_for(topic); + let topic_stream = if let Some(gossip_engine) = self.gossip_engine.as_ref() { + gossip_engine.messages_for(topic) + } else { + log::error!("Called gossip_messages_for on a test engine"); + futures03::channel::mpsc::unbounded().1 + }; + GossipMessageStream::new(Box::new(Compat::new(topic_stream.map(Ok)))) } fn gossip_message(&self, topic: Hash, message: GossipMessage) { - self.gossip_engine.gossip_message( - topic, - message.encode(), - false, - ); + if let Some(gossip_engine) = self.gossip_engine.as_ref() { + gossip_engine.gossip_message( + topic, + message.encode(), + false, + ); + } else { + log::error!("Called gossip_message on a test engine"); + } } fn send_message(&self, who: PeerId, message: GossipMessage) { - self.gossip_engine.send_message(vec![who], message.encode()); + if let Some(gossip_engine) = self.gossip_engine.as_ref() { + gossip_engine.send_message(vec![who], message.encode()); + } else { + log::error!("Called send_message on a test engine"); + } } fn with_spec(&self, with: F) where F: FnOnce(&mut PolkadotProtocol, &mut dyn Context) { - self.service.with_spec(with) + if let Some(service) = self.service.as_ref() { + service.with_spec(with) + } else { + log::error!("Called with_spec on a test engine"); + } } } From 5e9579b610cf492db864ff8868e0362bff2703cc Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 12 Dec 2019 13:01:08 +0100 Subject: [PATCH 3/3] Fixes --- network/Cargo.toml | 3 +- network/src/lib.rs | 70 +--------------------------------------------- 2 files changed, 2 insertions(+), 71 deletions(-) diff --git a/network/Cargo.toml b/network/Cargo.toml index 947601a5d974..21387dce3ce2 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -14,8 +14,7 @@ polkadot-primitives = { path = "../primitives" } polkadot-erasure-coding = { path = "../erasure-coding" } codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = ["derive"] } sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } -# TODO: change git repo before merging -sc-network-gossip = { git = "https://github.com/tomaka/polkadot", branch = "extract-gossip" } +sc-network-gossip = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } futures = "0.3.1" diff --git a/network/src/lib.rs b/network/src/lib.rs index f409d3842c57..c35cbabb65f0 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -28,11 +28,7 @@ pub mod gossip; use codec::{Decode, Encode}; use futures::channel::{oneshot, mpsc}; use futures::prelude::*; -<<<<<<< HEAD -use futures03::{compat::Stream01CompatExt, FutureExt, StreamExt, TryFutureExt}; -======= -use futures::future::Either; ->>>>>>> upstream/master +use futures::{compat::Stream01CompatExt, future::Either}; use polkadot_primitives::{Block, Hash, Header}; use polkadot_primitives::parachain::{ Id as ParaId, CollatorId, CandidateReceipt, Collation, PoVBlock, @@ -146,70 +142,6 @@ impl av_store::ProvideGossipMessages for AvailabilityNetworkShim { } } -<<<<<<< HEAD -======= -impl Clone for AvailabilityNetworkShim { - fn clone(&self) -> Self { - AvailabilityNetworkShim(self.0.clone()) - } -} - -impl NetworkService for PolkadotNetworkService { - fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream { - let (tx, rx) = std::sync::mpsc::channel(); - - PolkadotNetworkService::with_gossip(self, move |gossip, _| { - let inner_rx = gossip.messages_for(POLKADOT_ENGINE_ID, topic); - let _ = tx.send(inner_rx); - }); - - let topic_stream = match rx.recv() { - Ok(rx) => rx, - Err(_) => mpsc::unbounded().1, // return empty channel. - }; - - GossipMessageStream::new(topic_stream.boxed()) - } - - fn gossip_message(&self, topic: Hash, message: GossipMessage) { - self.gossip_consensus_message( - topic, - POLKADOT_ENGINE_ID, - message.encode(), - GossipMessageRecipient::BroadcastToAll, - ); - } - - fn with_gossip(&self, with: F) - where F: FnOnce(&mut dyn GossipService, &mut dyn Context) - { - PolkadotNetworkService::with_gossip(self, move |gossip, ctx| with(gossip, ctx)) - } - - fn with_spec(&self, with: F) - where F: FnOnce(&mut PolkadotProtocol, &mut dyn Context) - { - PolkadotNetworkService::with_spec(self, with) - } -} - -/// A gossip network subservice. -pub trait GossipService { - fn send_message(&mut self, ctx: &mut dyn Context, who: &PeerId, message: ConsensusMessage); - fn multicast(&mut self, ctx: &mut dyn Context, topic: &Hash, message: ConsensusMessage); -} - -impl GossipService for consensus_gossip::ConsensusGossip { - fn send_message(&mut self, ctx: &mut dyn Context, who: &PeerId, message: ConsensusMessage) { - consensus_gossip::ConsensusGossip::send_message(self, ctx, who, message) - } - - fn multicast(&mut self, ctx: &mut dyn Context, topic: &Hash, message: ConsensusMessage) { - consensus_gossip::ConsensusGossip::multicast(self, ctx, *topic, message, false) - } -} - ->>>>>>> upstream/master /// A stream of gossip messages and an optional sender for a topic. pub struct GossipMessageStream { topic_stream: Pin + Send>>,