Cargo.toml

Overview

This file is a Cargo manifest file used by the Rust package manager, Cargo, to define the configuration, dependencies, features, and metadata for the Rust package named node. It specifies the package details, its dependencies (both workspace and external), build instructions, development dependencies, conditional dependencies based on target OS, and feature flags that enable or disable various capabilities within the package.

The primary purpose of this file is to orchestrate the compilation and packaging process for the node crate by declaring all necessary components and configurations. It plays a critical role in managing dependencies and build features, ensuring that compilation is reproducible and consistent across different environments.

Package Section

[package]
name = "node"
version = "0.10.1"
edition.workspace = true
rust-version.workspace = true
build = 'build.rs'
license-file.workspace = true

The use of .workspace suffixes in keys means these values are delegated to the workspace root Cargo.toml file, enabling centralized configuration.

Dependencies Section

[dependencies]
anyhow.workspace = true
bincode.workspace = true
...
wasmtime.workspace = true

account-inbox = { path = "./libs/account-inbox" }
aerospike = "1.3.0"
cached = "0.56.0"
...
typed-builder = "0.20.0"
weak-table = "0.3.2"

Target-Specific Dependencies

[target.'cfg(not(target_os = "windows"))'.dependencies]
sha2 = { version = "0.10.8", features = ["asm"] }

[target.'cfg(target_os = "windows")'.dependencies]
sha2 = { version = "0.10.8" }

Development Dependencies

[dev-dependencies]
criterion = "0.5.1"
migration-tool.workspace = true
mockall = "0.11.4"
tempfile = "3.14.0"
testdir = "0.9.3"

Features Section

[features]
default = [
    "fail-fast",
    "deadlock-detection",
    "delay-references",
    "sync_files",
    "rayon_affinity",
    "messages_db",
    "monitor-accounts-number",
    "disable_db_for_messages",
]
use_automocks = []
allow-dappid-thread-split = []
...
monitor-accounts-number = []

Benchmarks Section

[[bench]]
name = "on_block_finalized"
harness = false

Package Metadata

[package.metadata.cargo-machete]
ignored = ["failure"]

Important Implementation Details

Interaction with Other Parts of the System

Visual Diagram

flowchart TD
Package["Package: node"]
BuildScript["build.rs"]
Dependencies["Dependencies"]
DevDependencies["Dev Dependencies"]
Features["Features"]
Benchmarks["Benchmarks"]
Metadata["Package Metadata"]
Package --> BuildScript
Package --> Dependencies
Package --> DevDependencies
Package --> Features
Package --> Benchmarks
Package --> Metadata
Dependencies --> WorkspaceDeps["Workspace Dependencies (e.g. anyhow, bincode)"]
Dependencies --> ExternalDeps["External Dependencies (e.g. aerospike, reqwest)"]
Dependencies --> TargetDeps["Target-specific Dependencies (sha2)"]
Features --> DefaultFeatures["Default Feature Set"]
Features --> OptionalFeatures["Optional Feature Flags"]
DevDependencies --> TestingDeps["Testing (mockall, testdir)"]
DevDependencies --> BenchmarkDeps["Benchmarking (criterion)"]
DevDependencies --> MigrationDeps["Migration Tool"]
Benchmarks --> CustomBench["on_block_finalized"]
Metadata --> CargoMachete["cargo-machete ignored crates"]

This flowchart illustrates the hierarchical organization of the manifest file sections and their key components, highlighting the relationships between package metadata, dependencies, features, and development tools.