diff --git a/Cargo.lock b/Cargo.lock index a50b69b07..1d1274cf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5876,9 +5876,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0b564323a0fb6d54b864f625ae139de9612e27edb944dda37c109f05aac531" +checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9" dependencies = [ "hashbrown 0.17.0", ] @@ -11460,7 +11460,7 @@ dependencies = [ "jsonrpsee 0.25.1", "k256", "libp2p", - "lru 0.17.0", + "lru 0.18.0", "lz4", "once_cell", "opentelemetry", diff --git a/zilliqa/Cargo.toml b/zilliqa/Cargo.toml index eb66365e5..1ea5ab865 100644 --- a/zilliqa/Cargo.toml +++ b/zilliqa/Cargo.toml @@ -115,7 +115,7 @@ arc-swap = "1.9.1" redis = { version = "0.32.7", features = ["keep-alive", "r2d2", "tcp_nodelay"], default-features = false } alloy = { version = "2.0.4", default-features = false, features = ["consensus", "contract", "dyn-abi", "eips", "hyper", "json-abi", "k256", "rlp", "rpc-types", "rpc-types-trace", "serde", "sol-types"] } crossbeam = "0.8.4" -lru = "0.17.0" +lru = "0.18.0" [dev-dependencies] alloy = { version = "2.0.4", default-features = false, features = ["consensus", "dyn-abi", "eips", "json-abi", "k256", "rlp", "rpc-types", "rpc-types-trace", "serde", "sol-types", "pubsub", "json-rpc", "contract", "signer-local"] } diff --git a/zilliqa/src/uccb/relayer.rs b/zilliqa/src/uccb/relayer.rs index 436059a69..351ea49aa 100644 --- a/zilliqa/src/uccb/relayer.rs +++ b/zilliqa/src/uccb/relayer.rs @@ -277,28 +277,26 @@ impl Relayer { // do this in an inner-scope to release the lock before calling `relay_ops()` below. let promote = { // 2. Get the cache entry - let bop = self - .signatures - .write() - .get_or_insert_mut_ref(&userop_hash, || { - let stakers = state.get_stakers(block.header).expect("must exist"); - let len = stakers.len(); - let total_stake: u128 = stakers - .into_iter() - .map(|pub_key| { - state - .get_stake(pub_key, block.header) - .expect("must have stake") - .expect("stake != 0") - .get() - }) - .sum(); - BlsUserOp { - userop: None, - threshold: 2 * total_stake / 3 + 1, - signatures: Vec::with_capacity(len), - } - }); + let mut cache = self.signatures.write(); + let bop = cache.get_or_insert_mut_ref(&userop_hash, || { + let stakers = state.get_stakers(block.header).expect("must exist"); + let len = stakers.len(); + let total_stake: u128 = stakers + .into_iter() + .map(|pub_key| { + state + .get_stake(pub_key, block.header) + .expect("must have stake") + .expect("stake != 0") + .get() + }) + .sum(); + BlsUserOp { + userop: None, + threshold: 2 * total_stake / 3 + 1, + signatures: Vec::with_capacity(len), + } + }); // 3. Cache the signature entry let stake = state