diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7286c2fc5..bd7647b04 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -39,10 +39,10 @@ jobs: run: cargo check - name: Tests (Bitcoin mode, REST+Electrum) - run: cargo test + run: RUST_LOG=debug cargo test - name: Tests (Liquid mode, REST) - run: cargo test --features liquid + run: RUST_LOG=debug cargo test --features liquid nix: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index ba517f5e4..336881850 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,24 +4,24 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aes" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -52,6 +52,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -63,9 +69,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" [[package]] name = "arraydeque" @@ -75,9 +81,9 @@ checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "ascii" @@ -85,6 +91,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "atty" version = "0.2.14" @@ -98,23 +115,68 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -146,9 +208,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64-compat" @@ -204,7 +266,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -249,6 +311,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" +[[package]] +name = "bitcoin-test-data" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c188654f9dce3bc6ce1bfa9c49777ad514bcad37e421b5f53e9d0ee10603f34" + [[package]] name = "bitcoin_hashes" version = "0.10.0" @@ -304,22 +372,9 @@ dependencies = [ [[package]] name = "bitcoind" -version = "0.34.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50548a349632abb9a2007d431a302bf0401a786c91f809ff31765fba87e2397" -dependencies = [ - "anyhow", - "bitcoincore-rpc", - "log", - "tempfile", - "which", -] - -[[package]] -name = "bitcoind" -version = "0.35.1" +version = "0.34.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09db6b30b527263d2e3a8768a2c9299763858cb84d01a9d63d174b9f515e1a32" +checksum = "2542fac51d8cd8fce6109f4a3ffd1acfdaa3394c36d4a8207af15b8b0540e2fc" dependencies = [ "anyhow", "bitcoin_hashes 0.13.0", @@ -341,9 +396,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -356,9 +411,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -368,9 +423,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bzip2" @@ -393,13 +448,21 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" -version = "1.0.85" +version = "1.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b918671670962b48bc23753aef0c51d072dca6f52f01f800854ada6ddb7f7d3" +checksum = "0f57c4b4da2a9d619dd035f27316d7a426305b75be93d09e92f2b9229c34feaf" dependencies = [ + "jobserver", "libc", + "shlex", ] [[package]] @@ -419,16 +482,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -437,6 +500,33 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.4.4" @@ -449,9 +539,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -468,16 +558,37 @@ dependencies = [ "atty", "bitflags 1.3.2", "strsim", - "textwrap", + "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "bitflags 1.3.2", + "clap_lex", + "indexmap 1.9.3", + "textwrap 0.16.1", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "const_fn" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" +checksum = "373e9fafaa20882876db20562275ff58d50e0caa2590077fe7ce7bef90211d0d" [[package]] name = "constant_time_eq" @@ -512,35 +623,81 @@ dependencies = [ "url", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap 3.2.25", + "criterion-plot", + "itertools 0.10.5", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -566,9 +723,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" @@ -627,11 +790,22 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "electrs" @@ -639,11 +813,13 @@ version = "0.4.1" dependencies = [ "arraydeque", "arrayref", - "base64 0.22.0", + "base64 0.22.1", "bincode", "bitcoin 0.31.2", - "bitcoind 0.35.1", - "clap", + "bitcoin-test-data", + "bitcoind", + "clap 2.34.0", + "criterion", "crossbeam-channel", "dirs", "electrum-client", @@ -655,11 +831,14 @@ dependencies = [ "hex-conservative", "hyper", "hyperlocal", - "itertools", + "itertools 0.12.1", "lazy_static", "libc", "log", "num_cpus", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", "page_size", "prometheus", "rayon", @@ -673,10 +852,13 @@ dependencies = [ "stderrlog", "sysconf", "tempfile", - "time 0.3.34", + "time 0.3.36", "tiny_http", "tokio", - "ureq 2.9.6", + "tracing", + "tracing-opentelemetry", + "tracing-subscriber", + "ureq 2.10.1", "url", ] @@ -698,7 +880,7 @@ dependencies = [ [[package]] name = "electrumd" version = "0.1.0" -source = "git+https://github.com/shesek/electrumd?rev=996fe2a8e563bc1bde6bbc2e0c2a2f4421abcdbc#996fe2a8e563bc1bde6bbc2e0c2a2f4421abcdbc" +source = "git+https://github.com/shesek/electrumd?rev=b35d9db285d932cb3c2296beab65e571a2506349#b35d9db285d932cb3c2296beab65e571a2506349" dependencies = [ "bitcoin_hashes 0.10.0", "home", @@ -723,17 +905,32 @@ dependencies = [ [[package]] name = "elementsd" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17022ca1a790518f66c46c40ab729cc275f8a009babad583972a946a851cadf" +checksum = "19b08013ae0b60e4a3ac9d126e230338dec55575ddf7811aeaebb096f7c3abbf" dependencies = [ "bitcoin_hashes 0.12.0", - "bitcoind 0.34.1", + "bitcoind", "flate2", "minreq", "tar", ] +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.2.8" @@ -747,9 +944,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -777,27 +974,27 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -826,45 +1023,71 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -888,9 +1111,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -899,9 +1122,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -909,6 +1132,47 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.6.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -920,9 +1184,15 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hermit-abi" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" @@ -932,9 +1202,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-conservative" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" [[package]] name = "hex_lit" @@ -962,9 +1232,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -984,9 +1254,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -996,14 +1266,15 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "httparse", @@ -1017,6 +1288,18 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "hyperlocal" version = "0.8.0" @@ -1032,9 +1315,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1054,73 +1337,246 @@ dependencies = [ ] [[package]] -name = "idna" -version = "0.2.3" +name = "icu_collections" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "yoke", + "zerofrom", + "zerovec", ] [[package]] -name = "idna" -version = "0.5.0" +name = "icu_locid" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", ] [[package]] -name = "inout" -version = "0.1.3" +name = "icu_locid_transform" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" dependencies = [ - "generic-array", + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", ] [[package]] -name = "is-terminal" -version = "0.4.12" +name = "icu_locid_transform_data" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" -dependencies = [ - "hermit-abi 0.3.5", - "libc", - "windows-sys 0.52.0", -] +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" [[package]] -name = "itertools" -version = "0.12.1" +name = "icu_normalizer" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" dependencies = [ - "either", + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", ] [[package]] -name = "itoa" -version = "1.0.10" +name = "icu_normalizer_data" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" [[package]] -name = "js-sys" -version = "0.3.68" +name = "icu_properties" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" dependencies = [ - "wasm-bindgen", + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", ] [[package]] -name = "jsonrpc" -version = "0.12.0" +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.1", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi 0.4.0", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpc" +version = "0.12.0" source = "git+https://github.com/shesek/rust-jsonrpc?branch=202201-nonarray#aaa0af349bd4885a59f6f6ba1753e78279014f98" dependencies = [ "base64-compat", @@ -1152,9 +1608,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lazycell" @@ -1164,27 +1620,27 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.6", ] [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", "redox_syscall", ] @@ -1207,9 +1663,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.15" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "pkg-config", @@ -1218,15 +1674,21 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1234,31 +1696,52 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.11.1+lz4-1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" dependencies = [ "cc", "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal-lexical" @@ -1268,35 +1751,36 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "minreq" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" +checksum = "763d142cdff44aaadd9268bebddb156ef6c65a0e13486bb81673cf2d8739f9b0" dependencies = [ "log", "once_cell", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-webpki", "webpki-roots 0.25.4", ] [[package]] name = "mio" -version = "0.8.10" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi 0.3.9", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1317,9 +1801,9 @@ checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -1330,24 +1814,134 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.5", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "object" -version = "0.32.2" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "oorandom" +version = "11.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" + +[[package]] +name = "opentelemetry" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54" +dependencies = [ + "opentelemetry_api", + "opentelemetry_sdk", +] + +[[package]] +name = "opentelemetry-http" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7594ec0e11d8e33faf03530a4c49af7064ebba81c1480e01be67d90b356508b" +dependencies = [ + "async-trait", + "bytes", + "http", + "opentelemetry_api", + "reqwest", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5e5a5c4135864099f3faafbe939eb4d7f9b80ebf68a8448da961b32a7c1275" +dependencies = [ + "async-trait", + "futures-core", + "http", + "opentelemetry-http", + "opentelemetry-proto", + "opentelemetry-semantic-conventions", + "opentelemetry_api", + "opentelemetry_sdk", + "prost", + "reqwest", + "thiserror", + "tokio", + "tonic", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e3f814aa9f8c905d0ee4bde026afd3b2577a97c10e1699912e3e44f0c4cbeb" +dependencies = [ + "opentelemetry_api", + "opentelemetry_sdk", + "prost", + "tonic", +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73c9f9340ad135068800e7f1b24e9e09ed9e7143f5bf8518ded3d3ec69789269" +dependencies = [ + "opentelemetry", +] + +[[package]] +name = "opentelemetry_api" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" +dependencies = [ + "futures-channel", + "futures-util", + "indexmap 1.9.3", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", + "urlencoding", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8e705a0612d48139799fcbaba0d4a90f06277153e43dd2bdc16c6f0edd8026" +dependencies = [ + "async-trait", + "crossbeam-channel", + "futures-channel", + "futures-executor", + "futures-util", + "once_cell", + "opentelemetry_api", + "ordered-float", + "percent-encoding", + "rand 0.8.5", + "regex", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", +] [[package]] name = "option-ext" @@ -1355,6 +1949,21 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "3.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + [[package]] name = "page_size" version = "0.6.0" @@ -1367,9 +1976,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -1377,15 +1986,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -1425,29 +2034,29 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -1457,9 +2066,37 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] [[package]] name = "powerfmt" @@ -1469,18 +2106,21 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" -version = "0.2.16" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -1491,18 +2131,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" dependencies = [ "cfg-if", "fnv", @@ -1513,6 +2153,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "protobuf" version = "2.28.0" @@ -1540,9 +2203,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1646,18 +2309,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -1666,32 +2329,83 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] [[package]] name = "ring" @@ -1710,16 +2424,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1747,9 +2462,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -1774,12 +2489,12 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ - "bitflags 2.4.2", - "errno 0.3.8", + "bitflags 2.6.0", + "errno 0.3.9", "libc", "linux-raw-sys", "windows-sys 0.52.0", @@ -1813,12 +2528,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.17.7", + "ring 0.17.8", "rustls-webpki", "sct 0.7.1", ] @@ -1829,15 +2544,30 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] [[package]] name = "scopeguard" @@ -1861,7 +2591,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.7", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -1945,30 +2675,43 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ + "form_urlencoded", "itoa", "ryu", "serde", @@ -1996,9 +2739,9 @@ dependencies = [ [[package]] name = "sha1_smol" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" [[package]] name = "sha2" @@ -2011,6 +2754,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -2029,9 +2781,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -2047,15 +2799,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2084,6 +2836,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "standback" version = "0.2.17" @@ -2163,9 +2921,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -2180,32 +2938,70 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "sysconf" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59e93f5d45535f49b6a05ef7ac2f0f795d28de494cf53a512751602c9849bea3" +dependencies = [ + "errno 0.2.8", + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", ] [[package]] -name = "sysconf" -version = "0.3.4" +name = "system-configuration-sys" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e93f5d45535f49b6a05ef7ac2f0f795d28de494cf53a512751602c9849bea3" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ - "errno 0.2.8", - "kernel32-sys", + "core-foundation-sys", "libc", - "winapi 0.2.8", ] [[package]] name = "tar" -version = "0.4.40" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" dependencies = [ "filetime", "libc", @@ -2214,14 +3010,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2242,31 +3039,37 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -2300,9 +3103,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -2310,7 +3113,7 @@ dependencies = [ "powerfmt", "serde", "time-core", - "time-macros 0.2.17", + "time-macros 0.2.18", ] [[package]] @@ -2331,9 +3134,9 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -2364,11 +3167,31 @@ dependencies = [ "log", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2381,36 +3204,124 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", + "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", +] + +[[package]] +name = "tokio-stream" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +dependencies = [ + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", ] +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -2419,9 +3330,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -2429,6 +3352,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-opentelemetry" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75327c6b667828ddc28f5e3f169036cb793c3f588d83bf0f262a7f062ffed3c8" +dependencies = [ + "once_cell", + "opentelemetry", + "opentelemetry_sdk", + "smallvec", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "once_cell", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", ] [[package]] @@ -2445,30 +3411,30 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "untrusted" @@ -2503,11 +3469,11 @@ dependencies = [ [[package]] name = "ureq" -version = "2.9.6" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "log", "once_cell", "serde", @@ -2517,15 +3483,39 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.3", "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2540,9 +3530,19 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] [[package]] name = "want" @@ -2567,34 +3567,47 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2602,28 +3615,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -2705,11 +3718,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi 0.3.9", + "windows-sys 0.59.0", ] [[package]] @@ -2724,7 +3737,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -2742,7 +3755,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -2762,17 +3784,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2783,9 +3806,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2795,9 +3818,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2807,9 +3830,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2819,9 +3848,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2831,9 +3860,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2843,9 +3872,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2855,9 +3884,31 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "xattr" @@ -2870,6 +3921,94 @@ dependencies = [ "rustix", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zip" version = "0.6.6" @@ -2886,7 +4025,7 @@ dependencies = [ "hmac", "pbkdf2", "sha1 0.10.6", - "time 0.3.34", + "time 0.3.36", "zstd", ] @@ -2911,9 +4050,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index 72c569a86..ce3860668 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,21 +10,35 @@ keywords = ["bitcoin", "electrum", "server", "index", "database"] documentation = "https://docs.rs/electrs/" readme = "README.md" edition = "2018" +default-run = "electrs" [features] liquid = [ "elements" ] electrum-discovery = [ "electrum-client"] +default = ["no-otlp-tracing"] +otlp-tracing = [ + "tracing/max_level_trace", + "tracing-subscriber", + "opentelemetry", + "tracing-opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions" +] +no-otlp-tracing = [ + "tracing/max_level_off" +] +bench = [] [dependencies] arraydeque = "0.5.1" arrayref = "0.3.6" base64 = "0.22" bincode = "1.3.1" -bitcoin = { version = "0.31", features = [ "serde" ] } +bitcoin = { version = "0.31", features = ["serde"] } clap = "2.33.3" crossbeam-channel = "0.5.0" dirs = "5.0.1" -elements = { version = "0.24", features = [ "serde" ], optional = true } +elements = { version = "0.24", features = ["serde"], optional = true } error-chain = "0.12.4" glob = "0.3" hex = { package = "hex-conservative", version = "0.1.1" } @@ -51,18 +65,32 @@ url = "2.2.0" hyper = "0.14" hyperlocal = "0.8" # close to same tokio version as dependent by hyper v0.14 and hyperlocal 0.8 -- things can go awry if they mismatch -tokio = { version = "1", features = ["sync", "macros"] } +tokio = { version = "1", features = ["sync", "macros", "rt-multi-thread", "rt"] } +opentelemetry = { version = "0.20.0", features = ["rt-tokio"], optional = true } +tracing-opentelemetry = { version = "0.21.0", optional = true } +opentelemetry-otlp = { version = "0.13.0", default-features = false, features = ["http-proto", "reqwest-client"], optional = true } +tracing-subscriber = { version = "0.3.17", default-features = false, features = ["env-filter", "fmt"], optional = true } +opentelemetry-semantic-conventions = { version = "0.12.0", optional = true } +tracing = { version = "0.1.40", default-features = false, features = ["attributes"], optional = true } # optional dependencies for electrum-discovery electrum-client = { version = "0.8", optional = true } [dev-dependencies] -bitcoind = { version = "0.35", features = [ "25_0" ] } -elementsd = { version = "0.9", features = [ "22_1_1" ] } -electrumd = { version = "0.1.0", features = [ "4_1_5" ] } -ureq = { version = "2.9", default-features = false, features = [ "json" ] } +bitcoind = { version = "0.34.3", features = ["25_0"] } +elementsd = { version = "0.9.2", features = ["22_1_1"] } +electrumd = { version = "0.1.0", features = ["4_5_4"] } +ureq = { version = "2.9", default-features = false, features = ["json"] } tempfile = "3.10" +criterion = { version = "0.4", features = ["html_reports"] } +bitcoin-test-data = { version = "*" } + +[[bench]] +name = "benches" +harness = false +required-features = ["bench"] + [profile.release] lto = true @@ -71,9 +99,9 @@ codegen-units = 1 [patch.crates-io.electrum-client] git = "https://github.com/Blockstream/rust-electrum-client" -rev = "d3792352992a539afffbe11501d1aff9fd5b919d" # add-peer branch +rev = "d3792352992a539afffbe11501d1aff9fd5b919d" # add-peer branch # not yet published on crates.io [patch.crates-io.electrumd] git = "https://github.com/shesek/electrumd" -rev = "996fe2a8e563bc1bde6bbc2e0c2a2f4421abcdbc" +rev = "b35d9db285d932cb3c2296beab65e571a2506349" diff --git a/benches/benches.rs b/benches/benches.rs new file mode 100644 index 000000000..35ee0c638 --- /dev/null +++ b/benches/benches.rs @@ -0,0 +1,17 @@ +use bitcoin::{consensus::Decodable, Block}; +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use electrs::new_index::schema::bench::*; + +fn criterion_benchmark(c: &mut Criterion) { + c.bench_function("add_blocks", |b| { + let block_bytes = bitcoin_test_data::blocks::mainnet_702861(); + let block = Block::consensus_decode(&mut &block_bytes[..]).unwrap(); + let data = Data::new(block); + // TODO use iter_batched to avoid measuring cloning inputs + + b.iter(move || black_box(add_blocks(&data))) + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/flake.nix b/flake.nix index d23f3735f..ece2db67d 100644 --- a/flake.nix +++ b/flake.nix @@ -36,16 +36,22 @@ nativeBuildInputs = with pkgs; [ rustToolchain clang ]; # required only at build time buildInputs = with pkgs; [ ]; # also required at runtime - envVars = { - LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; - ELEMENTSD_SKIP_DOWNLOAD = true; - BITCOIND_SKIP_DOWNLOAD = true; - ELECTRUMD_SKIP_DOWNLOAD = true; + envVars = + { + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + ELEMENTSD_SKIP_DOWNLOAD = true; + BITCOIND_SKIP_DOWNLOAD = true; + ELECTRUMD_SKIP_DOWNLOAD = true; - # link rocksdb dynamically - ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb}/include"; - ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib"; - }; + # link rocksdb dynamically + ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb}/include"; + ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib"; + + # for integration testing + BITCOIND_EXE = "${pkgs.bitcoind}/bin/bitcoind"; + ELEMENTSD_EXE = "${pkgs.elementsd}/bin/elementsd"; + ELECTRUMD_EXE = "${pkgs.electrum}/bin/electrum"; + }; commonArgs = { inherit src buildInputs nativeBuildInputs; @@ -54,16 +60,10 @@ cargoArtifacts = craneLib.buildDepsOnly commonArgs; bin = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; - - # TODO: do testing by providing executables via *_EXE env var for {bitcoin,elements,electrum}d - doCheck = false; }); binLiquid = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; cargoExtraArgs = "--features liquid"; - - # TODO: do testing by providing executables via *_EXE env var for {bitcoin,elements,electrum}d - doCheck = false; }); in @@ -73,7 +73,7 @@ { # that way we can build `bin` specifically, # but it's also the default. - inherit bin; + inherit bin binLiquid; default = bin; }; diff --git a/src/bin/electrs.rs b/src/bin/electrs.rs index fb25e68a8..d1172023b 100644 --- a/src/bin/electrs.rs +++ b/src/bin/electrs.rs @@ -20,6 +20,9 @@ use electrs::{ signal::Waiter, }; +#[cfg(feature = "otlp-tracing")] +use electrs::otlp_trace; + #[cfg(feature = "liquid")] use electrs::elements::AssetRegistry; use electrs::metrics::MetricOpts; @@ -49,6 +52,7 @@ fn run_server(config: Arc) -> Result<()> { &config.daemon_dir, &config.blocks_dir, config.daemon_rpc_addr, + config.daemon_parallelism, config.cookie_getter(), config.network_type, signal.clone(), @@ -81,14 +85,11 @@ fn run_server(config: Arc) -> Result<()> { &metrics, Arc::clone(&config), ))); - loop { - match Mempool::update(&mempool, &daemon) { - Ok(_) => break, - Err(e) => { - warn!("Error performing initial mempool update, trying again in 5 seconds: {}", e.display_chain()); - signal.wait(Duration::from_secs(5), false)?; - }, - } + + while !Mempool::update(&mempool, &daemon, &tip)? { + // Mempool syncing was aborted because the chain tip moved; + // Index the new block(s) and try again. + tip = indexer.update(&daemon)?; } #[cfg(feature = "liquid")] @@ -117,7 +118,6 @@ fn run_server(config: Arc) -> Result<()> { )); loop { - main_loop_count.inc(); if let Err(err) = signal.wait(Duration::from_secs(5), true) { @@ -130,14 +130,12 @@ fn run_server(config: Arc) -> Result<()> { // Index new blocks let current_tip = daemon.getbestblockhash()?; if current_tip != tip { - indexer.update(&daemon)?; - tip = current_tip; + tip = indexer.update(&daemon)?; }; // Update mempool - if let Err(e) = Mempool::update(&mempool, &daemon) { - // Log the error if the result is an Err - warn!("Error updating mempool, skipping mempool update: {}", e.display_chain()); + if !Mempool::update(&mempool, &daemon, &tip)? { + warn!("skipped failed mempool update, trying again in 5 seconds"); } // Update subscribed clients @@ -147,6 +145,25 @@ fn run_server(config: Arc) -> Result<()> { Ok(()) } +#[cfg_attr(feature = "otlp-tracing", tokio::main)] +#[cfg_attr(not(feature = "otlp-tracing"), allow(dead_code))] +async fn main_async() { + #[cfg(feature = "otlp-tracing")] + let _tracing_guard = otlp_trace::init_tracing("electrs"); + + let config = Arc::new(Config::from_args()); + if let Err(e) = run_server(config) { + error!("server failed: {}", e.display_chain()); + process::exit(1); + } +} + +#[cfg(feature = "otlp-tracing")] +fn main() { + main_async(); +} + +#[cfg(not(feature = "otlp-tracing"))] fn main() { let config = Arc::new(Config::from_args()); if let Err(e) = run_server(config) { diff --git a/src/bin/tx-fingerprint-stats.rs b/src/bin/tx-fingerprint-stats.rs index afe980f8c..94a3821ab 100644 --- a/src/bin/tx-fingerprint-stats.rs +++ b/src/bin/tx-fingerprint-stats.rs @@ -33,6 +33,7 @@ fn main() { &config.daemon_dir, &config.blocks_dir, config.daemon_rpc_addr, + config.daemon_parallelism, config.cookie_getter(), config.network_type, signal, diff --git a/src/config.rs b/src/config.rs index 8696ecf8f..bfac177bd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -25,6 +25,7 @@ pub struct Config { pub daemon_dir: PathBuf, pub blocks_dir: PathBuf, pub daemon_rpc_addr: SocketAddr, + pub daemon_parallelism: usize, pub cookie: Option, pub electrum_rpc_addr: SocketAddr, pub http_addr: SocketAddr, @@ -41,6 +42,12 @@ pub struct Config { pub electrum_banner: String, pub electrum_rpc_logging: Option, + /// Enable compaction during initial sync + /// + /// By default compaction is off until initial sync is finished for performance reasons, + /// however, this requires much more disk space. + pub initial_sync_compaction: bool, + #[cfg(feature = "liquid")] pub parent_network: BNetwork, #[cfg(feature = "liquid")] @@ -132,6 +139,12 @@ impl Config { .help("Bitcoin daemon JSONRPC 'addr:port' to connect (default: 127.0.0.1:8332 for mainnet, 127.0.0.1:18332 for testnet and 127.0.0.1:18443 for regtest)") .takes_value(true), ) + .arg( + Arg::with_name("daemon_parallelism") + .long("daemon-parallelism") + .help("Number of JSONRPC requests to send in parallel") + .default_value("4") + ) .arg( Arg::with_name("monitoring_addr") .long("monitoring-addr") @@ -191,6 +204,10 @@ impl Config { .long("electrum-rpc-logging") .help(&rpc_logging_help) .takes_value(true), + ).arg( + Arg::with_name("initial_sync_compaction") + .long("initial-sync-compaction") + .help("Perform compaction during initial sync (slower but less disk space required)") ); #[cfg(unix)] @@ -379,6 +396,7 @@ impl Config { stderrlog::Timestamp::Off }); log.init().expect("logging initialization failed"); + let config = Config { log, network_type, @@ -386,6 +404,7 @@ impl Config { daemon_dir, blocks_dir, daemon_rpc_addr, + daemon_parallelism: value_t_or_exit!(m, "daemon_parallelism", usize), cookie, utxos_limit: value_t_or_exit!(m, "utxos_limit", usize), electrum_rpc_addr, @@ -403,6 +422,7 @@ impl Config { index_unspendables: m.is_present("index_unspendables"), cors: m.value_of("cors").map(|s| s.to_string()), precache_scripts: m.value_of("precache_scripts").map(|s| s.to_string()), + initial_sync_compaction: m.is_present("initial_sync_compaction"), #[cfg(feature = "liquid")] parent_network, diff --git a/src/daemon.rs b/src/daemon.rs index 457bf4230..bc50e71ae 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -1,3 +1,4 @@ +use std::cell::OnceCell; use std::collections::{HashMap, HashSet}; use std::env; use std::io::{BufRead, BufReader, Lines, Write}; @@ -8,8 +9,9 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use base64::prelude::{Engine, BASE64_STANDARD}; +use error_chain::ChainedError; use hex::FromHex; -use itertools::Itertools; +use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; use serde_json::{from_str, from_value, Value}; #[cfg(not(feature = "liquid"))] @@ -17,6 +19,8 @@ use bitcoin::consensus::encode::{deserialize, serialize_hex}; #[cfg(feature = "liquid")] use elements::encode::{deserialize, serialize_hex}; +use tracing::instrument; + use crate::chain::{Block, BlockHash, BlockHeader, Network, Transaction, Txid}; use crate::metrics::{HistogramOpts, HistogramVec, Metrics}; use crate::signal::Waiter; @@ -36,6 +40,10 @@ lazy_static! { ); } +const MAX_ATTEMPTS: u32 = 5; +const RETRY_WAIT_DURATION: Duration = Duration::from_secs(1); + +#[instrument(skip_all, name="Daemon::parse_hash")] fn parse_hash(value: &Value) -> Result where T: FromStr, @@ -49,6 +57,7 @@ where .chain_err(|| format!("non-hex value: {}", value))?) } +#[instrument(skip_all, name="Daemon::header_from_value")] fn header_from_value(value: Value) -> Result { let header_hex = value .as_str() @@ -79,13 +88,13 @@ fn parse_error_code(err: &Value) -> Option { fn parse_jsonrpc_reply(mut reply: Value, method: &str, expected_id: u64) -> Result { if let Some(reply_obj) = reply.as_object_mut() { - if let Some(err) = reply_obj.get("error") { + if let Some(err) = reply_obj.get_mut("error") { if !err.is_null() { if let Some(code) = parse_error_code(&err) { match code { // RPC_IN_WARMUP -> retry by later reconnection -28 => bail!(ErrorKind::Connection(err.to_string())), - _ => bail!("{} RPC error: {}", method, err), + code => bail!(ErrorKind::RpcError(code, err.take(), method.to_string())), } } } @@ -140,6 +149,7 @@ struct Connection { signal: Waiter, } +#[instrument(skip_all, name="Daemon::tcp_connect")] fn tcp_connect(addr: SocketAddr, signal: &Waiter) -> Result { loop { match TcpStream::connect_timeout(&addr, *DAEMON_CONNECTION_TIMEOUT) { @@ -162,6 +172,7 @@ fn tcp_connect(addr: SocketAddr, signal: &Waiter) -> Result { } impl Connection { + #[instrument(skip_all, name="Daemon::Connection::new")] fn new( addr: SocketAddr, cookie_getter: Arc, @@ -181,10 +192,12 @@ impl Connection { }) } + #[instrument(skip(self))] fn reconnect(&self) -> Result { Connection::new(self.addr, self.cookie_getter.clone(), self.signal.clone()) } + #[instrument(skip_all, name="Daemon::Connection::send")] fn send(&mut self, request: &str) -> Result<()> { let cookie = &self.cookie_getter.get()?; let msg = format!( @@ -198,6 +211,8 @@ impl Connection { }) } + + #[instrument(skip_all, name="Daemon::Connection::recv")] fn recv(&mut self) -> Result { // TODO: use proper HTTP parser. let mut in_header = true; @@ -248,7 +263,7 @@ impl Connection { Ok(if status == "HTTP/1.1 200 OK" { contents } else if status == "HTTP/1.1 500 Internal Server Error" { - warn!("HTTP status: {}", status); + debug!("RPC HTTP 500 error: {}", contents); contents // the contents should have a JSONRPC error field } else { bail!( @@ -287,6 +302,8 @@ pub struct Daemon { message_id: Counter, // for monotonic JSONRPC 'id' signal: Waiter, + rpc_threads: Arc, + // monitoring latency: HistogramVec, size: HistogramVec, @@ -297,6 +314,7 @@ impl Daemon { daemon_dir: &PathBuf, blocks_dir: &PathBuf, daemon_rpc_addr: SocketAddr, + daemon_parallelism: usize, cookie_getter: Arc, network: Network, signal: Waiter, @@ -313,6 +331,13 @@ impl Daemon { )?), message_id: Counter::new(), signal: signal.clone(), + rpc_threads: Arc::new( + rayon::ThreadPoolBuilder::new() + .num_threads(daemon_parallelism) + .thread_name(|i| format!("rpc-requests-{}", i)) + .build() + .unwrap(), + ), latency: metrics.histogram_vec( HistogramOpts::new("daemon_rpc", "Bitcoind RPC latency (in seconds)"), &["method"], @@ -353,6 +378,7 @@ impl Daemon { Ok(daemon) } + #[instrument(skip(self))] pub fn reconnect(&self) -> Result { Ok(Daemon { daemon_dir: self.daemon_dir.clone(), @@ -361,11 +387,13 @@ impl Daemon { conn: Mutex::new(self.conn.lock().unwrap().reconnect()?), message_id: Counter::new(), signal: self.signal.clone(), + rpc_threads: self.rpc_threads.clone(), latency: self.latency.clone(), size: self.size.clone(), }) } + #[instrument(skip_all, name="Daemon::list_blk_files")] pub fn list_blk_files(&self) -> Result> { let path = self.blocks_dir.join("blk*.dat"); debug!("listing block files at {:?}", path); @@ -381,6 +409,7 @@ impl Daemon { self.network.magic() } + #[instrument(skip_all, name="Daemon::call_jsonrpc")] fn call_jsonrpc(&self, method: &str, request: &Value) -> Result { let mut conn = self.conn.lock().unwrap(); let timer = self.latency.with_label_values(&[method]).start_timer(); @@ -398,33 +427,20 @@ impl Daemon { Ok(result) } - fn handle_request_batch(&self, method: &str, params_list: &[Value]) -> Result> { + #[instrument(skip_all, name="Daemon::handle_request")] + fn handle_request(&self, method: &str, params: &Value) -> Result { let id = self.message_id.next(); - let chunks = params_list - .iter() - .map(|params| json!({"method": method, "params": params, "id": id})) - .chunks(50_000); // Max Amount of batched requests - let mut results = vec![]; - for chunk in &chunks { - let reqs = chunk.collect(); - let mut replies = self.call_jsonrpc(method, &reqs)?; - if let Some(replies_vec) = replies.as_array_mut() { - for reply in replies_vec { - results.push(parse_jsonrpc_reply(reply.take(), method, id)?) - } - } else { - bail!("non-array replies: {:?}", replies); - } - } - - Ok(results) + let req = json!({"method": method, "params": params, "id": id}); + let reply = self.call_jsonrpc(method, &req)?; + parse_jsonrpc_reply(reply, method, id) } - fn retry_request_batch(&self, method: &str, params_list: &[Value]) -> Result> { + #[instrument(skip_all, name="Daemon::retry_request")] + fn retry_request(&self, method: &str, params: &Value) -> Result { loop { - match self.handle_request_batch(method, params_list) { - Err(Error(ErrorKind::Connection(msg), _)) => { - warn!("reconnecting to bitcoind: {}", msg); + match self.handle_request(method, ¶ms) { + Err(e @ Error(ErrorKind::Connection(_), _)) => { + warn!("reconnecting to bitcoind: {}", e.display_chain()); self.signal.wait(Duration::from_secs(3), false)?; let mut conn = self.conn.lock().unwrap(); *conn = conn.reconnect()?; @@ -435,50 +451,92 @@ impl Daemon { } } + #[instrument(skip_all, name="Daemon::request")] fn request(&self, method: &str, params: Value) -> Result { - let mut values = self.retry_request_batch(method, &[params])?; - assert_eq!(values.len(), 1); - Ok(values.remove(0)) + self.retry_request(method, ¶ms) + } + + fn retry_reconnect(&self) -> Daemon { + // XXX add a max reconnection attempts limit? + loop { + match self.reconnect() { + Ok(daemon) => break daemon, + Err(e) => { + warn!("failed connecting to RPC daemon: {}", e.display_chain()); + } + } + } } - fn requests(&self, method: &str, params_list: &[Value]) -> Result> { - self.retry_request_batch(method, params_list) + // Send requests in parallel over multiple RPC connections as individual JSON-RPC requests (with no JSON-RPC batching), + // buffering the replies into a vector. If any of the requests fail, processing is terminated and an Err is returned. + #[instrument(skip_all, name="Daemon::requests")] + fn requests(&self, method: &str, params_list: Vec) -> Result> { + self.requests_iter(method, params_list).collect() + } + + // Send requests in parallel over multiple RPC connections, iterating over the results without buffering them. + // Errors are included in the iterator and do not terminate other pending requests. + fn requests_iter<'a>( + &'a self, + method: &'a str, + params_list: Vec, + ) -> impl ParallelIterator> + IndexedParallelIterator + 'a { + self.rpc_threads.install(move || { + params_list.into_par_iter().map(move |params| { + // Store a local per-thread Daemon, each with its own TCP connection. These will + // get initialized as necessary for the `rpc_threads` pool thread managed by rayon. + thread_local!(static DAEMON_INSTANCE: OnceCell = OnceCell::new()); + + DAEMON_INSTANCE.with(|daemon| { + daemon + .get_or_init(|| self.retry_reconnect()) + .retry_request(&method, ¶ms) + }) + }) + }) } // bitcoind JSONRPC API: + #[instrument(skip_all, name="Daemon::getblockchaininfo")] pub fn getblockchaininfo(&self) -> Result { let info: Value = self.request("getblockchaininfo", json!([]))?; Ok(from_value(info).chain_err(|| "invalid blockchain info")?) } + #[instrument(skip_all, name="Daemon::getnetworkinfo")] fn getnetworkinfo(&self) -> Result { let info: Value = self.request("getnetworkinfo", json!([]))?; Ok(from_value(info).chain_err(|| "invalid network info")?) } + #[instrument(skip_all, name="Daemon::getbestblockhash")] pub fn getbestblockhash(&self) -> Result { parse_hash(&self.request("getbestblockhash", json!([]))?) } + #[instrument(skip_all, name="Daemon::getblockheader")] pub fn getblockheader(&self, blockhash: &BlockHash) -> Result { header_from_value(self.request("getblockheader", json!([blockhash, /*verbose=*/ false]))?) } + #[instrument(skip_all, name="Daemon::getblockheaders")] pub fn getblockheaders(&self, heights: &[usize]) -> Result> { let heights: Vec = heights.iter().map(|height| json!([height])).collect(); let params_list: Vec = self - .requests("getblockhash", &heights)? + .requests("getblockhash", heights)? .into_iter() .map(|hash| json!([hash, /*verbose=*/ false])) .collect(); let mut result = vec![]; - for h in self.requests("getblockheader", ¶ms_list)? { + for h in self.requests("getblockheader", params_list)? { result.push(header_from_value(h)?); } Ok(result) } + #[instrument(skip_all, name="Daemon::getblock")] pub fn getblock(&self, blockhash: &BlockHash) -> Result { let block = block_from_value(self.request("getblock", json!([blockhash, /*verbose=*/ false]))?)?; @@ -486,16 +544,39 @@ impl Daemon { Ok(block) } + #[instrument(skip_all, name="Daemon::getblock_raw")] pub fn getblock_raw(&self, blockhash: &BlockHash, verbose: u32) -> Result { self.request("getblock", json!([blockhash, verbose])) } + #[instrument(skip_all, name="Daemon::getblocks")] pub fn getblocks(&self, blockhashes: &[BlockHash]) -> Result> { let params_list: Vec = blockhashes .iter() .map(|hash| json!([hash, /*verbose=*/ false])) .collect(); - let values = self.requests("getblock", ¶ms_list)?; + + let mut attempts = MAX_ATTEMPTS; + let values = loop { + attempts -= 1; + + match self.requests("getblock", params_list.clone()) { + Ok(blocks) => break blocks, + Err(e) => { + let err_msg = format!("{e:?}"); + if err_msg.contains("Block not found on disk") { + // There is a small chance the node returns the header but didn't finish to index the block + log::warn!("getblocks failing with: {e:?} trying {attempts} more time") + } else { + panic!("failed to get blocks from bitcoind: {}", err_msg); + } + } + } + if attempts == 0 { + panic!("failed to get blocks from bitcoind") + } + std::thread::sleep(RETRY_WAIT_DURATION); + }; let mut blocks = vec![]; for value in values { blocks.push(block_from_value(value)?); @@ -503,21 +584,34 @@ impl Daemon { Ok(blocks) } - pub fn gettransactions(&self, txhashes: &[&Txid]) -> Result> { - let params_list: Vec = txhashes + /// Fetch the given transactions in parallel over multiple threads and RPC connections, + /// ignoring any missing ones and returning whatever is available. + #[instrument(skip_all, name="Daemon::gettransactions_available")] + pub fn gettransactions_available(&self, txids: &[&Txid]) -> Result> { + const RPC_INVALID_ADDRESS_OR_KEY: i64 = -5; + + let params_list: Vec = txids .iter() .map(|txhash| json!([txhash, /*verbose=*/ false])) .collect(); - let values = self.requests("getrawtransaction", ¶ms_list)?; - let mut txs = vec![]; - for value in values { - txs.push(tx_from_value(value)?); - } - assert_eq!(txhashes.len(), txs.len()); - Ok(txs) + self.requests_iter("getrawtransaction", params_list) + .zip(txids) + .filter_map(|(res, txid)| match res { + Ok(val) => Some(tx_from_value(val).map(|tx| (**txid, tx))), + // Ignore 'tx not found' errors + Err(Error(ErrorKind::RpcError(code, _, _), _)) + if code == RPC_INVALID_ADDRESS_OR_KEY => + { + None + } + // Terminate iteration if any other errors are encountered + Err(e) => Some(Err(e)), + }) + .collect() } + #[instrument(skip_all, name="Daemon::gettransaction_raw")] pub fn gettransaction_raw( &self, txid: &Txid, @@ -527,20 +621,24 @@ impl Daemon { self.request("getrawtransaction", json!([txid, verbose, blockhash])) } + #[instrument(skip_all, name="getmempooltx")] pub fn getmempooltx(&self, txhash: &Txid) -> Result { let value = self.request("getrawtransaction", json!([txhash, /*verbose=*/ false]))?; tx_from_value(value) } + #[instrument(skip_all, name="getmempooltxids")] pub fn getmempooltxids(&self) -> Result> { let res = self.request("getrawmempool", json!([/*verbose=*/ false]))?; Ok(serde_json::from_value(res).chain_err(|| "invalid getrawmempool reply")?) } + #[instrument(skip_all, name="broadcast")] pub fn broadcast(&self, tx: &Transaction) -> Result { self.broadcast_raw(&serialize_hex(tx)) } + #[instrument(skip_all, name="broadcast_raw")] pub fn broadcast_raw(&self, txhex: &str) -> Result { let txid = self.request("sendrawtransaction", json!([txhex]))?; Ok( @@ -552,11 +650,15 @@ impl Daemon { // Get estimated feerates for the provided confirmation targets using a batch RPC request // Missing estimates are logged but do not cause a failure, whatever is available is returned #[allow(clippy::float_cmp)] + #[instrument(skip_all, name="Daemon::estimatesmartfee_batch")] pub fn estimatesmartfee_batch(&self, conf_targets: &[u16]) -> Result> { - let params_list: Vec = conf_targets.iter().map(|t| json!([t, "ECONOMICAL"])).collect(); + let params_list: Vec = conf_targets + .iter() + .map(|t| json!([t, "ECONOMICAL"])) + .collect(); Ok(self - .requests("estimatesmartfee", ¶ms_list)? + .requests("estimatesmartfee", params_list)? .iter() .zip(conf_targets) .filter_map(|(reply, target)| { @@ -583,6 +685,7 @@ impl Daemon { .collect()) } + #[instrument(skip_all, name="Daemon::get_all_headers")] fn get_all_headers(&self, tip: &BlockHash) -> Result> { let info: Value = self.request("getblockheader", json!([tip]))?; let tip_height = info @@ -610,6 +713,7 @@ impl Daemon { } // Returns a list of BlockHeaders in ascending height (i.e. the tip is last). + #[instrument(skip_all, name="Daemon::get_new_headers")] pub fn get_new_headers( &self, indexed_headers: &HeaderList, @@ -642,6 +746,7 @@ impl Daemon { Ok(new_headers) } + #[instrument(skip_all, name="Daemon::get_relayfee")] pub fn get_relayfee(&self) -> Result { let relayfee = self.getnetworkinfo()?.relayfee; diff --git a/src/electrum/server.rs b/src/electrum/server.rs index 6129cbbe8..f32007862 100644 --- a/src/electrum/server.rs +++ b/src/electrum/server.rs @@ -13,6 +13,9 @@ use error_chain::ChainedError; use hex::{self, DisplayHex}; use serde_json::{from_str, Value}; + +use tracing::instrument; + #[cfg(not(feature = "liquid"))] use bitcoin::consensus::encode::serialize_hex; #[cfg(feature = "liquid")] @@ -69,6 +72,7 @@ fn bool_from_value_or(val: Option<&Value>, name: &str, default: bool) -> Result< } // TODO: implement caching and delta updates +#[instrument(skip_all, name="electrum::server::get_status_hash")] fn get_status_hash(txs: Vec<(Txid, Option)>, query: &Query) -> Option { if txs.is_empty() { None @@ -203,6 +207,7 @@ impl Connection { Ok(json!(&self.query.mempool().backlog_stats().fee_histogram)) } + #[instrument(skip_all, name="electrum::server::blockchain_block_header")] fn blockchain_block_header(&self, params: &[Value]) -> Result { let height = usize_from_value(params.get(0), "height")?; let cp_height = usize_from_value_or(params.get(1), "cp_height", 0)?; @@ -226,6 +231,7 @@ impl Connection { })) } + #[instrument(skip_all, name="electrum::serer::blockchain_block_headers")] fn blockchain_block_headers(&self, params: &[Value]) -> Result { let start_height = usize_from_value(params.get(0), "start_height")?; let count = MAX_HEADERS.min(usize_from_value(params.get(1), "count")?); @@ -261,6 +267,7 @@ impl Connection { })) } + #[instrument(skip_all, name="electrum::server::blockchain_estimatefee")] fn blockchain_estimatefee(&self, params: &[Value]) -> Result { let conf_target = usize_from_value(params.get(0), "blocks_count")?; let fee_rate = self @@ -271,12 +278,14 @@ impl Connection { Ok(json!(fee_rate / 100_000f64)) } + #[instrument(skip_all, name="electrum::server::blockchain_relayfee")] fn blockchain_relayfee(&self) -> Result { let relayfee = self.query.get_relayfee()?; // convert from sat/b to BTC/kB, as expected by Electrum clients Ok(json!(relayfee / 100_000f64)) } + #[instrument(skip_all, name="electrum::server::blockchain_scripthash_subscribe")] fn blockchain_scripthash_subscribe(&mut self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; @@ -290,7 +299,20 @@ impl Connection { Ok(status_hash) } + fn blockchain_scripthash_unsubscribe(&mut self, params: &[Value]) -> Result { + let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; + + match self.status_hashes.remove(&script_hash) { + None => Ok(json!(false)), + Some(_) => { + self.stats.subscriptions.dec(); + Ok(json!(true)) + } + } + } + #[cfg(not(feature = "liquid"))] + #[instrument(skip_all, name="electrum::server::blockchain_scripthash_get_balance")] fn blockchain_scripthash_get_balance(&self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; let (chain_stats, mempool_stats) = self.query.stats(&script_hash[..]); @@ -301,6 +323,7 @@ impl Connection { })) } + #[instrument(skip_all, name="electrum::server::blockchain_scripthash_get_history")] fn blockchain_scripthash_get_history(&self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; let history_txids = get_history(&self.query, &script_hash[..], self.txs_limit)?; @@ -319,6 +342,7 @@ impl Connection { .collect::>())) } + #[instrument(skip_all, name="electrum::server::blockchain_scripthash_listunspent")] fn blockchain_scripthash_listunspent(&self, params: &[Value]) -> Result { let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?; let utxos = self.query.utxo(&script_hash[..])?; @@ -347,6 +371,7 @@ impl Connection { ))) } + #[instrument(skip_all, name="electrum::server::blockchain_transaction_broadcast")] fn blockchain_transaction_broadcast(&self, params: &[Value]) -> Result { let tx = params.get(0).chain_err(|| "missing tx")?; let tx = tx.as_str().chain_err(|| "non-string tx")?.to_string(); @@ -357,6 +382,7 @@ impl Connection { Ok(json!(txid)) } + #[instrument(skip_all, name="electrum::server::blockchain_transaction_get")] fn blockchain_transaction_get(&self, params: &[Value]) -> Result { let tx_hash = Txid::from(hash_from_value(params.get(0)).chain_err(|| "bad tx_hash")?); let verbose = match params.get(1) { @@ -376,6 +402,7 @@ impl Connection { Ok(json!(rawtx.to_lower_hex_string())) } + #[instrument(skip_all, name="electrum::server::blockchain_transaction_get_merkle")] fn blockchain_transaction_get_merkle(&self, params: &[Value]) -> Result { let txid = Txid::from(hash_from_value(params.get(0)).chain_err(|| "bad tx_hash")?); let height = usize_from_value(params.get(1), "height")?; @@ -396,6 +423,7 @@ impl Connection { })) } + #[instrument(skip_all, name="electrum::server::blockchain_transaction_id_from_pos")] fn blockchain_transaction_id_from_pos(&self, params: &[Value]) -> Result { let height = usize_from_value(params.get(0), "height")?; let tx_pos = usize_from_value(params.get(1), "tx_pos")?; @@ -413,6 +441,7 @@ impl Connection { })) } + #[instrument(skip(self, params, id), name="electrum::server::handle_command")] fn handle_command(&mut self, method: &str, params: &[Value], id: &Value) -> Result { let timer = self .stats @@ -430,6 +459,7 @@ impl Connection { "blockchain.scripthash.get_history" => self.blockchain_scripthash_get_history(¶ms), "blockchain.scripthash.listunspent" => self.blockchain_scripthash_listunspent(¶ms), "blockchain.scripthash.subscribe" => self.blockchain_scripthash_subscribe(¶ms), + "blockchain.scripthash.unsubscribe" => self.blockchain_scripthash_unsubscribe(¶ms), "blockchain.transaction.broadcast" => self.blockchain_transaction_broadcast(¶ms), "blockchain.transaction.get" => self.blockchain_transaction_get(¶ms), "blockchain.transaction.get_merkle" => self.blockchain_transaction_get_merkle(¶ms), @@ -467,6 +497,7 @@ impl Connection { }) } + #[instrument(skip_all, name="electrum::server::update_subscriptions")] fn update_subscriptions(&mut self) -> Result> { let timer = self .stats @@ -524,6 +555,7 @@ impl Connection { Ok(()) } + #[instrument(skip_all, name="electrum::server::handle_replies")] fn handle_replies(&mut self, receiver: Receiver) -> Result<()> { let empty_params = json!([]); loop { @@ -588,6 +620,8 @@ impl Connection { } } + + #[instrument(skip_all, name="electrum::server::parse_requests")] fn parse_requests(mut reader: BufReader, tx: &SyncSender) -> Result<()> { loop { let mut line = Vec::::new(); @@ -650,6 +684,7 @@ impl Connection { } } +#[instrument(skip_all, name="electrum::server::get_history")] fn get_history( query: &Query, scripthash: &[u8], diff --git a/src/errors.rs b/src/errors.rs index cec50ccef..c708d7dda 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -9,6 +9,11 @@ error_chain! { display("Connection error: {}", msg) } + RpcError(code: i64, error: serde_json::Value, method: String) { + description("RPC error") + display("{} RPC error {}: {}", method, code, error) + } + Interrupt(sig: i32) { description("Interruption by external signal") display("Iterrupted by signal {}", sig) diff --git a/src/lib.rs b/src/lib.rs index 9dbc58153..eee645605 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,3 +35,6 @@ pub mod util; #[cfg(feature = "liquid")] pub mod elements; + +#[cfg(feature = "otlp-tracing")] +pub mod otlp_trace; diff --git a/src/new_index/db.rs b/src/new_index/db.rs index f68da233c..d14dfe28d 100644 --- a/src/new_index/db.rs +++ b/src/new_index/db.rs @@ -2,6 +2,8 @@ use rocksdb; use std::path::Path; +use tracing::instrument; + use crate::config::Config; use crate::util::{bincode, Bytes}; @@ -90,7 +92,7 @@ impl DB { db_opts.set_compression_type(rocksdb::DBCompressionType::Snappy); db_opts.set_target_file_size_base(1_073_741_824); db_opts.set_write_buffer_size(256 << 20); - db_opts.set_disable_auto_compactions(true); // for initial bulk load + db_opts.set_disable_auto_compactions(!config.initial_sync_compaction); // for initial bulk load // db_opts.set_advise_random_on_open(???); db_opts.set_compaction_readahead_size(1 << 20); @@ -106,6 +108,7 @@ impl DB { db } + #[instrument(skip(self))] pub fn full_compaction(&self) { // TODO: make sure this doesn't fail silently debug!("starting full compaction on {:?}", self.db); @@ -113,6 +116,7 @@ impl DB { debug!("finished full compaction on {:?}", self.db); } + #[instrument(skip(self))] pub fn enable_auto_compaction(&self) { let opts = [("disable_auto_compactions", "false")]; self.db.set_options(&opts).unwrap(); @@ -154,7 +158,7 @@ impl DB { } pub fn write(&self, mut rows: Vec, flush: DBFlush) { - debug!( + log::trace!( "writing {} rows to {:?}, flush={:?}", rows.len(), self.db, @@ -178,6 +182,7 @@ impl DB { self.db.write_opt(batch, &opts).unwrap(); } + #[instrument(skip(self))] pub fn flush(&self) { self.db.flush().unwrap(); } @@ -186,6 +191,7 @@ impl DB { self.db.put(key, value).unwrap(); } + #[instrument(skip(self, key, value))] pub fn put_sync(&self, key: &[u8], value: &[u8]) { let mut opts = rocksdb::WriteOptions::new(); opts.set_sync(true); diff --git a/src/new_index/fetch.rs b/src/new_index/fetch.rs index 54369b5e5..ac3c6a8ab 100644 --- a/src/new_index/fetch.rs +++ b/src/new_index/fetch.rs @@ -14,6 +14,8 @@ use std::path::PathBuf; use std::sync::mpsc::Receiver; use std::thread; +use tracing::instrument; + use crate::chain::{Block, BlockHash}; use crate::daemon::Daemon; use crate::errors::*; @@ -25,6 +27,7 @@ pub enum FetchFrom { BlkFiles, } +#[instrument(skip(from, daemon, new_headers))] pub fn start_fetcher( from: FetchFrom, daemon: &Daemon, @@ -37,6 +40,7 @@ pub fn start_fetcher( fetcher(daemon, new_headers) } +#[derive(Clone)] pub struct BlockEntry { pub block: Block, pub entry: HeaderEntry, @@ -66,6 +70,7 @@ impl Fetcher { } } +#[instrument(skip_all, name="fetch::bitcoind_fetcher")] fn bitcoind_fetcher( daemon: &Daemon, new_headers: Vec, @@ -98,11 +103,13 @@ fn bitcoind_fetcher( sender .send(block_entries) .expect("failed to send fetched blocks"); + log::debug!("last fetch {:?}", entries.last()); } }), )) } +#[instrument(skip_all, name="fetch::blkfiles_fetcher")] fn blkfiles_fetcher( daemon: &Daemon, new_headers: Vec, @@ -149,6 +156,7 @@ fn blkfiles_fetcher( )) } +#[instrument(skip_all, name="fetch::blkfiles_reader")] fn blkfiles_reader(blk_files: Vec) -> Fetcher> { let chan = SyncChannel::new(1); let sender = chan.sender(); @@ -168,6 +176,7 @@ fn blkfiles_reader(blk_files: Vec) -> Fetcher> { ) } +#[instrument(skip_all, name="fetch::blkfiles_parser")] fn blkfiles_parser(blobs: Fetcher>, magic: u32) -> Fetcher> { let chan = SyncChannel::new(1); let sender = chan.sender(); @@ -186,6 +195,7 @@ fn blkfiles_parser(blobs: Fetcher>, magic: u32) -> Fetcher, magic: u32) -> Result> { let mut cursor = Cursor::new(&blob); let mut slices = vec![]; diff --git a/src/new_index/mempool.rs b/src/new_index/mempool.rs index 94ba7a41d..75594a1d6 100644 --- a/src/new_index/mempool.rs +++ b/src/new_index/mempool.rs @@ -11,7 +11,8 @@ use std::iter::FromIterator; use std::sync::{Arc, RwLock}; use std::time::{Duration, Instant}; -use crate::chain::{deserialize, Network, OutPoint, Transaction, TxOut, Txid}; +use tracing::instrument; +use crate::chain::{deserialize, BlockHash, Network, OutPoint, Transaction, TxOut, Txid}; use crate::config::Config; use crate::daemon::Daemon; use crate::errors::*; @@ -21,7 +22,7 @@ use crate::new_index::{ SpendingInfo, SpendingInput, TxHistoryInfo, Utxo, }; use crate::util::fees::{make_fee_histogram, TxFeeInfo}; -use crate::util::{extract_tx_prevouts, full_hash, has_prevout, is_spendable, Bytes}; +use crate::util::{extract_tx_prevouts, full_hash, get_prev_outpoints, is_spendable, Bytes}; #[cfg(feature = "liquid")] use crate::elements::asset; @@ -107,6 +108,7 @@ impl Mempool { self.txstore.get(txid).map(serialize) } + #[instrument(skip_all, name="Mempool::lookup_spend")] pub fn lookup_spend(&self, outpoint: &OutPoint) -> Option { self.edges.get(outpoint).map(|(txid, vin)| SpendingInput { txid: *txid, @@ -123,6 +125,7 @@ impl Mempool { Some(self.feeinfo.get(txid)?.fee) } + #[instrument(skip_all, name="Mempool::has_unconfirmed_parents")] pub fn has_unconfirmed_parents(&self, txid: &Txid) -> bool { let tx = match self.txstore.get(txid) { Some(tx) => tx, @@ -133,6 +136,7 @@ impl Mempool { .any(|txin| self.txstore.contains_key(&txin.previous_output.txid)) } + #[instrument(skip_all, name="Mempool::history")] pub fn history(&self, scripthash: &[u8], limit: usize) -> Vec { let _timer = self.latency.with_label_values(&["history"]).start_timer(); self.history @@ -140,6 +144,7 @@ impl Mempool { .map_or_else(|| vec![], |entries| self._history(entries, limit)) } + #[instrument(skip_all, name="Mempool::_history")] fn _history(&self, entries: &[TxHistoryInfo], limit: usize) -> Vec { entries .iter() @@ -151,6 +156,7 @@ impl Mempool { .collect() } + #[instrument(skip_all, name="Mempool::history_txids")] pub fn history_txids(&self, scripthash: &[u8], limit: usize) -> Vec { let _timer = self .latency @@ -167,6 +173,7 @@ impl Mempool { } } + #[instrument(skip_all, name="Mempool::utxo")] pub fn utxo(&self, scripthash: &[u8]) -> Vec { let _timer = self.latency.with_label_values(&["utxo"]).start_timer(); let entries = match self.history.get(scripthash) { @@ -209,6 +216,7 @@ impl Mempool { .collect() } + #[instrument(skip_all, name="Mempool::stats")] // @XXX avoid code duplication with ChainQuery::stats()? pub fn stats(&self, scripthash: &[u8]) -> ScriptStats { let _timer = self.latency.with_label_values(&["stats"]).start_timer(); @@ -258,12 +266,14 @@ impl Mempool { stats } + #[instrument(skip_all, name="Mempool::txids")] // Get all txids in the mempool pub fn txids(&self) -> Vec<&Txid> { let _timer = self.latency.with_label_values(&["txids"]).start_timer(); self.txstore.keys().collect() } + #[instrument(skip_all, name="Mempool::recent_txs_overview")] // Get an overview of the most recent transactions pub fn recent_txs_overview(&self) -> Vec<&TxOverview> { // We don't bother ever deleting elements from the recent list. @@ -272,14 +282,17 @@ impl Mempool { self.recent.iter().collect() } + #[instrument(skip_all, name="Mempool::backlog_stats")] pub fn backlog_stats(&self) -> &BacklogStats { &self.backlog_stats.0 } - pub fn old_txids(&self) -> HashSet { + #[instrument(skip_all, name="Mempool::txids_set")] + pub fn txids_set(&self) -> HashSet { return HashSet::from_iter(self.txstore.keys().cloned()); } + #[instrument(skip_all, name="Mempool::update_backlog_stats")] pub fn update_backlog_stats(&mut self) { let _timer = self .latency @@ -288,40 +301,57 @@ impl Mempool { self.backlog_stats = (BacklogStats::new(&self.feeinfo), Instant::now()); } - pub fn add_by_txid(&mut self, daemon: &Daemon, txid: &Txid) { - if self.txstore.get(txid).is_none() { + #[instrument(skip_all, name="Mempool::add_by_txid")] + pub fn add_by_txid(&mut self, daemon: &Daemon, txid: Txid) -> Result<()> { + if self.txstore.get(&txid).is_none() { if let Ok(tx) = daemon.getmempooltx(&txid) { - self.add(vec![tx]) + let mut txs_map = HashMap::new(); + txs_map.insert(txid, tx); + self.add(txs_map) + } else { + bail!("add_by_txid cannot find {}", txid); } + } else { + Ok(()) } } - fn add(&mut self, txs: Vec) { + #[instrument(skip_all, name="Mempool::add")] + fn add(&mut self, txs_map: HashMap) -> Result<()> { self.delta .with_label_values(&["add"]) - .observe(txs.len() as f64); + .observe(txs_map.len() as f64); let _timer = self.latency.with_label_values(&["add"]).start_timer(); - let mut txids = vec![]; - // Phase 1: add to txstore - for tx in txs { - let txid = tx.txid(); - txids.push(txid); + let spent_prevouts = get_prev_outpoints(txs_map.values()); + + // Lookup spent prevouts that were funded within the same `add` batch + let mut txos = HashMap::new(); + let remain_prevouts = spent_prevouts + .into_iter() + .filter(|prevout| { + if let Some(prevtx) = txs_map.get(&prevout.txid) { + if let Some(out) = prevtx.output.get(prevout.vout as usize) { + txos.insert(prevout.clone(), out.clone()); + // remove from the list of remaining `prevouts` + return false; + } + } + true + }) + .collect(); + + // Lookup remaining spent prevouts in mempool & on-chain + // Fails if any are missing. + txos.extend(self.lookup_txos(remain_prevouts)?); + + // Add to txstore and indexes + for (txid, tx) in txs_map { self.txstore.insert(txid, tx); - } - // Phase 2: index history and spend edges (can fail if some txos cannot be found) - let txos = match self.lookup_txos(self.get_prevouts(&txids)) { - Ok(txos) => txos, - Err(err) => { - warn!("lookup txouts failed: {}", err); - // TODO: should we remove txids from txstore? - return; - } - }; - for txid in txids { - let tx = self.txstore.get(&txid).expect("missing mempool tx"); - let txid_bytes = full_hash(&txid[..]); + let tx = self.txstore.get(&txid).expect("was just added"); + let prevouts = extract_tx_prevouts(&tx, &txos, false); + let txid_bytes = full_hash(&txid[..]); // Get feeinfo for caching and recent tx overview let feeinfo = TxFeeInfo::new(&tx, &prevouts, self.config.network_type); @@ -395,14 +425,17 @@ impl Mempool { &mut self.asset_issuance, ); } + + Ok(()) } + #[instrument(skip_all, name="Mempool::lookup_txo")] fn lookup_txo(&self, outpoint: &OutPoint) -> Option { self.txstore .get(&outpoint.txid) .and_then(|tx| tx.output.get(outpoint.vout as usize).cloned()) } - + #[instrument(skip_all, name="Mempool::lookup_txos")] pub fn lookup_txos(&self, outpoints: BTreeSet) -> Result> { let _timer = self .latency @@ -423,24 +456,7 @@ impl Mempool { Ok(txos) } - fn get_prevouts(&self, txids: &[Txid]) -> BTreeSet { - let _timer = self - .latency - .with_label_values(&["get_prevouts"]) - .start_timer(); - - txids - .iter() - .map(|txid| self.txstore.get(txid).expect("missing mempool tx")) - .flat_map(|tx| { - tx.input - .iter() - .filter(|txin| has_prevout(txin)) - .map(|txin| txin.previous_output) - }) - .collect() - } - + #[instrument(skip_all, name="Mempool::remove")] fn remove(&mut self, to_remove: HashSet<&Txid>) { self.delta .with_label_values(&["remove"]) @@ -476,6 +492,7 @@ impl Mempool { } #[cfg(feature = "liquid")] + #[instrument(skip_all, name="Mempool::remove")] pub fn asset_history(&self, asset_id: &AssetId, limit: usize) -> Vec { let _timer = self .latency @@ -486,31 +503,75 @@ impl Mempool { .map_or_else(|| vec![], |entries| self._history(entries, limit)) } - pub fn update(mempool: &Arc>, daemon: &Daemon) -> Result<()> { + /// Sync our local view of the mempool with the bitcoind Daemon RPC. If the chain tip moves before + /// the mempool is fetched in full, syncing is aborted and an Ok(false) is returned. + #[instrument(skip_all, name="Mempool::update")] + pub fn update( + mempool: &Arc>, + daemon: &Daemon, + tip: &BlockHash, + ) -> Result { let _timer = mempool.read().unwrap().latency.with_label_values(&["update"]).start_timer(); - // 1. Determine which transactions are no longer in the daemon's mempool and which ones have newly entered it - let old_txids = mempool.read().unwrap().old_txids(); - let all_txids = daemon - .getmempooltxids() - .chain_err(|| "failed to update mempool from daemon")?; - let txids_to_remove: HashSet<&Txid> = old_txids.difference(&all_txids).collect(); + // Continuously attempt to fetch mempool transactions until we're able to get them in full + let mut fetched_txs = HashMap::::new(); + let mut indexed_txids = mempool.read().unwrap().txids_set(); + loop { + // Get bitcoind's current list of mempool txids + let all_txids = daemon + .getmempooltxids() + .chain_err(|| "failed to update mempool from daemon")?; + + // Remove evicted mempool transactions + mempool + .write() + .unwrap() + .remove(indexed_txids.difference(&all_txids).collect()); + + indexed_txids.retain(|txid| all_txids.contains(txid)); + fetched_txs.retain(|txid, _| all_txids.contains(txid)); + + // Fetch missing transactions from bitcoind + let new_txids = all_txids + .iter() + .filter(|&txid| !fetched_txs.contains_key(txid) && !indexed_txids.contains(txid)) + .collect::>(); + if new_txids.is_empty() { + break; + } + debug!( + "mempool with total {} txs, {} fetched, {} missing", + all_txids.len(), + indexed_txids.len() + fetched_txs.len(), + new_txids.len() + ); + let new_txs = daemon.gettransactions_available(&new_txids)?; - // 2. Remove missing transactions. Even if we are unable to download new transactions from - // the daemon, we still want to remove the transactions that are no longer in the mempool. - mempool.write().unwrap().remove(txids_to_remove); + // Abort if the chain tip moved while fetching transactions + if daemon.getbestblockhash()? != *tip { + warn!("chain tip moved while updating mempool"); + return Ok(false); + } - // 3. Download the new transactions from the daemon's mempool - let new_txids: Vec<&Txid> = all_txids.difference(&old_txids).collect(); - let txs_to_add = daemon - .gettransactions(&new_txids) - .chain_err(|| format!("failed to get {} transactions", new_txids.len()))?; + let fetched_count = new_txs.len(); + fetched_txs.extend(new_txs); + + // Retry if any transactions were evicted form the mempool before we managed to get them + if fetched_count != new_txids.len() { + warn!( + "failed to fetch {} mempool txs, retrying...", + new_txids.len() - fetched_count + ); + } else { + break; + } + } - // 4. Update local mempool to match daemon's state + // Add fetched transactions to our view of the mempool { let mut mempool = mempool.write().unwrap(); - // Add new transactions - mempool.add(txs_to_add); + + mempool.add(fetched_txs)?; mempool .count @@ -523,7 +584,9 @@ impl Mempool { } } - Ok(()) + trace!("mempool is synced"); + + Ok(true) } } @@ -545,6 +608,7 @@ impl BacklogStats { } } + #[instrument(skip_all, name="Mempool::new")] fn new(feeinfo: &HashMap) -> Self { let (count, vsize, total_fee) = feeinfo .values() diff --git a/src/new_index/precache.rs b/src/new_index/precache.rs index 4db40c27d..f94e91115 100644 --- a/src/new_index/precache.rs +++ b/src/new_index/precache.rs @@ -13,6 +13,10 @@ use std::io; use std::io::prelude::*; use std::str::FromStr; + +use tracing::instrument; + +#[instrument(skip_all, name="precache::precache")] pub fn precache(chain: &ChainQuery, scripthashes: Vec) { let total = scripthashes.len(); info!("Pre-caching stats and utxo set for {} scripthashes", total); @@ -36,6 +40,7 @@ pub fn precache(chain: &ChainQuery, scripthashes: Vec) { }); } +#[instrument(skip_all, name="precache::scripthashes_from_file")] pub fn scripthashes_from_file(path: String) -> Result> { let reader = io::BufReader::new(File::open(path).chain_err(|| "cannot open precache scripthash file")?); diff --git a/src/new_index/query.rs b/src/new_index/query.rs index 60d7510ab..9d687db19 100644 --- a/src/new_index/query.rs +++ b/src/new_index/query.rs @@ -11,6 +11,9 @@ use crate::errors::*; use crate::new_index::{ChainQuery, Mempool, ScriptStats, SpendingInput, Utxo}; use crate::util::{is_spendable, BlockId, Bytes, TransactionStatus}; + +use tracing::instrument; + #[cfg(feature = "liquid")] use crate::{ chain::AssetId, @@ -69,15 +72,18 @@ impl Query { self.mempool.read().unwrap() } + #[instrument(skip_all, name="query::Query::broadcast_raw")] pub fn broadcast_raw(&self, txhex: &str) -> Result { let txid = self.daemon.broadcast_raw(txhex)?; - self.mempool + let _ = self + .mempool .write() .unwrap() - .add_by_txid(&self.daemon, &txid); + .add_by_txid(&self.daemon, txid); Ok(txid) } + #[instrument(skip_all, name="query::Query::utxo")] pub fn utxo(&self, scripthash: &[u8]) -> Result> { let mut utxos = self.chain.utxo(scripthash, self.config.utxos_limit)?; let mempool = self.mempool(); @@ -86,6 +92,7 @@ impl Query { Ok(utxos) } + #[instrument(skip_all, name="query::Query::history_txids")] pub fn history_txids(&self, scripthash: &[u8], limit: usize) -> Vec<(Txid, Option)> { let confirmed_txids = self.chain.history_txids(scripthash, limit); let confirmed_len = confirmed_txids.len(); @@ -107,17 +114,21 @@ impl Query { ) } + #[instrument(skip_all, name="query::Query::lookup_txn")] pub fn lookup_txn(&self, txid: &Txid) -> Option { self.chain .lookup_txn(txid, None) .or_else(|| self.mempool().lookup_txn(txid)) } + + #[instrument(skip_all, name="query::Query::lookup_raw_txn")] pub fn lookup_raw_txn(&self, txid: &Txid) -> Option { self.chain .lookup_raw_txn(txid, None) .or_else(|| self.mempool().lookup_raw_txn(txid)) } + #[instrument(skip_all, name="query::Query::lookup_txos")] pub fn lookup_txos(&self, outpoints: BTreeSet) -> HashMap { // the mempool lookup_txos() internally looks up confirmed txos as well self.mempool() @@ -125,12 +136,14 @@ impl Query { .expect("failed loading txos") } + #[instrument(skip_all, name="query::Query::lookup_spend")] pub fn lookup_spend(&self, outpoint: &OutPoint) -> Option { self.chain .lookup_spend(outpoint) .or_else(|| self.mempool().lookup_spend(outpoint)) } + #[instrument(skip_all, name="query::Query::lookup_tx_spends")] pub fn lookup_tx_spends(&self, tx: Transaction) -> Vec> { let txid = tx.txid(); @@ -150,18 +163,22 @@ impl Query { .collect() } + #[instrument(skip_all, name="query::Query::get_tx_status")] pub fn get_tx_status(&self, txid: &Txid) -> TransactionStatus { TransactionStatus::from(self.chain.tx_confirming_block(txid)) } + #[instrument(skip_all, name="query::Query::get_mempool_tx_fee")] pub fn get_mempool_tx_fee(&self, txid: &Txid) -> Option { self.mempool().get_tx_fee(txid) } + #[instrument(skip_all, name="query::Query::has_unconfirmed_parents")] pub fn has_unconfirmed_parents(&self, txid: &Txid) -> bool { self.mempool().has_unconfirmed_parents(txid) } + #[instrument(skip_all, name="query::Query::estimate_fee")] pub fn estimate_fee(&self, conf_target: u16) -> Option { if self.config.network_type.is_regtest() { return self.get_relayfee().ok(); @@ -181,6 +198,7 @@ impl Query { .copied() } + #[instrument(skip_all, name="query::Query::estimate_fee_map")] pub fn estimate_fee_map(&self) -> HashMap { if let (ref cache, Some(cache_time)) = *self.cached_estimates.read().unwrap() { if cache_time.elapsed() < Duration::from_secs(FEE_ESTIMATES_TTL) { @@ -192,6 +210,7 @@ impl Query { self.cached_estimates.read().unwrap().0.clone() } + #[instrument(skip_all, name="query::Query::update_fee_estimates")] fn update_fee_estimates(&self) { match self.daemon.estimatesmartfee_batch(&CONF_TARGETS) { Ok(estimates) => { @@ -203,6 +222,7 @@ impl Query { } } + #[instrument(skip_all, name="query::Query::get_relayfee")] pub fn get_relayfee(&self) -> Result { if let Some(cached) = *self.cached_relayfee.read().unwrap() { return Ok(cached); @@ -233,11 +253,13 @@ impl Query { } #[cfg(feature = "liquid")] + #[instrument(skip_all, name="query::Query::lookup_asset")] pub fn lookup_asset(&self, asset_id: &AssetId) -> Result> { lookup_asset(&self, self.asset_db.as_ref(), asset_id, None) } #[cfg(feature = "liquid")] + #[instrument(skip_all, name="query::Query::list_registry_assets")] pub fn list_registry_assets( &self, start_index: usize, diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index bbb2e2946..3c4e9ee84 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -21,6 +21,8 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use std::path::Path; use std::sync::{Arc, RwLock}; +use tracing::instrument; + use crate::chain::{ BlockHash, BlockHeader, Network, OutPoint, Script, Transaction, TxOut, Txid, Value, }; @@ -220,6 +222,7 @@ impl Indexer { self.duration.with_label_values(&[name]).start_timer() } + #[instrument(skip_all, name="schema::Indexer::headers_to_add")] fn headers_to_add(&self, new_headers: &[HeaderEntry]) -> Vec { let added_blockhashes = self.store.added_blockhashes.read().unwrap(); new_headers @@ -229,6 +232,7 @@ impl Indexer { .collect() } + #[instrument(skip_all, name="schema::Indexer::headers_to_index")] fn headers_to_index(&self, new_headers: &[HeaderEntry]) -> Vec { let indexed_blockhashes = self.store.indexed_blockhashes.read().unwrap(); new_headers @@ -238,6 +242,7 @@ impl Indexer { .collect() } + #[instrument(skip_all, name="schema::start_auto_compactions")] fn start_auto_compactions(&self, db: &DB) { let key = b"F".to_vec(); if db.get(&key).is_none() { @@ -248,6 +253,7 @@ impl Indexer { db.enable_auto_compaction(); } + #[instrument(skip_all, name="schema::get_new_headers")] fn get_new_headers(&self, daemon: &Daemon, tip: &BlockHash) -> Result> { let headers = self.store.indexed_headers.read().unwrap(); let new_headers = daemon.get_new_headers(&headers, &tip)?; @@ -259,6 +265,7 @@ impl Indexer { Ok(result) } + #[instrument(skip_all, name="schema::update")] pub fn update(&mut self, daemon: &Daemon) -> Result { let daemon = daemon.reconnect()?; let tip = daemon.getbestblockhash()?; @@ -306,6 +313,7 @@ impl Indexer { Ok(tip) } + #[instrument(skip_all, name="schema::add")] fn add(&self, blocks: &[BlockEntry]) { // TODO: skip orphaned blocks? let rows = { @@ -324,6 +332,7 @@ impl Indexer { .extend(blocks.iter().map(|b| b.entry.hash())); } + #[instrument(skip_all, name="schema::index")] fn index(&self, blocks: &[BlockEntry]) { let previous_txos_map = { let _timer = self.start_timer("index_lookup"); @@ -375,9 +384,8 @@ impl ChainQuery { self.duration.with_label_values(&[name]).start_timer() } + #[instrument(skip_all, name="sdchema::Indexer::get_block_txids")] pub fn get_block_txids(&self, hash: &BlockHash) -> Option> { - let _timer = self.start_timer("get_block_txids"); - if self.light_mode { // TODO fetch block as binary from REST API instead of as hex let mut blockinfo = self.daemon.getblock_raw(hash, 1).ok()?; @@ -390,6 +398,7 @@ impl ChainQuery { } } + #[instrument(skip_all, name="schema::ChainQuery::get_block_meta")] pub fn get_block_meta(&self, hash: &BlockHash) -> Option { let _timer = self.start_timer("get_block_meta"); @@ -404,6 +413,7 @@ impl ChainQuery { } } + #[instrument(skip_all, name="schema::ChainQuery::get_block_raw")] pub fn get_block_raw(&self, hash: &BlockHash) -> Option> { let _timer = self.start_timer("get_block_raw"); @@ -432,16 +442,19 @@ impl ChainQuery { } } + #[instrument(skip_all, name="schema::ChainQuery::get_block_header")] pub fn get_block_header(&self, hash: &BlockHash) -> Option { let _timer = self.start_timer("get_block_header"); Some(self.header_by_hash(hash)?.header().clone()) } + #[instrument(skip_all, name="schema::ChainQuery::get_mtp")] pub fn get_mtp(&self, height: usize) -> u32 { let _timer = self.start_timer("get_block_mtp"); self.store.indexed_headers.read().unwrap().get_mtp(height) } + #[instrument(skip_all, name="schema::ChainQuery::get_block_with_meta")] pub fn get_block_with_meta(&self, hash: &BlockHash) -> Option { let _timer = self.start_timer("get_block_with_meta"); let header_entry = self.header_by_hash(hash)?; @@ -452,12 +465,15 @@ impl ChainQuery { }) } + #[instrument(skip_all, name="schema::ChainQuery::history_iter_scan")] pub fn history_iter_scan(&self, code: u8, hash: &[u8], start_height: usize) -> ScanIterator { self.store.history_db.iter_scan_from( &TxHistoryRow::filter(code, &hash[..]), &TxHistoryRow::prefix_height(code, &hash[..], start_height as u32), ) } + + #[instrument(skip_all, name="schema::ChainQuery::history_iter_scan_reverse")] fn history_iter_scan_reverse(&self, code: u8, hash: &[u8]) -> ReverseScanIterator { self.store.history_db.iter_scan_reverse( &TxHistoryRow::filter(code, &hash[..]), @@ -465,6 +481,7 @@ impl ChainQuery { ) } + #[instrument(skip_all, name="schema::ChainQuery::history")] pub fn history( &self, scripthash: &[u8], @@ -475,6 +492,7 @@ impl ChainQuery { self._history(b'H', scripthash, last_seen_txid, limit) } + #[instrument(skip_all, name="schema::ChainQuery::_history")] fn _history( &self, code: u8, @@ -509,11 +527,13 @@ impl ChainQuery { .collect() } + #[instrument(skip_all, name="schema::ChainQuery::history_txids")] pub fn history_txids(&self, scripthash: &[u8], limit: usize) -> Vec<(Txid, BlockId)> { // scripthash lookup self._history_txids(b'H', scripthash, limit) } + #[instrument(skip_all, name="schema::ChainQuery::_history_txids")] fn _history_txids(&self, code: u8, hash: &[u8], limit: usize) -> Vec<(Txid, BlockId)> { let _timer = self.start_timer("history_txids"); self.history_iter_scan(code, hash, 0) @@ -525,6 +545,7 @@ impl ChainQuery { } // TODO: avoid duplication with stats/stats_delta? + #[instrument(skip_all, name="schema::ChainQuery::utxo")] pub fn utxo(&self, scripthash: &[u8], limit: usize) -> Result> { let _timer = self.start_timer("utxo"); @@ -585,6 +606,7 @@ impl ChainQuery { .collect()) } + #[instrument(skip_all, name="schema::ChainQuery::utxo_delta")] fn utxo_delta( &self, scripthash: &[u8], @@ -630,6 +652,7 @@ impl ChainQuery { Ok((utxos, lastblock, processed_items)) } + #[instrument(skip_all, name="schema::ChainQuery::stats")] pub fn stats(&self, scripthash: &[u8]) -> ScriptStats { let _timer = self.start_timer("stats"); @@ -664,6 +687,7 @@ impl ChainQuery { newstats } + #[instrument(skip_all, name="schema::ChainQuery::stats_delta")] fn stats_delta( &self, scripthash: &[u8], @@ -731,6 +755,7 @@ impl ChainQuery { (stats, lastblock) } + #[instrument(skip_all, name="schema::ChainQuery::address_search")] pub fn address_search(&self, prefix: &str, limit: usize) -> Vec { let _timer_scan = self.start_timer("address_search"); self.store @@ -741,6 +766,7 @@ impl ChainQuery { .collect() } + #[instrument(skip_all, name="schema::ChainQuery::header_by_hash")] fn header_by_hash(&self, hash: &BlockHash) -> Option { self.store .indexed_headers @@ -750,6 +776,7 @@ impl ChainQuery { .cloned() } + #[instrument(skip_all, name="schema::ChainQuery::height_by_hash")] // Get the height of a blockhash, only if its part of the best chain pub fn height_by_hash(&self, hash: &BlockHash) -> Option { self.store @@ -760,6 +787,7 @@ impl ChainQuery { .map(|header| header.height()) } + #[instrument(skip_all, name="schema::ChainQuery::header_by_height")] pub fn header_by_height(&self, height: usize) -> Option { self.store .indexed_headers @@ -769,6 +797,7 @@ impl ChainQuery { .cloned() } + #[instrument(skip_all, name="schema::ChainQuery::hash_by_height")] pub fn hash_by_height(&self, height: usize) -> Option { self.store .indexed_headers @@ -778,6 +807,7 @@ impl ChainQuery { .map(|entry| *entry.hash()) } + #[instrument(skip_all, name="schema::ChainQuery::blockid_by_height")] pub fn blockid_by_height(&self, height: usize) -> Option { self.store .indexed_headers @@ -787,6 +817,7 @@ impl ChainQuery { .map(BlockId::from) } + #[instrument(skip_all, name="schema::ChainQuery::blockid_by_hash")] // returns None for orphaned blocks pub fn blockid_by_hash(&self, hash: &BlockHash) -> Option { self.store @@ -797,14 +828,18 @@ impl ChainQuery { .map(BlockId::from) } + + #[instrument(skip_all, name="schema::ChainQuery::bests_height")] pub fn best_height(&self) -> usize { self.store.indexed_headers.read().unwrap().len() - 1 } + #[instrument(skip_all, name="schema::ChainQuery::best_hash")] pub fn best_hash(&self) -> BlockHash { *self.store.indexed_headers.read().unwrap().tip() } + #[instrument(skip_all, name="schema::ChainQuery::best_header")] pub fn best_header(&self) -> HeaderEntry { let headers = self.store.indexed_headers.read().unwrap(); headers @@ -815,6 +850,7 @@ impl ChainQuery { // TODO: can we pass txids as a "generic iterable"? // TODO: should also use a custom ThreadPoolBuilder? + #[instrument(skip_all, name="schema::ChainQuery::lookup_txns")] pub fn lookup_txns(&self, txids: &[(Txid, BlockId)]) -> Result> { let _timer = self.start_timer("lookup_txns"); txids @@ -826,6 +862,7 @@ impl ChainQuery { .collect::>>() } + #[instrument(skip_all, name="schema::ChainQuery::lookup_txn")] pub fn lookup_txn(&self, txid: &Txid, blockhash: Option<&BlockHash>) -> Option { let _timer = self.start_timer("lookup_txn"); self.lookup_raw_txn(txid, blockhash).map(|rawtx| { @@ -835,6 +872,7 @@ impl ChainQuery { }) } + #[instrument(skip_all, name="schema::ChainQuery::lookup_raw_txn")] pub fn lookup_raw_txn(&self, txid: &Txid, blockhash: Option<&BlockHash>) -> Option { let _timer = self.start_timer("lookup_raw_txn"); @@ -854,16 +892,19 @@ impl ChainQuery { } } + #[instrument(skip_all, name="schema::ChainQuery::lookup_txo")] pub fn lookup_txo(&self, outpoint: &OutPoint) -> Option { let _timer = self.start_timer("lookup_txo"); lookup_txo(&self.store.txstore_db, outpoint) } + #[instrument(skip_all, name="schema::ChainQuery::lookup_txos")] pub fn lookup_txos(&self, outpoints: BTreeSet) -> Result> { let _timer = self.start_timer("lookup_txos"); lookup_txos(&self.store.txstore_db, outpoints) } + #[instrument(skip_all, name="schema::ChainQuery::lookup_spend")] pub fn lookup_spend(&self, outpoint: &OutPoint) -> Option { let _timer = self.start_timer("lookup_spend"); self.store @@ -879,6 +920,8 @@ impl ChainQuery { }) }) } + + #[instrument(skip_all, name="schema::ChainQuery::tx_confirming_blocks")] pub fn tx_confirming_block(&self, txid: &Txid) -> Option { let _timer = self.start_timer("tx_confirming_block"); let headers = self.store.indexed_headers.read().unwrap(); @@ -895,6 +938,7 @@ impl ChainQuery { .map(BlockId::from) } + #[instrument(skip_all, name="schema::ChainQuery::get_block_status")] pub fn get_block_status(&self, hash: &BlockHash) -> BlockStatus { // TODO differentiate orphaned and non-existing blocks? telling them apart requires // an additional db read. @@ -916,6 +960,7 @@ impl ChainQuery { } #[cfg(not(feature = "liquid"))] + #[instrument(skip_all, name="schema::ChainQuery::get_merkleblock_proof")] pub fn get_merkleblock_proof(&self, txid: &Txid) -> Option { let _timer = self.start_timer("get_merkleblock_proof"); let blockid = self.tx_confirming_block(txid)?; @@ -930,6 +975,7 @@ impl ChainQuery { } #[cfg(feature = "liquid")] + #[instrument(skip_all, name="schema::ChainQuery::asset_history")] pub fn asset_history( &self, asset_id: &AssetId, @@ -940,11 +986,13 @@ impl ChainQuery { } #[cfg(feature = "liquid")] + #[instrument(skip_all, name="schema::ChainQuery::assets_history_txids")] pub fn asset_history_txids(&self, asset_id: &AssetId, limit: usize) -> Vec<(Txid, BlockId)> { self._history_txids(b'I', &asset_id.into_inner()[..], limit) } } +#[instrument(skip_all, name="schema::ChainQuery::load_blockhashes")] fn load_blockhashes(db: &DB, prefix: &[u8]) -> HashSet { db.iter_scan(prefix) .map(BlockRow::from_row) @@ -952,6 +1000,7 @@ fn load_blockhashes(db: &DB, prefix: &[u8]) -> HashSet { .collect() } +#[instrument(skip_all, name="schema::ChainQuery::load_blockheaders")] fn load_blockheaders(db: &DB) -> HashMap { db.iter_scan(&BlockRow::header_filter()) .map(BlockRow::from_row) @@ -963,6 +1012,7 @@ fn load_blockheaders(db: &DB) -> HashMap { .collect() } +#[instrument(skip_all, name="schema::add_blocks")] fn add_blocks(block_entries: &[BlockEntry], iconfig: &IndexerConfig) -> Vec { // persist individual transactions: // T{txid} → {rawtx} @@ -978,8 +1028,8 @@ fn add_blocks(block_entries: &[BlockEntry], iconfig: &IndexerConfig) -> Vec = b.block.txdata.iter().map(|tx| tx.txid()).collect(); - for tx in &b.block.txdata { - add_transaction(tx, blockhash, &mut rows, iconfig); + for (tx, txid) in b.block.txdata.iter().zip(txids.iter()) { + add_transaction(*txid, tx, blockhash, &mut rows, iconfig); } if !iconfig.light_mode { @@ -995,19 +1045,21 @@ fn add_blocks(block_entries: &[BlockEntry], iconfig: &IndexerConfig) -> Vec, iconfig: &IndexerConfig, ) { - rows.push(TxConfRow::new(tx, blockhash).into_row()); + rows.push(TxConfRow::new(txid, blockhash).into_row()); if !iconfig.light_mode { - rows.push(TxRow::new(tx).into_row()); + rows.push(TxRow::new(txid, tx).into_row()); } - let txid = full_hash(&tx.txid()[..]); + let txid = full_hash(&txid[..]); for (txo_index, txo) in tx.output.iter().enumerate() { if is_spendable(txo) { rows.push(TxOutRow::new(&txid, txo_index, txo).into_row()); @@ -1015,6 +1067,7 @@ fn add_transaction( } } +#[instrument(skip_all, name="schema::get_previous_txos")] fn get_previous_txos(block_entries: &[BlockEntry]) -> BTreeSet { block_entries .iter() @@ -1028,6 +1081,7 @@ fn get_previous_txos(block_entries: &[BlockEntry]) -> BTreeSet { .collect() } +#[instrument(skip_all, name = "schema::lookup_txos")] fn lookup_txos(txstore_db: &DB, outpoints: BTreeSet) -> Result> { let keys = outpoints.iter().map(TxOutRow::key).collect::>(); txstore_db @@ -1049,6 +1103,7 @@ fn lookup_txo(txstore_db: &DB, outpoint: &OutPoint) -> Option { .map(|val| deserialize(&val).expect("failed to parse TxOut")) } +#[instrument(skip_all, name="schema::index_blocks")] fn index_blocks( block_entries: &[BlockEntry], previous_txos_map: &HashMap, @@ -1069,7 +1124,9 @@ fn index_blocks( .collect() } + // TODO: return an iterator? +#[instrument(skip_all, name="schema::index_transaction")] fn index_transaction( tx: &Transaction, confirmed_height: u32, @@ -1144,6 +1201,7 @@ fn index_transaction( ); } +#[instrument(skip_all, name="schema::addr_search_row")] fn addr_search_row(spk: &Script, network: Network) -> Option { spk.to_address_str(network).map(|address| DBRow { key: [b"a", address.as_bytes()].concat(), @@ -1182,8 +1240,8 @@ struct TxRow { } impl TxRow { - fn new(txn: &Transaction) -> TxRow { - let txid = full_hash(&txn.txid()[..]); + fn new(txid: Txid, txn: &Transaction) -> TxRow { + let txid = full_hash(&txid[..]); TxRow { key: TxRowKey { code: b'T', txid }, value: serialize(txn), @@ -1215,8 +1273,8 @@ struct TxConfRow { } impl TxConfRow { - fn new(txn: &Transaction, blockhash: FullHash) -> TxConfRow { - let txid = full_hash(&txn.txid()[..]); + fn new(txid: Txid, blockhash: FullHash) -> TxConfRow { + let txid = full_hash(&txid[..]); TxConfRow { key: TxConfKey { code: b'C', @@ -1598,6 +1656,7 @@ impl UtxoCacheRow { } } +#[instrument(skip_all, name="schema::make_utxo_cache")] // keep utxo cache with just the block height (the hash/timestamp are read later from the headers to reconstruct BlockId) // and use a (txid,vout) tuple instead of OutPoints (they don't play nicely with bincode serialization) fn make_utxo_cache(utxos: &UtxoMap) -> CachedUtxoMap { @@ -1612,6 +1671,7 @@ fn make_utxo_cache(utxos: &UtxoMap) -> CachedUtxoMap { .collect() } +#[instrument(skip_all, name="schema::from_utxo_cache")] fn from_utxo_cache(utxos_cache: CachedUtxoMap, chain: &ChainQuery) -> UtxoMap { utxos_cache .into_iter() @@ -1646,3 +1706,46 @@ impl GetAmountVal for confidential::Value { self } } + +// This is needed to bench private functions +#[cfg(feature = "bench")] +pub mod bench { + use crate::new_index::schema::IndexerConfig; + use crate::new_index::BlockEntry; + use crate::new_index::DBRow; + use crate::util::HeaderEntry; + use bitcoin::Block; + + pub struct Data { + block_entry: BlockEntry, + iconfig: IndexerConfig, + } + + impl Data { + pub fn new(block: Block) -> Data { + let iconfig = IndexerConfig { + light_mode: false, + address_search: false, + index_unspendables: false, + network: crate::chain::Network::Regtest, + }; + let height = 702861; + let hash = block.block_hash(); + let header = block.header.clone(); + let block_entry = BlockEntry { + block, + entry: HeaderEntry::new(height, hash, header), + size: 0u32, // wrong but not needed for benching + }; + + Data { + block_entry, + iconfig, + } + } + } + + pub fn add_blocks(data: &Data) -> Vec { + super::add_blocks(&[data.block_entry.clone()], &data.iconfig) + } +} diff --git a/src/otlp_trace.rs b/src/otlp_trace.rs new file mode 100644 index 000000000..dcc23a553 --- /dev/null +++ b/src/otlp_trace.rs @@ -0,0 +1,85 @@ +use opentelemetry::{ + runtime, + sdk::{ + trace::{BatchConfig, RandomIdGenerator, Sampler, Tracer}, + Resource, + }, + KeyValue, +}; +use opentelemetry_otlp::{ExportConfig, Protocol, WithExportConfig}; +use opentelemetry_semantic_conventions::{ + resource::{SERVICE_NAME, SERVICE_VERSION}, + SCHEMA_URL, +}; +use std::env::var; +use std::time::Duration; +use tracing_opentelemetry::OpenTelemetryLayer; +use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt}; + +fn init_tracer(resource: Resource, endpoint: &str) -> Tracer { + let export_config = ExportConfig { + endpoint: endpoint.to_string(), + timeout: Duration::from_secs(3), + protocol: Protocol::Grpc, + }; + + opentelemetry_otlp::new_pipeline() + .tracing() + .with_trace_config( + opentelemetry::sdk::trace::Config::default() + .with_sampler(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased( + 1.0, + )))) + .with_id_generator(RandomIdGenerator::default()) + .with_resource(resource), + ) + .with_batch_config(BatchConfig::default()) + .with_exporter( + opentelemetry_otlp::new_exporter() + .tonic() + .with_endpoint(endpoint) + .with_export_config(export_config), + ) + .install_batch(runtime::Tokio) + .unwrap() +} + +fn init_tracing_subscriber(service_name: &str) -> OtelGuard { + let resource = Resource::from_schema_url( + [ + KeyValue::new(SERVICE_NAME, service_name.to_owned()), + KeyValue::new(SERVICE_VERSION, "0.4.1"), + ], + SCHEMA_URL, + ); + + let env_filter = EnvFilter::from_default_env(); + + let reg = tracing_subscriber::registry() + .with(env_filter) + .with(tracing_subscriber::fmt::layer() + .with_thread_ids(true) + .with_ansi(false) + .compact()); + let _ = if let Ok(endpoint) = var("OTLP_ENDPOINT") { + reg.with(OpenTelemetryLayer::new(init_tracer(resource, &endpoint))) + .try_init() + } else { + reg.try_init() + }; + + log::debug!("Initialized tracing"); + + OtelGuard {} +} + +pub fn init_tracing(service_name: &str) -> OtelGuard { + init_tracing_subscriber(service_name) +} + +pub struct OtelGuard {} +impl Drop for OtelGuard { + fn drop(&mut self) { + opentelemetry::global::shutdown_tracer_provider(); + } +} diff --git a/src/rest.rs b/src/rest.rs index 43eab5c60..7567bff81 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -24,6 +24,9 @@ use tokio::sync::oneshot; use std::fs; use std::str::FromStr; + +use tracing::instrument; + #[cfg(feature = "liquid")] use { crate::elements::{ebcompact::*, peg::PegoutValue, AssetSorting, IssuanceValue}, @@ -579,6 +582,7 @@ impl Handle { } } +#[instrument(skip_all, name="rest::handle_request")] fn handle_request( method: Method, uri: hyper::Uri, @@ -1154,6 +1158,7 @@ fn json_response(value: T, ttl: u32) -> Result, Htt .unwrap()) } +#[instrument(skip_all, name="rest::blocks")] fn blocks(query: &Query, start_height: Option) -> Result, HttpError> { let mut values = Vec::new(); let mut current_hash = match start_height { diff --git a/src/util/block.rs b/src/util/block.rs index 18dc91c27..19e54dd87 100644 --- a/src/util/block.rs +++ b/src/util/block.rs @@ -9,6 +9,8 @@ use std::slice; use time::format_description::well_known::Rfc3339; use time::OffsetDateTime as DateTime; +use tracing::instrument; + const MTP_SPAN: usize = 11; lazy_static! { @@ -43,6 +45,14 @@ pub struct HeaderEntry { } impl HeaderEntry { + #[cfg(feature = "bench")] + pub fn new(height: usize, hash: BlockHash, header: BlockHeader) -> Self { + Self { + height, + hash, + header, + } + } pub fn hash(&self) -> &BlockHash { &self.hash } @@ -84,6 +94,7 @@ impl HeaderList { } } + #[instrument(skip_all, name="block::new")] pub fn new( mut headers_map: HashMap, tip_hash: BlockHash, @@ -121,6 +132,7 @@ impl HeaderList { headers } + #[instrument(skip_all, name="block::HeaderList::order")] pub fn order(&self, new_headers: Vec) -> Vec { // header[i] -> header[i-1] (i.e. header.last() is the tip) struct HashedHeader { @@ -160,6 +172,7 @@ impl HeaderList { .collect() } + #[instrument(skip_all, name="block::HeaderList::apply")] pub fn apply(&mut self, new_headers: Vec) { // new_headers[i] -> new_headers[i - 1] (i.e. new_headers.last() is the tip) for i in 1..new_headers.len() { @@ -197,6 +210,7 @@ impl HeaderList { } } + #[instrument(skip_all, name="block::HeaderList::header_by_blockhash")] pub fn header_by_blockhash(&self, blockhash: &BlockHash) -> Option<&HeaderEntry> { let height = self.heights.get(blockhash)?; let header = self.headers.get(*height)?; @@ -207,6 +221,7 @@ impl HeaderList { } } + #[instrument(skip_all, name="block::HeaderList::header_by_height")] pub fn header_by_height(&self, height: usize) -> Option<&HeaderEntry> { self.headers.get(height).map(|entry| { assert_eq!(entry.height(), height); diff --git a/src/util/electrum_merkle.rs b/src/util/electrum_merkle.rs index 954782a7d..f26c5578e 100644 --- a/src/util/electrum_merkle.rs +++ b/src/util/electrum_merkle.rs @@ -3,6 +3,10 @@ use crate::errors::*; use crate::new_index::ChainQuery; use bitcoin::hashes::{sha256d::Hash as Sha256dHash, Hash}; + +use tracing::instrument; + +#[instrument(skip_all, name="electrum_merkle::get_tx_merkleproof")] pub fn get_tx_merkle_proof( chain: &ChainQuery, tx_hash: &Txid, @@ -21,6 +25,7 @@ pub fn get_tx_merkle_proof( Ok((branch, pos)) } +#[instrument(skip_all, name="electrum_merkle::get_header_merkle_proof")] pub fn get_header_merkle_proof( chain: &ChainQuery, height: usize, @@ -49,7 +54,7 @@ pub fn get_header_merkle_proof( let header_hashes = header_hashes.into_iter().map(Sha256dHash::from).collect(); Ok(create_merkle_branch_and_root(header_hashes, height)) } - +#[instrument(skip_all, name="electrum_merkle::get_id_from_pos")] pub fn get_id_from_pos( chain: &ChainQuery, height: usize, diff --git a/src/util/fees.rs b/src/util/fees.rs index 9cbe6c1d7..213dc7194 100644 --- a/src/util/fees.rs +++ b/src/util/fees.rs @@ -1,6 +1,8 @@ use crate::chain::{Network, Transaction, TxOut}; use std::collections::HashMap; +use tracing::instrument; + const VSIZE_BIN_WIDTH: u64 = 50_000; // in vbytes pub struct TxFeeInfo { @@ -46,6 +48,7 @@ pub fn get_tx_fee(tx: &Transaction, _prevouts: &HashMap, network: N tx.fee_in(*network.native_asset()) } +#[instrument(skip_all, name="fees::make_fee_histogram")] pub fn make_fee_histogram(mut entries: Vec<&TxFeeInfo>) -> Vec<(f64, u64)> { entries.sort_unstable_by(|e1, e2| e1.fee_per_vbyte.partial_cmp(&e2.fee_per_vbyte).unwrap()); diff --git a/src/util/mod.rs b/src/util/mod.rs index 3b03d41ce..0a9701b8e 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -12,8 +12,8 @@ pub use self::block::{ pub use self::fees::get_tx_fee; pub use self::script::{get_innerscripts, ScriptToAddr, ScriptToAsm}; pub use self::transaction::{ - extract_tx_prevouts, has_prevout, is_coinbase, is_spendable, serialize_outpoint, - TransactionStatus, TxInput, + extract_tx_prevouts, get_prev_outpoints, has_prevout, is_coinbase, is_spendable, + serialize_outpoint, TransactionStatus, TxInput, }; use std::collections::HashMap; diff --git a/src/util/transaction.rs b/src/util/transaction.rs index dda5e4f7c..4daa8547b 100644 --- a/src/util/transaction.rs +++ b/src/util/transaction.rs @@ -1,7 +1,7 @@ use crate::chain::{BlockHash, OutPoint, Transaction, TxIn, TxOut, Txid}; use crate::util::BlockId; -use std::collections::HashMap; +use std::collections::{BTreeSet, HashMap}; #[cfg(feature = "liquid")] lazy_static! { @@ -96,6 +96,16 @@ pub fn extract_tx_prevouts<'a>( .collect() } +pub fn get_prev_outpoints<'a>(txs: impl Iterator) -> BTreeSet { + txs.flat_map(|tx| { + tx.input + .iter() + .filter(|txin| has_prevout(txin)) + .map(|txin| txin.previous_output) + }) + .collect() +} + pub fn serialize_outpoint(outpoint: &OutPoint, serializer: S) -> Result where S: serde::ser::Serializer, diff --git a/tests/common.rs b/tests/common.rs index c85ebf7d9..bac94d8a2 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -1,6 +1,8 @@ +use std::str::FromStr; use std::sync::{Arc, Once, RwLock}; use std::{env, net}; +use log::LevelFilter; use stderrlog::StdErrLog; use tempfile::TempDir; @@ -53,7 +55,7 @@ impl TestRunner { #[cfg(feature = "liquid")] node_conf.args.push("-anyonecanspendaremine=1"); - node_conf.view_stdout = true; + node_conf.view_stdout = std::env::var_os("RUST_LOG").is_some(); } // Setup node @@ -89,6 +91,7 @@ impl TestRunner { network_type, db_path: electrsdb.path().to_path_buf(), daemon_dir: daemon_subdir.clone(), + daemon_parallelism: 3, blocks_dir: daemon_subdir.join("blocks"), daemon_rpc_addr: params.rpc_socket.into(), cookie: None, @@ -111,6 +114,7 @@ impl TestRunner { asset_db_path: None, // XXX #[cfg(feature = "liquid")] parent_network: bitcoin::Network::Regtest, + initial_sync_compaction: false, //#[cfg(feature = "electrum-discovery")] //electrum_public_hosts: Option, //#[cfg(feature = "electrum-discovery")] @@ -127,6 +131,7 @@ impl TestRunner { &config.daemon_dir, &config.blocks_dir, config.daemon_rpc_addr, + config.daemon_parallelism, config.cookie_getter(), config.network_type, signal.clone(), @@ -147,7 +152,7 @@ impl TestRunner { }; let mut indexer = Indexer::open(Arc::clone(&store), fetch_from, &config, &metrics); - indexer.update(&daemon)?; + let tip = indexer.update(&daemon)?; indexer.fetch_from(FetchFrom::Bitcoind); let chain = Arc::new(ChainQuery::new( @@ -162,7 +167,7 @@ impl TestRunner { &metrics, Arc::clone(&config), ))); - Mempool::update(&mempool, &daemon)?; + assert!(Mempool::update(&mempool, &daemon, &tip)?); let query = Arc::new(Query::new( Arc::clone(&chain), @@ -193,8 +198,8 @@ impl TestRunner { } pub fn sync(&mut self) -> Result<()> { - self.indexer.update(&self.daemon)?; - Mempool::update(&self.mempool, &self.daemon)?; + let tip = self.indexer.update(&self.daemon)?; + assert!(Mempool::update(&self.mempool, &self.daemon, &tip)?); // force an update for the mempool stats, which are normally cached self.mempool.write().unwrap().update_backlog_stats(); Ok(()) @@ -310,7 +315,11 @@ fn generate( fn init_log() -> StdErrLog { static ONCE: Once = Once::new(); let mut log = stderrlog::new(); - log.verbosity(4); + match std::env::var("RUST_LOG") { + Ok(e) => log.verbosity(LevelFilter::from_str(&e).unwrap_or(LevelFilter::Off)), + Err(_) => log.verbosity(0), + }; + // log.timestamp(stderrlog::Timestamp::Millisecond ); ONCE.call_once(|| log.init().expect("logging initialization failed")); log diff --git a/tests/electrum.rs b/tests/electrum.rs index 504d16ca8..b2bab95f9 100644 --- a/tests/electrum.rs +++ b/tests/electrum.rs @@ -21,7 +21,11 @@ fn test_electrum() -> Result<()> { // Spawn an headless Electrum wallet RPC daemon, connected to Electrs let mut electrum_wallet_conf = electrumd::Conf::default(); let server_arg = format!("{}:t", electrum_addr.to_string()); - electrum_wallet_conf.args = vec!["-v", "--server", &server_arg]; + electrum_wallet_conf.args = if std::env::var_os("RUST_LOG").is_some() { + vec!["-v", "--server", &server_arg] + } else { + vec!["--server", &server_arg] + }; electrum_wallet_conf.view_stdout = true; let electrum_wallet = ElectrumD::with_conf(electrumd::exe_path()?, &electrum_wallet_conf)?; @@ -125,7 +129,7 @@ fn test_electrum() -> Result<()> { )?]), )?; notify_wallet(); - assert_balance(0.3, -0.161); + assert_balance(0.139, 0.0); tester.mine()?; notify_wallet();