From 3dfe35b59976e8ac75db08aad37279e3d257ac8b Mon Sep 17 00:00:00 2001 From: Romain Ruetschi <106849+romac@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:50:04 +0100 Subject: [PATCH] Update dependencies and fix new warnings --- cometbft/src/chain/id.rs | 2 +- cometbft/src/crypto/ed25519/signing_key.rs | 3 +-- config/Cargo.toml | 2 +- light-client-detector/Cargo.toml | 3 +-- light-client/Cargo.toml | 4 ++-- light-client/tests/model_based.rs | 6 +++--- proto/Cargo.toml | 2 +- rpc/Cargo.toml | 11 ++++++----- rpc/src/utils.rs | 12 +++--------- rpc/tests/kvstore_fixtures/v0_34.rs | 14 +++++++------- rpc/tests/kvstore_fixtures/v0_37.rs | 14 +++++++------- rpc/tests/kvstore_fixtures/v0_38.rs | 14 +++++++------- testgen/Cargo.toml | 2 +- testgen/src/tester.rs | 4 +--- 14 files changed, 42 insertions(+), 51 deletions(-) diff --git a/cometbft/src/chain/id.rs b/cometbft/src/chain/id.rs index 0b11ff65..4c05fabf 100644 --- a/cometbft/src/chain/id.rs +++ b/cometbft/src/chain/id.rs @@ -57,7 +57,7 @@ impl Id { /// Get the chain ID as a raw bytes. pub fn as_bytes(&self) -> &[u8] { - self.0.as_str().as_bytes() + self.0.as_bytes() } } diff --git a/cometbft/src/crypto/ed25519/signing_key.rs b/cometbft/src/crypto/ed25519/signing_key.rs index 6abcc949..03455785 100644 --- a/cometbft/src/crypto/ed25519/signing_key.rs +++ b/cometbft/src/crypto/ed25519/signing_key.rs @@ -38,7 +38,6 @@ impl TryFrom for ed25519_consensus::SigningKey { type Error = Error; fn try_from(src: SigningKey) -> Result { - ed25519_consensus::SigningKey::try_from(src.0) - .map_err(|_| Error::invalid_key("malformed Ed25519 private key".into())) + Ok(ed25519_consensus::SigningKey::from(src.0)) } } diff --git a/config/Cargo.toml b/config/Cargo.toml index 103901d9..b8708023 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -28,7 +28,7 @@ cometbft = { version = "0.34.0", default-features = false, features = ["rust-cry flex-error = { version = "0.4.4", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" -toml = { version = "0.5" } +toml = { version = "0.8" } url = { version = "2.2" } [dev-dependencies] diff --git a/light-client-detector/Cargo.toml b/light-client-detector/Cargo.toml index a512aa54..6dfc6114 100644 --- a/light-client-detector/Cargo.toml +++ b/light-client-detector/Cargo.toml @@ -28,8 +28,7 @@ cometbft-rpc = { version = "0.34.0", path = "../rpc", features = ["http-client"] cometbft-proto = { version = "0.34.0", path = "../proto" } cometbft-light-client = { version = "0.34.0", path = "../light-client" } -contracts = { version = "0.6.2", default-features = false } -crossbeam-channel = { version = "0.4.2", default-features = false } +crossbeam-channel = { version = "0.5.11", default-features = false } derive_more = { version = "0.99.5", default-features = false, features = ["display"] } futures = { version = "0.3.4", default-features = false } serde = { version = "1.0.106", default-features = false } diff --git a/light-client/Cargo.toml b/light-client/Cargo.toml index 700d8aa6..0f874adc 100644 --- a/light-client/Cargo.toml +++ b/light-client/Cargo.toml @@ -40,7 +40,7 @@ cometbft-rpc = { version = "0.34.0", path = "../rpc", default-features = false } cometbft-light-client-verifier = { version = "0.34.0", path = "../light-client-verifier", default-features = false } contracts = { version = "0.6.2", default-features = false } -crossbeam-channel = { version = "0.4.2", default-features = false } +crossbeam-channel = { version = "0.5.11", default-features = false, features = ["std"] } derive_more = { version = "0.99.5", default-features = false, features = ["display"] } futures = { version = "0.3.4", default-features = false } serde = { version = "1.0.106", default-features = false } @@ -60,6 +60,6 @@ cometbft-testgen = { path = "../testgen", default-features = false } serde_json = { version = "1.0.51", default-features = false } gumdrop = { version = "0.8.0", default-features = false } -rand = { version = "0.7.3", default-features = false } +rand = { version = "0.8.3", default-features = false } tempfile = { version = "3.2.0", default-features = false } proptest = { version = "0.10.1", default-features = false, features = ["std"] } diff --git a/light-client/tests/model_based.rs b/light-client/tests/model_based.rs index 64fbc66c..89fff4d9 100644 --- a/light-client/tests/model_based.rs +++ b/light-client/tests/model_based.rs @@ -120,7 +120,7 @@ mod mbt { None } else { let mut rng = rand::thread_rng(); - let i = rng.gen_range(0, indices.len()); + let i = rng.gen_range(0..indices.len()); Some((i, tc.input.get_mut(i).unwrap())) } } @@ -170,7 +170,7 @@ mod mbt { fn fuzz_input(input: &mut BlockVerdict) -> (String, LiteVerdict) { let mut rng = rand::thread_rng(); let h: u64 = input.block.signed_header.header.height.into(); - let mut height: u64 = rng.gen_range(0u64, i64::MAX as u64); + let mut height: u64 = rng.gen_range(0u64..i64::MAX as u64); while height == h { height = rng.gen(); } @@ -190,7 +190,7 @@ mod mbt { .duration_since(cometbft::Time::unix_epoch()) .unwrap() .as_secs(); - let rand_secs = rng.gen_range(1, secs); + let rand_secs = rng.gen_range(1..secs); input.block.signed_header.header.time = (cometbft::Time::unix_epoch() + std::time::Duration::from_secs(rand_secs)).unwrap(); // TODO: the fuzzing below fails with one of: diff --git a/proto/Cargo.toml b/proto/Cargo.toml index fc593c8d..e851dea6 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -29,7 +29,7 @@ serde = { version = "1.0", default-features = false, features = ["derive"] } serde_bytes = { version = "0.11", default-features = false, features = ["alloc"] } subtle-encoding = { version = "0.5", default-features = false, features = ["hex", "base64", "alloc"] } num-traits = { version = "0.2", default-features = false } -num-derive = { version = "0.3", default-features = false } +num-derive = { version = "0.4", default-features = false } time = { version = "0.3", default-features = false, features = ["macros", "parsing"] } flex-error = { version = "0.4.4", default-features = false } tonic = { version = "0.10", optional = true } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index db60557e..26433d82 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -62,14 +62,15 @@ cometbft-proto = { version = "0.34.0", path = "../proto", default-features = fal async-trait = { version = "0.1", default-features = false } bytes = { version = "1.0", default-features = false } getrandom = { version = "0.2", default-features = false, features = ["js"] } -peg = { version = "0.7.0", default-features = false } +peg = { version = "0.8", default-features = false } pin-project = { version = "1.0.1", default-features = false } serde = { version = "1", default-features = false, features = [ "derive" ] } serde_bytes = { version = "0.11", default-features = false } serde_json = { version = "1", default-features = false, features = ["std"] } thiserror = { version = "1", default-features = false } time = { version = "0.3", default-features = false, features = ["macros", "parsing"] } -uuid = { version = "0.8", default-features = false } +uuid = { version = "1.7", default-features = false } +rand = { version = "0.8" } subtle-encoding = { version = "0.5", default-features = false, features = ["bech32-preview"] } url = { version = "2.4.1", default-features = false } walkdir = { version = "2.3", default-features = false } @@ -78,15 +79,15 @@ subtle = { version = "2", default-features = false } semver = { version = "1.0", default-features = false } # Optional dependencies -async-tungstenite = { version = "0.23", default-features = false, features = ["tokio-runtime", "tokio-rustls-native-certs"], optional = true } +async-tungstenite = { version = "0.24", default-features = false, features = ["tokio-runtime", "tokio-rustls-native-certs"], optional = true } futures = { version = "0.3", optional = true, default-features = false } reqwest = { version = "0.11.20", optional = true, default-features = false, features = ["rustls-tls-native-roots"] } structopt = { version = "0.3", optional = true, default-features = false } tokio = { version = "1.0", optional = true, default-features = false, features = ["rt-multi-thread"] } tracing = { version = "0.1", optional = true, default-features = false } -tracing-subscriber = { version = "0.2", optional = true, default-features = false, features = ["fmt"] } +tracing-subscriber = { version = "0.3", optional = true, default-features = false, features = ["fmt"] } [dev-dependencies] -http = { version = "0.2", default-features = false } +http = { version = "1", default-features = false, features = ["std"] } lazy_static = { version = "1.4.0", default-features = false } tokio-test = { version = "0.4", default-features = false } diff --git a/rpc/src/utils.rs b/rpc/src/utils.rs index 53ab7d77..65189808 100644 --- a/rpc/src/utils.rs +++ b/rpc/src/utils.rs @@ -1,6 +1,6 @@ //! Utility methods for the CometBFT RPC crate. -use getrandom::getrandom; +use rand::Rng; use crate::prelude::*; @@ -8,13 +8,7 @@ use crate::prelude::*; /// /// Panics if random number generation fails. pub fn uuid_str() -> String { - let mut bytes = [0; 16]; - getrandom(&mut bytes).expect("RNG failure!"); - - let uuid = uuid::Builder::from_bytes(bytes) - .set_variant(uuid::Variant::RFC4122) - .set_version(uuid::Version::Random) - .build(); - + let bytes: [u8; 16] = rand::thread_rng().gen(); + let uuid = uuid::Builder::from_random_bytes(bytes).into_uuid(); uuid.to_string() } diff --git a/rpc/tests/kvstore_fixtures/v0_34.rs b/rpc/tests/kvstore_fixtures/v0_34.rs index 82ead339..42fad00a 100644 --- a/rpc/tests/kvstore_fixtures/v0_34.rs +++ b/rpc/tests/kvstore_fixtures/v0_34.rs @@ -332,7 +332,7 @@ fn incoming_fixtures() { }, "block_at_height_1" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert!(result.block.header.app_hash.as_bytes().is_empty()); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -373,7 +373,7 @@ fn incoming_fixtures() { }, "block_at_height_10" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert_eq!(result.block.header.app_hash.as_bytes(), &[0u8; 8]); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -813,7 +813,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -868,7 +868,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -945,7 +945,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -1000,7 +1000,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -1055,7 +1055,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); diff --git a/rpc/tests/kvstore_fixtures/v0_37.rs b/rpc/tests/kvstore_fixtures/v0_37.rs index 8c10e92d..2f4ee9c0 100644 --- a/rpc/tests/kvstore_fixtures/v0_37.rs +++ b/rpc/tests/kvstore_fixtures/v0_37.rs @@ -331,7 +331,7 @@ fn incoming_fixtures() { }, "block_at_height_1" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert!(result.block.header.app_hash.as_bytes().is_empty()); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -372,7 +372,7 @@ fn incoming_fixtures() { }, "block_at_height_10" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert_eq!(result.block.header.app_hash.as_bytes(), &[0u8; 8]); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -807,7 +807,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -862,7 +862,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -939,7 +939,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -994,7 +994,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -1049,7 +1049,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); diff --git a/rpc/tests/kvstore_fixtures/v0_38.rs b/rpc/tests/kvstore_fixtures/v0_38.rs index 90dcd2cc..ea1f00f1 100644 --- a/rpc/tests/kvstore_fixtures/v0_38.rs +++ b/rpc/tests/kvstore_fixtures/v0_38.rs @@ -331,7 +331,7 @@ fn incoming_fixtures() { }, "block_at_height_1" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert_eq!(result.block.header.app_hash.as_bytes(), [0u8; 8]); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -372,7 +372,7 @@ fn incoming_fixtures() { }, "block_at_height_10" => { let result = endpoint::block::Response::from_string(content).unwrap(); - assert!(result.block.data.get(0).is_none()); + assert!(result.block.data.first().is_none()); assert!(result.block.evidence.iter().next().is_none()); assert_eq!(result.block.header.app_hash.as_bytes(), &[0u8; 8]); assert_eq!(result.block.header.chain_id.as_str(), CHAIN_ID); @@ -806,7 +806,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -864,7 +864,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -922,7 +922,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -980,7 +980,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); @@ -1038,7 +1038,7 @@ fn incoming_fixtures() { } = result.data.into() { let b = block.unwrap(); - assert!(b.data.get(0).is_none()); + assert!(b.data.first().is_none()); assert!(b.evidence.iter().next().is_none()); assert!(!b.header.app_hash.as_bytes().is_empty()); assert_eq!(b.header.chain_id.as_str(), CHAIN_ID); diff --git a/testgen/Cargo.toml b/testgen/Cargo.toml index b05d27bd..16a73adb 100644 --- a/testgen/Cargo.toml +++ b/testgen/Cargo.toml @@ -21,7 +21,7 @@ serde = { version = "1", default-features = false, features = ["derive"] } serde_json = { version = "1", default-features = false, features = ["std"] } ed25519-consensus = { version = "2", default-features = false } gumdrop = { version = "0.8.0", default-features = false } -simple-error = { version = "0.2.1", default-features = false } +simple-error = { version = "0.3.0", default-features = false } tempfile = { version = "3.1.0", default-features = false } time = { package = "time", version = "0.3", default-features = false, features = ["std"] } diff --git a/testgen/src/tester.rs b/testgen/src/tester.rs index f259ba7e..6639f8ef 100644 --- a/testgen/src/tester.rs +++ b/testgen/src/tester.rs @@ -323,9 +323,7 @@ impl Tester { } fn results_for(&mut self, name: &str) -> &mut Vec<(String, TestResult)> { - self.results - .entry(name.to_string()) - .or_insert_with(Vec::new) + self.results.entry(name.to_string()).or_default() } fn add_result(&mut self, name: &str, path: &str, result: TestResult) {