Skip to content

Commit 69f97fa

Browse files
authored
Merge pull request #2647 from ljedrz/feat/locktick_feature
[Feat] Introduce a lock accounting feature
2 parents dac95b8 + 4dc8567 commit 69f97fa

File tree

23 files changed

+143
-0
lines changed

23 files changed

+143
-0
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ cuda = [ "snarkvm-algorithms/cuda" ]
134134
save_r1cs_hashes = [ "snarkvm-circuit/save_r1cs_hashes" ]
135135
history = [ "snarkvm-synthesizer/history" ]
136136
parameters_no_std_out = [ "snarkvm-parameters/no_std_out" ]
137+
locktick = [
138+
"dep:locktick",
139+
"snarkvm-algorithms?/locktick",
140+
"snarkvm-ledger?/locktick",
141+
"snarkvm-parameters?/locktick",
142+
"snarkvm-synthesizer?/locktick"
143+
]
137144
noconfig = [ ]
138145
rocks = [ "snarkvm-ledger/rocks", "snarkvm-synthesizer/rocks" ]
139146
test = [ "snarkvm-ledger/test" ]
@@ -233,6 +240,11 @@ optional = true
233240
version = "2.0"
234241
features = [ "rayon" ]
235242

243+
[dependencies.locktick]
244+
version = "0.3"
245+
features = [ "parking_lot" ]
246+
optional = true
247+
236248
[dependencies.num-format]
237249
version = "0.4.4"
238250

algorithms/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ version = "0.11.0"
110110
version = "1.4"
111111
optional = true
112112

113+
[dependencies.locktick]
114+
version = "0.3"
115+
features = [ "parking_lot" ]
116+
optional = true
117+
113118
[dependencies.parking_lot]
114119
version = "0.12"
115120

@@ -200,6 +205,7 @@ cuda = [ "snarkvm-algorithms-cuda" ]
200205
profiler = [ "aleo-std/profiler" ]
201206
crypto_hash = [ ]
202207
fft = [ ]
208+
locktick = [ "dep:locktick", "snarkvm-parameters?/locktick" ]
203209
msm = [ ]
204210
test = [ ]
205211
polycommit = [ "crypto_hash", "fft", "msm", "rand_core" ]

ledger/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ async = [
3838
"ledger-query/async",
3939
"synthesizer/async"
4040
]
41+
locktick = [
42+
"dep:locktick",
43+
"ledger-puzzle/locktick",
44+
"ledger-store/locktick",
45+
"synthesizer/locktick"
46+
]
4147
metrics = [ "ledger-committee/metrics" ]
4248
rocks = [ "ledger-store/rocks" ]
4349
serial = [
@@ -122,6 +128,11 @@ version = "1.0.73"
122128
version = "2.0"
123129
features = [ "serde" ]
124130

131+
[dependencies.locktick]
132+
version = "0.3"
133+
features = [ "parking_lot" ]
134+
optional = true
135+
125136
[dependencies.lru]
126137
version = "0.12"
127138

ledger/puzzle/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ required-features = [ "setup" ]
3232
[features]
3333
default = [ "indexmap/rayon", "rayon" ]
3434
cuda = [ "snarkvm-algorithms/cuda" ]
35+
locktick = [ "dep:locktick", "snarkvm-algorithms/locktick" ]
3536
serial = [ "console/serial", "snarkvm-algorithms/serial" ]
3637
setup = [ ]
3738
timer = [ "aleo-std/timer" ]
@@ -60,6 +61,11 @@ version = "1"
6061
version = "2.0"
6162
features = [ "serde", "rayon" ]
6263

64+
[dependencies.locktick]
65+
version = "0.3"
66+
features = [ "parking_lot" ]
67+
optional = true
68+
6369
[dependencies.lru]
6470
version = "0.12"
6571

ledger/puzzle/epoch/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ edition = "2021"
2626
[features]
2727
default = [ "synthesis", "rayon" ]
2828
serial = [ "console/serial", "snarkvm-ledger-puzzle/serial" ]
29+
locktick = [
30+
"dep:locktick",
31+
"snarkvm-ledger-puzzle/locktick",
32+
"snarkvm-synthesizer-process/locktick"
33+
]
2934
merkle = [ ]
3035
synthesis = [
3136
"aleo-std",
@@ -78,6 +83,11 @@ version = "2"
7883
version = "2.0"
7984
features = [ "serde", "rayon" ]
8085

86+
[dependencies.locktick]
87+
version = "0.3"
88+
features = [ "parking_lot" ]
89+
optional = true
90+
8191
[dependencies.lru]
8292
version = "0.12"
8393
optional = true

ledger/puzzle/epoch/src/synthesis/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ use snarkvm_ledger_puzzle::PuzzleTrait;
2525

2626
use anyhow::{Result, bail};
2727
use core::{marker::PhantomData, num::NonZeroUsize};
28+
#[cfg(feature = "locktick")]
29+
use locktick::parking_lot::RwLock;
2830
use lru::LruCache;
31+
#[cfg(not(feature = "locktick"))]
2932
use parking_lot::RwLock;
3033
use rand_chacha::ChaChaRng;
3134
use std::sync::Arc;

ledger/puzzle/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ use console::{
5252
use aleo_std::prelude::*;
5353
use core::num::NonZeroUsize;
5454
use indexmap::IndexMap;
55+
#[cfg(feature = "locktick")]
56+
use locktick::parking_lot::RwLock;
5557
use lru::LruCache;
58+
#[cfg(not(feature = "locktick"))]
5659
use parking_lot::RwLock;
5760
use rand::SeedableRng;
5861
use rand_chacha::ChaChaRng;

ledger/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ use aleo_std::{
7070
use anyhow::Result;
7171
use core::ops::Range;
7272
use indexmap::IndexMap;
73+
#[cfg(feature = "locktick")]
74+
use locktick::parking_lot::{Mutex, RwLock};
7375
use lru::LruCache;
76+
#[cfg(not(feature = "locktick"))]
7477
use parking_lot::{Mutex, RwLock};
7578
use rand::{prelude::IteratorRandom, rngs::OsRng};
7679
use std::{borrow::Cow, sync::Arc};

ledger/store/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ edition = "2021"
1818

1919
[features]
2020
default = [ "indexmap/rayon", "rayon" ]
21+
locktick = [ "dep:locktick", "ledger-puzzle/locktick" ]
2122
rocks = [ "once_cell", "rocksdb", "smallvec", "tracing" ]
2223
serial = [
2324
"console/serial",
@@ -93,6 +94,11 @@ version = "1.3"
9394
version = "2.0"
9495
features = [ "serde" ]
9596

97+
[dependencies.locktick]
98+
version = "0.3"
99+
features = [ "parking_lot" ]
100+
optional = true
101+
96102
[dependencies.once_cell]
97103
version = "1.18"
98104
optional = true

ledger/store/src/block/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ use synthesizer_program::{FinalizeOperation, Program};
4848

4949
use aleo_std_storage::StorageMode;
5050
use anyhow::Result;
51+
#[cfg(feature = "locktick")]
52+
use locktick::parking_lot::RwLock;
53+
#[cfg(not(feature = "locktick"))]
5154
use parking_lot::RwLock;
5255
use std::{borrow::Cow, sync::Arc};
5356

ledger/store/src/helpers/memory/internal/map.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use console::network::prelude::*;
2020
use indexmap::IndexMap;
2121

2222
use core::{borrow::Borrow, hash::Hash};
23+
#[cfg(feature = "locktick")]
24+
use locktick::parking_lot::{Mutex, RwLock};
25+
#[cfg(not(feature = "locktick"))]
2326
use parking_lot::{Mutex, RwLock};
2427
use std::{
2528
borrow::Cow,

ledger/store/src/helpers/memory/internal/nested_map.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use crate::helpers::{NestedMap, NestedMapRead};
1919
use console::network::prelude::*;
2020

2121
use core::hash::Hash;
22+
#[cfg(feature = "locktick")]
23+
use locktick::parking_lot::{Mutex, RwLock};
24+
#[cfg(not(feature = "locktick"))]
2225
use parking_lot::{Mutex, RwLock};
2326
use std::{
2427
borrow::Cow,

ledger/store/src/helpers/rocksdb/internal/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ mod tests;
2727

2828
use aleo_std_storage::StorageMode;
2929
use anyhow::{Result, bail, ensure};
30+
#[cfg(feature = "locktick")]
31+
use locktick::parking_lot::Mutex;
3032
use once_cell::sync::OnceCell;
33+
#[cfg(not(feature = "locktick"))]
3134
use parking_lot::Mutex;
3235
use serde::{Serialize, de::DeserializeOwned};
3336
use std::{

parameters/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ edition = "2021"
2626
[features]
2727
large_params = [ ]
2828
default = [ "colored", "remote" ]
29+
locktick = [ "dep:locktick" ]
2930
no_std_out = [ ]
3031
remote = [ "curl" ]
3132
wasm = [ "encoding", "js-sys", "web-sys" ]
@@ -77,6 +78,11 @@ optional = true
7778
[dependencies.lazy_static]
7879
version = "1.4"
7980

81+
[dependencies.locktick]
82+
version = "0.3"
83+
features = [ "parking_lot" ]
84+
optional = true
85+
8086
[dependencies.parking_lot]
8187
version = "0.12"
8288

parameters/src/mainnet/powers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ use snarkvm_utilities::{
2929
};
3030

3131
use anyhow::{Result, anyhow, bail, ensure};
32+
#[cfg(feature = "locktick")]
33+
use locktick::parking_lot::RwLock;
34+
#[cfg(not(feature = "locktick"))]
3235
use parking_lot::RwLock;
3336
use std::{collections::BTreeMap, ops::Range, sync::Arc};
3437

synthesizer/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ edition = "2021"
2525

2626
[features]
2727
default = [ "process", "program", "rayon", "snark" ]
28+
locktick = [
29+
"dep:locktick",
30+
"ledger-puzzle/locktick",
31+
"ledger-puzzle-epoch/locktick",
32+
"ledger-store/locktick",
33+
"synthesizer-process?/locktick"
34+
]
2835
process = [ "synthesizer-process" ]
2936
program = [ "synthesizer-program" ]
3037
snark = [ "synthesizer-snark" ]
@@ -156,6 +163,11 @@ features = [ "serde", "rayon" ]
156163
[dependencies.itertools]
157164
version = "0.11.0"
158165

166+
[dependencies.locktick]
167+
version = "0.3"
168+
features = [ "parking_lot" ]
169+
optional = true
170+
159171
[dependencies.lru]
160172
version = "0.12"
161173

synthesizer/process/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ edition = "2021"
2727
default = [ "indexmap/rayon", "rayon" ]
2828
aleo-cli = [ ]
2929
async = [ "ledger-query/async" ]
30+
locktick = [ "dep:locktick", "ledger-store/locktick" ]
3031
rocks = [ "ledger-store/rocks" ]
3132
serial = [
3233
"console/serial",
@@ -109,6 +110,11 @@ version = "2"
109110
version = "2.0"
110111
features = [ "serde" ]
111112

113+
[dependencies.locktick]
114+
version = "0.3"
115+
features = [ "parking_lot" ]
116+
optional = true
117+
112118
[dependencies.once_cell]
113119
version = "1.18"
114120

0 commit comments

Comments
 (0)