Skip to content

Commit 9c11fd6

Browse files
committed
feat: better exposing of signer version
1 parent 609ad13 commit 9c11fd6

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

stacks-signer/src/cli.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use clarity::util::hash::Sha256Sum;
2929
use clarity::util::secp256k1::MessageSignature;
3030
use clarity::vm::types::{QualifiedContractIdentifier, TupleData};
3131
use clarity::vm::Value;
32-
use lazy_static::lazy_static;
3332
use serde::{Deserialize, Serialize};
3433
use stacks_common::address::{
3534
b58, AddressHashMode, C32_ADDRESS_VERSION_MAINNET_MULTISIG,
@@ -39,31 +38,9 @@ use stacks_common::address::{
3938
use stacks_common::define_u8_enum;
4039
use stacks_common::types::chainstate::StacksPrivateKey;
4140

42-
extern crate alloc;
41+
use crate::VERSION_STRING;
4342

44-
const GIT_BRANCH: Option<&'static str> = option_env!("GIT_BRANCH");
45-
const GIT_COMMIT: Option<&'static str> = option_env!("GIT_COMMIT");
46-
#[cfg(debug_assertions)]
47-
const BUILD_TYPE: &str = "debug";
48-
#[cfg(not(debug_assertions))]
49-
const BUILD_TYPE: &str = "release";
50-
51-
lazy_static! {
52-
static ref VERSION_STRING: String = {
53-
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
54-
let git_branch = GIT_BRANCH.unwrap_or("");
55-
let git_commit = GIT_COMMIT.unwrap_or("");
56-
format!(
57-
"{} ({}:{}, {} build, {} [{}])",
58-
pkg_version,
59-
git_branch,
60-
git_commit,
61-
BUILD_TYPE,
62-
std::env::consts::OS,
63-
std::env::consts::ARCH
64-
)
65-
};
66-
}
43+
extern crate alloc;
6744

6845
#[derive(Parser, Debug)]
6946
#[command(author, version, about)]

stacks-signer/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ mod tests;
4848
use std::fmt::{Debug, Display};
4949
use std::sync::mpsc::{channel, Receiver, Sender};
5050

51+
use blockstack_lib::version_string;
5152
use chainstate::SortitionsView;
5253
use config::GlobalConfig;
54+
use lazy_static::lazy_static;
5355
use libsigner::{SignerEvent, SignerEventReceiver, SignerEventTrait};
5456
use runloop::SignerResult;
5557
use slog::{slog_info, slog_warn};
@@ -59,6 +61,14 @@ use crate::client::StacksClient;
5961
use crate::config::SignerConfig;
6062
use crate::runloop::RunLoop;
6163

64+
lazy_static! {
65+
/// The version string for the signer
66+
pub static ref VERSION_STRING: String = {
67+
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
68+
version_string("stacks-signer", pkg_version)
69+
};
70+
}
71+
6272
/// A trait which provides a common `Signer` interface for `v0` and `v1`
6373
pub trait Signer<T: SignerEventTrait>: Debug + Display {
6474
/// Create a new `Signer` instance
@@ -113,6 +123,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SpawnedSigner
113123
/// Create a new spawned signer
114124
pub fn new(config: GlobalConfig) -> Self {
115125
let endpoint = config.endpoint;
126+
info!("Stacks signer version {:?}", VERSION_STRING.as_str());
116127
info!("Starting signer with config: {:?}", config);
117128
warn!(
118129
"Reminder: The signer is primarily designed for use with a local or subnet network stacks node. \

stacks-signer/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use stacks_signer::config::GlobalConfig;
4747
use stacks_signer::monitor_signers::SignerMonitor;
4848
use stacks_signer::utils::stackerdb_session;
4949
use stacks_signer::v0::SpawnedSigner;
50+
use stacks_signer::VERSION_STRING;
5051
use tracing_subscriber::prelude::*;
5152
use tracing_subscriber::{fmt, EnvFilter};
5253

@@ -157,7 +158,11 @@ fn handle_generate_stacking_signature(
157158

158159
fn handle_check_config(args: RunSignerArgs) {
159160
let config = GlobalConfig::try_from(&args.config).unwrap();
160-
println!("Config: {}", config);
161+
println!(
162+
"Signer version: {}\nConfig: \n{}",
163+
VERSION_STRING.to_string(),
164+
config
165+
);
161166
}
162167

163168
fn handle_generate_vote(args: GenerateVoteArgs, do_print: bool) -> MessageSignature {

stacks-signer/src/monitoring/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::client::{ClientError, StacksClient};
2828
use crate::config::{GlobalConfig, Network};
2929
use crate::monitoring::prometheus::gather_metrics_string;
3030
use crate::monitoring::{update_signer_nonce, update_stacks_tip_height};
31+
use crate::VERSION_STRING;
3132

3233
#[derive(thiserror::Error, Debug)]
3334
/// Monitoring server errors
@@ -215,6 +216,7 @@ impl MonitoringServer {
215216
"signerPublicKey": to_hex(&self.public_key.to_bytes_compressed()),
216217
"network": self.network.to_string(),
217218
"stxAddress": self.stacks_client.get_signer_address().to_string(),
219+
"version": VERSION_STRING.to_string(),
218220
}))
219221
.expect("Failed to serialize JSON")
220222
}

0 commit comments

Comments
 (0)