From c184a981701e1c9ab70c0e02719f1d00e2d80b45 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Wed, 15 Jan 2020 14:48:09 +1100 Subject: [PATCH] Sync fixes (#801) * Randomize peer selection for batch errors * Downgrade attestation logging * Handle range sync errors * Update lock file * Downgrade logs * Decrease batch size for better thread handling * Optimise peer selection in range sync --- Cargo.lock | 151 ++++++++++-------- beacon_node/beacon_chain/src/beacon_chain.rs | 4 +- beacon_node/eth2-libp2p/src/rpc/handler.rs | 12 +- beacon_node/network/src/message_processor.rs | 25 ++- beacon_node/network/src/service.rs | 2 +- .../network/src/sync/network_context.rs | 20 ++- .../network/src/sync/range_sync/batch.rs | 107 +++++++++++++ .../network/src/sync/range_sync/chain.rs | 120 +++++--------- .../network/src/sync/range_sync/mod.rs | 1 + .../network/src/sync/range_sync/range.rs | 28 ++-- 10 files changed, 285 insertions(+), 185 deletions(-) create mode 100644 beacon_node/network/src/sync/range_sync/batch.rs diff --git a/Cargo.lock b/Cargo.lock index a2a598c580..4ebb0f53c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -153,6 +153,11 @@ name = "autocfg" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" version = "0.3.40" @@ -218,7 +223,7 @@ dependencies = [ "merkle_proof 0.1.0", "operation_pool 0.1.0", "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)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -270,7 +275,7 @@ dependencies = [ "lighthouse_bootstrap 0.1.0", "logging 0.1.0", "node_test_rig 0.1.0", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (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 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -371,7 +376,7 @@ dependencies = [ "eth2_ssz_types 0.2.0", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "milagro_bls 0.11.0 (git+https://github.com/sigp/milagro_bls?tag=v0.11.1)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_hex 0.1.0", @@ -390,7 +395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bstr" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -484,8 +489,8 @@ name = "chrono" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -606,7 +611,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -674,7 +679,7 @@ dependencies = [ "csv 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -803,7 +808,7 @@ name = "csv" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -909,7 +914,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -963,7 +968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1016,7 +1021,7 @@ dependencies = [ "libp2p-core 0.13.2 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "libsecp256k1 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1030,7 +1035,7 @@ dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1042,7 +1047,7 @@ dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1162,7 +1167,7 @@ version = "0.1.1" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-test 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1176,7 +1181,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "milagro_bls 0.11.0 (git+https://github.com/sigp/milagro_bls?tag=v0.11.1)", - "num-bigint 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1231,7 +1236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1245,7 +1250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1344,7 +1349,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1354,8 +1359,8 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (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)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1848,7 +1853,7 @@ dependencies = [ "genesis 0.1.0", "hex 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)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", "simple_logger 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1952,7 +1957,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2106,7 +2111,7 @@ dependencies = [ "parity-multiaddr 0.6.0 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "parity-multihash 0.2.0 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2167,7 +2172,7 @@ dependencies = [ "libp2p-core 0.13.2 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2186,7 +2191,7 @@ dependencies = [ "libp2p-swarm 0.3.0 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.6.0 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (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)", "wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2343,7 +2348,7 @@ dependencies = [ "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "hmac-drbg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2362,7 +2367,7 @@ dependencies = [ [[package]] name = "lighthouse" -version = "0.1.0" +version = "0.1.1" dependencies = [ "account_manager 0.0.1", "beacon_node 0.1.0", @@ -2420,7 +2425,7 @@ dependencies = [ "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.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)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "slot_clock 0.1.0", "store 0.1.0", "types 0.1.0", @@ -2537,7 +2542,7 @@ dependencies = [ "amcl 0.1.0 (git+https://github.com/sigp/milagro_bls?tag=v0.11.1)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2675,7 +2680,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (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)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sloggers 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2736,29 +2741,29 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-integer" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2813,7 +2818,7 @@ dependencies = [ "eth2_ssz_derive 0.1.0", "int_to_bytes 0.1.0", "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)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "state_processing 0.1.0", "types 0.1.0", ] @@ -3048,7 +3053,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3064,7 +3069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3147,7 +3152,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3333,13 +3338,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3352,7 +3357,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3473,7 +3478,7 @@ name = "rlp" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3493,7 +3498,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-hex" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3779,7 +3784,7 @@ name = "slog-kvfilter" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3834,7 +3839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4085,7 +4090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4132,6 +4137,14 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread_local" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.42" @@ -4464,7 +4477,7 @@ dependencies = [ "eth2_hashing 0.1.1", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "tree_hash_derive 0.2.0", "types 0.1.0", ] @@ -4532,7 +4545,7 @@ dependencies = [ "int_to_bytes 0.1.0", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "merkle_proof 0.1.0", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4555,7 +4568,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4565,7 +4578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4909,7 +4922,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5046,7 +5059,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5090,7 +5103,7 @@ dependencies = [ "nohash-hasher 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5155,6 +5168,7 @@ dependencies = [ "checksum asn1_der_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -5172,7 +5186,7 @@ dependencies = [ "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" -"checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" +"checksum bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3ede750122d9d1f87919570cb2cccee38c84fbc8c5599b25c289af40625b7030" "checksum bumpalo 3.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5fb8038c1ddc0a5f73787b130f4cc75151e96ed33e417fde765eb5a81e3532f4" "checksum byte-slice-cast 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" @@ -5356,9 +5370,9 @@ dependencies = [ "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum nohash-hasher 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4e657a6ec97f9a3ba46f6f7034ea6db9fcd5b71d25ef1074b7bc03da49be0e8e" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum num-bigint 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "343b3df15c945a59e72aae31e89a7cfc9e11850e96d4fde6fed5e3c7c8d9c887" -"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" -"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" +"checksum num-bigint 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f115de20ad793e857f76da2563ff4a09fbcfd6fe93cca0c5d996ab5f3ee38d" +"checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" @@ -5397,7 +5411,7 @@ dependencies = [ "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -5418,9 +5432,9 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" +"checksum regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" "checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" @@ -5428,7 +5442,7 @@ dependencies = [ "checksum rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a44d5ae8afcb238af8b75640907edc6c931efcfab2c854e81ed35fa080f84cd" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" -"checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" +"checksum rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" "checksum rw-stream-sink 0.1.2 (git+https://github.com/SigP/rust-libp2p/?rev=735313ebda6a98604929f6c4606aefac19e00760)" = "" @@ -5494,6 +5508,7 @@ dependencies = [ "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum thread_local 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88ddf1ad580c7e3d1efff877d972bcc93f995556b9087a5a259630985c88ceab" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" "checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 06f0a3dbd7..99e8f4b050 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -954,13 +954,13 @@ impl BeaconChain { // Only log a warning if our head is in a reasonable place to verify this attestation. // This avoids excess logging during syncing. if head_epoch + 1 >= attestation_epoch { - debug!( + trace!( self.log, "Dropped attestation for unknown block"; "block" => format!("{}", attestation.data.beacon_block_root) ); } else { - debug!( + trace!( self.log, "Dropped attestation for unknown block"; "block" => format!("{}", attestation.data.beacon_block_root) diff --git a/beacon_node/eth2-libp2p/src/rpc/handler.rs b/beacon_node/eth2-libp2p/src/rpc/handler.rs index 19c752a7b8..3206a17a25 100644 --- a/beacon_node/eth2-libp2p/src/rpc/handler.rs +++ b/beacon_node/eth2-libp2p/src/rpc/handler.rs @@ -12,7 +12,7 @@ use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeError}; use libp2p::swarm::protocols_handler::{ KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol, }; -use slog::{crit, debug, error, trace}; +use slog::{crit, debug, error}; use smallvec::SmallVec; use std::collections::hash_map::Entry; use std::time::{Duration, Instant}; @@ -294,7 +294,7 @@ where InboundSubstreamState::ResponseIdle(substream) => { // close the stream if there is no response if let RPCErrorResponse::StreamTermination(_) = response { - trace!(self.log, "Stream termination sent. Ending the stream"); + //trace!(self.log, "Stream termination sent. Ending the stream"); *substream_state = InboundSubstreamState::Closing(substream); } else { // send the response @@ -565,7 +565,7 @@ where InboundSubstreamState::Closing(mut substream) => { match substream.close() { Ok(Async::Ready(())) | Err(_) => { - trace!(self.log, "Inbound stream dropped"); + //trace!(self.log, "Inbound stream dropped"); let delay_key = &entry.get().1; self.queued_outbound_items.remove(&request_id); self.inbound_substreams_delay.remove(delay_key); @@ -613,7 +613,7 @@ where } else { // either this is a single response request or we received an // error - trace!(self.log, "Closing single stream request"); + //trace!(self.log, "Closing single stream request"); // only expect a single response, close the stream entry.get_mut().0 = OutboundSubstreamState::Closing(substream); } @@ -626,7 +626,7 @@ where // stream closed // if we expected multiple streams send a stream termination, // else report the stream terminating only. - trace!(self.log, "RPC Response - stream closed by remote"); + //trace!(self.log, "RPC Response - stream closed by remote"); // drop the stream let delay_key = &entry.get().1; self.outbound_substreams_delay.remove(delay_key); @@ -670,7 +670,7 @@ where }, OutboundSubstreamState::Closing(mut substream) => match substream.close() { Ok(Async::Ready(())) | Err(_) => { - trace!(self.log, "Outbound stream dropped"); + //trace!(self.log, "Outbound stream dropped"); // drop the stream let delay_key = &entry.get().1; self.outbound_substreams_delay.remove(delay_key); diff --git a/beacon_node/network/src/message_processor.rs b/beacon_node/network/src/message_processor.rs index 21b28f68dd..f77f8e6acd 100644 --- a/beacon_node/network/src/message_processor.rs +++ b/beacon_node/network/src/message_processor.rs @@ -120,6 +120,16 @@ impl MessageProcessor { /// Sends a `Status` message to the peer. pub fn on_connect(&mut self, peer_id: PeerId) { if let Some(status_message) = status_message(&self.chain) { + debug!( + self.log, + "Sending Status Request"; + "peer" => format!("{:?}", peer_id), + "fork_version" => format!("{:?}", status_message.fork_version), + "finalized_root" => format!("{:?}", status_message.finalized_root), + "finalized_epoch" => format!("{:?}", status_message.finalized_epoch), + "head_root" => format!("{}", status_message.head_root), + "head_slot" => format!("{}", status_message.head_slot), + ); self.network .send_rpc_request(peer_id, RPCRequest::Status(status_message)); } @@ -134,9 +144,18 @@ impl MessageProcessor { request_id: RequestId, status: StatusMessage, ) { - // ignore status responses if we are shutting down - trace!(self.log, "StatusRequest"; "peer" => format!("{:?}", peer_id)); + debug!( + self.log, + "Received Status Request"; + "peer" => format!("{:?}", peer_id), + "fork_version" => format!("{:?}", status.fork_version), + "finalized_root" => format!("{:?}", status.finalized_root), + "finalized_epoch" => format!("{:?}", status.finalized_epoch), + "head_root" => format!("{}", status.head_root), + "head_slot" => format!("{}", status.head_slot), + ); + // ignore status responses if we are shutting down if let Some(status_message) = status_message(&self.chain) { // Say status back. self.network.send_rpc_response( @@ -550,7 +569,7 @@ impl MessageProcessor { } AttestationProcessingOutcome::UnknownHeadBlock { beacon_block_root } => { // TODO: Maintain this attestation and re-process once sync completes - debug!( + trace!( self.log, "Attestation for unknown block"; "peer_id" => format!("{:?}", peer_id), diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index 458129ea0a..b1bbc3bbe5 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -237,7 +237,7 @@ fn network_service( match libp2p_service.lock().poll() { Ok(Async::Ready(Some(event))) => match event { Libp2pEvent::RPC(peer_id, rpc_event) => { - trace!(log, "Received RPC"; "rpc" => format!("{}", rpc_event)); + // trace!(log, "Received RPC"; "rpc" => format!("{}", rpc_event)); // if we received a Goodbye message, drop and ban the peer if let RPCEvent::Request(_, RPCRequest::Goodbye(_)) = rpc_event { diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index e885332605..a470ce9c65 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -36,14 +36,19 @@ impl SyncNetworkContext { chain: Weak>, peer_id: PeerId, ) { - trace!( - self.log, - "Sending Status Request"; - "method" => "STATUS", - "peer" => format!("{:?}", peer_id) - ); if let Some(chain) = chain.upgrade() { if let Some(status_message) = status_message(&chain) { + debug!( + self.log, + "Sending Status Request"; + "peer" => format!("{:?}", peer_id), + "fork_version" => format!("{:?}", status_message.fork_version), + "finalized_root" => format!("{:?}", status_message.finalized_root), + "finalized_epoch" => format!("{:?}", status_message.finalized_epoch), + "head_root" => format!("{}", status_message.head_root), + "head_slot" => format!("{}", status_message.head_slot), + ); + let _ = self.send_rpc_request(peer_id, RPCRequest::Status(status_message)); } } @@ -124,8 +129,7 @@ impl SyncNetworkContext { self.network_send .try_send(NetworkMessage::RPC(peer_id, rpc_event)) .map_err(|_| { - // This is likely to happen when shutting down. Suppress this warning to trace for now - trace!( + debug!( self.log, "Could not send RPC message to the network service" ); diff --git a/beacon_node/network/src/sync/range_sync/batch.rs b/beacon_node/network/src/sync/range_sync/batch.rs new file mode 100644 index 0000000000..c6f8c44770 --- /dev/null +++ b/beacon_node/network/src/sync/range_sync/batch.rs @@ -0,0 +1,107 @@ +use eth2_libp2p::rpc::RequestId; +use eth2_libp2p::PeerId; +use fnv::FnvHashMap; +use std::cmp::Ordering; +use std::collections::hash_map::Entry; +use std::collections::{HashMap, HashSet}; +use types::{BeaconBlock, EthSpec, Hash256, Slot}; + +/// A collection of sequential blocks that are requested from peers in a single RPC request. +#[derive(PartialEq)] +pub struct Batch { + /// The ID of the batch, these are sequential. + pub id: u64, + /// The requested start slot of the batch, inclusive. + pub start_slot: Slot, + /// The requested end slot of batch, exclusive. + pub end_slot: Slot, + /// The hash of the chain root to requested from the peer. + pub head_root: Hash256, + /// The peer that was originally assigned to the batch. + pub _original_peer: PeerId, + /// The peer that is currently assigned to the batch. + pub current_peer: PeerId, + /// The number of retries this batch has undergone. + pub retries: u8, + /// The blocks that have been downloaded. + pub downloaded_blocks: Vec>, +} + +impl Ord for Batch { + fn cmp(&self, other: &Self) -> Ordering { + self.id.cmp(&other.id) + } +} + +impl PartialOrd for Batch { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +/// A structure that contains a mapping of pending batch requests, that also keeps track of which +/// peers are currently making batch requests. +/// +/// This is used to optimise searches for idle peers (peers that have no outbound batch requests). +pub struct PendingBatches { + /// The current pending batches. + batches: FnvHashMap>, + /// A mapping of peers to the number of pending requests. + peer_requests: HashMap>, +} + +impl PendingBatches { + pub fn new() -> Self { + PendingBatches { + batches: FnvHashMap::default(), + peer_requests: HashMap::new(), + } + } + + pub fn insert(&mut self, request_id: RequestId, batch: Batch) -> Option> { + let peer_request = batch.current_peer.clone(); + self.peer_requests + .entry(peer_request) + .or_insert_with(|| HashSet::new()) + .insert(request_id); + self.batches.insert(request_id, batch) + } + + pub fn remove(&mut self, request_id: &RequestId) -> Option> { + if let Some(batch) = self.batches.remove(request_id) { + if let Entry::Occupied(mut entry) = self.peer_requests.entry(batch.current_peer.clone()) + { + entry.get_mut().remove(request_id); + + if entry.get().is_empty() { + entry.remove(); + } + } + Some(batch) + } else { + None + } + } + + /// Adds a block to the batches if the request id exists. Returns None if there is no batch + /// matching the request id. + pub fn add_block(&mut self, request_id: &RequestId, block: BeaconBlock) -> Option<()> { + let batch = self.batches.get_mut(request_id)?; + batch.downloaded_blocks.push(block); + Some(()) + } + + /// Returns true if there the peer does not exist in the peer_requests mapping. Indicating it + /// has no pending outgoing requests. + pub fn peer_is_idle(&self, peer_id: &PeerId) -> bool { + self.peer_requests.get(peer_id).is_none() + } + + /// Removes a batch for a given peer. + pub fn remove_batch_by_peer(&mut self, peer_id: &PeerId) -> Option> { + let request_ids = self.peer_requests.get(peer_id)?; + + let request_id = request_ids.iter().next()?.clone(); + self.remove(&request_id) + } +} diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index fac2d82230..be2fcf2c82 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -1,12 +1,11 @@ use crate::message_processor::FUTURE_SLOT_TOLERANCE; use crate::sync::network_context::SyncNetworkContext; +use crate::sync::range_sync::batch::{Batch, PendingBatches}; use beacon_chain::{BeaconChain, BeaconChainTypes, BlockProcessingOutcome}; use eth2_libp2p::rpc::methods::*; use eth2_libp2p::rpc::RequestId; use eth2_libp2p::PeerId; -use fnv::FnvHashMap; use slog::{crit, debug, error, trace, warn, Logger}; -use std::cmp::Ordering; use std::collections::HashSet; use std::ops::Sub; use std::sync::Weak; @@ -18,44 +17,12 @@ use types::{BeaconBlock, EthSpec, Hash256, Slot}; /// responder will fill the response up to the max request size, assuming they have the bandwidth /// to do so. //TODO: Make this dynamic based on peer's bandwidth -const BLOCKS_PER_BATCH: u64 = 50; +//TODO: This is lower due to current thread design. Modify once rebuilt. +const BLOCKS_PER_BATCH: u64 = 25; /// The number of times to retry a batch before the chain is considered failed and removed. const MAX_BATCH_RETRIES: u8 = 5; -/// A collection of sequential blocks that are requested from peers in a single RPC request. -#[derive(PartialEq)] -pub struct Batch { - /// The ID of the batch, batches are ID's sequentially. - id: u64, - /// The requested start slot of the batch, inclusive. - start_slot: Slot, - /// The requested end slot of batch, exclusive. - end_slot: Slot, - /// The hash of the chain root to requested from the peer. - head_root: Hash256, - /// The peer that was originally assigned to the batch. - _original_peer: PeerId, - /// The peer that is currently assigned to the batch. - pub current_peer: PeerId, - /// The number of retries this batch has undergone. - retries: u8, - /// The blocks that have been downloaded. - downloaded_blocks: Vec>, -} - -impl Ord for Batch { - fn cmp(&self, other: &Self) -> Ordering { - self.id.cmp(&other.id) - } -} - -impl PartialOrd for Batch { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - /// A return type for functions that act on a `Chain` which informs the caller whether the chain /// has been completed and should be removed or to be kept if further processing is /// required. @@ -105,7 +72,7 @@ pub struct SyncingChain { /// The batches that are currently awaiting a response from a peer. An RPC request for these /// have been sent. - pub pending_batches: FnvHashMap>, + pub pending_batches: PendingBatches, /// The batches that have been downloaded and are awaiting processing and/or validation. completed_batches: Vec>, @@ -151,7 +118,7 @@ impl SyncingChain { start_slot, target_head_slot, target_head_root, - pending_batches: FnvHashMap::default(), + pending_batches: PendingBatches::new(), completed_batches: Vec::new(), peer_pool, to_be_downloaded_id: 1, @@ -176,9 +143,8 @@ impl SyncingChain { log: &slog::Logger, ) -> Option { if let Some(block) = beacon_block { - let batch = self.pending_batches.get_mut(&request_id)?; // This is not a stream termination, simply add the block to the request - batch.downloaded_blocks.push(block.clone()); + self.pending_batches.add_block(&request_id, block.clone())?; return Some(ProcessingResult::KeepChain); } else { // A stream termination has been sent. This batch has ended. Process a completed batch. @@ -202,10 +168,6 @@ impl SyncingChain { // blocks for the peer. debug!(log, "Completed batch received"; "id"=>batch.id, "blocks"=>batch.downloaded_blocks.len(), "awaiting_batches" => self.completed_batches.len()); - // The peer that completed this batch, may be re-requested if this batch doesn't complete - // the chain and there is no error in processing - let current_peer = batch.current_peer.clone(); - // verify the range of received blocks // Note that the order of blocks is verified in block processing if let Some(last_slot) = batch.downloaded_blocks.last().map(|b| b.slot) { @@ -244,7 +206,9 @@ impl SyncingChain { if self.state == ChainSyncingState::Syncing { // pre-emptively request more blocks from peers whilst we process current blocks, - self.send_range_request(network, current_peer, log); + if !self.send_range_request(network, log) { + debug!(log, "No peer available for next batch.") + } } // Try and process batches sequentially in the ordered list. @@ -424,38 +388,22 @@ impl SyncingChain { .retain(|batch| batch.id >= last_processed_id.saturating_sub(1)); } - // Now begin requesting blocks from the peer pool. Ignore any peers with currently - // pending requests - let pending_peers = self - .pending_batches - .values() - .map(|batch| batch.current_peer.clone()) - .collect::>(); - - let peers = self - .peer_pool - .iter() - .filter(|peer| !pending_peers.contains(peer)) - .cloned() - .collect::>(); - - for peer_id in peers { - // send a blocks by range request to the peer - self.send_range_request(network, peer_id, log); - } + // Now begin requesting blocks from the peer pool, until all peers are exhausted. + while self.send_range_request(network, log) {} self.state = ChainSyncingState::Syncing; } - /// A peer has been added. + /// Add a peer to the chain. /// /// If the chain is active, this starts requesting batches from this peer. - pub fn peer_added( + pub fn add_peer( &mut self, network: &mut SyncNetworkContext, peer_id: PeerId, log: &slog::Logger, ) { + self.peer_pool.insert(peer_id.clone()); // do not request blocks if the chain is not syncing if let ChainSyncingState::Stopped = self.state { debug!(log, "Peer added to a non-syncing chain"; "peer_id" => format!("{:?}", peer_id)); @@ -463,7 +411,7 @@ impl SyncingChain { } // find the next batch and request it from the peer - self.send_range_request(network, peer_id, log); + self.send_range_request(network, log); } /// Sends a STATUS message to all peers in the peer pool. @@ -473,19 +421,31 @@ impl SyncingChain { } } - /// Requests the next required batch from the provided peer. - fn send_range_request( - &mut self, - network: &mut SyncNetworkContext, - peer_id: PeerId, - log: &slog::Logger, - ) { + /// Requests the next required batch from a peer. Returns true, if there was a peer available + /// to send a request and there are batches to request, false otherwise. + fn send_range_request(&mut self, network: &mut SyncNetworkContext, log: &slog::Logger) -> bool { // find the next pending batch and request it from the peer - if let Some(batch) = self.get_next_batch(peer_id) { - debug!(log, "Requesting batch"; "start_slot" => batch.start_slot, "end_slot" => batch.end_slot, "id" => batch.id, "peer" => format!("{:?}", batch.current_peer), "head_root"=> format!("{}", batch.head_root)); - // send the batch - self.send_batch(network, batch); + if let Some(peer_id) = self.get_next_peer() { + if let Some(batch) = self.get_next_batch(peer_id) { + debug!(log, "Requesting batch"; "start_slot" => batch.start_slot, "end_slot" => batch.end_slot, "id" => batch.id, "peer" => format!("{:?}", batch.current_peer), "head_root"=> format!("{}", batch.head_root)); + // send the batch + self.send_batch(network, batch); + return true; + } } + return false; + } + + /// Returns a peer if there exists a peer which does not currently have a pending request. + /// + /// This is used to create the next request. + fn get_next_peer(&self) -> Option { + for peer in self.peer_pool.iter() { + if self.pending_batches.peer_is_idle(peer) { + return Some(peer.clone()); + } + } + None } /// Requests the provided batch from the provided peer. @@ -546,7 +506,7 @@ impl SyncingChain { if let Some(batch) = self.pending_batches.remove(&request_id) { warn!(log, "Batch failed. RPC Error"; "id" => batch.id, "retries" => batch.retries, "peer" => format!("{:?}", peer_id)); - Some(self.failed_batch(network, batch)) + Some(self.failed_batch(network, batch, log)) } else { None } @@ -561,6 +521,7 @@ impl SyncingChain { &mut self, network: &mut SyncNetworkContext, mut batch: Batch, + log: &Logger, ) -> ProcessingResult { batch.retries += 1; @@ -580,6 +541,7 @@ impl SyncingChain { .unwrap_or_else(|| current_peer); batch.current_peer = new_peer.clone(); + debug!(log, "Re-Requesting batch"; "start_slot" => batch.start_slot, "end_slot" => batch.end_slot, "id" => batch.id, "peer" => format!("{:?}", batch.current_peer), "head_root"=> format!("{}", batch.head_root)); self.send_batch(network, batch); ProcessingResult::KeepChain } diff --git a/beacon_node/network/src/sync/range_sync/mod.rs b/beacon_node/network/src/sync/range_sync/mod.rs index 534f4d345c..601840b8f0 100644 --- a/beacon_node/network/src/sync/range_sync/mod.rs +++ b/beacon_node/network/src/sync/range_sync/mod.rs @@ -1,6 +1,7 @@ //! This provides the logic for syncing a chain when the local node is far behind it's current //! peers. +mod batch; mod chain; mod chain_collection; mod range; diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index 35309f75df..8f38b90c00 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -154,8 +154,7 @@ impl RangeSync { debug!(self.log, "Finalized chain exists, adding peer"; "peer_id" => format!("{:?}", peer_id), "target_root" => format!("{}", chain.target_head_root), "end_slot" => chain.target_head_slot, "start_slot"=> chain.start_slot); // add the peer to the chain's peer pool - chain.peer_pool.insert(peer_id.clone()); - chain.peer_added(network, peer_id, &self.log); + chain.add_peer(network, peer_id, &self.log); // check if the new peer's addition will favour a new syncing chain. self.chains.update_finalized(network, &self.log); @@ -189,8 +188,7 @@ impl RangeSync { debug!(self.log, "Adding peer to the existing head chain peer pool"; "head_root" => format!("{}",remote.head_root), "head_slot" => remote.head_slot, "peer_id" => format!("{:?}", peer_id)); // add the peer to the head's pool - chain.peer_pool.insert(peer_id.clone()); - chain.peer_added(network, peer_id.clone(), &self.log); + chain.add_peer(network, peer_id.clone(), &self.log); } else { // There are no other head chains that match this peer's status, create a new one, and let start_slot = std::cmp::min(local_info.head_slot, remote_finalized_slot); @@ -306,22 +304,16 @@ impl RangeSync { /// for this peer. If so we mark the batch as failed. The batch may then hit it's maximum /// retries. In this case, we need to remove the chain and re-status all the peers. fn remove_peer(&mut self, network: &mut SyncNetworkContext, peer_id: &PeerId) { + let log_ref = &self.log; match self.chains.head_finalized_request(|chain| { - if chain.peer_pool.remove(&peer_id) { + if chain.peer_pool.remove(peer_id) { // this chain contained the peer - let pending_batches_requests = chain - .pending_batches - .iter() - .filter(|(_, batch)| batch.current_peer == *peer_id) - .map(|(id, _)| id) - .cloned() - .collect::>(); - for request_id in pending_batches_requests { - if let Some(batch) = chain.pending_batches.remove(&request_id) { - if let ProcessingResult::RemoveChain = chain.failed_batch(network, batch) { - // a single batch failed, remove the chain - return Some(ProcessingResult::RemoveChain); - } + while let Some(batch) = chain.pending_batches.remove_batch_by_peer(peer_id) { + if let ProcessingResult::RemoveChain = + chain.failed_batch(network, batch, log_ref) + { + // a single batch failed, remove the chain + return Some(ProcessingResult::RemoveChain); } } // peer removed from chain, no batch failed