diff --git a/Cargo.lock b/Cargo.lock index d4e128d62..012b94e58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,11 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "antidote" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "arc-swap" version = "0.3.2" @@ -315,6 +320,11 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "crossbeam-channel" version = "0.2.6" @@ -666,10 +676,10 @@ dependencies = [ "grin_util 0.4.0", "grin_wallet 0.4.0", "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -691,13 +701,13 @@ dependencies = [ "hyper 0.12.12 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -722,11 +732,11 @@ dependencies = [ "grin_util 0.4.0", "grin_wallet 0.4.0", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -760,6 +770,7 @@ dependencies = [ "grin_util 0.4.0", "grin_wallet 0.4.0", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -767,7 +778,6 @@ dependencies = [ "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -779,13 +789,13 @@ dependencies = [ "digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "grin_util 0.4.0", "hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "ripemd160 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -802,12 +812,12 @@ dependencies = [ "grin_store 0.4.0", "grin_util 0.4.0", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -822,10 +832,10 @@ dependencies = [ "grin_store 0.4.0", "grin_util 0.4.0", "grin_wallet 0.4.0", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -852,11 +862,11 @@ dependencies = [ "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -873,11 +883,11 @@ dependencies = [ "grin_util 0.4.0", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -888,13 +898,13 @@ dependencies = [ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log4rs 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "secp256k1zkp 0.7.1 (git+https://github.com/mimblewimble/rust-secp256k1-zkp?tag=grin_integration_28)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (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.0 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -916,12 +926,12 @@ dependencies = [ "grin_store 0.4.0", "grin_util 0.4.0", "hyper 0.12.12 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "prettytable-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1076,17 +1086,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "isatty" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itertools" version = "0.7.8" @@ -1194,6 +1193,11 @@ name = "linked-hash-map" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "linked-hash-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lmdb-zero" version = "0.4.4" @@ -1228,6 +1232,36 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log-mdc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log4rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde-value 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1592,6 +1626,15 @@ dependencies = [ "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ordered-float" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "owning_ref" version = "0.3.3" @@ -2026,6 +2069,15 @@ name = "serde" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "serde-value" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serde_derive" version = "1.0.80" @@ -2057,6 +2109,17 @@ dependencies = [ "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_yaml" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sha2" version = "0.7.1" @@ -2087,33 +2150,6 @@ name = "slab" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "slog" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slog-async" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slog-term" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "0.6.5" @@ -2173,11 +2209,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "tar" version = "0.4.17" @@ -2247,6 +2278,16 @@ dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread-id" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.6" @@ -2473,11 +2514,24 @@ dependencies = [ "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "traitobject" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "try-lock" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "typemap" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "typenum" version = "1.10.0" @@ -2540,6 +2594,14 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unsafe-any" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "untrusted" version = "0.6.2" @@ -2712,6 +2774,14 @@ name = "xi-unicode" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "yaml-rust" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "zip" version = "0.4.2" @@ -2728,6 +2798,7 @@ dependencies = [ "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum arc-swap 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f344c31716d7f1afc56f8cc08163f7d1826b223924c04b89b0a533459d5f99f" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum array-macro 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8b1b1a00de235e9f2cc0e650423dc249d875c116a5934188c08fdd0c02d840ef" @@ -2764,6 +2835,7 @@ dependencies = [ "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum croaring 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "38961600edf0408acc371eb2359901f5ed2e634dde8537fc9a05e88fb26cde0e" "checksum croaring-sys 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "48a344ef01931b3106d6083c08fefc16e2b0b9d2de695a49a7437e56607cfda1" +"checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" "checksum crossbeam-deque 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3486aefc4c0487b9cb52372c97df0a48b8c249514af1ee99703bf70d2f2ceda1" "checksum crossbeam-epoch 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30fecfcac6abfef8771151f8be4abc9e4edc112c2bcb233314cafde2680536e9" @@ -2816,7 +2888,6 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" @@ -2830,10 +2901,13 @@ dependencies = [ "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum libz-sys 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "4401fe74560a0d46fce3464625ac8aa7a79d291dd28cee021d18852d5191c280" "checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" +"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "13416eee745b087c22934f35f1f24da22da41ba2a5ce197143d168ce055cc58d" "checksum lock_api 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775751a3e69bde4df9b38dd00a1b5d6ac13791e4223d4a0506577f0dd27cfb7a" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" +"checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" +"checksum log4rs 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25e0fc8737a634116a2deb38d821e4400ed16ce9dcb0d628a978d399260f5902" "checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -2873,6 +2947,7 @@ dependencies = [ "checksum openssl 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5af9e83eb3c51ee806387d26a43056f3246d865844caa6dd704d2ba7e831c264" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3d1b390ab1b9700f682ad95a30dc9c0f40dd212ca57266012cfc678b0e365a" +"checksum ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7eb5259643245d3f292c7a146b2df53bba24d7eab159410e648eb73dc164669d" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -2925,16 +3000,15 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" +"checksum serde-value 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "52903ade2290cbd61a0937a66a268f26cebf246e3ddd7964a8babb297111fb0d" "checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c" "checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce" "checksum serde_urlencoded 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aaed41d9fb1e2f587201b863356590c90c1157495d811430a0c0325fe8169650" +"checksum serde_yaml 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "980f5cc4e92ba24ba471b6a7b3df17d5b7b2c16fb1900a1aa0a79062320b16c4" "checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" "checksum signal-hook 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f7ca1f1c0ed6c8beaab713ad902c041e4f09d06e1b4bb74c5fc553c078ed0110" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d" -"checksum slog 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "09e4f1d0276ac7d448d98db16f0dab0220c24d4842d88ce4dad4b306fa234f1d" -"checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" -"checksum slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5951a808c40f419922ee014c15b6ae1cd34d963538b57d8a4778b9ca3fff1e0b" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970" @@ -2943,7 +3017,6 @@ dependencies = [ "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.12 (registry+https://github.com/rust-lang/crates.io-index)" = "34ab9797e47d24cb76b8dc4d24ff36807018c7cc549c4cba050b068be0c586b0" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" -"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum tar 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "83b0d14b53dbfd62681933fadd651e815f99e6084b649e049ab99296e05ab3de" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" @@ -2951,6 +3024,7 @@ dependencies = [ "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum thread-id 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" "checksum tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6e93c78d23cc61aa245a8acd2c4a79c4d7fa7fb5c3ca90d5737029f043a84895" @@ -2970,7 +3044,9 @@ dependencies = [ "checksum tokio-udp 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "da941144b816d0dcda4db3a1ba87596e4df5e860a72b70783fe435891f80601c" "checksum tokio-uds 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22e3aa6d1fcc19e635418dc0a30ab5bd65d347973d6f43f1a37bf8d9d1335fc9" "checksum toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4a2ecc31b0351ea18b3fe11274b8db6e4d82bce861bbb22e6dbed40417902c65" +"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +"checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" @@ -2981,6 +3057,7 @@ dependencies = [ "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a321979c09843d272956e73700d12c4e7d3d92b2ee112b31548aef0d4efc5a6" "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" @@ -3005,4 +3082,5 @@ dependencies = [ "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" "checksum xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12ea8eda4b1eb72f02d148402e23832d56a33f55d8c1b2d5bcdde91d79d47cb1" +"checksum yaml-rust 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "95acf0db5515d07da9965ec0e0ba6cc2d825e2caeb7303b66ca441729801254e" "checksum zip 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "36b9e08fb518a65cf7e08a1e482573eb87a2f4f8c6619316612a3c1f162fe822" diff --git a/Cargo.toml b/Cargo.toml index 98a50ecc3..e28069eab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ humansize = "1.1.0" daemonize = "0.3" serde = "1" serde_json = "1" -slog = { version = "~2.3", features = ["max_level_trace", "release_max_level_trace"] } +log = "0.4" term = "0.5" grin_api = { path = "./api" } diff --git a/api/Cargo.toml b/api/Cargo.toml index a944eb7a1..10cbadce0 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -15,7 +15,7 @@ ring = "0.13" serde = "1" serde_derive = "1" serde_json = "1" -slog = { version = "~2.3", features = ["max_level_trace", "release_max_level_trace"] } +log = "0.4" tokio = "0.1.7" tokio-core = "0.1.17" tokio-tcp = "0.1" diff --git a/api/src/handlers.rs b/api/src/handlers.rs index e2960ddf8..d684d4262 100644 --- a/api/src/handlers.rs +++ b/api/src/handlers.rs @@ -14,7 +14,8 @@ use std::collections::HashMap; use std::net::SocketAddr; -use std::sync::{Arc, RwLock, Weak}; +use std::sync::{Arc, Weak}; +use util::RwLock; use failure::ResultExt; use futures::future::ok; @@ -36,7 +37,6 @@ use types::*; use url::form_urlencoded; use util; use util::secp::pedersen::Commitment; -use util::LOGGER; use web::*; // All handlers use `Weak` references instead of `Arc` to avoid cycles that @@ -205,12 +205,8 @@ impl OutputHandler { } debug!( - LOGGER, "outputs_block_batch: {}-{}, {:?}, {:?}", - start_height, - end_height, - commitments, - include_rp, + start_height, end_height, commitments, include_rp, ); let mut return_vec = vec![]; @@ -695,7 +691,7 @@ struct PoolInfoHandler { impl Handler for PoolInfoHandler { fn get(&self, _req: Request) -> ResponseFuture { let pool_arc = w(&self.tx_pool); - let pool = pool_arc.read().unwrap(); + let pool = pool_arc.read(); json_response(&PoolInfo { pool_size: pool.total_size(), @@ -744,7 +740,6 @@ impl PoolPushHandler { identifier: "?.?.?.?".to_string(), }; info!( - LOGGER, "Pushing transaction {} to pool (inputs: {}, outputs: {}, kernels: {})", tx.hash(), tx.inputs().len(), @@ -753,12 +748,12 @@ impl PoolPushHandler { ); // Push to tx pool. - let mut tx_pool = pool_arc.write().unwrap(); + let mut tx_pool = pool_arc.write(); let header = tx_pool.blockchain.chain_head().unwrap(); tx_pool .add_to_pool(source, tx, !fluff, &header) .map_err(|e| { - error!(LOGGER, "update_pool: failed with error: {:?}", e); + error!("update_pool: failed with error: {:?}", e); ErrorKind::Internal(format!("Failed to update pool: {:?}", e)).into() }) }), @@ -807,7 +802,7 @@ pub fn start_rest_apis( router.add_middleware(basic_auth_middleware); } - info!(LOGGER, "Starting HTTP API server at {}.", addr); + info!("Starting HTTP API server at {}.", addr); let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address"); apis.start(socket_addr, router, tls_config).is_ok() } diff --git a/api/src/lib.rs b/api/src/lib.rs index 5df900aaf..cde0399ef 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -33,7 +33,7 @@ extern crate serde; extern crate serde_derive; extern crate serde_json; #[macro_use] -extern crate slog; +extern crate log; extern crate futures; extern crate http; extern crate hyper_rustls; diff --git a/api/src/rest.rs b/api/src/rest.rs index f7738d0a5..54e7d2446 100644 --- a/api/src/rest.rs +++ b/api/src/rest.rs @@ -33,7 +33,6 @@ use std::sync::Arc; use std::{io, thread}; use tokio_rustls::ServerConfigExt; use tokio_tcp; -use util::LOGGER; /// Errors that can be returned by an ApiEndpoint implementation. #[derive(Debug)] @@ -243,13 +242,10 @@ impl ApiServer { // TODO re-enable stop after investigation //let tx = mem::replace(&mut self.shutdown_sender, None).unwrap(); //tx.send(()).expect("Failed to stop API server"); - info!(LOGGER, "API server has been stoped"); + info!("API server has been stoped"); true } else { - error!( - LOGGER, - "Can't stop API server, it's not running or doesn't spport stop operation" - ); + error!("Can't stop API server, it's not running or doesn't spport stop operation"); false } } @@ -263,7 +259,7 @@ impl Handler for LoggingMiddleware { req: Request, mut handlers: Box>, ) -> ResponseFuture { - debug!(LOGGER, "REST call: {} {}", req.method(), req.uri().path()); + debug!("REST call: {} {}", req.method(), req.uri().path()); handlers.next().unwrap().call(req, handlers) } } diff --git a/chain/Cargo.toml b/chain/Cargo.toml index c59bc55cd..ff9456ed8 100644 --- a/chain/Cargo.toml +++ b/chain/Cargo.toml @@ -12,7 +12,7 @@ lmdb-zero = "0.4.4" failure = "0.1" failure_derive = "0.1" croaring = "0.3" -slog = { version = "~2.3", features = ["max_level_trace", "release_max_level_trace"] } +log = "0.4" serde = "1" serde_derive = "1" chrono = "0.4.4" diff --git a/chain/src/chain.rs b/chain/src/chain.rs index e36ea528c..9bc893e5f 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -18,8 +18,9 @@ use std::collections::HashMap; use std::fs::File; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; use std::time::{Duration, Instant}; +use util::RwLock; use lmdb; use lru_cache::LruCache; @@ -37,7 +38,6 @@ use store; use txhashset; use types::{ChainAdapter, NoStatus, Options, Tip, TxHashSetRoots, TxHashsetWriteStatus}; use util::secp::pedersen::{Commitment, RangeProof}; -use util::LOGGER; /// Orphan pool size is limited by MAX_ORPHAN_SIZE pub const MAX_ORPHAN_SIZE: usize = 200; @@ -75,7 +75,7 @@ impl OrphanBlockPool { } fn len(&self) -> usize { - let orphans = self.orphans.read().unwrap(); + let orphans = self.orphans.read(); orphans.len() } @@ -84,8 +84,8 @@ impl OrphanBlockPool { } fn add(&self, orphan: Orphan) { - let mut orphans = self.orphans.write().unwrap(); - let mut height_idx = self.height_idx.write().unwrap(); + let mut orphans = self.orphans.write(); + let mut height_idx = self.height_idx.write(); { let height_hashes = height_idx .entry(orphan.block.header.height) @@ -125,15 +125,15 @@ impl OrphanBlockPool { /// Get an orphan from the pool indexed by the hash of its parent, removing /// it at the same time, preventing clone fn remove_by_height(&self, height: &u64) -> Option> { - let mut orphans = self.orphans.write().unwrap(); - let mut height_idx = self.height_idx.write().unwrap(); + let mut orphans = self.orphans.write(); + let mut height_idx = self.height_idx.write(); height_idx .remove(height) .map(|hs| hs.iter().filter_map(|h| orphans.remove(h)).collect()) } pub fn contains(&self, hash: &Hash) -> bool { - let orphans = self.orphans.read().unwrap(); + let orphans = self.orphans.read(); orphans.contains_key(hash) } } @@ -183,7 +183,6 @@ impl Chain { let head = store.head()?; debug!( - LOGGER, "Chain init: {} @ {} [{}]", head.total_difficulty.to_num(), head.height, @@ -221,7 +220,7 @@ impl Chain { fn process_block_single(&self, b: Block, opts: Options) -> Result, Error> { let maybe_new_head: Result, Error>; { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let batch = self.store.batch()?; let mut ctx = self.new_ctx(opts, batch, &mut txhashset)?; @@ -235,7 +234,7 @@ impl Chain { let add_to_hash_cache = |hash: Hash| { // only add to hash cache below if block is definitively accepted // or rejected - let mut cache = self.block_hashes_cache.write().unwrap(); + let mut cache = self.block_hashes_cache.write(); cache.insert(hash, true); }; @@ -260,7 +259,6 @@ impl Chain { &self.orphans.add(orphan); debug!( - LOGGER, "process_block: orphan: {:?}, # orphans {}{}", block_hash, self.orphans.len(), @@ -274,7 +272,6 @@ impl Chain { } ErrorKind::Unfit(ref msg) => { debug!( - LOGGER, "Block {} at {} is unfit at this time: {}", b.hash(), b.header.height, @@ -284,7 +281,6 @@ impl Chain { } _ => { info!( - LOGGER, "Rejected block {} at {}: {:?}", b.hash(), b.header.height, @@ -299,7 +295,7 @@ impl Chain { /// Process a block header received during "header first" propagation. pub fn process_block_header(&self, bh: &BlockHeader, opts: Options) -> Result<(), Error> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let batch = self.store.batch()?; let mut ctx = self.new_ctx(opts, batch, &mut txhashset)?; pipe::process_block_header(bh, &mut ctx)?; @@ -315,7 +311,7 @@ impl Chain { headers: &Vec, opts: Options, ) -> Result<(), Error> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let batch = self.store.batch()?; let mut ctx = self.new_ctx(opts, batch, &mut txhashset)?; @@ -359,7 +355,6 @@ impl Chain { // Is there an orphan in our orphans that we can now process? loop { trace!( - LOGGER, "check_orphans: at {}, # orphans {}", height, self.orphans.len(), @@ -372,7 +367,6 @@ impl Chain { let orphans_len = orphans.len(); for (i, orphan) in orphans.into_iter().enumerate() { debug!( - LOGGER, "check_orphans: get block {} at {}{}", orphan.block.hash(), height, @@ -401,7 +395,6 @@ impl Chain { if initial_height != height { debug!( - LOGGER, "check_orphans: {} blocks accepted since height {}, remaining # orphans {}", height - initial_height, initial_height, @@ -417,7 +410,7 @@ impl Chain { /// current chain state, specifically the current winning (valid, most /// work) fork. pub fn is_unspent(&self, output_ref: &OutputIdentifier) -> Result { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let res = txhashset.is_unspent(output_ref); match res { Err(e) => Err(e), @@ -427,7 +420,7 @@ impl Chain { /// Validate the tx against the current UTXO set. pub fn validate_tx(&self, tx: &Transaction) -> Result<(), Error> { - let txhashset = self.txhashset.read().unwrap(); + let txhashset = self.txhashset.read(); txhashset::utxo_view(&txhashset, |utxo| { utxo.validate_tx(tx)?; Ok(()) @@ -443,7 +436,7 @@ impl Chain { /// that has not yet sufficiently matured. pub fn verify_coinbase_maturity(&self, tx: &Transaction) -> Result<(), Error> { let height = self.next_block_height()?; - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset::extending_readonly(&mut txhashset, |extension| { extension.verify_coinbase_maturity(&tx.inputs(), height)?; Ok(()) @@ -470,7 +463,7 @@ impl Chain { return Ok(()); } - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); // Now create an extension from the txhashset and validate against the // latest block header. Rewind the extension to the specified header to @@ -485,7 +478,7 @@ impl Chain { /// Sets the txhashset roots on a brand new block by applying the block on /// the current txhashset state. pub fn set_txhashset_roots(&self, b: &mut Block, is_fork: bool) -> Result<(), Error> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let (prev_root, roots, sizes) = txhashset::extending_readonly(&mut txhashset, |extension| { if is_fork { @@ -526,7 +519,7 @@ impl Chain { output: &OutputIdentifier, block_header: &BlockHeader, ) -> Result { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let merkle_proof = txhashset::extending_readonly(&mut txhashset, |extension| { extension.rewind(&block_header)?; @@ -539,13 +532,13 @@ impl Chain { /// Return a merkle proof valid for the current output pmmr state at the /// given pos pub fn get_merkle_proof_for_pos(&self, commit: Commitment) -> Result { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.merkle_proof(commit) } /// Returns current txhashset roots pub fn get_txhashset_roots(&self) -> TxHashSetRoots { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.roots() } @@ -560,7 +553,7 @@ impl Chain { // to rewind after receiving the txhashset zip. let header = self.get_block_header(&h)?; { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset::extending_readonly(&mut txhashset, |extension| { extension.rewind(&header)?; extension.snapshot()?; @@ -588,7 +581,6 @@ impl Chain { txhashset: &txhashset::TxHashSet, ) -> Result<(), Error> { debug!( - LOGGER, "chain: validate_kernel_history: rewinding and validating kernel history (readonly)" ); @@ -605,8 +597,8 @@ impl Chain { })?; debug!( - LOGGER, - "chain: validate_kernel_history: validated kernel root on {} headers", count, + "chain: validate_kernel_history: validated kernel root on {} headers", + count, ); Ok(()) @@ -617,7 +609,7 @@ impl Chain { /// have an MMR we can safely rewind based on the headers received from a peer. /// TODO - think about how to optimize this. pub fn rebuild_sync_mmr(&self, head: &Tip) -> Result<(), Error> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let mut batch = self.store.batch()?; txhashset::sync_extending(&mut txhashset, &mut batch, |extension| { extension.rebuild(head, &self.genesis)?; @@ -681,10 +673,7 @@ impl Chain { self.validate_kernel_history(&header, &txhashset)?; // all good, prepare a new batch and update all the required records - debug!( - LOGGER, - "chain: txhashset_write: rewinding a 2nd time (writeable)" - ); + debug!("chain: txhashset_write: rewinding a 2nd time (writeable)"); let mut batch = self.store.batch()?; @@ -708,10 +697,7 @@ impl Chain { Ok(()) })?; - debug!( - LOGGER, - "chain: txhashset_write: finished validating and rebuilding" - ); + debug!("chain: txhashset_write: finished validating and rebuilding"); status.on_save(); @@ -726,21 +712,15 @@ impl Chain { // Commit all the changes to the db. batch.commit()?; - debug!( - LOGGER, - "chain: txhashset_write: finished committing the batch (head etc.)" - ); + debug!("chain: txhashset_write: finished committing the batch (head etc.)"); // Replace the chain txhashset with the newly built one. { - let mut txhashset_ref = self.txhashset.write().unwrap(); + let mut txhashset_ref = self.txhashset.write(); *txhashset_ref = txhashset; } - debug!( - LOGGER, - "chain: txhashset_write: replaced our txhashset with the new one" - ); + debug!("chain: txhashset_write: replaced our txhashset with the new one"); // Check for any orphan blocks and process them based on the new chain state. self.check_orphans(header.height + 1); @@ -749,33 +729,11 @@ impl Chain { Ok(()) } - /// Triggers chain compaction, cleaning up some unnecessary historical - /// information. We introduce a chain depth called horizon, which is - /// typically in the range of a couple days. Before that horizon, this - /// method will: - /// - /// * compact the MMRs data files and flushing the corresponding remove logs - /// * delete old records from the k/v store (older blocks, indexes, etc.) - /// - /// This operation can be resource intensive and takes some time to execute. - /// Meanwhile, the chain will not be able to accept new blocks. It should - /// therefore be called judiciously. - pub fn compact(&self) -> Result<(), Error> { - if self.archive_mode { - debug!( - LOGGER, - "Blockchain compaction disabled, node running in archive mode." - ); - return Ok(()); - } - - debug!(LOGGER, "Starting blockchain compaction."); - // Compact the txhashset via the extension. + fn compact_txhashset(&self) -> Result<(), Error> { + debug!("Starting blockchain compaction."); { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.compact()?; - - // print out useful debug info after compaction txhashset::extending_readonly(&mut txhashset, |extension| { extension.dump_output_pmmr(); Ok(()) @@ -784,23 +742,33 @@ impl Chain { // Now check we can still successfully validate the chain state after // compacting, shouldn't be necessary once all of this is well-oiled - debug!(LOGGER, "Validating state after compaction."); + debug!("Validating state after compaction."); self.validate(true)?; + Ok(()) + } - // we need to be careful here in testing as 20 blocks is not that long - // in wall clock time - let horizon = global::cut_through_horizon() as u64; - let head = self.head()?; - - if head.height <= horizon { + /// Cleanup old blocks from the db. + /// Determine the cutoff height from the horizon and the current block height. + /// *Only* runs if we are not in archive mode. + fn compact_blocks_db(&self) -> Result<(), Error> { + if self.archive_mode { return Ok(()); } + let horizon = global::cut_through_horizon() as u64; + let head = self.head()?; + + let cutoff = head.height.saturating_sub(horizon); + debug!( - LOGGER, - "Compaction remove blocks older than {}.", - head.height - horizon + "chain: compact_blocks_db: head height: {}, horizon: {}, cutoff: {}", + head.height, horizon, cutoff, ); + + if cutoff == 0 { + return Ok(()); + } + let mut count = 0; let batch = self.store.batch()?; let mut current = batch.get_header_by_height(head.height - horizon - 1)?; @@ -830,25 +798,40 @@ impl Chain { } } batch.commit()?; - debug!(LOGGER, "Compaction removed {} blocks, done.", count); + debug!("chain: compact_blocks_db: removed {} blocks.", count); + Ok(()) + } + + /// Triggers chain compaction. + /// + /// * compacts the txhashset based on current prune_list + /// * removes historical blocks and associated data from the db (unless archive mode) + /// + pub fn compact(&self) -> Result<(), Error> { + self.compact_txhashset()?; + + if !self.archive_mode { + self.compact_blocks_db()?; + } + Ok(()) } /// returns the last n nodes inserted into the output sum tree pub fn get_last_n_output(&self, distance: u64) -> Vec<(Hash, OutputIdentifier)> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.last_n_output(distance) } /// as above, for rangeproofs pub fn get_last_n_rangeproof(&self, distance: u64) -> Vec<(Hash, RangeProof)> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.last_n_rangeproof(distance) } /// as above, for kernels pub fn get_last_n_kernel(&self, distance: u64) -> Vec<(Hash, TxKernel)> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); txhashset.last_n_kernel(distance) } @@ -858,7 +841,7 @@ impl Chain { start_index: u64, max: u64, ) -> Result<(u64, u64, Vec), Error> { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let max_index = txhashset.highest_output_insertion_index(); let outputs = txhashset.outputs_by_insertion_index(start_index, max); let rangeproofs = txhashset.rangeproofs_by_insertion_index(start_index, max); @@ -945,7 +928,7 @@ impl Chain { &self, output_ref: &OutputIdentifier, ) -> Result { - let mut txhashset = self.txhashset.write().unwrap(); + let mut txhashset = self.txhashset.write(); let (_, pos) = txhashset.is_unspent(output_ref)?; let mut min = 1; let mut max = { @@ -1051,7 +1034,6 @@ fn setup_head( if header.height > 0 && extension.batch.get_block_sums(&header.hash()).is_err() { debug!( - LOGGER, "chain: init: building (missing) block sums for {} @ {}", header.height, header.hash() @@ -1072,7 +1054,6 @@ fn setup_head( } debug!( - LOGGER, "chain: init: rewinding and validating before we start... {} at {}", header.hash(), header.height, @@ -1109,7 +1090,7 @@ fn setup_head( // Save the block_sums to the db for use later. batch.save_block_sums(&genesis.hash(), &BlockSums::default())?; - info!(LOGGER, "chain: init: saved genesis: {:?}", genesis.hash()); + info!("chain: init: saved genesis: {:?}", genesis.hash()); } Err(e) => return Err(ErrorKind::StoreErr(e, "chain init load head".to_owned()))?, }; diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 83fc8faa9..82db548fb 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -30,7 +30,7 @@ extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] -extern crate slog; +extern crate log; extern crate chrono; extern crate failure; #[macro_use] diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index c2f4c8527..0e2218144 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -14,7 +14,8 @@ //! Implementation of the chain block acceptance (or refusal) pipeline. -use std::sync::{Arc, RwLock}; +use std::sync::Arc; +use util::RwLock; use chrono::prelude::Utc; use chrono::Duration; @@ -34,7 +35,6 @@ use grin_store; use store; use txhashset; use types::{Options, Tip}; -use util::LOGGER; /// Contextual information required to process a new block and either reject or /// accept it. @@ -70,7 +70,6 @@ pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result, E // spend resources reading the full block when its header is invalid debug!( - LOGGER, "pipe: process_block {} at {} with {} inputs, {} outputs, {} kernels", b.hash(), b.header.height, @@ -167,7 +166,6 @@ pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result, E })?; trace!( - LOGGER, "pipe: process_block: {} at {} is valid, save and append.", b.hash(), b.header.height, @@ -189,7 +187,6 @@ pub fn sync_block_headers( ) -> Result, Error> { if let Some(header) = headers.first() { debug!( - LOGGER, "pipe: sync_block_headers: {} headers from {} at {}", headers.len(), header.hash(), @@ -250,7 +247,6 @@ pub fn sync_block_headers( /// it. pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { debug!( - LOGGER, "pipe: process_block_header: {} at {}", header.hash(), header.height, @@ -288,7 +284,7 @@ fn check_known_head(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), /// Keeps duplicates from the network in check. /// Checks against the cache of recently processed block hashes. fn check_known_cache(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> { - let mut cache = ctx.block_hashes_cache.write().unwrap(); + let mut cache = ctx.block_hashes_cache.write(); if cache.contains_key(&header.hash()) { return Err(ErrorKind::Unfit("already known in cache".to_string()).into()); } @@ -355,8 +351,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E // check version, enforces scheduled hard fork if !consensus::valid_header_version(header.height, header.version) { error!( - LOGGER, - "Invalid block header version received ({}), maybe update Grin?", header.version + "Invalid block header version received ({}), maybe update Grin?", + header.version ); return Err(ErrorKind::InvalidBlockVersion(header.version).into()); } @@ -377,8 +373,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E let edge_bits = header.pow.edge_bits(); if !(ctx.pow_verifier)(header, edge_bits).is_ok() { error!( - LOGGER, - "pipe: error validating header with cuckoo edge_bits {}", edge_bits + "pipe: error validating header with cuckoo edge_bits {}", + edge_bits ); return Err(ErrorKind::InvalidPow.into()); } @@ -433,7 +429,6 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E let next_header_info = consensus::next_difficulty(header.height, diff_iter); if target_difficulty != next_header_info.difficulty { info!( - LOGGER, "validate_header: header target difficulty {} != {}", target_difficulty.to_num(), next_header_info.difficulty.to_num() @@ -553,8 +548,8 @@ fn update_head(b: &Block, ctx: &BlockContext) -> Result, Error> { .map_err(|e| ErrorKind::StoreErr(e, "pipe save body".to_owned()))?; debug!( - LOGGER, - "pipe: head updated to {} at {}", tip.last_block_h, tip.height + "pipe: head updated to {} at {}", + tip.last_block_h, tip.height ); Ok(Some(tip)) @@ -574,7 +569,7 @@ fn update_sync_head(bh: &BlockHeader, batch: &mut store::Batch) -> Result<(), Er batch .save_sync_head(&tip) .map_err(|e| ErrorKind::StoreErr(e, "pipe save sync head".to_owned()))?; - debug!(LOGGER, "sync head {} @ {}", bh.hash(), bh.height); + debug!("sync head {} @ {}", bh.hash(), bh.height); Ok(()) } @@ -588,8 +583,8 @@ fn update_header_head(bh: &BlockHeader, ctx: &mut BlockContext) -> Result