Skip to content

Commit 47dc3f1

Browse files
authored
Replace dashmap with papaya. (#4481)
## Motivation `dashmap` can cause deadlocks if guards are held across `await` points, but the compiler does not warn about it. ## Proposal Use the lock-free `papaya` instead. (The first commit was mostly written by Claude, the rest by me.) ## Test Plan CI (no new functionality) ## Release Plan - Nothing to do / These changes follow the usual release cycle. - (But could be backported.) ## Links - Closes #4139. - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 6394236 commit 47dc3f1

File tree

29 files changed

+372
-346
lines changed

29 files changed

+372
-346
lines changed

Cargo.lock

Lines changed: 27 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ console_error_panic_hook = "0.1.7"
105105
convert_case = "0.6.0"
106106
criterion = { version = "0.5.1", default-features = false }
107107
custom_debug_derive = "0.6.1"
108-
dashmap = "5.5.3"
109108
deluxe = "0.5.0"
110109
derive_more = "1.0.0"
111110
dirs = "5.0.1"
@@ -156,6 +155,7 @@ num-format = "0.4.4"
156155
num-traits = "0.2.18"
157156
octocrab = "0.42.1"
158157
oneshot = "0.1.6"
158+
papaya = "0.1.5"
159159
pathdiff = "0.2.1"
160160
port-selector = "0.1.6"
161161
prettyplease = "0.2.16"

examples/Cargo.lock

Lines changed: 27 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

linera-chain/src/unit_tests/chain_tests.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,11 @@ async fn test_application_permissions() -> anyhow::Result<()> {
268268
let mut chain = ChainStateView::new(chain_id).await;
269269

270270
let extra = &chain.context().extra();
271-
extra
272-
.user_contracts()
273-
.insert(application_id, application.clone().into());
274-
extra
275-
.user_contracts()
276-
.insert(another_app_id, application.clone().into());
271+
{
272+
let pinned = extra.user_contracts().pin();
273+
pinned.insert(application_id, application.clone().into());
274+
pinned.insert(another_app_id, application.clone().into());
275+
}
277276

278277
extra
279278
.add_blobs([committee_blob(Default::default())])
@@ -723,12 +722,14 @@ async fn prepare_test_with_dummy_mock_application(
723722
let application_id = ApplicationId::from(&app_description);
724723
let application = MockApplication::default();
725724
let extra = &chain.context().extra();
726-
extra
727-
.user_contracts()
728-
.insert(application_id, application.clone().into());
729-
extra
730-
.user_services()
731-
.insert(application_id, application.clone().into());
725+
{
726+
let pinned = extra.user_contracts().pin();
727+
pinned.insert(application_id, application.clone().into());
728+
}
729+
{
730+
let pinned = extra.user_services().pin();
731+
pinned.insert(application_id, application.clone().into());
732+
}
732733
extra
733734
.add_blobs([
734735
committee_blob,

linera-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ bcs.workspace = true
5656
cfg-if.workspace = true
5757
clap.workspace = true
5858
custom_debug_derive.workspace = true
59-
dashmap.workspace = true
6059
futures.workspace = true
6160
linera-base.workspace = true
6261
linera-chain.workspace = true
@@ -65,6 +64,7 @@ linera-storage.workspace = true
6564
linera-version.workspace = true
6665
linera-views.workspace = true
6766
lru.workspace = true
67+
papaya.workspace = true
6868
prometheus = { workspace = true, optional = true }
6969
proptest = { workspace = true, optional = true }
7070
rand = { workspace = true, features = ["std_rng"] }

linera-core/src/client/chain_client_state.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ impl ChainClientState {
3232
}
3333
}
3434

35+
/// Clones the state. This must only be used to update the state, and one of the two clones
36+
/// must be dropped.
37+
pub(super) fn clone_for_update_unchecked(&self) -> ChainClientState {
38+
ChainClientState {
39+
pending_proposal: self.pending_proposal.clone(),
40+
client_mutex: Arc::clone(&self.client_mutex),
41+
}
42+
}
43+
3544
pub fn pending_proposal(&self) -> &Option<PendingProposal> {
3645
&self.pending_proposal
3746
}

0 commit comments

Comments
 (0)