From 29620287f4ccea6f5ca7ca0b2b71e14ba21b4a4d Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Tue, 29 Nov 2022 09:34:15 +0200 Subject: [PATCH] feat: log app version on startup (#4970) * Log base_node and FFI version on startup * clippy --- applications/tari_base_node/src/main.rs | 7 ++++++- .../output_manager_service/storage/sqlite_db/mod.rs | 2 +- base_layer/wallet_ffi/Cargo.toml | 1 + base_layer/wallet_ffi/build.rs | 5 +++++ base_layer/wallet_ffi/src/lib.rs | 10 ++++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/applications/tari_base_node/src/main.rs b/applications/tari_base_node/src/main.rs index d1b4bbc9b9..e0c5d1395d 100644 --- a/applications/tari_base_node/src/main.rs +++ b/applications/tari_base_node/src/main.rs @@ -73,7 +73,7 @@ use std::{process, sync::Arc}; use clap::Parser; use log::*; -use tari_app_utilities::{identity_management::setup_node_identity, utilities::setup_runtime}; +use tari_app_utilities::{consts, identity_management::setup_node_identity, utilities::setup_runtime}; use tari_base_node::{cli::Cli, run_base_node_with_cli, ApplicationConfig}; use tari_common::{exit_codes::ExitError, initialize_logging, load_configuration}; use tari_comms::peer_manager::PeerFeatures; @@ -111,6 +111,11 @@ fn main_inner() -> Result<(), ExitError> { &cli.common.log_config_path("base_node"), include_str!("../log4rs_sample.yml"), )?; + info!( + target: LOG_TARGET, + "Starting Tari Base Node version: {}", + consts::APP_VERSION + ); let mut config = ApplicationConfig::load_from(&cfg)?; if let Some(network) = cli.network { diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs index a581d30496..0158b4b86d 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs @@ -1512,7 +1512,7 @@ mod test { let cipher = XChaCha20Poly1305::new(key_ga); let (_, uo) = make_input(MicroTari::from(100 + OsRng.next_u64() % 1000)); - let decrypted_spending_key = uo.spending_key.clone().to_vec(); + let decrypted_spending_key = uo.spending_key.to_vec(); let uo = DbUnblindedOutput::from_unblinded_output(uo, &factories, None, OutputSource::Unknown).unwrap(); diff --git a/base_layer/wallet_ffi/Cargo.toml b/base_layer/wallet_ffi/Cargo.toml index aa0dbfeaa2..3e4a42606a 100644 --- a/base_layer/wallet_ffi/Cargo.toml +++ b/base_layer/wallet_ffi/Cargo.toml @@ -56,3 +56,4 @@ tari_service_framework = { path = "../../base_layer/service_framework" } [build-dependencies] cbindgen = "0.24.3" +tari_common = { path = "../../common", features = ["build", "static-application-info"] } diff --git a/base_layer/wallet_ffi/build.rs b/base_layer/wallet_ffi/build.rs index 29e32918c4..3e0fe81495 100644 --- a/base_layer/wallet_ffi/build.rs +++ b/base_layer/wallet_ffi/build.rs @@ -4,10 +4,15 @@ use std::{env, path::PathBuf}; use cbindgen::{Config, ExportConfig, Language, ParseConfig, Style}; +use tari_common::build::StaticApplicationInfo; fn main() { let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + // generate version info + let gen = StaticApplicationInfo::initialize().unwrap(); + gen.write_consts_to_outdir("consts.rs").unwrap(); + // let package_name = env::var("CARGO_PKG_NAME").unwrap(); let output_file = PathBuf::from(&crate_dir).join("wallet.h").display().to_string(); diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index 73a120c31f..e4c79201db 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -177,6 +177,11 @@ mod error; mod output_manager_service_mock; mod tasks; +mod consts { + // Import the auto-generated const values from the Manifest and Git + include!(concat!(env!("OUT_DIR"), "/consts.rs")); +} + const LOG_TARGET: &str = "wallet_ffi"; pub type TariTransportConfig = tari_p2p::TransportConfig; @@ -4296,6 +4301,11 @@ pub unsafe extern "C" fn wallet_create( return ptr::null_mut(); } } + info!( + target: LOG_TARGET, + "Starting Tari Wallet FFI version: {}", + consts::APP_VERSION + ); let passphrase_option = if passphrase.is_null() { None