Skip to content

Commit 5fab220

Browse files
committed
feat: add default version to version_string function
1 parent 38ae702 commit 5fab220

File tree

9 files changed

+27
-25
lines changed

9 files changed

+27
-25
lines changed

docs/release-process.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
6464
- Add cherry-picked commits to the `feat/X.Y.Z.A.n-pr_number` branch
6565
- Merge `feat/X.Y.Z.A.n-pr_number` into `release/X.Y.Z.A.n`.
6666

67-
4. Open a PR to update the [CHANGELOG](../CHANGELOG.md) file in the `release/X.Y.Z.A.n` branch.
67+
4. Open a PR to update the [CHANGELOG](../CHANGELOG.md) and [stackslib/src/lib.rs](../stackslib/src/lib.rs) files in the `release/X.Y.Z.A.n` branch.
6868

6969
- Create a chore branch from `release/X.Y.Z.A.n`, ex: `chore/X.Y.Z.A.n-changelog`.
7070
- Add summaries of all Pull Requests to the `Added`, `Changed` and `Fixed` sections.
71+
- Update the `STACKS_VERSION` string in [stackslib/src/lib.rs](../stackslib/src/lib.rs) to match this release.
7172

7273
- Pull requests merged into `develop` can be found [here](https://github.com/stacks-network/stacks-core/pulls?q=is%3Apr+is%3Aclosed+base%3Adevelop+sort%3Aupdated-desc).
7374

libsigner/src/libsigner.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ pub use crate::runloop::{RunningSigner, Signer, SignerRunLoop};
6363
pub use crate::session::{SignerSession, StackerDBSession};
6464
pub use crate::signer_set::{Error as ParseSignerEntriesError, SignerEntries};
6565

66+
/// The version string for the signer
67+
pub const SIGNER_VERSION: &str = "3.0.0.0.0.1";
68+
6669
/// A trait for message slots used for signer communication
6770
pub trait MessageSlotID: Sized + Eq + Hash + Debug + Copy {
6871
/// The contract identifier for the message slot in stacker db
@@ -80,7 +83,16 @@ pub trait SignerMessage<T: MessageSlotID>: StacksMessageCodec {
8083
lazy_static! {
8184
/// The version string for the signer
8285
pub static ref VERSION_STRING: String = {
83-
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
86+
let pkg_version = option_env!("STACKS_NODE_VERSION").or(Some(SIGNER_VERSION));
8487
version_string("stacks-signer", pkg_version)
8588
};
8689
}
90+
91+
#[test]
92+
fn test_version_string() {
93+
let version = VERSION_STRING.to_string();
94+
assert_eq!(
95+
version.contains(format!("stacks-signer {}", SIGNER_VERSION).as_str()),
96+
true
97+
);
98+
}

stacks-signer/release-process.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ The timing of the next Stacking cycle can be found [here](https://stx.eco/dao/to
6363
- Add cherry-picked commits to the `feat/signer-X.Y.Z.A.n.x-pr_number` branch
6464
- Merge `feat/signer-X.Y.Z.A.n.x-pr_number` into `release/signer-X.Y.Z.A.n.x`.
6565

66-
4. Open a PR to update the [CHANGELOG](./CHANGELOG.md) file in the `release/signer-X.Y.Z.A.n.x` branch.
66+
4. Open a PR to update the [CHANGELOG](./CHANGELOG.md) and [libsigner/src/libsigner.rs](../libsigner/src/libsigner.rs) files in the `release/signer-X.Y.Z.A.n.x` branch.
6767

6868
- Create a chore branch from `release/signer-X.Y.Z.A.n.x`, ex: `chore/signer-X.Y.Z.A.n.x-changelog`.
6969
- Add summaries of all Pull Requests to the `Added`, `Changed` and `Fixed` sections.
70+
- Update the `SIGNER_VERSION` string in [libsigner/src/libsigner.rs](../libsigner/src/libsigner.rs) to match this release.
7071

7172
- Pull requests merged into `develop` can be found [here](https://github.com/stacks-network/stacks-core/pulls?q=is%3Apr+is%3Aclosed+base%3Adevelop+sort%3Aupdated-desc).
7273

stackslib/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ const BUILD_TYPE: &'static str = "debug";
7878
#[cfg(not(debug_assertions))]
7979
const BUILD_TYPE: &'static str = "release";
8080

81-
pub fn version_string(pkg_name: &str, pkg_version: &str) -> String {
81+
/// The version string for the stackslib
82+
pub const STACKS_VERSION: &str = "3.0.0.0.0";
83+
84+
pub fn version_string(pkg_name: &str, pkg_version: Option<&str>) -> String {
85+
let pkg_version = pkg_version.unwrap_or(STACKS_VERSION);
8286
let git_branch = GIT_BRANCH
8387
.map(|x| format!("{}", x))
8488
.unwrap_or("".to_string());

stackslib/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fn main() {
260260
"{}",
261261
&blockstack_lib::version_string(
262262
option_env!("CARGO_PKG_NAME").unwrap_or(&argv[0]),
263-
option_env!("CARGO_PKG_VERSION").unwrap_or("0.0.0.0")
263+
option_env!("STACKS_NODE_VERSION")
264264
)
265265
);
266266
process::exit(0);

stackslib/src/net/api/getinfo.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,7 @@ impl RPCPeerInfoData {
111111
coinbase_height: u64,
112112
ibd: bool,
113113
) -> RPCPeerInfoData {
114-
let server_version = version_string(
115-
"stacks-node",
116-
option_env!("STACKS_NODE_VERSION")
117-
.or(option_env!("CARGO_PKG_VERSION"))
118-
.unwrap_or("0.0.0.0"),
119-
);
114+
let server_version = version_string("stacks-node", option_env!("STACKS_NODE_VERSION"));
120115
let (unconfirmed_tip, unconfirmed_seq) = match chainstate.unconfirmed_state {
121116
Some(ref unconfirmed) => {
122117
if unconfirmed.num_mined_txs() > 0 {

stackslib/src/net/api/getstxtransfercost.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use crate::net::httpcore::{
4242
};
4343
use crate::net::p2p::PeerNetwork;
4444
use crate::net::{Error as NetError, HttpServerError, StacksNodeState};
45-
use crate::version_string;
4645

4746
pub(crate) const SINGLESIG_TX_TRANSFER_LEN: u64 = 180;
4847

testnet/stacks-node/src/main.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,7 @@ fn main() {
444444
}
445445

446446
fn version() -> String {
447-
stacks::version_string(
448-
"stacks-node",
449-
option_env!("STACKS_NODE_VERSION")
450-
.or(option_env!("CARGO_PKG_VERSION"))
451-
.unwrap_or("0.0.0.0"),
452-
)
447+
stacks::version_string("stacks-node", option_env!("STACKS_NODE_VERSION"))
453448
}
454449

455450
fn print_help() {
@@ -467,7 +462,7 @@ SUBCOMMANDS:
467462
468463
mainnet\t\tStart a node that will join and stream blocks from the public mainnet.
469464
470-
mocknet\t\tStart a node based on a fast local setup emulating a burnchain. Ideal for smart contract development.
465+
mocknet\t\tStart a node based on a fast local setup emulating a burnchain. Ideal for smart contract development.
471466
472467
helium\t\tStart a node based on a local setup relying on a local instance of bitcoind.
473468
\t\tThe following bitcoin.conf is expected:

testnet/stacks-node/src/neon_node.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,12 +2249,7 @@ impl BlockMinerThread {
22492249
/// Only used in mock signing to generate a peer info view
22502250
fn generate_peer_info(&self) -> PeerInfo {
22512251
// Create a peer info view of the current state
2252-
let server_version = version_string(
2253-
"stacks-node",
2254-
option_env!("STACKS_NODE_VERSION")
2255-
.or(option_env!("CARGO_PKG_VERSION"))
2256-
.unwrap_or("0.0.0.0"),
2257-
);
2252+
let server_version = version_string("stacks-node", option_env!("STACKS_NODE_VERSION"));
22582253
let stacks_tip_height = self.burn_block.canonical_stacks_tip_height;
22592254
let stacks_tip = self.burn_block.canonical_stacks_tip_hash;
22602255
let stacks_tip_consensus_hash = self.burn_block.canonical_stacks_tip_consensus_hash;

0 commit comments

Comments
 (0)