From f21d7c69347856b4d65ebe3eaaaf04013af894c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 01:26:54 +0000 Subject: [PATCH] build(deps): bump the prod group with 6 updates (#8125) * build(deps): bump the prod group with 6 updates Bumps the prod group with 6 updates: | Package | From | To | | --- | --- | --- | | [futures](https://github.com/rust-lang/futures-rs) | `0.3.29` | `0.3.30` | | [tokio](https://github.com/tokio-rs/tokio) | `1.35.0` | `1.35.1` | | [metrics](https://github.com/metrics-rs/metrics) | `0.21.1` | `0.22.0` | | [metrics-exporter-prometheus](https://github.com/metrics-rs/metrics) | `0.12.2` | `0.13.0` | | [reqwest](https://github.com/seanmonstar/reqwest) | `0.11.22` | `0.11.23` | | [owo-colors](https://github.com/jam1garner/owo-colors) | `3.5.0` | `4.0.0` | Updates `futures` from 0.3.29 to 0.3.30 - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.29...0.3.30) Updates `tokio` from 1.35.0 to 1.35.1 - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.35.0...tokio-1.35.1) Updates `metrics` from 0.21.1 to 0.22.0 - [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml) - [Commits](https://github.com/metrics-rs/metrics/compare/metrics-v0.21.1...metrics-v0.22.0) Updates `metrics-exporter-prometheus` from 0.12.2 to 0.13.0 - [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml) - [Commits](https://github.com/metrics-rs/metrics/compare/metrics-exporter-prometheus-v0.12.2...metrics-exporter-prometheus-v0.13.0) Updates `reqwest` from 0.11.22 to 0.11.23 - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.22...v0.11.23) Updates `owo-colors` from 3.5.0 to 4.0.0 - [Commits](https://github.com/jam1garner/owo-colors/compare/v3.5.0...v4.0.0) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod - dependency-name: metrics dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod - dependency-name: metrics-exporter-prometheus dependency-type: direct:production update-type: version-update:semver-minor dependency-group: prod - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch dependency-group: prod - dependency-name: owo-colors dependency-type: direct:production update-type: version-update:semver-major dependency-group: prod ... Signed-off-by: dependabot[bot] * update all metric macros * fix deprecated function * fix duplicated deps * Fix an incorrect gauge method call * Expand documentation and error messages for best chain length --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alfredo Garcia Co-authored-by: teor --- Cargo.lock | 100 ++++++++++-------- deny.toml | 6 ++ tower-batch-control/Cargo.toml | 6 +- tower-fallback/Cargo.toml | 2 +- zebra-chain/Cargo.toml | 6 +- zebra-consensus/Cargo.toml | 8 +- zebra-consensus/src/checkpoint.rs | 36 +++---- zebra-consensus/src/primitives/ed25519.rs | 4 +- zebra-consensus/src/primitives/groth16.rs | 4 +- zebra-consensus/src/primitives/halo2.rs | 4 +- zebra-consensus/src/primitives/redjubjub.rs | 4 +- zebra-consensus/src/primitives/redpallas.rs | 4 +- zebra-network/Cargo.toml | 8 +- zebra-network/src/address_book.rs | 15 ++- zebra-network/src/config.rs | 12 +-- zebra-network/src/peer/connection.rs | 40 +++---- zebra-network/src/peer/handshake.rs | 28 ++--- zebra-network/src/peer_set/initialize.rs | 3 +- .../src/peer_set/inventory_registry.rs | 4 +- zebra-network/src/peer_set/set.rs | 6 +- zebra-network/src/protocol/external/codec.rs | 7 +- zebra-node-services/Cargo.toml | 4 +- zebra-rpc/Cargo.toml | 6 +- zebra-scan/Cargo.toml | 4 +- zebra-state/Cargo.toml | 8 +- zebra-state/src/request.rs | 8 +- zebra-state/src/service.rs | 17 +-- zebra-state/src/service/finalized_state.rs | 24 ++--- .../finalized_state/zebra_db/metrics.rs | 40 +++---- .../src/service/non_finalized_state.rs | 28 +++-- .../non_finalized_state/tests/vectors.rs | 4 +- zebra-state/src/service/queued_blocks.rs | 33 +++--- zebra-state/src/service/write.rs | 21 ++-- zebra-test/Cargo.toml | 6 +- zebra-utils/Cargo.toml | 4 +- zebrad/Cargo.toml | 10 +- zebrad/src/components/inbound/downloads.rs | 22 ++-- zebrad/src/components/mempool.rs | 4 +- zebrad/src/components/mempool/downloads.rs | 37 +++---- zebrad/src/components/mempool/gossip.rs | 2 +- zebrad/src/components/mempool/storage.rs | 12 +-- .../mempool/storage/verified_set.rs | 54 +++++----- zebrad/src/components/metrics.rs | 5 +- zebrad/src/components/sync.rs | 20 ++-- zebrad/src/components/sync/downloads.rs | 22 ++-- 45 files changed, 328 insertions(+), 374 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e07fa0b46..667eb8b8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -825,7 +825,7 @@ dependencies = [ "eyre", "indenter", "once_cell", - "owo-colors", + "owo-colors 3.5.0", "tracing-error", "url", ] @@ -837,7 +837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" dependencies = [ "once_cell", - "owo-colors", + "owo-colors 3.5.0", "tracing-core", "tracing-error", ] @@ -1491,9 +1491,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1506,9 +1506,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1516,15 +1516,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1533,15 +1533,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -1550,21 +1550,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -2497,16 +2497,26 @@ dependencies = [ ] [[package]] -name = "metrics-exporter-prometheus" -version = "0.12.2" +name = "metrics" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950" +checksum = "77b9e10a211c839210fd7f99954bda26e5f8e26ec686ad68da6a32df7c80e782" +dependencies = [ + "ahash", + "portable-atomic", +] + +[[package]] +name = "metrics-exporter-prometheus" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea" dependencies = [ "base64 0.21.5", "hyper", "indexmap 1.9.3", "ipnet", - "metrics", + "metrics 0.22.0", "metrics-util", "quanta", "thiserror", @@ -2526,14 +2536,14 @@ dependencies = [ [[package]] name = "metrics-util" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" +checksum = "2670b8badcc285d486261e2e9f1615b506baff91427b61bd336a472b65bbf5ed" dependencies = [ "crossbeam-epoch", "crossbeam-utils", "hashbrown 0.13.1", - "metrics", + "metrics 0.22.0", "num_cpus", "quanta", "sketches-ddsketch", @@ -2789,6 +2799,12 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" + [[package]] name = "pairing" version = "0.23.0" @@ -3245,9 +3261,9 @@ dependencies = [ [[package]] name = "quanta" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab" +checksum = "577c55a090a94ed7da0e6580cc38a553558e2d736398b5d8ebf81bc9880f8acd" dependencies = [ "crossbeam-utils", "libc", @@ -3394,11 +3410,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "10.7.0" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", ] [[package]] @@ -3527,9 +3543,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "async-compression", "base64 0.21.5", @@ -4405,9 +4421,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -5669,7 +5685,7 @@ dependencies = [ "jubjub", "libc", "memuse", - "metrics", + "metrics 0.21.1", "orchard", "rand 0.8.5", "rand_core 0.6.4", @@ -5762,7 +5778,7 @@ dependencies = [ "howudoin", "jubjub", "lazy_static", - "metrics", + "metrics 0.22.0", "num-integer", "once_cell", "orchard", @@ -5807,7 +5823,7 @@ dependencies = [ "indexmap 2.1.0", "itertools 0.12.0", "lazy_static", - "metrics", + "metrics 0.22.0", "num-integer", "ordered-map", "pin-project", @@ -5938,7 +5954,7 @@ dependencies = [ "itertools 0.12.0", "jubjub", "lazy_static", - "metrics", + "metrics 0.22.0", "mset", "once_cell", "proptest", @@ -5975,7 +5991,7 @@ dependencies = [ "itertools 0.12.0", "lazy_static", "once_cell", - "owo-colors", + "owo-colors 4.0.0", "proptest", "rand 0.8.5", "regex", @@ -6039,7 +6055,7 @@ dependencies = [ "jsonrpc-core", "lazy_static", "log", - "metrics", + "metrics 0.22.0", "metrics-exporter-prometheus", "num-integer", "once_cell", diff --git a/deny.toml b/deny.toml index 510e11b09..428084835 100644 --- a/deny.toml +++ b/deny.toml @@ -70,11 +70,17 @@ skip-tree = [ # wait for `parking_lot` crate inside `jsonrpc-http-server` to upgrade { name = "redox_syscall", version = "=0.2.16" }, + # wait for `color-eyre` to upgrade + { name = "owo-colors", version = "=3.5.0" }, + # ZF crates # wait for indexmap, toml_edit, serde_json, tower to upgrade { name = "hashbrown", version = "=0.12.3" }, + # wait for zcash_script to upgrade + { name = "metrics", version = "=0.21.1" }, + # ECC crates # wait for hdwallet to upgrade diff --git a/tower-batch-control/Cargo.toml b/tower-batch-control/Cargo.toml index 8b12c70d5..3b7075ab2 100644 --- a/tower-batch-control/Cargo.toml +++ b/tower-batch-control/Cargo.toml @@ -22,11 +22,11 @@ keywords = ["tower", "batch"] categories = ["algorithms", "asynchronous"] [dependencies] -futures = "0.3.29" +futures = "0.3.30" futures-core = "0.3.28" pin-project = "1.1.3" rayon = "1.7.0" -tokio = { version = "1.34.0", features = ["time", "sync", "tracing", "macros"] } +tokio = { version = "1.35.1", features = ["time", "sync", "tracing", "macros"] } tokio-util = "0.7.10" tower = { version = "0.4.13", features = ["util", "buffer"] } tracing = "0.1.39" @@ -41,7 +41,7 @@ tinyvec = { version = "1.6.0", features = ["rustc_1_55"] } ed25519-zebra = "4.0.3" rand = "0.8.5" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } tokio-test = "0.4.3" tower-fallback = { path = "../tower-fallback/" } tower-test = "0.4.0" diff --git a/tower-fallback/Cargo.toml b/tower-fallback/Cargo.toml index 791093a3a..dc823d8ef 100644 --- a/tower-fallback/Cargo.toml +++ b/tower-fallback/Cargo.toml @@ -22,6 +22,6 @@ futures-core = "0.3.28" tracing = "0.1.39" [dev-dependencies] -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } zebra-test = { path = "../zebra-test/" } diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index c9c6092e2..a68ab4258 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -101,7 +101,7 @@ serde_with = "3.4.0" serde-big-array = "0.5.1" # Processing -futures = "0.3.29" +futures = "0.3.30" itertools = "0.12.0" rayon = "1.7.0" @@ -114,7 +114,7 @@ reddsa = "0.5.1" serde_json = { version = "1.0.108", optional = true } # Production feature async-error and testing feature proptest-impl -tokio = { version = "1.34.0", optional = true } +tokio = { version = "1.35.1", optional = true } # Experimental feature getblocktemplate-rpcs zcash_address = { version = "0.3.0", optional = true } @@ -147,7 +147,7 @@ proptest-derive = "0.4.0" rand = "0.8.5" rand_chacha = "0.3.1" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } zebra-test = { path = "../zebra-test/" } diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index 4346e31c8..c230921c3 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -49,11 +49,11 @@ lazy_static = "1.4.0" once_cell = "1.18.0" serde = { version = "1.0.193", features = ["serde_derive"] } -futures = "0.3.29" +futures = "0.3.30" futures-util = "0.3.28" -metrics = "0.21.1" +metrics = "0.22.0" thiserror = "1.0.51" -tokio = { version = "1.34.0", features = ["time", "sync", "tracing", "rt-multi-thread"] } +tokio = { version = "1.35.1", features = ["time", "sync", "tracing", "rt-multi-thread"] } tower = { version = "0.4.13", features = ["timeout", "util", "buffer"] } tracing = "0.1.39" tracing-futures = "0.2.5" @@ -90,7 +90,7 @@ proptest = "1.4.0" proptest-derive = "0.4.0" spandoc = "0.2.2" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } tracing-error = "0.2.0" tracing-subscriber = "0.3.18" diff --git a/zebra-consensus/src/checkpoint.rs b/zebra-consensus/src/checkpoint.rs index bcd491877..6541c502f 100644 --- a/zebra-consensus/src/checkpoint.rs +++ b/zebra-consensus/src/checkpoint.rs @@ -103,8 +103,8 @@ fn progress_from_tip( if height >= checkpoint_list.max_height() { (None, Progress::FinalCheckpoint) } else { - metrics::gauge!("checkpoint.verified.height", height.0 as f64); - metrics::gauge!("checkpoint.processing.next.height", height.0 as f64); + metrics::gauge!("checkpoint.verified.height").set(height.0 as f64); + metrics::gauge!("checkpoint.processing.next.height").set(height.0 as f64); (Some(hash), Progress::InitialTip(height)) } } @@ -303,7 +303,7 @@ where .next_back() .expect("queued has at least one entry"); - metrics::gauge!("checkpoint.queued.max.height", max_queued_height.0 as f64); + metrics::gauge!("checkpoint.queued.max.height").set(max_queued_height.0 as f64); let is_checkpoint = self.checkpoint_list.contains(height); tracing::debug!(?height, ?hash, ?is_checkpoint, "queued block"); @@ -326,12 +326,12 @@ where return; }; - metrics::gauge!("checkpoint.verified.height", verified_height.0 as f64); + metrics::gauge!("checkpoint.verified.height").set(verified_height.0 as f64); let checkpoint_index = self.checkpoint_list.prev_checkpoint_index(verified_height); let checkpoint_count = self.checkpoint_list.len(); - metrics::gauge!("checkpoint.verified.count", checkpoint_index as f64); + metrics::gauge!("checkpoint.verified.count").set(checkpoint_index as f64); tracing::debug!( ?verified_height, @@ -409,7 +409,7 @@ where // Check if we have the genesis block as a special case, to simplify the loop BeforeGenesis if !self.queued.contains_key(&block::Height(0)) => { tracing::trace!("Waiting for genesis block"); - metrics::counter!("checkpoint.waiting.count", 1); + metrics::counter!("checkpoint.waiting.count").increment(1); return WaitingForBlocks; } BeforeGenesis => block::Height(0), @@ -444,10 +444,7 @@ where break; } } - metrics::gauge!( - "checkpoint.queued.continuous.height", - pending_height.0 as f64, - ); + metrics::gauge!("checkpoint.queued.continuous.height").set(pending_height.0 as f64); // Now find the start of the checkpoint range let start = self.current_start_bound().expect( @@ -466,14 +463,11 @@ where ); if let Some(block::Height(target_checkpoint)) = target_checkpoint { - metrics::gauge!( - "checkpoint.processing.next.height", - target_checkpoint as f64, - ); + metrics::gauge!("checkpoint.processing.next.height").set(target_checkpoint as f64); } else { // Use the start height if there is no potential next checkpoint - metrics::gauge!("checkpoint.processing.next.height", start_height.0 as f64); - metrics::counter!("checkpoint.waiting.count", 1); + metrics::gauge!("checkpoint.processing.next.height").set(start_height.0 as f64); + metrics::counter!("checkpoint.waiting.count").increment(1); } target_checkpoint @@ -541,12 +535,12 @@ where /// Increase the current checkpoint height to `verified_height`, fn update_progress(&mut self, verified_height: block::Height) { if let Some(max_height) = self.queued.keys().next_back() { - metrics::gauge!("checkpoint.queued.max.height", max_height.0 as f64); + metrics::gauge!("checkpoint.queued.max.height").set(max_height.0 as f64); } else { // use f64::NAN as a sentinel value for "None", because 0 is a valid height - metrics::gauge!("checkpoint.queued.max.height", f64::NAN); + metrics::gauge!("checkpoint.queued.max.height").set(f64::NAN); } - metrics::gauge!("checkpoint.queued_slots", self.queued.len() as f64); + metrics::gauge!("checkpoint.queued_slots").set(self.queued.len() as f64); // Ignore blocks that are below the previous checkpoint, or otherwise // have invalid heights. @@ -869,7 +863,7 @@ where let block_count = rev_valid_blocks.len(); tracing::info!(?block_count, ?current_range, "verified checkpoint range"); - metrics::counter!("checkpoint.verified.block.count", block_count as u64); + metrics::counter!("checkpoint.verified.block.count").increment(block_count as u64); // All the blocks we've kept are valid, so let's verify them // in height order. @@ -1058,7 +1052,7 @@ where self.process_checkpoint_range(); - metrics::gauge!("checkpoint.queued_slots", self.queued.len() as f64); + metrics::gauge!("checkpoint.queued_slots").set(self.queued.len() as f64); // Because the checkpoint verifier duplicates state from the state // service (it tracks which checkpoints have been verified), we must diff --git a/zebra-consensus/src/primitives/ed25519.rs b/zebra-consensus/src/primitives/ed25519.rs index 7a17ac9e1..d51113276 100644 --- a/zebra-consensus/src/primitives/ed25519.rs +++ b/zebra-consensus/src/primitives/ed25519.rs @@ -164,10 +164,10 @@ impl Service> for Verifier { if result.is_ok() { tracing::trace!(?result, "validated ed25519 signature"); - metrics::counter!("signatures.ed25519.validated", 1); + metrics::counter!("signatures.ed25519.validated").increment(1); } else { tracing::trace!(?result, "invalid ed25519 signature"); - metrics::counter!("signatures.ed25519.invalid", 1); + metrics::counter!("signatures.ed25519.invalid").increment(1); } result.map_err(BoxError::from) } diff --git a/zebra-consensus/src/primitives/groth16.rs b/zebra-consensus/src/primitives/groth16.rs index e6d7ad17a..e2ec64144 100644 --- a/zebra-consensus/src/primitives/groth16.rs +++ b/zebra-consensus/src/primitives/groth16.rs @@ -485,10 +485,10 @@ impl Service> for Verifier { if result.is_ok() { tracing::trace!(?result, "verified groth16 proof"); - metrics::counter!("proofs.groth16.verified", 1); + metrics::counter!("proofs.groth16.verified").increment(1); } else { tracing::trace!(?result, "invalid groth16 proof"); - metrics::counter!("proofs.groth16.invalid", 1); + metrics::counter!("proofs.groth16.invalid").increment(1); } result.map_err(BoxError::from) diff --git a/zebra-consensus/src/primitives/halo2.rs b/zebra-consensus/src/primitives/halo2.rs index e9cbc4262..ffc58a5fe 100644 --- a/zebra-consensus/src/primitives/halo2.rs +++ b/zebra-consensus/src/primitives/halo2.rs @@ -348,10 +348,10 @@ impl Service> for Verifier { if result.is_ok() { tracing::trace!(?result, "verified halo2 proof"); - metrics::counter!("proofs.halo2.verified", 1); + metrics::counter!("proofs.halo2.verified").increment(1); } else { tracing::trace!(?result, "invalid halo2 proof"); - metrics::counter!("proofs.halo2.invalid", 1); + metrics::counter!("proofs.halo2.invalid").increment(1); } result.map_err(BoxError::from) diff --git a/zebra-consensus/src/primitives/redjubjub.rs b/zebra-consensus/src/primitives/redjubjub.rs index 94be0cdb5..31641a9f7 100644 --- a/zebra-consensus/src/primitives/redjubjub.rs +++ b/zebra-consensus/src/primitives/redjubjub.rs @@ -165,10 +165,10 @@ impl Service> for Verifier { if result.is_ok() { tracing::trace!(?result, "validated redjubjub signature"); - metrics::counter!("signatures.redjubjub.validated", 1); + metrics::counter!("signatures.redjubjub.validated").increment(1); } else { tracing::trace!(?result, "invalid redjubjub signature"); - metrics::counter!("signatures.redjubjub.invalid", 1); + metrics::counter!("signatures.redjubjub.invalid").increment(1); } result.map_err(BoxError::from) diff --git a/zebra-consensus/src/primitives/redpallas.rs b/zebra-consensus/src/primitives/redpallas.rs index 5064fa817..d848682aa 100644 --- a/zebra-consensus/src/primitives/redpallas.rs +++ b/zebra-consensus/src/primitives/redpallas.rs @@ -164,10 +164,10 @@ impl Service> for Verifier { if result.is_ok() { tracing::trace!(?result, "validated redpallas signature"); - metrics::counter!("signatures.redpallas.validated", 1); + metrics::counter!("signatures.redpallas.validated").increment(1); } else { tracing::trace!(?result, "invalid redpallas signature"); - metrics::counter!("signatures.redpallas.invalid", 1); + metrics::counter!("signatures.redpallas.invalid").increment(1); } result.map_err(BoxError::from) diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index 802f49c0c..ad7bea90e 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -60,13 +60,13 @@ serde = { version = "1.0.193", features = ["serde_derive"] } tempfile = "3.8.1" thiserror = "1.0.51" -futures = "0.3.29" -tokio = { version = "1.34.0", features = ["fs", "io-util", "net", "time", "tracing", "macros", "rt-multi-thread"] } +futures = "0.3.30" +tokio = { version = "1.35.1", features = ["fs", "io-util", "net", "time", "tracing", "macros", "rt-multi-thread"] } tokio-stream = { version = "0.1.14", features = ["sync", "time"] } tokio-util = { version = "0.7.10", features = ["codec"] } tower = { version = "0.4.13", features = ["retry", "discover", "load", "load-shed", "timeout", "util", "buffer"] } -metrics = "0.21.1" +metrics = "0.22.0" tracing-futures = "0.2.5" tracing-error = { version = "0.2.0", features = ["traced-error"] } tracing = "0.1.39" @@ -90,7 +90,7 @@ proptest = "1.4.0" proptest-derive = "0.4.0" static_assertions = "1.1.0" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } toml = "0.8.8" zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] } diff --git a/zebra-network/src/address_book.rs b/zebra-network/src/address_book.rs index c9d4d1ee5..2f2142b6e 100644 --- a/zebra-network/src/address_book.rs +++ b/zebra-network/src/address_book.rs @@ -696,18 +696,15 @@ impl AddressBook { let _ = self.address_metrics_tx.send(m); // TODO: rename to address_book.[state_name] - metrics::gauge!("candidate_set.responded", m.responded as f64); - metrics::gauge!("candidate_set.gossiped", m.never_attempted_gossiped as f64); - metrics::gauge!("candidate_set.failed", m.failed as f64); - metrics::gauge!("candidate_set.pending", m.attempt_pending as f64); + metrics::gauge!("candidate_set.responded").set(m.responded as f64); + metrics::gauge!("candidate_set.gossiped").set(m.never_attempted_gossiped as f64); + metrics::gauge!("candidate_set.failed").set(m.failed as f64); + metrics::gauge!("candidate_set.pending").set(m.attempt_pending as f64); // TODO: rename to address_book.responded.recently_live - metrics::gauge!("candidate_set.recently_live", m.recently_live as f64); + metrics::gauge!("candidate_set.recently_live").set(m.recently_live as f64); // TODO: rename to address_book.responded.stopped_responding - metrics::gauge!( - "candidate_set.disconnected", - m.recently_stopped_responding as f64, - ); + metrics::gauge!("candidate_set.disconnected").set(m.recently_stopped_responding as f64); std::mem::drop(_guard); self.log_metrics(&m, instant_now); diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index 1f7cc2d80..2c7a9b416 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -353,10 +353,10 @@ impl Config { // (But we only make one initial connection attempt to each IP.) metrics::counter!( "zcash.net.peers.initial", - 1, "seed" => host.to_string(), "remote_ip" => ip.to_string() - ); + ) + .increment(1); } Ok(ip_addrs.into_iter().collect()) @@ -440,10 +440,10 @@ impl Config { // (But we only make one initial connection attempt to each IP.) metrics::counter!( "zcash.net.peers.initial", - 1, "cache" => peer_cache_file.display().to_string(), "remote_ip" => ip.to_string() - ); + ) + .increment(1); } Ok(peer_list) @@ -553,10 +553,10 @@ impl Config { for ip in &peer_list { metrics::counter!( "zcash.net.peers.cache", - 1, "cache" => peer_cache_file.display().to_string(), "remote_ip" => ip.to_string() - ); + ) + .increment(1); } Ok(()) diff --git a/zebra-network/src/peer/connection.rs b/zebra-network/src/peer/connection.rs index b8eddcb23..f5ea2d0a4 100644 --- a/zebra-network/src/peer/connection.rs +++ b/zebra-network/src/peer/connection.rs @@ -790,10 +790,10 @@ where // Add a metric for inbound responses to outbound requests. metrics::counter!( "zebra.net.in.responses", - 1, "command" => response.command(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1); } else { debug!(error = ?response, "error in peer response to Zebra request"); } @@ -969,15 +969,15 @@ where let InProgressClientRequest { request, tx, span } = req; if tx.is_canceled() { - metrics::counter!("peer.canceled", 1); + metrics::counter!("peer.canceled").increment(1); debug!(state = %self.state, %request, "ignoring canceled request"); metrics::counter!( "zebra.net.out.requests.canceled", - 1, "command" => request.command(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1); self.update_state_metrics(format!("Out::Req::Canceled::{}", request.command())); return; @@ -988,10 +988,10 @@ where // Add a metric for outbound requests. metrics::counter!( "zebra.net.out.requests", - 1, "command" => request.command(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1); self.update_state_metrics(format!("Out::Req::{}", request.command())); let new_handler = match (&self.state, request) { @@ -1360,10 +1360,10 @@ where // Add a metric for inbound requests metrics::counter!( "zebra.net.in.requests", - 1, "command" => req.command(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1); self.update_state_metrics(format!("In::Req::{}", req.command())); // Give the inbound service time to clear its queue, @@ -1431,10 +1431,10 @@ where // Add a metric for outbound responses to inbound requests metrics::counter!( "zebra.net.out.responses", - 1, "command" => rsp.command(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1); self.update_state_metrics(format!("In::Rsp::{}", rsp.command())); // TODO: split response handler into its own method @@ -1570,9 +1570,9 @@ where if thread_rng().gen::() < drop_connection_probability { if matches!(error, PeerError::Overloaded) { - metrics::counter!("pool.closed.loadshed", 1); + metrics::counter!("pool.closed.loadshed").increment(1); } else { - metrics::counter!("pool.closed.inbound.timeout", 1); + metrics::counter!("pool.closed.inbound.timeout").increment(1); } tracing::info!( @@ -1594,9 +1594,9 @@ where self.update_state_metrics(format!("In::Req::{}/Rsp::{error}::Ignored", req.command())); if matches!(error, PeerError::Overloaded) { - metrics::counter!("pool.ignored.loadshed", 1); + metrics::counter!("pool.ignored.loadshed").increment(1); } else { - metrics::counter!("pool.ignored.inbound.timeout", 1); + metrics::counter!("pool.ignored.inbound.timeout").increment(1); } } } @@ -1659,12 +1659,12 @@ where self.erase_state_metrics(); // Set the new state - metrics::increment_gauge!( + metrics::gauge!( "zebra.net.connection.state", - 1.0, "command" => current_metrics_state.clone(), "addr" => self.metrics_label.clone(), - ); + ) + .increment(1.0); self.last_metrics_state = Some(current_metrics_state); } @@ -1674,10 +1674,10 @@ where if let Some(last_metrics_state) = self.last_metrics_state.take() { metrics::gauge!( "zebra.net.connection.state", - 0.0, "command" => last_metrics_state, "addr" => self.metrics_label.clone(), - ); + ) + .set(0.0); } } diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index 898b0a14b..161c25f0a 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -743,19 +743,19 @@ where // the value is the number of rejected handshakes, by peer IP and protocol version metrics::counter!( "zcash.net.peers.obsolete", - 1, "remote_ip" => their_addr.to_string(), "remote_version" => remote.version.to_string(), "min_version" => min_version.to_string(), "user_agent" => remote.user_agent.clone(), - ); + ) + .increment(1); // the value is the remote version of the most recent rejected handshake from each peer metrics::gauge!( "zcash.net.peers.version.obsolete", - remote.version.0 as f64, "remote_ip" => their_addr.to_string(), - ); + ) + .set(remote.version.0 as f64); // Disconnect if peer is using an obsolete version. return Err(HandshakeError::ObsoleteVersion(remote.version)); @@ -782,20 +782,20 @@ where // the value is the number of connected handshakes, by peer IP and protocol version metrics::counter!( "zcash.net.peers.connected", - 1, "remote_ip" => their_addr.to_string(), "remote_version" => connection_info.remote.version.to_string(), "negotiated_version" => negotiated_version.to_string(), "min_version" => min_version.to_string(), "user_agent" => connection_info.remote.user_agent.clone(), - ); + ) + .increment(1); // the value is the remote version of the most recent connected handshake from each peer metrics::gauge!( "zcash.net.peers.version.connected", - connection_info.remote.version.0 as f64, "remote_ip" => their_addr.to_string(), - ); + ) + .set(connection_info.remote.version.0 as f64); peer_conn.send(Message::Verack).await?; @@ -954,10 +954,10 @@ where // Add a metric for outbound messages. metrics::counter!( "zcash.net.out.messages", - 1, "command" => msg.command(), "addr" => connected_addr.get_transient_addr_label(), - ); + ) + .increment(1); // We need to use future::ready rather than an async block here, // because we need the sink to be Unpin, and the With // returned by .with is Unpin only if Fut is Unpin, and the @@ -991,10 +991,10 @@ where Ok(msg) => { metrics::counter!( "zcash.net.in.messages", - 1, "command" => msg.command(), "addr" => connected_addr.get_transient_addr_label(), - ); + ) + .increment(1); // # Security // @@ -1004,10 +1004,10 @@ where Err(err) => { metrics::counter!( "zebra.net.in.errors", - 1, "error" => err.to_string(), "addr" => connected_addr.get_transient_addr_label(), - ); + ) + .increment(1); // # Security // diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index fc07a3837..e9ba3d380 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -813,8 +813,7 @@ where // To avoid hangs and starvation, the crawler must spawn a separate task for each crawl // and handshake, so they can make progress independently (and avoid deadlocking each other). loop { - metrics::gauge!( - "crawler.in_flight_handshakes", + metrics::gauge!("crawler.in_flight_handshakes").set( handshakes .len() .checked_sub(1) diff --git a/zebra-network/src/peer_set/inventory_registry.rs b/zebra-network/src/peer_set/inventory_registry.rs index b43915822..0b4e01cea 100644 --- a/zebra-network/src/peer_set/inventory_registry.rs +++ b/zebra-network/src/peer_set/inventory_registry.rs @@ -342,8 +342,8 @@ impl InventoryRegistry { Poll::Ready(Some(Err(BroadcastStreamRecvError::Lagged(count)))) => { // This isn't a fatal inventory error, it's expected behaviour when Zebra is // under load from peers. - metrics::counter!("pool.inventory.dropped", 1); - metrics::counter!("pool.inventory.dropped.messages", count); + metrics::counter!("pool.inventory.dropped").increment(1); + metrics::counter!("pool.inventory.dropped.messages").increment(count); // If this message happens a lot, we should improve inventory registry // performance, or poll the registry or peer set in a separate task. diff --git a/zebra-network/src/peer_set/set.rs b/zebra-network/src/peer_set/set.rs index fdec72fde..722e09b6e 100644 --- a/zebra-network/src/peer_set/set.rs +++ b/zebra-network/src/peer_set/set.rs @@ -1080,9 +1080,9 @@ where let num_ready = self.ready_services.len(); let num_unready = self.unready_services.len(); let num_peers = num_ready + num_unready; - metrics::gauge!("pool.num_ready", num_ready as f64); - metrics::gauge!("pool.num_unready", num_unready as f64); - metrics::gauge!("zcash.net.peers", num_peers as f64); + metrics::gauge!("pool.num_ready").set(num_ready as f64); + metrics::gauge!("pool.num_unready").set(num_unready as f64); + metrics::gauge!("zcash.net.peers").set(num_peers as f64); // Security: make sure we haven't exceeded the connection limit if num_peers > self.peerset_total_connection_limit { diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index 6a4ae0585..88f54c6b2 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -126,8 +126,8 @@ impl Encoder for Codec { if let Some(addr_label) = self.builder.metrics_addr_label.clone() { metrics::counter!("zcash.net.out.bytes.total", - (body_length + HEADER_LEN) as u64, - "addr" => addr_label); + "addr" => addr_label) + .increment((body_length + HEADER_LEN) as u64); } use Message::*; @@ -397,7 +397,8 @@ impl Decoder for Codec { } if let Some(label) = self.builder.metrics_addr_label.clone() { - metrics::counter!("zcash.net.in.bytes.total", (body_len + HEADER_LEN) as u64, "addr" => label); + metrics::counter!("zcash.net.in.bytes.total", "addr" => label) + .increment((body_len + HEADER_LEN) as u64); } // Reserve buffer space for the expected body and the following header. diff --git a/zebra-node-services/Cargo.toml b/zebra-node-services/Cargo.toml index a50fa4b35..d4fafd956 100644 --- a/zebra-node-services/Cargo.toml +++ b/zebra-node-services/Cargo.toml @@ -43,7 +43,7 @@ zebra-chain = { path = "../zebra-chain" , version = "1.0.0-beta.32" } color-eyre = { version = "0.6.2", optional = true } jsonrpc-core = { version = "18.0.0", optional = true } # Security: avoid default dependency on openssl -reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls"], optional = true } +reqwest = { version = "0.11.23", default-features = false, features = ["rustls-tls"], optional = true } serde = { version = "1.0.193", optional = true } serde_json = { version = "1.0.108", optional = true } @@ -51,6 +51,6 @@ serde_json = { version = "1.0.108", optional = true } color-eyre = "0.6.2" jsonrpc-core = "18.0.0" -reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls"] } +reqwest = { version = "0.11.23", default-features = false, features = ["rustls-tls"] } serde = "1.0.193" serde_json = "1.0.108" diff --git a/zebra-rpc/Cargo.toml b/zebra-rpc/Cargo.toml index a90d64cd8..95405ec29 100644 --- a/zebra-rpc/Cargo.toml +++ b/zebra-rpc/Cargo.toml @@ -40,7 +40,7 @@ proptest-impl = [ [dependencies] chrono = { version = "0.4.31", default-features = false, features = ["clock", "std"] } -futures = "0.3.29" +futures = "0.3.30" # lightwalletd sends JSON-RPC requests over HTTP 1.1 hyper = { version = "0.14.28", features = ["http1", "server"] } @@ -54,7 +54,7 @@ num_cpus = "1.16.0" serde_json = { version = "1.0.108", features = ["preserve_order"] } indexmap = { version = "2.0.1", features = ["serde"] } -tokio = { version = "1.34.0", features = ["time", "rt-multi-thread", "macros", "tracing"] } +tokio = { version = "1.35.1", features = ["time", "rt-multi-thread", "macros", "tracing"] } tower = "0.4.13" tracing = "0.1.39" @@ -83,7 +83,7 @@ insta = { version = "1.33.0", features = ["redactions", "json", "ron"] } proptest = "1.4.0" thiserror = "1.0.51" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] } zebra-consensus = { path = "../zebra-consensus", features = ["proptest-impl"] } diff --git a/zebra-scan/Cargo.toml b/zebra-scan/Cargo.toml index 661c24872..aa2c737a5 100644 --- a/zebra-scan/Cargo.toml +++ b/zebra-scan/Cargo.toml @@ -41,7 +41,7 @@ indexmap = { version = "2.0.1", features = ["serde"] } itertools = "0.12.0" semver = "1.0.20" serde = { version = "1.0.193", features = ["serde_derive"] } -tokio = { version = "1.34.0", features = ["time"] } +tokio = { version = "1.35.1", features = ["time"] } tower = "0.4.13" tracing = "0.1.39" @@ -69,7 +69,7 @@ zebra-test = { path = "../zebra-test", version = "1.0.0-beta.31", optional = tru [dev-dependencies] insta = { version = "1.33.0", features = ["ron", "redactions"] } -tokio = { version = "1.34.0", features = ["test-util"] } +tokio = { version = "1.35.1", features = ["test-util"] } proptest = "1.4.0" proptest-derive = "0.4.0" diff --git a/zebra-state/Cargo.toml b/zebra-state/Cargo.toml index c33f7ea81..f19b427f5 100644 --- a/zebra-state/Cargo.toml +++ b/zebra-state/Cargo.toml @@ -49,14 +49,14 @@ elasticsearch = [ bincode = "1.3.3" chrono = { version = "0.4.31", default-features = false, features = ["clock", "std"] } dirs = "5.0.1" -futures = "0.3.29" +futures = "0.3.30" hex = "0.4.3" hex-literal = "0.4.1" humantime-serde = "1.1.1" indexmap = "2.0.1" itertools = "0.12.0" lazy_static = "1.4.0" -metrics = "0.21.1" +metrics = "0.22.0" mset = "0.1.1" regex = "1.10.2" rlimit = "0.10.1" @@ -67,7 +67,7 @@ tempfile = "3.8.1" thiserror = "1.0.51" rayon = "1.7.0" -tokio = { version = "1.34.0", features = ["rt-multi-thread", "sync", "tracing"] } +tokio = { version = "1.35.1", features = ["rt-multi-thread", "sync", "tracing"] } tower = { version = "0.4.13", features = ["buffer", "util"] } tracing = "0.1.39" @@ -105,7 +105,7 @@ rand = "0.8.5" halo2 = { package = "halo2_proofs", version = "0.3.0" } jubjub = "0.10.0" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] } zebra-test = { path = "../zebra-test/" } diff --git a/zebra-state/src/request.rs b/zebra-state/src/request.rs index 0db06735c..2a6b3b1a5 100644 --- a/zebra-state/src/request.rs +++ b/zebra-state/src/request.rs @@ -742,10 +742,10 @@ impl Request { pub fn count_metric(&self) { metrics::counter!( "state.requests", - 1, "service" => "state", "type" => self.variant_name() - ); + ) + .increment(1); } } @@ -1031,10 +1031,10 @@ impl ReadRequest { pub fn count_metric(&self) { metrics::counter!( "state.requests", - 1, "service" => "read_state", "type" => self.variant_name() - ); + ) + .increment(1); } } diff --git a/zebra-state/src/service.rs b/zebra-state/src/service.rs index 69b800bf1..64c193647 100644 --- a/zebra-state/src/service.rs +++ b/zebra-state/src/service.rs @@ -520,14 +520,9 @@ impl StateService { self.max_finalized_queue_height = queued_height.0 as f64; } - metrics::gauge!( - "state.checkpoint.queued.max.height", - self.max_finalized_queue_height, - ); - metrics::gauge!( - "state.checkpoint.queued.block.count", - self.finalized_state_queued_blocks.len() as f64, - ); + metrics::gauge!("state.checkpoint.queued.max.height").set(self.max_finalized_queue_height); + metrics::gauge!("state.checkpoint.queued.block.count") + .set(self.finalized_state_queued_blocks.len() as f64); rsp_rx } @@ -583,10 +578,8 @@ impl StateService { "block commit task exited. Is Zebra shutting down?", ); } else { - metrics::gauge!( - "state.checkpoint.sent.block.height", - last_sent_finalized_block_height.0 as f64, - ); + metrics::gauge!("state.checkpoint.sent.block.height") + .set(last_sent_finalized_block_height.0 as f64); }; } } diff --git a/zebra-state/src/service/finalized_state.rs b/zebra-state/src/service/finalized_state.rs index 7ca3d40d1..bdcb8db6e 100644 --- a/zebra-state/src/service/finalized_state.rs +++ b/zebra-state/src/service/finalized_state.rs @@ -255,26 +255,20 @@ impl FinalizedState { ); if result.is_ok() { - metrics::counter!("state.checkpoint.finalized.block.count", 1); - metrics::gauge!( - "state.checkpoint.finalized.block.height", - checkpoint_verified.height.0 as f64, - ); + metrics::counter!("state.checkpoint.finalized.block.count").increment(1); + metrics::gauge!("state.checkpoint.finalized.block.height") + .set(checkpoint_verified.height.0 as f64); // This height gauge is updated for both fully verified and checkpoint blocks. // These updates can't conflict, because the state makes sure that blocks // are committed in order. - metrics::gauge!( - "zcash.chain.verified.block.height", - checkpoint_verified.height.0 as f64, - ); - metrics::counter!("zcash.chain.verified.block.total", 1); + metrics::gauge!("zcash.chain.verified.block.height") + .set(checkpoint_verified.height.0 as f64); + metrics::counter!("zcash.chain.verified.block.total").increment(1); } else { - metrics::counter!("state.checkpoint.error.block.count", 1); - metrics::gauge!( - "state.checkpoint.error.block.height", - checkpoint_verified.height.0 as f64, - ); + metrics::counter!("state.checkpoint.error.block.count").increment(1); + metrics::gauge!("state.checkpoint.error.block.height") + .set(checkpoint_verified.height.0 as f64); }; // Make the error cloneable, so we can send it to the block verify future, diff --git a/zebra-state/src/service/finalized_state/zebra_db/metrics.rs b/zebra-state/src/service/finalized_state/zebra_db/metrics.rs index 75b342e2c..9a5b5aef5 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/metrics.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/metrics.rs @@ -38,36 +38,24 @@ pub(crate) fn block_precommit_metrics(block: &Block, hash: block::Hash, height: if height.is_min() { "genesis " } else { "" } ); - metrics::counter!("state.finalized.block.count", 1); - metrics::gauge!("state.finalized.block.height", height.0 as f64); + metrics::counter!("state.finalized.block.count").increment(1); + metrics::gauge!("state.finalized.block.height").set(height.0 as f64); - metrics::counter!( - "state.finalized.cumulative.transactions", - transaction_count as u64 - ); + metrics::counter!("state.finalized.cumulative.transactions") + .increment(transaction_count as u64); - metrics::counter!( - "state.finalized.cumulative.sprout_nullifiers", - sprout_nullifier_count as u64 - ); - metrics::counter!( - "state.finalized.cumulative.sapling_nullifiers", - sapling_nullifier_count as u64 - ); - metrics::counter!( - "state.finalized.cumulative.orchard_nullifiers", - orchard_nullifier_count as u64 - ); + metrics::counter!("state.finalized.cumulative.sprout_nullifiers") + .increment(sprout_nullifier_count as u64); + metrics::counter!("state.finalized.cumulative.sapling_nullifiers") + .increment(sapling_nullifier_count as u64); + metrics::counter!("state.finalized.cumulative.orchard_nullifiers") + .increment(orchard_nullifier_count as u64); // The outputs from the genesis block can't be spent, so we skip them here. if !height.is_min() { - metrics::counter!( - "state.finalized.cumulative.transparent_prevouts", - transparent_prevout_count as u64 - ); - metrics::counter!( - "state.finalized.cumulative.transparent_newouts", - transparent_newout_count as u64 - ); + metrics::counter!("state.finalized.cumulative.transparent_prevouts") + .increment(transparent_prevout_count as u64); + metrics::counter!("state.finalized.cumulative.transparent_newouts") + .increment(transparent_newout_count as u64); } } diff --git a/zebra-state/src/service/non_finalized_state.rs b/zebra-state/src/service/non_finalized_state.rs index c01c16767..7d75f05e8 100644 --- a/zebra-state/src/service/non_finalized_state.rs +++ b/zebra-state/src/service/non_finalized_state.rs @@ -418,12 +418,12 @@ impl NonFinalizedState { chain_push_result.expect("scope has finished") } - /// Returns the length of the non-finalized portion of the current best chain. - pub fn best_chain_len(&self) -> u32 { - self.best_chain() - .expect("only called after inserting a block") - .blocks - .len() as u32 + /// Returns the length of the non-finalized portion of the current best chain + /// or `None` if the best chain has no blocks. + pub fn best_chain_len(&self) -> Option { + // This `as` can't overflow because the number of blocks in the chain is limited to i32::MAX, + // and the non-finalized chain is further limited by the fork length (slightly over 100 blocks). + Some(self.best_chain()?.blocks.len() as u32) } /// Returns `true` if `hash` is contained in the non-finalized portion of any @@ -619,8 +619,8 @@ impl NonFinalizedState { return; } - metrics::counter!("state.memory.committed.block.count", 1); - metrics::gauge!("state.memory.committed.block.height", height.0 as f64); + metrics::counter!("state.memory.committed.block.count").increment(1); + metrics::gauge!("state.memory.committed.block.height").set(height.0 as f64); if self .best_chain() @@ -628,8 +628,8 @@ impl NonFinalizedState { .non_finalized_tip_hash() == hash { - metrics::counter!("state.memory.best.committed.block.count", 1); - metrics::gauge!("state.memory.best.committed.block.height", height.0 as f64); + metrics::counter!("state.memory.best.committed.block.count").increment(1); + metrics::gauge!("state.memory.best.committed.block.height").set(height.0 as f64); } self.update_metrics_for_chains(); @@ -641,11 +641,9 @@ impl NonFinalizedState { return; } - metrics::gauge!("state.memory.chain.count", self.chain_set.len() as f64); - metrics::gauge!( - "state.memory.best.chain.length", - self.best_chain_len() as f64, - ); + metrics::gauge!("state.memory.chain.count").set(self.chain_set.len() as f64); + metrics::gauge!("state.memory.best.chain.length",) + .set(self.best_chain_len().unwrap_or_default() as f64); } /// Update the progress bars after any chain is modified. diff --git a/zebra-state/src/service/non_finalized_state/tests/vectors.rs b/zebra-state/src/service/non_finalized_state/tests/vectors.rs index 78c5de9d8..eae0235ea 100644 --- a/zebra-state/src/service/non_finalized_state/tests/vectors.rs +++ b/zebra-state/src/service/non_finalized_state/tests/vectors.rs @@ -327,7 +327,7 @@ fn shorter_chain_can_be_best_chain_for_network(network: Network) -> Result<()> { state.commit_block(short_chain_block.prepare(), &finalized_state)?; assert_eq!(2, state.chain_set.len()); - assert_eq!(2, state.best_chain_len()); + assert_eq!(Some(2), state.best_chain_len()); Ok(()) } @@ -381,7 +381,7 @@ fn longer_chain_with_more_work_wins_for_network(network: Network) -> Result<()> state.commit_block(short_chain_block.prepare(), &finalized_state)?; assert_eq!(2, state.chain_set.len()); - assert_eq!(5, state.best_chain_len()); + assert_eq!(Some(5), state.best_chain_len()); Ok(()) } diff --git a/zebra-state/src/service/queued_blocks.rs b/zebra-state/src/service/queued_blocks.rs index e38398498..52424d2aa 100644 --- a/zebra-state/src/service/queued_blocks.rs +++ b/zebra-state/src/service/queued_blocks.rs @@ -186,19 +186,19 @@ impl QueuedBlocks { /// Update metrics after the queue is modified fn update_metrics(&self) { if let Some(min_height) = self.by_height.keys().next() { - metrics::gauge!("state.memory.queued.min.height", min_height.0 as f64); + metrics::gauge!("state.memory.queued.min.height").set(min_height.0 as f64); } else { // use f64::NAN as a sentinel value for "None", because 0 is a valid height - metrics::gauge!("state.memory.queued.min.height", f64::NAN); + metrics::gauge!("state.memory.queued.min.height").set(f64::NAN); } if let Some(max_height) = self.by_height.keys().next_back() { - metrics::gauge!("state.memory.queued.max.height", max_height.0 as f64); + metrics::gauge!("state.memory.queued.max.height").set(max_height.0 as f64); } else { // use f64::NAN as a sentinel value for "None", because 0 is a valid height - metrics::gauge!("state.memory.queued.max.height", f64::NAN); + metrics::gauge!("state.memory.queued.max.height").set(f64::NAN); } - metrics::gauge!("state.memory.queued.block.count", self.blocks.len() as f64); + metrics::gauge!("state.memory.queued.block.count").set(self.blocks.len() as f64); } /// Try to look up this UTXO in any queued block. @@ -357,8 +357,8 @@ impl SentHashes { /// Update sent block metrics after a block is sent. fn update_metrics_for_block(&self, height: block::Height) { - metrics::counter!("state.memory.sent.block.count", 1); - metrics::gauge!("state.memory.sent.block.height", height.0 as f64); + metrics::counter!("state.memory.sent.block.count").increment(1); + metrics::gauge!("state.memory.sent.block.height").set(height.0 as f64); self.update_metrics_for_cache(); } @@ -371,30 +371,25 @@ impl SentHashes { .flat_map(|batch| batch.front().map(|(_hash, height)| height)) .min() { - metrics::gauge!("state.memory.sent.cache.min.height", min_height.0 as f64); + metrics::gauge!("state.memory.sent.cache.min.height").set(min_height.0 as f64); } else { // use f64::NAN as a sentinel value for "None", because 0 is a valid height - metrics::gauge!("state.memory.sent.cache.min.height", f64::NAN); + metrics::gauge!("state.memory.sent.cache.min.height").set(f64::NAN); } if let Some(max_height) = batch_iter() .flat_map(|batch| batch.back().map(|(_hash, height)| height)) .max() { - metrics::gauge!("state.memory.sent.cache.max.height", max_height.0 as f64); + metrics::gauge!("state.memory.sent.cache.max.height").set(max_height.0 as f64); } else { // use f64::NAN as a sentinel value for "None", because 0 is a valid height - metrics::gauge!("state.memory.sent.cache.max.height", f64::NAN); + metrics::gauge!("state.memory.sent.cache.max.height").set(f64::NAN); } - metrics::gauge!( - "state.memory.sent.cache.block.count", - batch_iter().flatten().count() as f64, - ); + metrics::gauge!("state.memory.sent.cache.block.count") + .set(batch_iter().flatten().count() as f64); - metrics::gauge!( - "state.memory.sent.cache.batch.count", - batch_iter().count() as f64, - ); + metrics::gauge!("state.memory.sent.cache.batch.count").set(batch_iter().count() as f64); } } diff --git a/zebra-state/src/service/write.rs b/zebra-state/src/service/write.rs index cb36b6a2b..acbc5c14c 100644 --- a/zebra-state/src/service/write.rs +++ b/zebra-state/src/service/write.rs @@ -290,7 +290,11 @@ pub fn write_blocks_from_channels( // Update the caller with the result. let _ = rsp_tx.send(result.clone().map(|()| child_hash).map_err(BoxError::from)); - while non_finalized_state.best_chain_len() > MAX_BLOCK_REORG_HEIGHT { + while non_finalized_state + .best_chain_len() + .expect("just successfully inserted a non-finalized block above") + > MAX_BLOCK_REORG_HEIGHT + { tracing::trace!("finalizing block past the reorg limit"); let contextually_verified_with_trees = non_finalized_state.finalize(); prev_finalized_note_commitment_trees = finalized_state @@ -303,21 +307,16 @@ pub fn write_blocks_from_channels( // Update the metrics if semantic and contextual validation passes // // TODO: split this out into a function? - metrics::counter!("state.full_verifier.committed.block.count", 1); - metrics::counter!("zcash.chain.verified.block.total", 1); + metrics::counter!("state.full_verifier.committed.block.count").increment(1); + metrics::counter!("zcash.chain.verified.block.total").increment(1); - metrics::gauge!( - "state.full_verifier.committed.block.height", - tip_block_height.0 as f64, - ); + metrics::gauge!("state.full_verifier.committed.block.height") + .set(tip_block_height.0 as f64); // This height gauge is updated for both fully verified and checkpoint blocks. // These updates can't conflict, because this block write task makes sure that blocks // are committed in order. - metrics::gauge!( - "zcash.chain.verified.block.height", - tip_block_height.0 as f64, - ); + metrics::gauge!("zcash.chain.verified.block.height").set(tip_block_height.0 as f64); tracing::trace!("finished processing queued block"); } diff --git a/zebra-test/Cargo.toml b/zebra-test/Cargo.toml index cb7d3d422..7dc45835d 100644 --- a/zebra-test/Cargo.toml +++ b/zebra-test/Cargo.toml @@ -25,9 +25,9 @@ once_cell = "1.18.0" rand = "0.8.5" regex = "1.10.2" -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } tower = { version = "0.4.13", features = ["util"] } -futures = "0.3.29" +futures = "0.3.30" color-eyre = "0.6.2" # This is a transitive dependency via color-eyre. @@ -35,7 +35,7 @@ color-eyre = "0.6.2" tinyvec = { version = "1.6.0", features = ["rustc_1_55"] } humantime = "2.1.0" -owo-colors = "3.5.0" +owo-colors = "4.0.0" spandoc = "0.2.2" thiserror = "1.0.51" diff --git a/zebra-utils/Cargo.toml b/zebra-utils/Cargo.toml index 4b90c3bb1..b32a99c7c 100644 --- a/zebra-utils/Cargo.toml +++ b/zebra-utils/Cargo.toml @@ -100,10 +100,10 @@ itertools = { version = "0.12.0", optional = true } # These crates are needed for the search-issue-refs binary regex = { version = "1.10.2", optional = true } # Avoid default openssl dependency to reduce the dependency tree and security alerts. -reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls"], optional = true } +reqwest = { version = "0.11.23", default-features = false, features = ["rustls-tls"], optional = true } # These crates are needed for the zebra-checkpoints and search-issue-refs binaries -tokio = { version = "1.34.0", features = ["full"], optional = true } +tokio = { version = "1.35.1", features = ["full"], optional = true } jsonrpc = { version = "0.16.0", optional = true } diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 799c73752..9df4307ad 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -172,9 +172,9 @@ semver = "1.0.20" serde = { version = "1.0.193", features = ["serde_derive"] } toml = "0.8.8" -futures = "0.3.29" +futures = "0.3.30" rayon = "1.7.0" -tokio = { version = "1.34.0", features = ["time", "rt-multi-thread", "macros", "tracing", "signal"] } +tokio = { version = "1.35.1", features = ["time", "rt-multi-thread", "macros", "tracing", "signal"] } tokio-stream = { version = "0.1.14", features = ["time"] } tower = { version = "0.4.13", features = ["hedge", "limit"] } pin-project = "1.1.3" @@ -192,7 +192,7 @@ tracing-error = "0.2.0" tracing-futures = "0.2.5" tracing = "0.1.39" -metrics = "0.21.1" +metrics = "0.22.0" dirs = "5.0.1" atty = "0.2.14" @@ -214,7 +214,7 @@ tracing-journald = { version = "0.3.0", optional = true } hyper = { version = "0.14.28", features = ["http1", "http2", "server"], optional = true } # prod feature prometheus -metrics-exporter-prometheus = { version = "0.12.2", default-features = false, features = ["http-listener"], optional = true } +metrics-exporter-prometheus = { version = "0.13.0", default-features = false, features = ["http-listener"], optional = true } # prod feature release_max_level_info # @@ -255,7 +255,7 @@ tempfile = "3.8.1" hyper = { version = "0.14.28", features = ["http1", "http2", "server"]} tracing-test = { version = "0.2.4", features = ["no-env-filter"] } -tokio = { version = "1.34.0", features = ["full", "tracing", "test-util"] } +tokio = { version = "1.35.1", features = ["full", "tracing", "test-util"] } tokio-stream = "0.1.14" # test feature lightwalletd-grpc-tests diff --git a/zebrad/src/components/inbound/downloads.rs b/zebrad/src/components/inbound/downloads.rs index 11200e664..a1a36ed26 100644 --- a/zebrad/src/components/inbound/downloads.rs +++ b/zebrad/src/components/inbound/downloads.rs @@ -213,8 +213,8 @@ where "block hash already queued for inbound download: ignored block", ); - metrics::gauge!("gossip.queued.block.count", self.pending.len() as f64); - metrics::counter!("gossip.already.queued.dropped.block.hash.count", 1); + metrics::gauge!("gossip.queued.block.count").set(self.pending.len() as f64); + metrics::counter!("gossip.already.queued.dropped.block.hash.count").increment(1); return DownloadAction::AlreadyQueued; } @@ -227,8 +227,8 @@ where "too many blocks queued for inbound download: ignored block", ); - metrics::gauge!("gossip.queued.block.count", self.pending.len() as f64); - metrics::counter!("gossip.full.queue.dropped.block.hash.count", 1); + metrics::gauge!("gossip.queued.block.count").set(self.pending.len() as f64); + metrics::counter!("gossip.full.queue.dropped.block.hash.count").increment(1); return DownloadAction::FullQueue; } @@ -271,7 +271,7 @@ where } else { unreachable!("wrong response to block request"); }; - metrics::counter!("gossip.downloaded.block.count", 1); + metrics::counter!("gossip.downloaded.block.count").increment(1); // # Security & Performance // @@ -312,7 +312,7 @@ where ?hash, "gossiped block with no height: dropped downloaded block" ); - metrics::counter!("gossip.no.height.dropped.block.count", 1); + metrics::counter!("gossip.no.height.dropped.block.count").increment(1); BoxError::from("gossiped block with no height") })?; @@ -326,7 +326,7 @@ where lookahead_limit = full_verify_concurrency_limit, "gossiped block height too far ahead of the tip: dropped downloaded block", ); - metrics::counter!("gossip.max.height.limit.dropped.block.count", 1); + metrics::counter!("gossip.max.height.limit.dropped.block.count").increment(1); Err("gossiped block height too far ahead")?; } else if block_height < min_accepted_height { @@ -338,7 +338,7 @@ where behind_tip_limit = ?zs::MAX_BLOCK_REORG_HEIGHT, "gossiped block height behind the finalized tip: dropped downloaded block", ); - metrics::counter!("gossip.min.height.limit.dropped.block.count", 1); + metrics::counter!("gossip.min.height.limit.dropped.block.count").increment(1); Err("gossiped block height behind the finalized tip")?; } @@ -350,7 +350,7 @@ where } .map_ok(|(hash, height)| { info!(?height, "downloaded and verified gossiped block"); - metrics::counter!("gossip.verified.block.count", 1); + metrics::counter!("gossip.verified.block.count").increment(1); hash }) // Tack the hash onto the error so we can remove the cancel handle @@ -364,7 +364,7 @@ where biased; _ = &mut cancel_rx => { trace!("task cancelled prior to completion"); - metrics::counter!("gossip.cancelled.count", 1); + metrics::counter!("gossip.cancelled.count").increment(1); Err(("canceled".into(), hash)) } verification = fut => verification, @@ -383,7 +383,7 @@ where concurrency_limit = self.full_verify_concurrency_limit, "queued hash for download", ); - metrics::gauge!("gossip.queued.block.count", self.pending.len() as f64); + metrics::gauge!("gossip.queued.block.count").set(self.pending.len() as f64); DownloadAction::AddedToQueue } diff --git a/zebrad/src/components/mempool.rs b/zebrad/src/components/mempool.rs index 0e9aa2d38..2d9b2b3e0 100644 --- a/zebrad/src/components/mempool.rs +++ b/zebrad/src/components/mempool.rs @@ -615,7 +615,7 @@ impl Service for Mempool { Ok(Err((txid, error))) => { tracing::debug!(?txid, ?error, "mempool transaction failed to verify"); - metrics::counter!("mempool.failed.verify.tasks.total", 1, "reason" => error.to_string()); + metrics::counter!("mempool.failed.verify.tasks.total", "reason" => error.to_string()).increment(1); storage.reject_if_needed(txid, error); } Err(_elapsed) => { @@ -624,7 +624,7 @@ impl Service for Mempool { tracing::info!("mempool transaction failed to verify due to timeout"); - metrics::counter!("mempool.failed.verify.tasks.total", 1, "reason" => "timeout"); + metrics::counter!("mempool.failed.verify.tasks.total", "reason" => "timeout").increment(1); } }; } diff --git a/zebrad/src/components/mempool/downloads.rs b/zebrad/src/components/mempool/downloads.rs index 33e5d975d..d3f62b408 100644 --- a/zebrad/src/components/mempool/downloads.rs +++ b/zebrad/src/components/mempool/downloads.rs @@ -253,10 +253,8 @@ where ?MAX_INBOUND_CONCURRENCY, "transaction id already queued for inbound download: ignored transaction" ); - metrics::gauge!( - "mempool.currently.queued.transactions", - self.pending.len() as f64, - ); + metrics::gauge!("mempool.currently.queued.transactions",) + .set(self.pending.len() as f64); return Err(MempoolError::AlreadyQueued); } @@ -268,10 +266,8 @@ where ?MAX_INBOUND_CONCURRENCY, "too many transactions queued for inbound download: ignored transaction" ); - metrics::gauge!( - "mempool.currently.queued.transactions", - self.pending.len() as f64, - ); + metrics::gauge!("mempool.currently.queued.transactions",) + .set(self.pending.len() as f64); return Err(MempoolError::FullQueue); } @@ -327,17 +323,15 @@ where metrics::counter!( "mempool.downloaded.transactions.total", - 1, "version" => format!("{}",tx.transaction.version()), - ); + ).increment(1); tx } Gossip::Tx(tx) => { metrics::counter!( "mempool.pushed.transactions.total", - 1, "version" => format!("{}",tx.transaction.version()), - ); + ).increment(1); tx } }; @@ -363,9 +357,8 @@ where .map_ok(|(tx, tip_height)| { metrics::counter!( "mempool.verified.transactions.total", - 1, "version" => format!("{}", tx.transaction.transaction.version()), - ); + ).increment(1); (tx, tip_height) }) // Tack the hash onto the error so we can remove the cancel handle @@ -384,7 +377,7 @@ where biased; _ = &mut cancel_rx => { trace!("task cancelled prior to completion"); - metrics::counter!("mempool.cancelled.verify.tasks.total", 1); + metrics::counter!("mempool.cancelled.verify.tasks.total").increment(1); Err((TransactionDownloadVerifyError::Cancelled, txid)) } verification = fut => verification, @@ -405,11 +398,8 @@ where ?MAX_INBOUND_CONCURRENCY, "queued transaction hash for download" ); - metrics::gauge!( - "mempool.currently.queued.transactions", - self.pending.len() as f64, - ); - metrics::counter!("mempool.queued.transactions.total", 1); + metrics::gauge!("mempool.currently.queued.transactions",).set(self.pending.len() as f64); + metrics::counter!("mempool.queued.transactions.total").increment(1); Ok(()) } @@ -446,10 +436,7 @@ where } assert!(self.pending.is_empty()); assert!(self.cancel_handles.is_empty()); - metrics::gauge!( - "mempool.currently.queued.transactions", - self.pending.len() as f64, - ); + metrics::gauge!("mempool.currently.queued.transactions",).set(self.pending.len() as f64); } /// Get the number of currently in-flight download tasks. @@ -498,6 +485,6 @@ where fn drop(mut self: Pin<&mut Self>) { self.cancel_all(); - metrics::gauge!("mempool.currently.queued.transactions", 0 as f64); + metrics::gauge!("mempool.currently.queued.transactions").set(0 as f64); } } diff --git a/zebrad/src/components/mempool/gossip.rs b/zebrad/src/components/mempool/gossip.rs index 6d3b2b638..4fee90d85 100644 --- a/zebrad/src/components/mempool/gossip.rs +++ b/zebrad/src/components/mempool/gossip.rs @@ -93,7 +93,7 @@ where // broadcast requests don't return errors, and we'd just want to ignore them anyway let _ = broadcast_network.ready().await?.call(request).await; - metrics::counter!("mempool.gossiped.transactions.total", txs_len as u64); + metrics::counter!("mempool.gossiped.transactions.total").increment(txs_len as u64); // wait for at least the network timeout between gossips // diff --git a/zebrad/src/components/mempool/storage.rs b/zebrad/src/components/mempool/storage.rs index bed0f9aab..90b114fff 100644 --- a/zebrad/src/components/mempool/storage.rs +++ b/zebrad/src/components/mempool/storage.rs @@ -651,16 +651,12 @@ impl Storage { /// /// Must be called every time the rejected lists change. fn update_rejected_metrics(&mut self) { - metrics::gauge!( - "mempool.rejected.transaction.ids", - self.rejected_transaction_count() as f64, - ); + metrics::gauge!("mempool.rejected.transaction.ids",) + .set(self.rejected_transaction_count() as f64); // This is just an approximation. // TODO: make it more accurate #2869 let item_size = size_of::<(transaction::Hash, SameEffectsTipRejectionError)>(); - metrics::gauge!( - "mempool.rejected.transaction.ids.bytes", - (self.rejected_transaction_count() * item_size) as f64, - ); + metrics::gauge!("mempool.rejected.transaction.ids.bytes",) + .set((self.rejected_transaction_count() * item_size) as f64); } } diff --git a/zebrad/src/components/mempool/storage/verified_set.rs b/zebrad/src/components/mempool/storage/verified_set.rs index 1d1f835fb..a9c850b4e 100644 --- a/zebrad/src/components/mempool/storage/verified_set.rs +++ b/zebrad/src/components/mempool/storage/verified_set.rs @@ -337,63 +337,57 @@ impl VerifiedSet { metrics::gauge!( "zcash.mempool.actions.unpaid", - unpaid_actions_with_weight_lt20pct as f64, "bk" => "< 0.2", - ); + ) + .set(unpaid_actions_with_weight_lt20pct as f64); metrics::gauge!( "zcash.mempool.actions.unpaid", - unpaid_actions_with_weight_lt40pct as f64, "bk" => "< 0.4", - ); + ) + .set(unpaid_actions_with_weight_lt40pct as f64); metrics::gauge!( "zcash.mempool.actions.unpaid", - unpaid_actions_with_weight_lt60pct as f64, "bk" => "< 0.6", - ); + ) + .set(unpaid_actions_with_weight_lt60pct as f64); metrics::gauge!( "zcash.mempool.actions.unpaid", - unpaid_actions_with_weight_lt80pct as f64, "bk" => "< 0.8", - ); + ) + .set(unpaid_actions_with_weight_lt80pct as f64); metrics::gauge!( "zcash.mempool.actions.unpaid", - unpaid_actions_with_weight_lt1 as f64, "bk" => "< 1", - ); - metrics::gauge!("zcash.mempool.actions.paid", paid_actions as f64); - metrics::gauge!( - "zcash.mempool.size.transactions", - self.transaction_count() as f64, - ); + ) + .set(unpaid_actions_with_weight_lt1 as f64); + metrics::gauge!("zcash.mempool.actions.paid").set(paid_actions as f64); + metrics::gauge!("zcash.mempool.size.transactions",).set(self.transaction_count() as f64); metrics::gauge!( "zcash.mempool.size.weighted", - size_with_weight_lt1 as f64, "bk" => "< 1", - ); + ) + .set(size_with_weight_lt1 as f64); metrics::gauge!( "zcash.mempool.size.weighted", - size_with_weight_eq1 as f64, "bk" => "1", - ); + ) + .set(size_with_weight_eq1 as f64); metrics::gauge!( "zcash.mempool.size.weighted", - size_with_weight_gt1 as f64, "bk" => "> 1", - ); + ) + .set(size_with_weight_gt1 as f64); metrics::gauge!( "zcash.mempool.size.weighted", - size_with_weight_gt2 as f64, "bk" => "> 2", - ); + ) + .set(size_with_weight_gt2 as f64); metrics::gauge!( "zcash.mempool.size.weighted", - size_with_weight_gt3 as f64, "bk" => "> 3", - ); - metrics::gauge!( - "zcash.mempool.size.bytes", - self.transactions_serialized_size as f64, - ); - metrics::gauge!("zcash.mempool.cost.bytes", self.total_cost as f64); + ) + .set(size_with_weight_gt3 as f64); + metrics::gauge!("zcash.mempool.size.bytes",).set(self.transactions_serialized_size as f64); + metrics::gauge!("zcash.mempool.cost.bytes").set(self.total_cost as f64); } } diff --git a/zebrad/src/components/metrics.rs b/zebrad/src/components/metrics.rs index ab6ba6f77..5527d3774 100644 --- a/zebrad/src/components/metrics.rs +++ b/zebrad/src/components/metrics.rs @@ -27,10 +27,11 @@ impl MetricsEndpoint { // Expose binary metadata to metrics, using a single time series with // value 1: // https://www.robustperception.io/exposing-the-software-version-to-prometheus - metrics::increment_counter!( + metrics::counter!( format!("{}.build.info", env!("CARGO_PKG_NAME")), "version" => env!("CARGO_PKG_VERSION") - ); + ) + .increment(1); } Err(e) => panic!( "Opening metrics endpoint listener {addr:?} failed: {e:?}. \ diff --git a/zebrad/src/components/sync.rs b/zebrad/src/components/sync.rs index b3a05484f..160e27777 100644 --- a/zebrad/src/components/sync.rs +++ b/zebrad/src/components/sync.rs @@ -789,7 +789,8 @@ where let new_download_len = download_set.len(); let new_hashes = new_download_len - prev_download_len; debug!(new_hashes, "added hashes to download set"); - metrics::histogram!("sync.obtain.response.hash.count", new_hashes as f64); + metrics::histogram!("sync.obtain.response.hash.count") + .record(new_hashes as f64); } Ok(_) => unreachable!("network returned wrong response"), // We ignore this error because we made multiple fanout requests. @@ -809,7 +810,7 @@ where let new_downloads = download_set.len(); debug!(new_downloads, "queueing new downloads"); - metrics::gauge!("sync.obtain.queued.hash.count", new_downloads as f64); + metrics::gauge!("sync.obtain.queued.hash.count").set(new_downloads as f64); // security: use the actual number of new downloads from all peers, // so the last peer to respond can't toggle our mempool @@ -935,7 +936,8 @@ where let new_download_len = download_set.len(); let new_hashes = new_download_len - prev_download_len; debug!(new_hashes, "added hashes to download set"); - metrics::histogram!("sync.extend.response.hash.count", new_hashes as f64); + metrics::histogram!("sync.extend.response.hash.count") + .record(new_hashes as f64); } Ok(_) => unreachable!("network returned wrong response"), // We ignore this error because we made multiple fanout requests. @@ -946,7 +948,7 @@ where let new_downloads = download_set.len(); debug!(new_downloads, "queueing new downloads"); - metrics::gauge!("sync.extend.queued.hash.count", new_downloads as f64); + metrics::gauge!("sync.extend.queued.hash.count").set(new_downloads as f64); // security: use the actual number of new downloads from all peers, // so the last peer to respond can't toggle our mempool @@ -1149,14 +1151,8 @@ where } fn update_metrics(&mut self) { - metrics::gauge!( - "sync.prospective_tips.len", - self.prospective_tips.len() as f64, - ); - metrics::gauge!( - "sync.downloads.in_flight", - self.downloads.in_flight() as f64, - ); + metrics::gauge!("sync.prospective_tips.len",).set(self.prospective_tips.len() as f64); + metrics::gauge!("sync.downloads.in_flight",).set(self.downloads.in_flight() as f64); } /// Return if the sync should be restarted based on the given error diff --git a/zebrad/src/components/sync/downloads.rs b/zebrad/src/components/sync/downloads.rs index c3322d089..67f6ee484 100644 --- a/zebrad/src/components/sync/downloads.rs +++ b/zebrad/src/components/sync/downloads.rs @@ -330,7 +330,7 @@ where hash: block::Hash, ) -> Result<(), BlockDownloadVerifyError> { if self.cancel_handles.contains_key(&hash) { - metrics::counter!("sync.already.queued.dropped.block.hash.count", 1); + metrics::counter!("sync.already.queued.dropped.block.hash.count").increment(1); return Err(BlockDownloadVerifyError::DuplicateBlockQueuedForDownload { hash }); } @@ -368,7 +368,7 @@ where biased; _ = &mut cancel_rx => { trace!("task cancelled prior to download completion"); - metrics::counter!("sync.cancelled.download.count", 1); + metrics::counter!("sync.cancelled.download.count").increment(1); return Err(BlockDownloadVerifyError::CancelledDuringDownload { hash }) } rsp = block_req => rsp.map_err(|error| BlockDownloadVerifyError::DownloadFailed { error, hash})?, @@ -389,7 +389,7 @@ where } else { unreachable!("wrong response to block request"); }; - metrics::counter!("sync.downloaded.block.count", 1); + metrics::counter!("sync.downloaded.block.count").increment(1); // Security & Performance: reject blocks that are too far ahead of our tip. // Avoids denial of service attacks, and reduces wasted work on high blocks @@ -440,7 +440,7 @@ where ?hash, "synced block with no height: dropped downloaded block" ); - metrics::counter!("sync.no.height.dropped.block.count", 1); + metrics::counter!("sync.no.height.dropped.block.count").increment(1); return Err(BlockDownloadVerifyError::InvalidHeight { hash }); }; @@ -480,16 +480,16 @@ where ); } - metrics::counter!("sync.max.height.limit.paused.count", 1); + metrics::counter!("sync.max.height.limit.paused.count").increment(1); } else if block_height <= lookahead_reset_height && past_lookahead_limit_receiver.cloned_watch_data() { // Reset the watched value to false, since we're well under the limit. // We need to block here, because if we don't the syncer can hang. // But if Zebra is shutting down, ignore the send error. let _ = past_lookahead_limit_sender.lock().expect("thread panicked while holding the past_lookahead_limit_sender mutex guard").send(false); - metrics::counter!("sync.max.height.limit.reset.count", 1); + metrics::counter!("sync.max.height.limit.reset.count").increment(1); - metrics::counter!("sync.max.height.limit.reset.attempt.count", 1); + metrics::counter!("sync.max.height.limit.reset.attempt.count").increment(1); } if block_height < min_accepted_height { @@ -501,7 +501,7 @@ where behind_tip_limit = ?zs::MAX_BLOCK_REORG_HEIGHT, "synced block height behind the finalized tip: dropped downloaded block" ); - metrics::counter!("gossip.min.height.limit.dropped.block.count", 1); + metrics::counter!("gossip.min.height.limit.dropped.block.count").increment(1); Err(BlockDownloadVerifyError::BehindTipHeightLimit { height: block_height, hash })?; } @@ -513,7 +513,7 @@ where biased; _ = &mut cancel_rx => { trace!("task cancelled waiting for verifier service readiness"); - metrics::counter!("sync.cancelled.verify.ready.count", 1); + metrics::counter!("sync.cancelled.verify.ready.count").increment(1); return Err(BlockDownloadVerifyError::CancelledAwaitingVerifierReadiness { height: block_height, hash }) } verifier = readiness => verifier, @@ -536,14 +536,14 @@ where biased; _ = &mut cancel_rx => { trace!("task cancelled prior to verification"); - metrics::counter!("sync.cancelled.verify.count", 1); + metrics::counter!("sync.cancelled.verify.count").increment(1); return Err(BlockDownloadVerifyError::CancelledDuringVerification { height: block_height, hash }) } verification = rsp => verification, }; if verification.is_ok() { - metrics::counter!("sync.verified.block.count", 1); + metrics::counter!("sync.verified.block.count").increment(1); } verification