Skip to content

Commit 8de48b0

Browse files
committed
feat: add tracing feature
1 parent 9d8d290 commit 8de48b0

File tree

14 files changed

+87
-9
lines changed

14 files changed

+87
-9
lines changed

Cargo.lock

Lines changed: 2 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ locktick = [
158158
"snarkvm-parameters?/locktick",
159159
"snarkvm-synthesizer?/locktick"
160160
]
161+
tracing = [ "snarkvm-ledger/tracing" ]
161162
noconfig = [ ]
162163
rocks = [ "snarkvm-ledger/rocks", "snarkvm-synthesizer/rocks" ]
163164
test = [ "snarkvm-ledger/test" ]

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ We recommend installing Rust using [rustup](https://www.rustup.rs/). You can ins
4949
- Windows (64-bit):
5050

5151
Download the [Windows 64-bit executable](https://win.rustup.rs/x86_64) or
52-
[Windows 32-bit executable](https://win.rustup.rs/i686) and follow the on-screen instructions.
52+
[Windows 32-bit executable](https://win.rustup.rs/i686) and follow the on-screen instructions.i
5353

54-
### 2.2.1 Build from Crates.io
54+
### 2.2 Additional Dependencies
55+
56+
On Linux, you also need the `lld` linker. For example, on a Debian system you would run the following to install it.
57+
58+
```
59+
sudo apt install lld
60+
```
61+
62+
### 2.3.1 Build from Crates.io
5563

5664
We recommend installing `snarkvm` this way. In your terminal, run:
5765

@@ -64,27 +72,57 @@ Now to use `snarkvm`, in your terminal, run:
6472
snarkvm
6573
```
6674

67-
### 2.2.2 Build from Source Code
75+
### 2.3.2 Build from Source Code
6876

6977
Alternatively, you can install `snarkvm` by building from the source code as follows:
7078

7179
```bash
7280
# Download the source code
7381
git clone --branch mainnet --single-branch https://github.com/ProvableHQ/snarkVM.git
7482
cd snarkVM
75-
git checkout tags/testnet-beta
7683
# Install snarkVM
77-
cargo install --path .
84+
cargo install --path . --features=cli
7885
```
7986

8087
Now to use `snarkvm`, in your terminal, run:
8188
```bash
8289
snarkvm
8390
```
8491

92+
### 2.4 Feature Flags
93+
94+
The following is an (incomplete) list of features flags in the snarkVM crate.
95+
96+
* **cuda** -
97+
Allows some operations to run on the (NVidia) GPU, instead of on the CPU.
98+
* **cli** -
99+
Enables the command-line interface. Needed when installing the `snarkvm` binary.
100+
* **locktick** -
101+
This feature turns on code for detecting deadlocks.
102+
* **test_targets** -
103+
This feature allows the lowering of coinbase and proof targets for testing.
104+
* **tracing** -
105+
Adds additional tracing statements to the code. This is useful for profiling, but can clutter the logs.
106+
* **serial** -
107+
*Disables* paralle processing using `rayon`.
108+
* **algorithms** -
109+
Adds the `algorithms` crate to `snarkvm` (as `snarkvm::algorithms`)
110+
* **circuit** -
111+
Adds the `circuit` crate to `snarkvm` (as `snarkvm::circuit`)
112+
* **fields** -
113+
Adds the `fields` crate to `snarkvm` (as `snarkvm::fields`)
114+
* **ledger** -
115+
Adds the `ledger` crate to `snarkvm` (as `snarkvm::ledger`)
116+
* **synthesizer** -
117+
Adds the `synthesizer` crate to `snarkvm` (as `snarkvm::synthesizer`)
118+
* **parameters** -
119+
Adds the `parameters` crate to `snarkvm` (as `snarkvm::parameters`)
120+
* **wasm** -
121+
Enables behavior specific for WebAssembly. This feature should only be enabled when compiling to the `wasm32` architecture.
122+
85123
## 3. Contributors
86124

87-
Thank you for helping make snarkVM better!
125+
Thank you for helping make snarkVM betkter!
88126
[🧐 What do the emojis mean?](https://allcontributors.org/docs/en/emoji-key)
89127

90128
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

ledger/Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ serial = [
5757
"snarkvm-ledger-store/serial",
5858
"snarkvm-synthesizer/serial"
5959
]
60-
test = [ "snarkvm-console/test", "snarkvm-ledger-block/test", "snarkvm-ledger-store/test", "snarkvm-synthesizer/test" ]
60+
tracing = [
61+
"snarkvm-synthesizer/tracing",
62+
"snarkvm-ledger-block/tracing",
63+
"snarkvm-ledger-store/tracing"
64+
]
65+
test = [
66+
"snarkvm-console/test",
67+
"snarkvm-ledger-block/test",
68+
"snarkvm-ledger-store/test",
69+
"snarkvm-synthesizer/test"
70+
]
6171
test-helpers = [
6272
"snarkvm-ledger-test-helpers",
6373
"snarkvm-ledger-committee/test-helpers",

ledger/block/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ wasm = [
3434
"snarkvm-synthesizer-program/wasm",
3535
"snarkvm-synthesizer-snark/wasm"
3636
]
37+
tracing = [ "dep:tracing" ]
3738
test = [ "snarkvm-synthesizer-process/test" ]
3839

3940
[dependencies.snarkvm-console]
@@ -72,6 +73,10 @@ workspace = true
7273
workspace = true
7374
features = [ "serde" ]
7475

76+
[dependencies.tracing]
77+
workspace = true
78+
optional = true
79+
7580
[dependencies.rayon]
7681
workspace = true
7782

ledger/block/src/verify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rayon::prelude::*;
2727

2828
impl<N: Network> Block<N> {
2929
/// Ensures the block is correct.
30+
#[cfg_attr(feature = "tracing", tracing::instrument(skip_all))]
3031
pub fn verify(
3132
&self,
3233
previous_block: &Block<N>,

ledger/src/advance.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
8888
}
8989

9090
/// Adds the given block as the next block in the ledger.
91+
#[cfg_attr(feature = "tracing", tracing::instrument(skip_all))]
9192
pub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()> {
9293
// Acquire the write lock on the current block.
9394
let mut current_block = self.current_block.write();

ledger/src/check_next_block.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
4747
/// * This will reject any blocks with a height <= the current height and any blocks with a height >= the current height + GC.
4848
/// For the former, a valid block already exists and,
4949
/// for the latter, the comittte is still unknown.
50+
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self, block, pending_blocks)))]
5051
pub fn check_block_subdag(&self, block: Block<N>, pending_blocks: &[PendingBlock<N>]) -> Result<PendingBlock<N>> {
5152
self.check_block_subdag_inner(&block, pending_blocks)?;
5253
Ok(PendingBlock(block))
@@ -91,6 +92,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
9192
}
9293

9394
/// Checks the given block is a valid next block with regard to the current state/height of the Ledger.
95+
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self, block, rng)))]
9496
pub fn check_next_block<R: CryptoRng + Rng>(&self, block: &Block<N>, rng: &mut R) -> Result<()> {
9597
self.check_block_subdag_inner(block, &[])?;
9698
self.check_block_content_inner(block, rng)?;
@@ -226,6 +228,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
226228
///
227229
/// This does not verify that the batches are signed correctly or that the edges are valid
228230
/// (only point to the previous round), as those checks already happened when the node received the batch.
231+
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self, block, previous_blocks)))]
229232
fn check_block_subdag_leaves(&self, block: &Block<N>, previous_blocks: &[PendingBlock<N>]) -> Result<()> {
230233
// Check if the block has a subdag.
231234
let Authority::Quorum(subdag) = block.authority() else {
@@ -276,6 +279,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
276279
/// Check that the certificates in the block subdag have met quorum requirements.
277280
///
278281
/// Called by [`Self::check_block_subdag`]
282+
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self, block)))]
279283
fn check_block_subdag_quorum(&self, block: &Block<N>) -> Result<()> {
280284
// Check if the block has a subdag.
281285
let subdag = match block.authority() {

ledger/src/get.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C> {
5050
}
5151

5252
/// Returns the committee lookback for the given round.
53+
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
5354
pub fn get_committee_lookback_for_round(&self, round: u64) -> Result<Option<Committee<N>>> {
5455
// Get the round number for the previous committee. Note, we subtract 2 from odd rounds,
5556
// because committees are updated in even rounds.

ledger/store/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ edition = "2024"
1919
[features]
2020
default = [ "indexmap/rayon" ]
2121
locktick = [ "dep:locktick", "snarkvm-ledger-puzzle/locktick" ]
22-
rocks = [ "rocksdb", "smallvec", "tracing" ]
22+
rocks = [ "dep:rocksdb", "dep:smallvec", "dep:tracing" ]
2323
serial = [
2424
"snarkvm-console/serial",
2525
"snarkvm-ledger-block/serial",
@@ -39,6 +39,7 @@ wasm = [
3939
"snarkvm-synthesizer-snark/wasm"
4040
]
4141
test = [ ]
42+
tracing = [ "dep:tracing" ]
4243

4344
[dependencies.snarkvm-console]
4445
workspace = true

0 commit comments

Comments
 (0)