From 8a498246b2c2d88d63e51049bb3acd20a8166479 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Wed, 11 Dec 2024 16:48:04 +0100 Subject: [PATCH] fix: TimeoutQC aggregation (#220) Custom Ord implementation was causing timeout votes with different high qc (with the same view) to be deduplicated, which invalidated the aggregated signature. I've added a test for this case, and preemptively removed all custom Ord implementations on messages. --- .github/workflows/protobuf_conformance.yaml | 1 + node/Cargo.lock | 436 ++++++++++-------- node/Cargo.toml | 2 +- node/components/bft/src/chonky_bft/mod.rs | 10 +- .../components/bft/src/chonky_bft/new_view.rs | 10 +- .../components/bft/src/chonky_bft/proposal.rs | 13 +- .../components/bft/src/chonky_bft/proposer.rs | 3 +- .../components/bft/src/chonky_bft/testonly.rs | 9 +- .../bft/src/chonky_bft/tests/timeout.rs | 45 +- node/components/bft/src/chonky_bft/timeout.rs | 12 +- node/components/bft/src/metrics.rs | 1 - node/components/bft/src/testonly/node.rs | 3 +- .../bft/src/testonly/twins/scenario.rs | 4 + .../network/src/gossip/loadtest/mod.rs | 2 +- node/components/network/src/testonly.rs | 5 +- node/libs/concurrency/src/limiter/mod.rs | 2 +- .../src/validator/messages/replica_commit.rs | 14 +- .../src/validator/messages/tests/versions.rs | 3 +- 18 files changed, 329 insertions(+), 246 deletions(-) diff --git a/.github/workflows/protobuf_conformance.yaml b/.github/workflows/protobuf_conformance.yaml index fbc68def..c77156e8 100644 --- a/.github/workflows/protobuf_conformance.yaml +++ b/.github/workflows/protobuf_conformance.yaml @@ -13,6 +13,7 @@ env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "true" RUST_BACKTRACE: "1" + USE_BAZEL_VERSION: "7.0.0" jobs: conformance: diff --git a/node/Cargo.lock b/node/Cargo.lock index c9b74ebd..dcdeafb9 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anes" @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "assert_matches" @@ -206,21 +206,20 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7c2840b66236045acd2607d5866e274380afd87ef99d6226e961e2cb47df45" +checksum = "f47bb8cc16b669d267eeccf585aea077d0882f4777b1c1f740217885d6e6e5a3" dependencies = [ "aws-lc-sys", - "mirai-annotations", "paste", "zeroize", ] [[package]] name = "aws-lc-sys" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad3a619a9de81e1d7de1f1186dcba4506ed661a0e483d84410fdef0ee87b2f96" +checksum = "a2101df3813227bbaaaa0b04cd61c534c7954b22bd68d399b440be937dc63ff7" dependencies = [ "bindgen 0.69.5", "cc", @@ -286,9 +285,6 @@ name = "beef" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] [[package]] name = "bindgen" @@ -306,7 +302,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn", ] @@ -328,7 +324,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn", "which", @@ -411,9 +407,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "bytesize" @@ -440,9 +436,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" dependencies = [ "jobserver", "libc", @@ -496,9 +492,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "num-traits", "serde", @@ -555,9 +551,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -565,9 +561,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -589,15 +585,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cmake" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" dependencies = [ "cc", ] @@ -649,6 +645,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -657,9 +663,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -756,9 +762,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", "syn", @@ -1014,12 +1020,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1035,9 +1041,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener", "pin-project-lite", @@ -1045,9 +1051,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "ff" @@ -1244,7 +1250,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http 1.2.0", "indexmap", "slab", "tokio", @@ -1274,9 +1280,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "headers" @@ -1287,7 +1293,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http 1.1.0", + "http 1.2.0", "httpdate", "mime", "sha1", @@ -1299,7 +1305,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -1357,9 +1363,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -1384,7 +1390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -1395,7 +1401,7 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] @@ -1451,7 +1457,7 @@ dependencies = [ "futures-channel", "futures-util", "h2", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "httparse", "httpdate", @@ -1471,7 +1477,7 @@ dependencies = [ "bytes", "futures-util", "headers", - "http 1.1.0", + "http 1.2.0", "hyper 1.5.1", "hyper-rustls", "hyper-util", @@ -1489,12 +1495,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http 1.1.0", + "http 1.2.0", "hyper 1.5.1", "hyper-util", "log", "rustls", - "rustls-native-certs 0.8.0", + "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", "tokio-rustls", @@ -1523,7 +1529,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "hyper 1.5.1", "pin-project-lite", @@ -1694,12 +1700,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -1757,9 +1763,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a73e9fe3c49d7afb2ace819fa181a287ce54a0983eda4e0eb05c22f82ffe534" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jni" @@ -1771,7 +1777,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.69", "walkdir", ] @@ -1792,10 +1798,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1808,7 +1815,7 @@ dependencies = [ "jsonptr", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1823,7 +1830,7 @@ dependencies = [ "pest_derive", "regex", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1839,9 +1846,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.23.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b089779ad7f80768693755a031cc14a7766aba707cbe886674e3f79e9b7e47" +checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -1852,34 +1859,32 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.23.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79712302e737d23ca0daa178e752c9334846b08321d439fd89af9a384f8c830b" +checksum = "f2882f6f8acb9fdaec7cefc4fd607119a9bd709831df7d7672a1d3b644628280" dependencies = [ - "anyhow", "async-trait", - "beef", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "jsonrpsee-types", "parking_lot", "rand", - "rustc-hash", + "rustc-hash 2.1.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] [[package]] name = "jsonrpsee-http-client" -version = "0.23.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d90064e04fb9d7282b1c71044ea94d0bbc6eff5621c66f1a0bce9e9de7cf3ac" +checksum = "b3638bc4617f96675973253b3a45006933bde93c2fd8a6170b33c777cc389e5b" dependencies = [ "async-trait", "base64 0.22.1", @@ -1893,7 +1898,7 @@ dependencies = [ "rustls-platform-verifier", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tower 0.4.13", "tracing", @@ -1902,13 +1907,12 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.23.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "654afab2e92e5d88ebd8a39d6074483f3f2bfdf91c5ac57fe285e7127cdd4f51" +checksum = "82ad8ddc14be1d4290cd68046e7d1d37acd408efed6d3ca08aefcc3ad6da069c" dependencies = [ - "anyhow", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -1920,7 +1924,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-stream", "tokio-util", @@ -1930,15 +1934,14 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.23.2" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c465fbe385238e861fdc4d1c85e04ada6c1fd246161d26385c1b311724d2af" +checksum = "a178c60086f24cc35bb82f57c651d0d25d99c4742b4d335de04e97fa1f08a8a1" dependencies = [ - "beef", - "http 1.1.0", + "http 1.2.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2002,7 +2005,7 @@ dependencies = [ "either", "futures", "home", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "hyper 1.5.1", @@ -2020,10 +2023,10 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-util", - "tower 0.5.1", + "tower 0.5.2", "tower-http", "tracing", ] @@ -2036,14 +2039,14 @@ checksum = "f42346d30bb34d1d7adc5c549b691bce7aa3a1e60254e68fab7e2d7b26fe3d77" dependencies = [ "chrono", "form_urlencoded", - "http 1.1.0", + "http 1.2.0", "json-patch", "k8s-openapi", "schemars", "serde", "serde-value", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2081,7 +2084,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-util", "tracing", @@ -2101,15 +2104,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets", @@ -2150,9 +2153,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -2235,7 +2238,7 @@ checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" dependencies = [ "miette-derive", "once_cell", - "thiserror", + "thiserror 1.0.69", "unicode-width", ] @@ -2273,22 +2276,15 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", ] -[[package]] -name = "mirai-annotations" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" - [[package]] name = "multimap" version = "0.10.0" @@ -2466,20 +2462,20 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror", + "thiserror 2.0.6", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" +checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" dependencies = [ "pest", "pest_generator", @@ -2487,9 +2483,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" +checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" dependencies = [ "pest", "pest_meta", @@ -2500,9 +2496,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.14" +version = "2.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" +checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" dependencies = [ "once_cell", "pest", @@ -2655,9 +2651,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -2766,7 +2762,7 @@ dependencies = [ "prost-reflect", "prost-types", "protox-parse", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2778,7 +2774,7 @@ dependencies = [ "logos", "miette", "prost-types", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2964,6 +2960,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" + [[package]] name = "rustc_version" version = "0.4.1" @@ -2975,22 +2977,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.17" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "aws-lc-rs", "log", @@ -3012,20 +3014,19 @@ dependencies = [ "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] name = "rustls-native-certs" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.0.1", ] [[package]] @@ -3049,7 +3050,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" dependencies = [ - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "jni", "log", @@ -3058,7 +3059,7 @@ dependencies = [ "rustls-native-certs 0.7.3", "rustls-platform-verifier-android", "rustls-webpki", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "webpki-roots", "winapi", @@ -3166,13 +3167,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", "libc", "num-bigint", "security-framework-sys", ] +[[package]] +name = "security-framework" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +dependencies = [ + "bitflags 2.6.0", + "core-foundation 0.10.0", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + [[package]] name = "security-framework-sys" version = "2.12.1" @@ -3191,9 +3205,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -3210,9 +3224,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -3364,9 +3378,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3374,14 +3388,14 @@ dependencies = [ [[package]] name = "soketto" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" +checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" dependencies = [ "base64 0.22.1", "bytes", "futures", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "rand", @@ -3424,9 +3438,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -3435,9 +3449,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" [[package]] name = "synstructure" @@ -3503,7 +3517,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +dependencies = [ + "thiserror-impl 2.0.6", ] [[package]] @@ -3517,6 +3540,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -3538,9 +3572,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "num-conv", @@ -3583,16 +3617,16 @@ checksum = "0f1d8809f604e448c7bc53a5a0e4c2a0a20ba44cb1fb407314c8eeccb92127f9" dependencies = [ "futures-util", "pin-project-lite", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-rustls", ] [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -3619,20 +3653,19 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ "rustls", - "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -3642,9 +3675,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -3672,9 +3705,9 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", @@ -3696,7 +3729,7 @@ dependencies = [ "base64 0.22.1", "bitflags 2.6.0", "bytes", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "mime", "pin-project-lite", @@ -3719,9 +3752,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -3731,9 +3764,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -3742,9 +3775,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -3763,9 +3796,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -3833,9 +3866,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -3943,9 +3976,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -3954,13 +3987,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -3969,9 +4001,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3979,9 +4011,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -3992,15 +4024,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -4008,9 +4040,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -4160,9 +4192,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -4172,9 +4204,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", @@ -4205,18 +4237,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", @@ -4276,7 +4308,7 @@ dependencies = [ "pin-project", "rand", "sha3", - "thiserror", + "thiserror 1.0.69", "time", "tokio", "tracing", @@ -4295,7 +4327,7 @@ dependencies = [ "pretty_assertions", "rand", "test-casing", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "vise", @@ -4323,7 +4355,7 @@ dependencies = [ "num-traits", "rand", "sha3", - "thiserror", + "thiserror 1.0.69", "tracing", "zeroize", ] @@ -4373,7 +4405,7 @@ dependencies = [ "semver", "snow", "test-casing", - "thiserror", + "thiserror 1.0.69", "tls-listener", "tokio", "tokio-rustls", @@ -4400,7 +4432,7 @@ dependencies = [ "prost", "rand", "serde", - "thiserror", + "thiserror 1.0.69", "tracing", "zksync_concurrency", "zksync_consensus_crypto", @@ -4420,7 +4452,7 @@ dependencies = [ "rand", "tempfile", "test-casing", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "vise", @@ -4472,7 +4504,7 @@ version = "0.6.0" dependencies = [ "anyhow", "rand", - "thiserror", + "thiserror 1.0.69", "zksync_concurrency", ] diff --git a/node/Cargo.toml b/node/Cargo.toml index f45eee73..9d8b3df5 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -71,7 +71,7 @@ human-repr = "1.1.0" hyper = { version = "1", features = ["full"] } hyper-util = { version = "0.1", features = ["full"] } im = "15.1.0" -jsonrpsee = { version = "0.23.0", features = ["http-client", "server"] } +jsonrpsee = { version = "0.24.0", features = ["http-client", "server"] } k256 = { version = "0.13", features = ["ecdsa"] } k8s-openapi = { version = "0.23.0", features = ["latest"] } kube = { version = "0.96.0", features = ["derive", "runtime"] } diff --git a/node/components/bft/src/chonky_bft/mod.rs b/node/components/bft/src/chonky_bft/mod.rs index 71340dbb..2d6a25c4 100644 --- a/node/components/bft/src/chonky_bft/mod.rs +++ b/node/components/bft/src/chonky_bft/mod.rs @@ -1,6 +1,5 @@ use crate::{metrics, Config, FromNetworkMessage, ToNetworkMessage}; use std::{ - cmp::max, collections::{BTreeMap, HashMap}, sync::Arc, }; @@ -276,7 +275,14 @@ impl StateMachine { ctx: &ctx::Ctx, qc: &validator::CommitQC, ) -> ctx::Result<()> { - self.high_commit_qc = max(Some(qc.clone()), self.high_commit_qc.clone()); + if self + .high_commit_qc + .as_ref() + .map_or(false, |old| old.view().number >= qc.view().number) + { + return Ok(()); + } + self.high_commit_qc = Some(qc.clone()); self.save_block(ctx, qc).await.wrap("save_block()") } } diff --git a/node/components/bft/src/chonky_bft/new_view.rs b/node/components/bft/src/chonky_bft/new_view.rs index c8107dd1..21ddb65a 100644 --- a/node/components/bft/src/chonky_bft/new_view.rs +++ b/node/components/bft/src/chonky_bft/new_view.rs @@ -1,5 +1,3 @@ -use std::cmp::max; - use super::StateMachine; use crate::{chonky_bft::VIEW_TIMEOUT_DURATION, metrics}; use zksync_concurrency::{ctx, error::Wrap, metrics::LatencyHistogramExt as _, time}; @@ -94,7 +92,13 @@ impl StateMachine { .await .wrap("process_commit_qc()")?; } - self.high_timeout_qc = max(Some(qc.clone()), self.high_timeout_qc.clone()); + if self + .high_timeout_qc + .as_ref() + .map_or(true, |old| old.view.number < qc.view.number) + { + self.high_timeout_qc = Some(qc.clone()); + } } }; diff --git a/node/components/bft/src/chonky_bft/proposal.rs b/node/components/bft/src/chonky_bft/proposal.rs index 7da6962c..846d07c1 100644 --- a/node/components/bft/src/chonky_bft/proposal.rs +++ b/node/components/bft/src/chonky_bft/proposal.rs @@ -1,7 +1,5 @@ -use crate::metrics; - use super::StateMachine; -use std::cmp::max; +use crate::metrics; use zksync_concurrency::{ctx, error::Wrap, metrics::LatencyHistogramExt as _}; use zksync_consensus_network::io::ConsensusInputMessage; use zksync_consensus_roles::validator::{self, BlockHeader, BlockNumber}; @@ -223,6 +221,7 @@ impl StateMachine { // Update the state machine. self.view_number = message.view().number; + metrics::METRICS.replica_view_number.set(self.view_number.0); self.phase = validator::Phase::Commit; self.high_vote = Some(commit_vote.clone()); match &message.justification { @@ -236,7 +235,13 @@ impl StateMachine { .await .wrap("process_commit_qc()")?; } - self.high_timeout_qc = max(Some(qc.clone()), self.high_timeout_qc.clone()); + if self + .high_timeout_qc + .as_ref() + .map_or(true, |old| old.view.number < qc.view.number) + { + self.high_timeout_qc = Some(qc.clone()); + } } }; diff --git a/node/components/bft/src/chonky_bft/proposer.rs b/node/components/bft/src/chonky_bft/proposer.rs index ec9e0e33..ad88d854 100644 --- a/node/components/bft/src/chonky_bft/proposer.rs +++ b/node/components/bft/src/chonky_bft/proposer.rs @@ -1,11 +1,10 @@ +use super::VIEW_TIMEOUT_DURATION; use crate::{metrics, Config, ToNetworkMessage}; use std::sync::Arc; use zksync_concurrency::{ctx, error::Wrap as _, sync}; use zksync_consensus_network::io::ConsensusInputMessage; use zksync_consensus_roles::validator; -use super::VIEW_TIMEOUT_DURATION; - /// The proposer loop is responsible for proposing new blocks to the network. It watches for new /// justifications from the replica and if it is the leader for the view, it proposes a new block. pub(crate) async fn run_proposer( diff --git a/node/components/bft/src/chonky_bft/testonly.rs b/node/components/bft/src/chonky_bft/testonly.rs index 686c971b..7aba4cd7 100644 --- a/node/components/bft/src/chonky_bft/testonly.rs +++ b/node/components/bft/src/chonky_bft/testonly.rs @@ -1,13 +1,12 @@ -use crate::testonly::RandomPayload; use crate::{ chonky_bft::{self, commit, new_view, proposal, timeout, StateMachine}, - Config, PayloadManager, + create_input_channel, + testonly::RandomPayload, + Config, FromNetworkMessage, PayloadManager, ToNetworkMessage, }; -use crate::{create_input_channel, FromNetworkMessage, ToNetworkMessage}; use assert_matches::assert_matches; use std::sync::Arc; -use zksync_concurrency::sync::prunable_mpsc; -use zksync_concurrency::{ctx, sync}; +use zksync_concurrency::{ctx, sync, sync::prunable_mpsc}; use zksync_consensus_roles::validator; use zksync_consensus_storage::{ testonly::{in_memory, TestMemoryStorage}, diff --git a/node/components/bft/src/chonky_bft/tests/timeout.rs b/node/components/bft/src/chonky_bft/tests/timeout.rs index af778b69..6a3c8cde 100644 --- a/node/components/bft/src/chonky_bft/tests/timeout.rs +++ b/node/components/bft/src/chonky_bft/tests/timeout.rs @@ -1,9 +1,52 @@ use crate::chonky_bft::{testonly::UTHarness, timeout}; use assert_matches::assert_matches; -use rand::Rng; +use rand::{seq::SliceRandom as _, Rng}; use zksync_concurrency::{ctx, scope}; use zksync_consensus_roles::validator; +#[test] +fn timeout_qc_aggregation() { + zksync_concurrency::testonly::abort_on_panic(); + let ctx = &ctx::test_root(&ctx::RealClock); + let rng = &mut ctx.rng(); + let setup = validator::testonly::Setup::new(rng, 10); + let view = validator::View { + number: rng.gen(), + genesis: setup.genesis.hash(), + }; + let commit = validator::ReplicaCommit { + view, + proposal: validator::BlockHeader { + number: rng.gen(), + payload: rng.gen(), + }, + }; + let mut timeout_qc = validator::TimeoutQC::new(view); + for k in &setup.validator_keys { + // Generate ReplicaTimeout which differ just by the high_qc signer set. + let mut commit_qc = validator::CommitQC::new(commit.clone(), &setup.genesis); + // Add signatures in random order until the CommitQC is valid. + let mut keys = setup.validator_keys.clone(); + keys.shuffle(rng); + for k in &keys { + if commit_qc.verify(&setup.genesis).is_ok() { + break; + } + commit_qc + .add(&k.sign_msg(commit.clone()), &setup.genesis) + .unwrap(); + } + // Add vote to the TimeoutQC. + let vote = validator::ReplicaTimeout { + view, + high_vote: None, + high_qc: Some(commit_qc.clone()), + }; + timeout_qc.add(&k.sign_msg(vote), &setup.genesis).unwrap(); + } + timeout_qc.verify(&setup.genesis).unwrap(); +} + #[tokio::test] async fn timeout_yield_new_view_sanity() { zksync_concurrency::testonly::abort_on_panic(); diff --git a/node/components/bft/src/chonky_bft/timeout.rs b/node/components/bft/src/chonky_bft/timeout.rs index 43bb4919..5200f3b0 100644 --- a/node/components/bft/src/chonky_bft/timeout.rs +++ b/node/components/bft/src/chonky_bft/timeout.rs @@ -1,6 +1,5 @@ use super::StateMachine; -use crate::metrics; -use std::{cmp::max, collections::HashSet}; +use std::collections::HashSet; use zksync_concurrency::{ctx, error::Wrap, time}; use zksync_consensus_network::io::ConsensusInputMessage; use zksync_consensus_roles::validator; @@ -142,7 +141,13 @@ impl StateMachine { .await .wrap("process_commit_qc()")?; } - self.high_timeout_qc = max(Some(timeout_qc.clone()), self.high_timeout_qc.clone()); + if self + .high_timeout_qc + .as_ref() + .map_or(true, |old| old.view.number < timeout_qc.view.number) + { + self.high_timeout_qc = Some(timeout_qc.clone()); + } // Start a new view. self.start_new_view(ctx, message.view.number.next()).await?; @@ -180,7 +185,6 @@ impl StateMachine { // Log the event. tracing::info!("Timed out at view {}", self.view_number); - metrics::METRICS.replica_view_number.set(self.view_number.0); Ok(()) } diff --git a/node/components/bft/src/metrics.rs b/node/components/bft/src/metrics.rs index 248b57c9..abfa82e7 100644 --- a/node/components/bft/src/metrics.rs +++ b/node/components/bft/src/metrics.rs @@ -54,7 +54,6 @@ pub(crate) struct ProcessingLatencyLabels { #[metrics(prefix = "consensus")] pub(crate) struct ConsensusMetrics { /// Number of the current view of the replica. - #[metrics(unit = Unit::Seconds)] pub(crate) replica_view_number: Gauge, /// Number of the last finalized block observed by the node. pub(crate) finalized_block_number: Gauge, diff --git a/node/components/bft/src/testonly/node.rs b/node/components/bft/src/testonly/node.rs index 45696136..8296274a 100644 --- a/node/components/bft/src/testonly/node.rs +++ b/node/components/bft/src/testonly/node.rs @@ -1,8 +1,7 @@ use crate::{testonly, FromNetworkMessage, PayloadManager, ToNetworkMessage}; use anyhow::Context as _; use std::sync::Arc; -use zksync_concurrency::ctx::channel; -use zksync_concurrency::{ctx, scope, sync}; +use zksync_concurrency::{ctx, ctx::channel, scope, sync}; use zksync_consensus_network as network; use zksync_consensus_storage as storage; use zksync_consensus_storage::testonly::in_memory; diff --git a/node/components/bft/src/testonly/twins/scenario.rs b/node/components/bft/src/testonly/twins/scenario.rs index c1522af1..e16e81c0 100644 --- a/node/components/bft/src/testonly/twins/scenario.rs +++ b/node/components/bft/src/testonly/twins/scenario.rs @@ -91,15 +91,19 @@ where /// The configuration for a single round of P phases. pub struct RoundConfig<'a, T: HasKey, const P: usize> { + /// Leader of the round. pub leader: &'a T::Key, + /// Partitioning of the nodes for each phase. pub phase_partitions: [Split<'a, T>; P], } /// Configuration for a number of rounds. pub struct Scenario<'a, T: HasKey, const P: usize> { + /// Rounds to simulate. pub rounds: Vec>, } +/// Generator of scenarios according to the spec. pub struct ScenarioGenerator<'a, T, const P: usize> where T: Twin, diff --git a/node/components/network/src/gossip/loadtest/mod.rs b/node/components/network/src/gossip/loadtest/mod.rs index 081440f0..c1b7039f 100644 --- a/node/components/network/src/gossip/loadtest/mod.rs +++ b/node/components/network/src/gossip/loadtest/mod.rs @@ -13,7 +13,7 @@ mod tests; struct PushBlockStoreStateServer(sync::watch::Sender>); -impl<'a> PushBlockStoreStateServer { +impl PushBlockStoreStateServer { fn new() -> Self { Self(sync::watch::channel(None).0) } diff --git a/node/components/network/src/testonly.rs b/node/components/network/src/testonly.rs index 48421f80..203916b0 100644 --- a/node/components/network/src/testonly.rs +++ b/node/components/network/src/testonly.rs @@ -1,8 +1,9 @@ //! Testonly utilities. #![allow(dead_code)] use crate::{ - gossip::attestation, io::ConsensusInputMessage, io::ConsensusReq, Config, GossipConfig, - Network, RpcConfig, Runner, + gossip::attestation, + io::{ConsensusInputMessage, ConsensusReq}, + Config, GossipConfig, Network, RpcConfig, Runner, }; use rand::{ distributions::{Distribution, Standard}, diff --git a/node/libs/concurrency/src/limiter/mod.rs b/node/libs/concurrency/src/limiter/mod.rs index cb6a0da5..ca20f9c7 100644 --- a/node/libs/concurrency/src/limiter/mod.rs +++ b/node/libs/concurrency/src/limiter/mod.rs @@ -129,7 +129,7 @@ pub struct Permit<'a> { ctx: &'a ctx::Ctx, } -impl<'a> Drop for Permit<'a> { +impl Drop for Permit<'_> { /// Consumes the reserved permits. fn drop(&mut self) { if self.permits == 0 { diff --git a/node/libs/roles/src/validator/messages/replica_commit.rs b/node/libs/roles/src/validator/messages/replica_commit.rs index 939df5cc..13563a84 100644 --- a/node/libs/roles/src/validator/messages/replica_commit.rs +++ b/node/libs/roles/src/validator/messages/replica_commit.rs @@ -31,7 +31,7 @@ pub enum ReplicaCommitVerifyError { /// A Commit Quorum Certificate. It is an aggregate of signed ReplicaCommit messages. /// The Commit Quorum Certificate is over identical messages, so we only need one message. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct CommitQC { /// The ReplicaCommit message that the QC is for. pub message: ReplicaCommit, @@ -137,18 +137,6 @@ impl CommitQC { } } -impl Ord for CommitQC { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.message.view.number.cmp(&other.message.view.number) - } -} - -impl PartialOrd for CommitQC { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - /// Error returned by `CommitQC::add()`. #[derive(thiserror::Error, Debug)] pub enum CommitQCAddError { diff --git a/node/libs/roles/src/validator/messages/tests/versions.rs b/node/libs/roles/src/validator/messages/tests/versions.rs index a19f152a..dbcc8b2a 100644 --- a/node/libs/roles/src/validator/messages/tests/versions.rs +++ b/node/libs/roles/src/validator/messages/tests/versions.rs @@ -3,9 +3,8 @@ use anyhow::Context as _; use zksync_consensus_crypto::Text; mod version1 { - use zksync_consensus_utils::enum_util::Variant as _; - use super::*; + use zksync_consensus_utils::enum_util::Variant as _; /// Note that genesis is NOT versioned by ProtocolVersion. /// Even if it was, ALL versions of genesis need to be supported FOREVER,