cuprated: killswitch and version module (#365)
Some checks are pending
CI / fmt (push) Waiting to run
CI / typo (push) Waiting to run
CI / wasm-32-bit-support (cuprate-epee-encoding) (push) Waiting to run
CI / wasm-32-bit-support (cuprate-fixed-bytes) (push) Waiting to run
CI / wasm-32-bit-support (cuprate-rpc-types) (push) Waiting to run
CI / ci (macos-latest, stable, bash) (push) Waiting to run
CI / ci (ubuntu-latest, stable, bash) (push) Waiting to run
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Waiting to run
Deny / audit (push) Waiting to run
Doc / build (push) Waiting to run
Doc / deploy (push) Blocked by required conditions

* add cuprated skeleton

* fmt and add deny exception

* add main chain batch handler

* add blockchain init

* very rough block manager

* misc changes

* move more config values

* add new tables & types

* add function to fully add an alt block

* resolve current todo!s

* add new requests

* WIP: starting re-orgs

* add last service request

* commit Cargo.lock

* add test

* more docs + cleanup + alt blocks request

* clippy + fmt

* document types

* move tx_fee to helper

* more doc updates

* fmt

* fix imports

* remove config files

* fix merge errors

* fix generated coins

* handle more p2p requests + alt blocks

* clean up handler code

* add function for incoming blocks

* add docs to handler functions

* broadcast new blocks + add commands

* add fluffy block handler

* fix new block handling

* small cleanup

* increase outbound peer count

* fix merge

* clean up the blockchain manger

* add more docs + cleanup imports

* fix typo

* fix doc

* remove unrelated changes

* add `get_objects` handler

* add `get_chain` handler

* add `fluffy_missing_txs` handler

* add `new_fluffy_block` handler

* improve interface globals

* manger -> manager

* enums instead of bools

* move chain service to separate file

* more review fixes

* sort imports + docs

* init config

* init dandelion integration

* add dandelion start function

* finish incoming tx handler

* Add tx blob hash table

* Add missing txpool requests

* handle duplicate stem txs

* check txpool on incoming block

* add request to remove tx in new blocks from the pool

* tell the txpool about incoming blocks

* fix merge

* typos

* remove blockchain height from txpool

* fix merge

* fix merge

* handle incoming txs in p2p request handler

* split sections

* finish initial config.

* fix clap

* misc changes

* fix doc

* fix test & clippy

* fix test 2

* try fix windows

* testing

* testing 2

* fix windows test

* fix windows: the remix.

* Allow `IncomingTxHandler` to be given later

* add p2p clearnet init

* fix build

* misc changes

* review comments

* fix imports

* rename & fix default config file

* fix cargo hack

* enable serde on `cuprate-helper`

* changes from matrix chats

* fix ci

* fix doc

* fix doc test

* doc updates

* more doc updates

* sort imports

* add startup code

* d -> h

* add file logging

* fix stem peer service

* todo

* remove `get_range`

* change usages of `get_range`

* clippy

* cargo update

* fix test + update comment

* manually set numb threads for each pool

* fix address book saves

* add more data to status

* fix config

* cleanup main + logging

* add more info to output when changing log level

* cleanup commands

* fix small issue in block downloader  more misc clean up

* cross block bp(+) batch verification

* add message when syncing is done

* Revert "cross block bp(+) batch verification"

This reverts commit 764c4663a0.

* fix fmt & clippy

* move `io_loop` to commands

* cuprated: killswitch module

* use `const` for major version

* `|| -> !`

* spacing

* fixes

* fixes

* fixes

---------

Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Co-authored-by: Boog900 <boog900@tutanota.com>
This commit is contained in:
hinto-janai 2025-01-21 14:02:10 -05:00 committed by GitHub
parent 4f14452c77
commit 9842535e86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 277 additions and 59 deletions

85
Cargo.lock generated
View file

@ -97,7 +97,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -108,7 +108,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -302,7 +302,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -328,7 +328,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -410,7 +410,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -426,6 +426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd"
dependencies = [
"const_format_proc_macros",
"konst",
]
[[package]]
@ -436,6 +437,7 @@ checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
"unicode-xid",
]
@ -1057,6 +1059,7 @@ dependencies = [
"cuprate-consensus",
"cuprate-consensus-context",
"cuprate-consensus-rules",
"cuprate-constants",
"cuprate-cryptonight",
"cuprate-dandelion-tower",
"cuprate-database",
@ -1131,7 +1134,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1232,7 +1235,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1377,7 +1380,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1792,7 +1795,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1862,6 +1865,21 @@ dependencies = [
"cpufeatures",
]
[[package]]
name = "konst"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330f0e13e6483b8c34885f7e6c9f19b1a7bd449c673fbb948a51c99d66ef74f4"
dependencies = [
"konst_macro_rules",
]
[[package]]
name = "konst_macro_rules"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37"
[[package]]
name = "lazy_static"
version = "1.5.0"
@ -2280,7 +2298,7 @@ dependencies = [
"phf_shared",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2309,7 +2327,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2395,7 +2413,7 @@ checksum = "4ee1c9ac207483d5e7db4940700de86a9aae46ef90c48b57f99fe7edb8345e49"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2544,7 +2562,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2740,7 +2758,7 @@ checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2931,7 +2949,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn",
"syn 2.0.90",
]
[[package]]
@ -2940,6 +2958,17 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.90"
@ -2980,7 +3009,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3029,7 +3058,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3115,7 +3144,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3290,7 +3319,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3462,7 +3491,7 @@ dependencies = [
"log",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"wasm-bindgen-shared",
]
@ -3484,7 +3513,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3566,7 +3595,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3577,7 +3606,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3803,7 +3832,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"synstructure",
]
@ -3825,7 +3854,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3845,7 +3874,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"synstructure",
]
@ -3866,7 +3895,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -3888,5 +3917,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]

View file

@ -9,32 +9,32 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/binaries/cuprated"
[dependencies]
# TODO: after v1.0.0, remove unneeded dependencies.
cuprate-constants = { workspace = true, features = ["build"] }
cuprate-consensus = { workspace = true }
cuprate-fast-sync = { workspace = true }
cuprate-consensus-context = { workspace = true }
cuprate-consensus-rules = { workspace = true }
cuprate-cryptonight = { workspace = true }
cuprate-helper = { workspace = true, features = ["std", "serde", "time"] }
cuprate-epee-encoding = { workspace = true }
cuprate-fixed-bytes = { workspace = true }
cuprate-levin = { workspace = true }
cuprate-wire = { workspace = true }
cuprate-p2p = { workspace = true }
cuprate-p2p-core = { workspace = true }
cuprate-dandelion-tower = { workspace = true, features = ["txpool"] }
cuprate-async-buffer = { workspace = true }
cuprate-address-book = { workspace = true }
cuprate-blockchain = { workspace = true }
cuprate-database-service = { workspace = true, features = ["serde"] }
cuprate-txpool = { workspace = true }
cuprate-database = { workspace = true, features = ["serde"] }
cuprate-pruning = { workspace = true }
cuprate-test-utils = { workspace = true }
cuprate-types = { workspace = true }
cuprate-json-rpc = { workspace = true }
cuprate-rpc-interface = { workspace = true }
cuprate-rpc-types = { workspace = true }
cuprate-consensus-rules = { workspace = true }
cuprate-cryptonight = { workspace = true }
cuprate-helper = { workspace = true, features = ["std", "serde", "time"] }
cuprate-epee-encoding = { workspace = true }
cuprate-fixed-bytes = { workspace = true }
cuprate-levin = { workspace = true }
cuprate-wire = { workspace = true }
cuprate-p2p = { workspace = true }
cuprate-p2p-core = { workspace = true }
cuprate-dandelion-tower = { workspace = true, features = ["txpool"] }
cuprate-async-buffer = { workspace = true }
cuprate-address-book = { workspace = true }
cuprate-blockchain = { workspace = true }
cuprate-database-service = { workspace = true, features = ["serde"] }
cuprate-txpool = { workspace = true }
cuprate-database = { workspace = true, features = ["serde"] }
cuprate-pruning = { workspace = true }
cuprate-test-utils = { workspace = true }
cuprate-types = { workspace = true }
cuprate-json-rpc = { workspace = true }
cuprate-rpc-interface = { workspace = true }
cuprate-rpc-types = { workspace = true }
# TODO: after v1.0.0, remove unneeded dependencies.
anyhow = { workspace = true }
@ -49,7 +49,7 @@ chrono = { workspace = true }
crypto-bigint = { workspace = true }
crossbeam = { workspace = true }
curve25519-dalek = { workspace = true }
const_format = { workspace = true }
const_format = { workspace = true, features = ["all"] }
dashmap = { workspace = true }
dirs = { workspace = true }
futures = { workspace = true }

View file

@ -1,14 +1,15 @@
use std::{io::Write, path::PathBuf, process::exit};
use clap::builder::TypedValueParser;
use serde_json::Value;
use cuprate_helper::network::Network;
use crate::{config::Config, constants::EXAMPLE_CONFIG};
use crate::{config::Config, constants::EXAMPLE_CONFIG, version::CupratedVersionInfo};
/// Cuprate Args.
#[derive(clap::Parser, Debug)]
#[command(version, about)]
#[command(about)]
pub struct Args {
/// The network to run on.
#[arg(
@ -18,15 +19,22 @@ pub struct Args {
.map(|s| s.parse::<Network>().unwrap()),
)]
pub network: Network,
/// The amount of outbound clear-net connections to maintain.
#[arg(long)]
pub outbound_connections: Option<usize>,
/// The PATH of the `cuprated` config file.
#[arg(long)]
pub config_file: Option<PathBuf>,
/// Generate a config file and print it to stdout.
#[arg(long)]
pub generate_config: bool,
/// Print misc version information in JSON.
#[arg(short, long)]
pub version: bool,
}
impl Args {
@ -34,6 +42,13 @@ impl Args {
///
/// May cause the process to [`exit`].
pub fn do_quick_requests(&self) {
if self.version {
let version_info = CupratedVersionInfo::new();
let json = serde_json::to_string_pretty(&version_info).unwrap();
println!("{json}");
exit(0);
}
if self.generate_config {
println!("{EXAMPLE_CONFIG}");
exit(0);

View file

@ -5,14 +5,19 @@ use const_format::formatcp;
/// `cuprated`'s semantic version (`MAJOR.MINOR.PATCH`) as string.
pub const VERSION: &str = clap::crate_version!();
/// Major version number of `cuprated`.
pub const MAJOR_VERSION: &str = env!("CARGO_PKG_VERSION_MAJOR");
/// Major version number of `cuprated`.
pub const MINOR_VERSION: &str = env!("CARGO_PKG_VERSION_MINOR");
/// Patch version number of `cuprated`.
pub const PATCH_VERSION: &str = env!("CARGO_PKG_VERSION_PATCH");
/// [`VERSION`] + the build type.
///
/// If a debug build, the suffix is `-debug`, else it is `-release`.
pub const VERSION_BUILD: &str = if cfg!(debug_assertions) {
formatcp!("{VERSION}-debug")
} else {
formatcp!("{VERSION}-release")
};
pub const VERSION_BUILD: &str = formatcp!("{VERSION}-{}", cuprate_constants::build::BUILD);
/// The panic message used when cuprated encounters a critical service error.
pub const PANIC_CRITICAL_SERVICE_ERROR: &str =
@ -27,6 +32,8 @@ mod test {
#[test]
fn version() {
let semantic_version = format!("{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}");
assert_eq!(VERSION, VERSION);
assert_eq!(VERSION, "0.0.1");
}

View file

@ -0,0 +1,82 @@
//! Killswitch.
//!
//! This module implements code for shutting down `cuprated`
//! after a certain timestamp has passed.
//!
//! The reasoning is twofold:
//! 1. Limiting the effects of any network errors
//! caused by a faulty `cuprated`.
//! 2. To enforce users to update `alpha` builds,
//! if they choose to run them.
//!
//! This behavior is limited to an alpha build;
//! this module will be removed after a stable v1 release.
use std::{process::exit, time::Duration};
use cuprate_helper::time::current_unix_timestamp;
/// Assert that this is not a v1 release and an alpha release.
const _: () = {
const_format::assertcp_ne!(
crate::constants::MAJOR_VERSION,
"1",
"`cuprated` major version is 1, killswitch module should be deleted."
);
};
/// The killswitch activates if the current timestamp is ahead of this timestamp.
///
/// Sat Mar 01 2025 05:00:00 GMT+0000
pub const KILLSWITCH_ACTIVATION_TIMESTAMP: u64 = 1740805200;
/// Check if the system clock is past a certain timestamp,
/// if so, exit the entire program.
fn killswitch() {
/// A timestamp known to have been passed.
///
/// This is an arbitrary timestamp used for
/// sanity checking the system's clock to make
/// sure it is not overly behind.
///
/// Fri Jan 17 2025 14:19:10 GMT+0000
const SYSTEM_CLOCK_SANITY_TIMESTAMP: u64 = 1737123550;
let current_ts = current_unix_timestamp();
// Prints a generic killswitch message.
let print_killswitch_msg = |msg| {
eprintln!("killswitch: {msg}. (current_ts: {current_ts}, killswitch_activation_timestamp: {KILLSWITCH_ACTIVATION_TIMESTAMP}). `cuprated` will now exit. For more details on why this exists, see: <https://github.com/Cuprate/cuprate/pull/365>.");
};
if current_ts < SYSTEM_CLOCK_SANITY_TIMESTAMP {
print_killswitch_msg("The system clock is too far behind and is not reliable to use");
exit(66);
}
if current_ts > KILLSWITCH_ACTIVATION_TIMESTAMP {
print_killswitch_msg("The killswitch activation timestamp for alpha builds has passed.");
exit(88);
}
}
/// Spawn a thread that sleeps until the [`KILLSWITCH_ACTIVATION_TIMESTAMP`] activates.
pub fn init_killswitch() {
// Check if we should exit immediately.
killswitch();
// Else spawn a thread that waits until we should.
std::thread::spawn(|| -> ! {
// Sleep until killswitch activation.
let current_ts = current_unix_timestamp();
let sleep_duration = Duration::from_secs(KILLSWITCH_ACTIVATION_TIMESTAMP - current_ts);
std::thread::sleep(sleep_duration);
// To account for any miscalculated or drifted sleep time,
// loop until the killswitch activates.
loop {
killswitch();
std::thread::sleep(Duration::from_secs(30));
}
});
}

View file

@ -36,14 +36,19 @@ mod blockchain;
mod commands;
mod config;
mod constants;
mod killswitch;
mod logging;
mod p2p;
mod rpc;
mod signals;
mod statics;
mod txpool;
mod version;
fn main() {
// Initialize the killswitch.
killswitch::init_killswitch();
// Initialize global static `LazyLock` data.
statics::init_lazylock_statics();

View file

@ -0,0 +1,73 @@
//! Misc version information about `cuprated`.
use std::fmt::Display;
use serde::{Deserialize, Serialize};
use cuprate_constants::build::{BUILD, COMMIT};
use cuprate_rpc_types::{CORE_RPC_VERSION, CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR};
use cuprate_types::HardFork;
use crate::{
constants::{MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, VERSION},
killswitch::KILLSWITCH_ACTIVATION_TIMESTAMP,
};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct CupratedVersionInfo {
/// `cuprated`'s major version.
major_version: u8,
/// `cuprated`'s minor version.
minor_version: u8,
/// `cuprated`'s patch version.
patch_version: u8,
/// RPC major version (from `monerod`).
rpc_major_version: u32,
/// RPC minor version (from `monerod`).
rpc_minor_version: u32,
/// RPC version (from `monerod`).
rpc_version: u32,
/// The latest hardfork supported.
hardfork: u8,
/// The blockchain database version specific to `cuprated`.
blockchain_db_version: u64,
/// `cuprated`'s semantic version.
semantic_version: &'static str,
/// Build type, either `debug` or `release`.
build: &'static str,
/// Git commit hash of the build.
commit: &'static str,
/// Timestamp at which `cuprated`'s killswitch activates.
killswitch_timestamp: u64,
}
impl CupratedVersionInfo {
/// Generate version info.
pub fn new() -> Self {
Self {
major_version: MAJOR_VERSION.parse().unwrap(),
minor_version: MINOR_VERSION.parse().unwrap(),
patch_version: PATCH_VERSION.parse().unwrap(),
rpc_major_version: CORE_RPC_VERSION_MAJOR,
rpc_minor_version: CORE_RPC_VERSION_MINOR,
rpc_version: CORE_RPC_VERSION,
blockchain_db_version: cuprate_blockchain::DATABASE_VERSION,
hardfork: HardFork::LATEST.as_u8(),
semantic_version: VERSION,
build: BUILD,
commit: COMMIT,
killswitch_timestamp: KILLSWITCH_ACTIVATION_TIMESTAMP,
}
}
}
#[cfg(test)]
mod tests {
use super::CupratedVersionInfo;
/// Tests that [`CupratedVersionInfo`] can be generated.
#[test]
fn new() {
CupratedVersionInfo::new();
}
}

View file

@ -15,6 +15,13 @@
/// ```
pub const COMMIT: &str = core::env!("COMMIT"); // Set in `constants/build.rs`.
/// `debug` if debug build, else `release`.
pub const BUILD: &str = if cfg!(debug_assertions) {
"debug"
} else {
"release"
};
/// `true` if debug build, else `false`.
pub const DEBUG: bool = cfg!(debug_assertions);