Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update some dependencies to prune duplicated crates with different version #12560

Merged
merged 19 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
349 changes: 137 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions client/consensus/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = "0.1.57"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
futures = "0.3.21"
log = "0.4.17"
merlin = "2.0"
num-bigint = "0.2.3"
num-rational = "0.2.2"
num-bigint = "0.4.3"
num-rational = "0.4.1"
num-traits = "0.2.8"
parking_lot = "0.12.1"
rand = "0.7.2"
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated"] }
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/src/authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub(super) fn calculate_primary_threshold(
qed.",
);

((BigUint::one() << 128) * numer / denom).to_u128().expect(
((BigUint::one() << 128usize) * numer / denom).to_u128().expect(
"returns None if the underlying value cannot be represented with 128 bits; \
we start with 2^128 which is one more than can be represented with 128 bits; \
we multiple by p which is defined in [0, 1); \
Expand Down
6 changes: 4 additions & 2 deletions client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ use super::*;
use authorship::claim_slot;
use futures::executor::block_on;
use log::debug;
use rand::RngCore;
use rand_chacha::{rand_core::SeedableRng, ChaChaRng};
use rand_chacha::{
rand_core::{RngCore, SeedableRng},
ChaChaRng,
};
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
use sc_client_api::{backend::TransactionFor, BlockchainEvents, Finalizer};
use sc_consensus::{BoxBlockImport, BoxJustificationImport};
Expand Down
2 changes: 1 addition & 1 deletion client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
lazy_static = "1.4.0"
lru = "0.7.5"
lru = "0.8.1"
parking_lot = "0.12.1"
tracing = "0.1.29"
wasmi = "0.13"
Expand Down
11 changes: 5 additions & 6 deletions client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use sc_executor_common::{
use sp_core::traits::{Externalities, FetchRuntimeCode, RuntimeCode};
use sp_version::RuntimeVersion;
use std::{
num::NonZeroUsize,
panic::AssertUnwindSafe,
path::{Path, PathBuf},
sync::Arc,
Expand Down Expand Up @@ -179,17 +180,15 @@ impl RuntimeCache {
/// for caching.
///
/// `runtime_cache_size` specifies the number of different runtimes versions preserved in an
/// in-memory cache.
/// in-memory cache, must always be at least 1.
pub fn new(
max_runtime_instances: usize,
cache_path: Option<PathBuf>,
runtime_cache_size: u8,
) -> RuntimeCache {
RuntimeCache {
runtimes: Mutex::new(LruCache::new(runtime_cache_size.into())),
max_runtime_instances,
cache_path,
}
let cap =
NonZeroUsize::new(runtime_cache_size.max(1) as usize).expect("cache size is not zero");
RuntimeCache { runtimes: Mutex::new(LruCache::new(cap)), max_runtime_instances, cache_path }
}

/// Prepares a WASM module instance and executes given function for it.
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = { version = "0.49.0", default-features = false }
log = "0.4.17"
lru = "0.7.5"
lru = "0.8.1"
tracing = "0.1.29"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
Expand Down
8 changes: 6 additions & 2 deletions client/network-gossip/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use lru::LruCache;
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
use sc_network_common::protocol::{role::ObservedRole, ProtocolName};
use sp_runtime::traits::{Block as BlockT, Hash, HashFor};
use std::{collections::HashMap, iter, sync::Arc, time, time::Instant};
use std::{collections::HashMap, iter, num::NonZeroUsize, sync::Arc, time, time::Instant};

// FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115
// NOTE: The current value is adjusted based on largest production network deployment (Kusama) and
Expand Down Expand Up @@ -180,7 +180,11 @@ impl<B: BlockT> ConsensusGossip<B> {
ConsensusGossip {
peers: HashMap::new(),
messages: Default::default(),
known_messages: LruCache::new(KNOWN_MESSAGES_CACHE_SIZE),
known_messages: {
let cap = NonZeroUsize::new(KNOWN_MESSAGES_CACHE_SIZE)
.expect("cache capacity is not zero");
LruCache::new(cap)
},
protocol,
validator,
next_broadcast: Instant::now() + REBROADCAST_INTERVAL,
Expand Down
2 changes: 1 addition & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ libp2p = { version = "0.49.0", features = ["async-std", "dns", "identify", "kad"
linked_hash_set = "0.1.3"
linked-hash-map = "0.5.4"
log = "0.4.17"
lru = "0.7.5"
lru = "0.8.1"
parking_lot = "0.12.1"
pin-project = "1.0.12"
prost = "0.11"
Expand Down
14 changes: 9 additions & 5 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use libp2p::{
Multiaddr, PeerId,
};
use log::{debug, error, info, log, trace, warn, Level};
use lru::LruCache;
use message::{generic::Message as GenericMessage, Message};
use notifications::{Notifications, NotificationsOut};
use prometheus_endpoint::{register, Gauge, GaugeVec, Opts, PrometheusError, Registry, U64};
Expand Down Expand Up @@ -200,7 +201,7 @@ pub struct Protocol<B: BlockT, Client> {
/// The `PeerId`'s of all boot nodes.
boot_node_ids: HashSet<PeerId>,
/// A cache for the data that was associated to a block announcement.
block_announce_data_cache: lru::LruCache<B::Hash, Vec<u8>>,
block_announce_data_cache: LruCache<B::Hash, Vec<u8>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -356,10 +357,13 @@ where
)
};

let block_announce_data_cache = lru::LruCache::new(
network_config.default_peers_set.in_peers as usize +
network_config.default_peers_set.out_peers as usize,
);
let cache_capacity = NonZeroUsize::new(
(network_config.default_peers_set.in_peers as usize +
network_config.default_peers_set.out_peers as usize)
.max(1),
)
.expect("cache capacity is not zero");
let block_announce_data_cache = LruCache::new(cache_capacity);

let protocol = Self {
tick_timeout: Box::pin(interval(TICK_TIMEOUT)),
Expand Down
6 changes: 2 additions & 4 deletions client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ prost-build = "0.11"

[dependencies]
array-bytes = "4.1"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
futures = "0.3.21"
libp2p = "0.49.0"
log = "0.4.17"
lru = "0.7.5"
lru = "0.8.1"
mockall = "0.11.2"
prost = "0.11"
smallvec = "1.8.0"
Expand Down
5 changes: 4 additions & 1 deletion client/network/sync/src/block_request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use sp_runtime::{
use std::{
cmp::min,
hash::{Hash, Hasher},
num::NonZeroUsize,
sync::Arc,
time::Duration,
};
Expand Down Expand Up @@ -164,7 +165,9 @@ where
);
protocol_config.inbound_queue = Some(tx);

let seen_requests = LruCache::new(num_peer_hint * 2);
let capacity =
NonZeroUsize::new(num_peer_hint.max(1) * 2).expect("cache capacity is not zero");
let seen_requests = LruCache::new(capacity);

(Self { client, request_receiver, seen_requests }, protocol_config)
}
Expand Down
5 changes: 4 additions & 1 deletion client/network/sync/src/state_request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use sc_network_common::{
use sp_runtime::traits::Block as BlockT;
use std::{
hash::{Hash, Hasher},
num::NonZeroUsize,
sync::Arc,
time::Duration,
};
Expand Down Expand Up @@ -144,7 +145,9 @@ where
);
protocol_config.inbound_queue = Some(tx);

let seen_requests = LruCache::new(num_peer_hint * 2);
let capacity =
NonZeroUsize::new(num_peer_hint.max(1) * 2).expect("cache capacity is not zero");
let seen_requests = LruCache::new(capacity);

(Self { client, request_receiver, seen_requests }, protocol_config)
}
Expand Down
2 changes: 1 addition & 1 deletion frame/examples/offchain-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
lite-json = { version = "0.1", default-features = false }
lite-json = { version = "0.2.0", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" }
Expand Down
2 changes: 1 addition & 1 deletion frame/merkle-mountain-range/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
mmr-lib = { package = "ckb-merkle-mountain-range", version = "0.3.2", default-features = false }
mmr-lib = { package = "ckb-merkle-mountain-range", version = "0.5.2", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
Expand Down
4 changes: 2 additions & 2 deletions frame/merkle-mountain-range/src/mmr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pub struct Hasher<H, L>(sp_std::marker::PhantomData<(H, L)>);
impl<H: traits::Hash, L: FullLeaf> mmr_lib::Merge for Hasher<H, L> {
type Item = Node<H, L>;

fn merge(left: &Self::Item, right: &Self::Item) -> Self::Item {
fn merge(left: &Self::Item, right: &Self::Item) -> mmr_lib::Result<Self::Item> {
let mut concat = left.hash().as_ref().to_vec();
concat.extend_from_slice(right.hash().as_ref());

Node::Hash(<H as traits::Hash>::hash(&concat))
Ok(Node::Hash(<H as traits::Hash>::hash(&concat)))
}
}
2 changes: 1 addition & 1 deletion primitives/arithmetic/fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
honggfuzz = "0.5.49"
num-bigint = "0.2"
num-bigint = "0.4.3"
primitive-types = "0.12.0"
sp-arithmetic = { version = "5.0.0", path = ".." }

Expand Down
2 changes: 1 addition & 1 deletion primitives/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
futures = "0.3.21"
log = "0.4.17"
lru = "0.7.5"
lru = "0.8.1"
parking_lot = "0.12.1"
thiserror = "1.0.30"
sp-api = { version = "4.0.0-dev", path = "../api" }
Expand Down
6 changes: 4 additions & 2 deletions primitives/blockchain/src/header_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use lru::LruCache;
use parking_lot::RwLock;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One};
use std::num::NonZeroUsize;

/// Set to the expected max difference between `best` and `finalized` blocks at sync.
const LRU_CACHE_SIZE: usize = 5_000;
Expand Down Expand Up @@ -239,14 +240,15 @@ pub struct HeaderMetadataCache<Block: BlockT> {

impl<Block: BlockT> HeaderMetadataCache<Block> {
/// Creates a new LRU header metadata cache with `capacity`.
pub fn new(capacity: usize) -> Self {
pub fn new(capacity: NonZeroUsize) -> Self {
HeaderMetadataCache { cache: RwLock::new(LruCache::new(capacity)) }
}
}

impl<Block: BlockT> Default for HeaderMetadataCache<Block> {
fn default() -> Self {
HeaderMetadataCache { cache: RwLock::new(LruCache::new(LRU_CACHE_SIZE)) }
let cap = NonZeroUsize::new(LRU_CACHE_SIZE).expect("cache capacity is not zero");
HeaderMetadataCache { cache: RwLock::new(LruCache::new(cap)) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion primitives/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hashbrown = { version = "0.12.3", optional = true }
hash-db = { version = "0.15.2", default-features = false }
lazy_static = { version = "1.4.0", optional = true }
lru = { version = "0.7.5", optional = true }
lru = { version = "0.8.1", optional = true }
memory-db = { version = "0.30.0", default-features = false }
nohash-hasher = { version = "0.2.0", optional = true }
parking_lot = { version = "0.12.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion primitives/trie/src/cache/shared_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ lazy_static::lazy_static! {
}

/// No hashing [`LruCache`].
type NoHashingLruCache<K, T> = lru::LruCache<K, T, BuildNoHashHasher<K>>;
type NoHashingLruCache<K, T> = LruCache<K, T, BuildNoHashHasher<K>>;

/// The shared node cache.
///
Expand Down
2 changes: 1 addition & 1 deletion utils/frame/generate-bags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ sp-io = { version = "6.0.0", path = "../../../primitives/io" }
# third party
chrono = { version = "0.4.19" }
git2 = { version = "0.14.2", default-features = false }
num-format = { version = "0.4.0" }
num-format = "0.4.3"