From 3f3beea7f0190145332c7033fef3eaa28db7f65d Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Thu, 6 Aug 2020 13:30:55 +0200 Subject: [PATCH] Don't validate a block announcement when syncing (#177) --- Cargo.lock | 186 ++++++++++++++++------------------ collator/src/lib.rs | 17 +++- network/src/lib.rs | 14 ++- network/src/tests.rs | 19 +++- test/parachain/src/service.rs | 17 +++- 5 files changed, 145 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c15f5632a..b9c4791a1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,9 +27,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "adler32" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aead" @@ -196,7 +196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" dependencies = [ "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -221,9 +221,9 @@ checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" [[package]] name = "async-channel" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958a8af017616083a7c739a9c4da4b757a6816593734b4b6145adbe1421526a5" +checksum = "43de69555a39d52918e2bc33a408d3c0a86c829b212d898f4ca25d21a6387478" dependencies = [ "concurrent-queue", "event-listener", @@ -650,9 +650,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.1.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1582139bb74d97ef232c30bc236646017db06f13ee7cc01fa24c9e55640f86d4" +checksum = "39ff9c66992ebea984b9446b2a45b300947216c17544ec9d7f045afe24333cd0" dependencies = [ "cache-padded", ] @@ -1169,7 +1169,7 @@ checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1251,7 +1251,7 @@ checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1326,7 +1326,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1392,9 +1392,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829694371bd7bbc6aee17c4ff624aad8bf9f4dc06c6f9f6071eaa08c89530d10" +checksum = "298f00c3b04c1d9b4cb86aefaaa35348af0957d98b30a5306fc635f8e718923d" [[package]] name = "exit-future" @@ -1433,7 +1433,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "synstructure", ] @@ -1628,7 +1628,7 @@ dependencies = [ "frame-support-procedural-tools", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1640,7 +1640,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1650,7 +1650,7 @@ source = "git+https://github.com/paritytech/substrate?branch=rococo-branch#270a9 dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -1832,7 +1832,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -2351,7 +2351,7 @@ checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -2446,9 +2446,9 @@ dependencies = [ [[package]] name = "jsonrpc-client-transports" -version = "14.2.0" +version = "14.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbdaacc17243168d9d1fa6b2bd7556a27e1e60a621d8a2a6e590ae2b145d158" +checksum = "2773fa94a2a1fd51efb89a8f45b8861023dbb415d18d3c9235ae9388d780f9ec" dependencies = [ "failure", "futures 0.1.29", @@ -2491,7 +2491,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -2585,7 +2585,7 @@ dependencies = [ [[package]] name = "kusama-runtime" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-executive", @@ -2826,7 +2826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f753d9324cd3ec14bf04b8a8cd0d269c87f294153d6bf2a84497a63a5ad22213" dependencies = [ "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -3982,7 +3982,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -4161,7 +4161,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -4212,7 +4212,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2 1.0.19", - "syn 1.0.36", + "syn 1.0.38", "synstructure", ] @@ -4381,7 +4381,7 @@ checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -4411,7 +4411,7 @@ checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" [[package]] name = "polkadot-availability-store" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "derive_more 0.99.9", "exit-future 0.2.0", @@ -4438,7 +4438,7 @@ dependencies = [ [[package]] name = "polkadot-cli" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "frame-benchmarking-cli", "futures 0.3.5", @@ -4461,7 +4461,7 @@ dependencies = [ [[package]] name = "polkadot-collator" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "futures 0.3.5", "futures-timer 2.0.2", @@ -4488,7 +4488,7 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "0.7.30" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "parity-scale-codec", "sp-core", @@ -4499,7 +4499,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "derive_more 0.15.0", "parity-scale-codec", @@ -4512,7 +4512,7 @@ dependencies = [ [[package]] name = "polkadot-network" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "arrayvec 0.4.12", "bytes 0.5.6", @@ -4532,6 +4532,7 @@ dependencies = [ "sc-network-gossip", "sp-api", "sp-blockchain", + "sp-consensus", "sp-core", "sp-runtime", "wasm-timer", @@ -4540,7 +4541,7 @@ dependencies = [ [[package]] name = "polkadot-parachain" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "derive_more 0.99.9", "futures 0.3.5", @@ -4561,7 +4562,7 @@ dependencies = [ [[package]] name = "polkadot-primitives" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-system", @@ -4584,7 +4585,7 @@ dependencies = [ [[package]] name = "polkadot-rpc" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "jsonrpc-core", "pallet-transaction-payment-rpc", @@ -4611,7 +4612,7 @@ dependencies = [ [[package]] name = "polkadot-runtime" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-executive", @@ -4676,7 +4677,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-support", @@ -4710,7 +4711,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" version = "0.8.0" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-support", @@ -4741,7 +4742,7 @@ dependencies = [ [[package]] name = "polkadot-service" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "frame-benchmarking", "frame-system-rpc-runtime-api", @@ -4801,7 +4802,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -4811,7 +4812,7 @@ dependencies = [ [[package]] name = "polkadot-test-runtime" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-executive", @@ -4865,7 +4866,7 @@ dependencies = [ [[package]] name = "polkadot-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "futures 0.3.5", "pallet-timestamp", @@ -4889,7 +4890,7 @@ dependencies = [ [[package]] name = "polkadot-test-service" version = "0.8.2" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "frame-benchmarking", "frame-system", @@ -4936,7 +4937,7 @@ dependencies = [ [[package]] name = "polkadot-validation" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "ansi_term 0.12.1", "bitvec", @@ -5046,27 +5047,25 @@ dependencies = [ [[package]] name = "proc-macro-error" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc175e9777c3116627248584e8f8b3e2987405cabe1c0adf7d1dd28f09dc7880" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "version_check", ] [[package]] name = "proc-macro-error-attr" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc9795ca17eb581285ec44936da7fc2335a3f34f2ddd13118b6f4d515435c50" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", - "syn-mid", "version_check", ] @@ -5166,7 +5165,7 @@ dependencies = [ "itertools 0.8.2", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -5513,7 +5512,7 @@ checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -5584,7 +5583,7 @@ checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -5686,7 +5685,7 @@ dependencies = [ [[package]] name = "rococo-runtime" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-executive", @@ -5949,7 +5948,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -6790,7 +6789,7 @@ checksum = "e367622f934864ffa1c704ba2b82280aab856e3d8213c84c5720257eb34b15b9" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -6879,7 +6878,7 @@ checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -6991,9 +6990,9 @@ dependencies = [ [[package]] name = "signature" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ad6641b36e4115f2422f61e6f706ba67c2b0f12a1eef5f09c4e1dae44b1645" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" [[package]] name = "slab" @@ -7042,7 +7041,7 @@ checksum = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7163,7 +7162,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7392,7 +7391,7 @@ source = "git+https://github.com/paritytech/substrate?branch=rococo-branch#270a9 dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7496,7 +7495,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7573,7 +7572,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7800,9 +7799,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de2f5e239ee807089b62adce73e48c625e0ed80df02c7ab3f068f5db5281065c" +checksum = "de5472fb24d7e80ae84a7801b7978f95a19ec32cb1876faea59ab711eb901976" dependencies = [ "clap", "lazy_static", @@ -7811,15 +7810,15 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510413f9de616762a4fbeab62509bf15c729603b72d7cd71280fbca431b1c118" +checksum = "1e0eb37335aeeebe51be42e2dc07f031163fbabfa6ac67d7ea68b5c2f68d5f99" dependencies = [ "heck", "proc-macro-error", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -7840,7 +7839,7 @@ dependencies = [ "heck", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -8059,26 +8058,15 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" +checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", "unicode-xid 0.2.1", ] -[[package]] -name = "syn-mid" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" -dependencies = [ - "proc-macro2 1.0.19", - "quote 1.0.7", - "syn 1.0.36", -] - [[package]] name = "synom" version = "0.11.3" @@ -8096,7 +8084,7 @@ checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "unicode-xid 0.2.1", ] @@ -8187,7 +8175,7 @@ checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -8379,7 +8367,7 @@ checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] @@ -8563,9 +8551,9 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] name = "tracing" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9" +checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178" dependencies = [ "cfg-if", "log 0.4.11", @@ -8581,14 +8569,14 @@ checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", ] [[package]] name = "tracing-core" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" +checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9" dependencies = [ "lazy_static", ] @@ -8653,9 +8641,9 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "uint" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173cd16430c206dc1a430af8a89a0e9c076cf15cb42b4aedb10e8cc8fee73681" +checksum = "429ffcad8c8c15f874578c7337d156a3727eb4a1c2374c0ae937ad9a9b748c80" dependencies = [ "byteorder", "crunchy", @@ -8863,7 +8851,7 @@ dependencies = [ "log 0.4.11", "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "wasm-bindgen-shared", ] @@ -8897,7 +8885,7 @@ checksum = "841a6d1c35c6f596ccea1f82504a192a60378f64b3bb0261904ad8f2f5657556" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9157,7 +9145,7 @@ dependencies = [ [[package]] name = "westend-runtime" version = "0.8.22" -source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#e91642361133dba084a9c9b3efa45fcb6cd3c5ca" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-branch#bb44855a05857c5f1a6a541bc4963537e132d60c" dependencies = [ "bitvec", "frame-executive", @@ -9345,7 +9333,7 @@ checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" dependencies = [ "proc-macro2 1.0.19", "quote 1.0.7", - "syn 1.0.36", + "syn 1.0.38", "synstructure", ] diff --git a/collator/src/lib.rs b/collator/src/lib.rs index abcc46bd61..82f1a9766a 100644 --- a/collator/src/lib.rs +++ b/collator/src/lib.rs @@ -35,7 +35,7 @@ use sp_api::ApiExt; use sp_blockchain::HeaderBackend; use sp_consensus::{ BlockImport, BlockImportParams, BlockOrigin, BlockStatus, Environment, Error as ConsensusError, - ForkChoiceStrategy, Proposal, Proposer, RecordProof, + ForkChoiceStrategy, Proposal, Proposer, RecordProof, SyncOracle, }; use sp_core::traits::SpawnNamed; use sp_inherents::{InherentData, InherentDataProviders}; @@ -431,7 +431,7 @@ where self, polkadot_client: polkadot_collator::Client, spawner: Spawner, - polkadot_network: impl CollatorNetwork + Clone + 'static, + polkadot_network: impl CollatorNetwork + SyncOracle + Clone + 'static, ) -> Result where Spawner: SpawnNamed + Clone + Send + Sync + 'static, @@ -497,7 +497,7 @@ where for<'a> &'a Client: BlockImport, BS: BlockBackend, Spawner: SpawnNamed + Clone + Send + Sync + 'static, - Network: CollatorNetwork + Clone + 'static, + Network: CollatorNetwork + SyncOracle + Clone + 'static, { type Output = Result, ()>; @@ -516,6 +516,7 @@ where .set(Box::new(JustifiedBlockAnnounceValidator::new( polkadot_client.clone(), self.para_id, + Box::new(self.polkadot_network.clone()), ))); let follow = @@ -637,6 +638,16 @@ mod tests { } } + impl SyncOracle for DummyCollatorNetwork { + fn is_major_syncing(&mut self) -> bool { + unimplemented!("Not required in tests") + } + + fn is_offline(&mut self) -> bool { + unimplemented!("Not required in tests") + } + } + #[derive(Clone)] struct DummyPolkadotClient; diff --git a/network/src/lib.rs b/network/src/lib.rs index 68d26134ab..04c634d0a7 100644 --- a/network/src/lib.rs +++ b/network/src/lib.rs @@ -23,7 +23,7 @@ mod tests; use sp_api::ProvideRuntimeApi; use sp_blockchain::{Error as ClientError, HeaderBackend}; -use sp_consensus::block_validation::{BlockAnnounceValidator, Validation}; +use sp_consensus::{block_validation::{BlockAnnounceValidator, Validation}, SyncOracle}; use sp_core::traits::SpawnNamed; use sp_runtime::{ generic::BlockId, @@ -55,14 +55,20 @@ pub struct JustifiedBlockAnnounceValidator { phantom: PhantomData, polkadot_client: Arc

, para_id: ParaId, + polkadot_sync_oracle: Box, } impl JustifiedBlockAnnounceValidator { - pub fn new(polkadot_client: Arc

, para_id: ParaId) -> Self { + pub fn new( + polkadot_client: Arc

, + para_id: ParaId, + polkadot_sync_oracle: Box, + ) -> Self { Self { phantom: Default::default(), polkadot_client, para_id, + polkadot_sync_oracle, } } } @@ -77,6 +83,10 @@ where header: &B::Header, mut data: &[u8], ) -> Result> { + if self.polkadot_sync_oracle.is_major_syncing() { + return Ok(Validation::Success { is_new_best: false }); + } + let runtime_api = self.polkadot_client.runtime_api(); let polkadot_info = self.polkadot_client.info(); diff --git a/network/src/tests.rs b/network/src/tests.rs index d5d558afb7..6d4da4c204 100644 --- a/network/src/tests.rs +++ b/network/src/tests.rs @@ -32,6 +32,19 @@ use sp_core::H256; use sp_keyring::Sr25519Keyring; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero}; +#[derive(Clone)] +struct DummyCollatorNetwork; + +impl SyncOracle for DummyCollatorNetwork { + fn is_major_syncing(&mut self) -> bool { + false + } + + fn is_offline(&mut self) -> bool { + unimplemented!("Not required in tests") + } +} + fn make_validator() -> JustifiedBlockAnnounceValidator { let (validator, _client) = make_validator_and_client(); @@ -46,7 +59,11 @@ fn make_validator_and_client() -> ( let client = Arc::new(TestApi::new(Arc::new(builder.build()))); ( - JustifiedBlockAnnounceValidator::new(client.clone(), ParaId::from(56)), + JustifiedBlockAnnounceValidator::new( + client.clone(), + ParaId::from(56), + Box::new(DummyCollatorNetwork), + ), client, ) } diff --git a/test/parachain/src/service.rs b/test/parachain/src/service.rs index 1b4bd47cd3..c28e0295cb 100644 --- a/test/parachain/src/service.rs +++ b/test/parachain/src/service.rs @@ -28,6 +28,7 @@ use sp_core::crypto::Pair; use sp_trie::PrefixedMemoryDB; use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; use polkadot_service::{AbstractClient, RuntimeApiCollection}; +use sp_consensus::SyncOracle; // Our native executor instance. native_executor_instance!( @@ -204,7 +205,7 @@ pub fn run_collator( .spawn("polkadot", polkadot_future); } else { let is_light = matches!(polkadot_config.role, Role::Light); - let (mut polkadot_task_manager, client, _) = if is_light { + let (mut polkadot_task_manager, client, handles) = if is_light { Err("Light client not supported.".into()) } else { polkadot_service::build_full( @@ -219,7 +220,12 @@ pub fn run_collator( let polkadot_future = async move { polkadot_task_manager.future().await.expect("polkadot essential task failed"); }; - client.execute_with(SetDelayedBlockAnnounceValidator { block_announce_validator, para_id: id }); + let polkadot_network = handles.polkadot_network.expect("polkadot service is started; qed"); + client.execute_with(SetDelayedBlockAnnounceValidator { + block_announce_validator, + para_id: id, + polkadot_sync_oracle: Box::new(polkadot_network), + }); task_manager .spawn_essential_handle() @@ -232,6 +238,7 @@ pub fn run_collator( struct SetDelayedBlockAnnounceValidator { block_announce_validator: DelayedBlockAnnounceValidator, para_id: ParaId, + polkadot_sync_oracle: Box, } impl polkadot_service::ExecuteWithClient for SetDelayedBlockAnnounceValidator { @@ -244,6 +251,10 @@ impl polkadot_service::ExecuteWithClient for SetDelayedBlockAnnounceV Api: RuntimeApiCollection, Client: AbstractClient + 'static { - self.block_announce_validator.set(Box::new(JustifiedBlockAnnounceValidator::new(client, self.para_id))); + self.block_announce_validator.set(Box::new(JustifiedBlockAnnounceValidator::new( + client, + self.para_id, + self.polkadot_sync_oracle, + ))); } }