Skip to content

Commit

Permalink
Update dependencies and fix new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Jan 24, 2024
1 parent ee5d2d1 commit 3dfe35b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cometbft/src/chain/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
3 changes: 1 addition & 2 deletions cometbft/src/crypto/ed25519/signing_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl TryFrom<SigningKey> for ed25519_consensus::SigningKey {
type Error = Error;

fn try_from(src: SigningKey) -> Result<Self, Error> {
ed25519_consensus::SigningKey::try_from(src.0)
.map_err(|_| Error::invalid_key("malformed Ed25519 private key".into()))
Ok(ed25519_consensus::SigningKey::from(src.0))
}
}
2 changes: 1 addition & 1 deletion config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions light-client-detector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"] }
6 changes: 3 additions & 3 deletions light-client/tests/model_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
11 changes: 6 additions & 5 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
12 changes: 3 additions & 9 deletions rpc/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
//! Utility methods for the CometBFT RPC crate.
use getrandom::getrandom;
use rand::Rng;

use crate::prelude::*;

/// Produce a string containing a UUID.
///
/// 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()
}
14 changes: 7 additions & 7 deletions rpc/tests/kvstore_fixtures/v0_34.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions rpc/tests/kvstore_fixtures/v0_37.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions rpc/tests/kvstore_fixtures/v0_38.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion testgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
4 changes: 1 addition & 3 deletions testgen/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3dfe35b

Please sign in to comment.