Advertise node software version in gossip (#9981)

* Advertise node version in gossip

* Remove solana_clap_utils::version! macro
This commit is contained in:
Michael Vines 2020-05-11 15:02:01 -07:00 committed by GitHub
parent 965204b8e0
commit 2521f75c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 223 additions and 66 deletions

29
Cargo.lock generated
View File

@ -3700,6 +3700,7 @@ dependencies = [
"solana-metrics",
"solana-net-utils",
"solana-sdk",
"solana-version",
]
[[package]]
@ -3790,6 +3791,7 @@ dependencies = [
"solana-net-utils",
"solana-runtime",
"solana-sdk",
"solana-version",
]
[[package]]
@ -3801,6 +3803,7 @@ dependencies = [
"solana-logger",
"solana-net-utils",
"solana-streamer",
"solana-version",
]
[[package]]
@ -3829,6 +3832,7 @@ dependencies = [
"solana-net-utils",
"solana-runtime",
"solana-sdk",
"solana-version",
]
[[package]]
@ -3966,6 +3970,7 @@ dependencies = [
"solana-stake-program",
"solana-storage-program",
"solana-transaction-status",
"solana-version",
"solana-vote-program",
"solana-vote-signer",
"tempfile",
@ -4081,6 +4086,7 @@ dependencies = [
"solana-streamer",
"solana-sys-tuner",
"solana-transaction-status",
"solana-version",
"solana-vote-program",
"solana-vote-signer",
"systemstat",
@ -4131,6 +4137,7 @@ dependencies = [
"solana-net-utils",
"solana-runtime",
"solana-sdk",
"solana-version",
]
[[package]]
@ -4187,6 +4194,7 @@ dependencies = [
"solana-logger",
"solana-metrics",
"solana-sdk",
"solana-version",
"tokio 0.1.22",
"tokio-codec",
]
@ -4208,6 +4216,7 @@ dependencies = [
"solana-sdk",
"solana-stake-program",
"solana-storage-program",
"solana-version",
"solana-vote-program",
"tempfile",
]
@ -4237,6 +4246,7 @@ dependencies = [
"solana-logger",
"solana-net-utils",
"solana-sdk",
"solana-version",
]
[[package]]
@ -4264,6 +4274,7 @@ dependencies = [
"solana-config-program",
"solana-logger",
"solana-sdk",
"solana-version",
"tar",
"tempdir",
"url 2.1.1",
@ -4283,6 +4294,7 @@ dependencies = [
"solana-cli-config",
"solana-remote-wallet",
"solana-sdk",
"solana-version",
"tiny-bip39",
]
@ -4353,6 +4365,7 @@ dependencies = [
"solana-sdk",
"solana-stake-program",
"solana-transaction-status",
"solana-version",
"solana-vote-program",
"tempfile",
]
@ -4410,6 +4423,7 @@ dependencies = [
"serde_json",
"solana-clap-utils",
"solana-logger",
"solana-version",
]
[[package]]
@ -4512,6 +4526,7 @@ dependencies = [
"socket2",
"solana-clap-utils",
"solana-logger",
"solana-version",
"tokio 0.1.22",
"tokio-codec",
]
@ -4742,6 +4757,7 @@ dependencies = [
"solana-sdk",
"solana-stake-program",
"solana-transaction-status",
"solana-version",
"tempfile",
]
@ -4804,6 +4820,7 @@ dependencies = [
"nix",
"solana-clap-utils",
"solana-logger",
"solana-version",
"sysctl",
"unix_socket2",
"users",
@ -4852,10 +4869,20 @@ dependencies = [
"solana-perf",
"solana-runtime",
"solana-sdk",
"solana-version",
"solana-vote-program",
"solana-vote-signer",
]
[[package]]
name = "solana-version"
version = "1.2.0"
dependencies = [
"serde",
"serde_derive",
"solana-sdk",
]
[[package]]
name = "solana-vest-program"
version = "1.2.0"
@ -4900,6 +4927,7 @@ dependencies = [
"solana-clap-utils",
"solana-metrics",
"solana-sdk",
"solana-version",
]
[[package]]
@ -4919,6 +4947,7 @@ dependencies = [
"solana-metrics",
"solana-sdk",
"solana-transaction-status",
"solana-version",
"solana-vote-program",
]

View File

@ -59,6 +59,7 @@ members = [
"transaction-status",
"upload-perf",
"net-utils",
"version",
"vote-signer",
"cli",
"rayon-threadlimit",

View File

@ -17,7 +17,7 @@ solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-archiver-lib = { path = "../archiver-lib", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -24,7 +24,7 @@ fn main() {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("identity_keypair")
.short("i")
@ -105,7 +105,7 @@ fn main() {
println!(
"{} version {} (branch={}, commit={})",
style(crate_name!()).bold(),
solana_clap_utils::version!(),
solana_version::version!(),
option_env!("CI_BRANCH").unwrap_or("unknown"),
option_env!("CI_COMMIT").unwrap_or("unknown")
);

View File

@ -29,6 +29,7 @@ solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-runtime = { path = "../runtime", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[dev-dependencies]
solana-local-cluster = { path = "../local-cluster", version = "1.2.0" }

View File

@ -11,7 +11,7 @@ fn main() {
solana_logger::setup();
solana_metrics::set_panic_hook("bench-exchange");
let matches = cli::build_args(solana_clap_utils::version!()).get_matches();
let matches = cli::build_args(solana_version::version!()).get_matches();
let cli_config = cli::extract_args(&matches);
let cli::Config {

View File

@ -13,6 +13,7 @@ solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-streamer = { path = "../streamer", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -52,7 +52,7 @@ fn main() -> Result<()> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("num-recv-sockets")
.long("num-recv-sockets")

View File

@ -27,6 +27,7 @@ solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-runtime = { path = "../runtime", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-move-loader-program = { path = "../programs/move_loader", version = "1.2.0", optional = true }
solana-version = { path = "../version", version = "1.2.0" }
[dev-dependencies]
serial_test = "0.4.0"

View File

@ -15,7 +15,7 @@ fn main() {
solana_logger::setup_with_default("solana=info");
solana_metrics::set_panic_hook("bench-tps");
let matches = cli::build_args(solana_clap_utils::version!()).get_matches();
let matches = cli::build_args(solana_version::version!()).get_matches();
let cli_config = cli::extract_args(&matches);
let cli::Config {

View File

@ -1,24 +1,5 @@
use thiserror::Error;
#[macro_export]
macro_rules! version {
() => {
&*format!(
"{}{}",
env!("CARGO_PKG_VERSION"),
if option_env!("CI_TAG").unwrap_or("").is_empty() {
format!(
" [channel={} commit={}]",
option_env!("CHANNEL").unwrap_or("unknown"),
option_env!("CI_COMMIT").unwrap_or("unknown"),
)
} else {
"".to_string()
},
)
};
}
pub struct ArgConstant<'a> {
pub long: &'a str,
pub name: &'a str,

View File

@ -41,6 +41,7 @@ solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-stake-program = { path = "../programs/stake", version = "1.2.0" }
solana-storage-program = { path = "../programs/storage", version = "1.2.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
solana-vote-signer = { path = "../vote-signer", version = "1.2.0" }
thiserror = "1.0.15"

View File

@ -156,7 +156,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let matches = app(
crate_name!(),
crate_description!(),
solana_clap_utils::version!(),
solana_version::version!(),
)
.arg({
let arg = Arg::with_name("config_file")

View File

@ -61,6 +61,7 @@ solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-stake-program = { path = "../programs/stake", version = "1.2.0" }
solana-storage-program = { path = "../programs/storage", version = "1.2.0" }
solana-streamer = { path = "../streamer", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
solana-vote-signer = { path = "../vote-signer", version = "1.2.0" }
solana-sys-tuner = { path = "../sys-tuner", version = "1.2.0" }

View File

@ -18,8 +18,8 @@ use crate::{
crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{CrdsFilter, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
crds_value::{
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, SnapshotHash, Vote,
MAX_WALLCLOCK,
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, SnapshotHash,
Version, Vote, MAX_WALLCLOCK,
},
epoch_slots::EpochSlots,
result::{Error, Result},
@ -378,6 +378,7 @@ impl ClusterInfo {
archivers += 1;
}
let node_version = self.get_node_version(&node.id);
if my_shred_version != 0 && (node.shred_version != 0 && node.shred_version != my_shred_version) {
different_shred_nodes += 1;
None
@ -393,10 +394,9 @@ impl ClusterInfo {
"none".to_string()
}
}
let ip_addr = node.gossip.ip();
Some(format!(
"{:15} {:2}| {:5} | {:44} | {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {}\n",
"{:15} {:2}| {:5} | {:44} |{:^15}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {:5}| {}\n",
if ContactInfo::is_valid_address(&node.gossip) {
ip_addr.to_string()
} else {
@ -405,6 +405,11 @@ impl ClusterInfo {
if node.id == my_pubkey { "me" } else { "" }.to_string(),
now.saturating_sub(last_updated),
node.id.to_string(),
if let Some(node_version) = node_version {
node_version.to_string()
} else {
"-".to_string()
},
addr_to_string(&ip_addr, &node.gossip),
addr_to_string(&ip_addr, &node.tpu),
addr_to_string(&ip_addr, &node.tpu_forwards),
@ -412,7 +417,6 @@ impl ClusterInfo {
addr_to_string(&ip_addr, &node.tvu_forwards),
addr_to_string(&ip_addr, &node.repair),
addr_to_string(&ip_addr, &node.serve_repair),
addr_to_string(&ip_addr, &node.storage_addr),
addr_to_string(&ip_addr, &node.rpc),
addr_to_string(&ip_addr, &node.rpc_pubsub),
node.shred_version,
@ -423,9 +427,9 @@ impl ClusterInfo {
format!(
"IP Address |Age(ms)| Node identifier \
|Gossip| TPU |TPUfwd| TVU |TVUfwd|Repair|ServeR|Storag| RPC |PubSub|ShredVer\n\
------------------+-------+----------------------------------------------+\
------+------+------+------+------+------+------+------+------+------+--------\n\
| Version |Gossip| TPU |TPUfwd| TVU |TVUfwd|Repair|ServeR| RPC |PubSub|ShredVer\n\
------------------+-------+----------------------------------------------+---------------+\
------+------+------+------+------+------+------+------+------+--------\n\
{}\
Nodes: {}{}{}{}",
nodes.join(""),
@ -440,7 +444,7 @@ impl ClusterInfo {
} else {
"".to_string()
},
if spy_nodes > 0 {
if different_shred_nodes > 0 {
format!(
"\nNodes with different shred version: {}",
different_shred_nodes
@ -703,6 +707,18 @@ impl ClusterInfo {
(vec, max)
}
pub fn get_node_version(&self, pubkey: &Pubkey) -> Option<solana_version::Version> {
self.gossip
.read()
.unwrap()
.crds
.table
.get(&CrdsValueLabel::Version(*pubkey))
.map(|x| x.value.version())
.flatten()
.map(|version| version.version.clone())
}
/// all validators that have a valid rpc port regardless of `shred_version`.
pub fn all_rpc_peers(&self) -> Vec<ContactInfo> {
self.gossip
@ -1313,6 +1329,9 @@ impl ClusterInfo {
let mut last_contact_info_trace = timestamp();
let mut adopt_shred_version = obj.my_shred_version() == 0;
let recycler = PacketsRecycler::default();
let message = CrdsData::Version(Version::new(obj.id()));
obj.push_message(CrdsValue::new_signed(message, &obj.keypair));
loop {
let start = timestamp();
thread_mem_usage::datapoint("solana-gossip");

View File

@ -75,6 +75,7 @@ pub enum CrdsData {
SnapshotHashes(SnapshotHash),
AccountsHashes(SnapshotHash),
EpochSlots(EpochSlotsIndex, EpochSlots),
Version(Version),
}
impl Sanitize for CrdsData {
@ -101,6 +102,7 @@ impl Sanitize for CrdsData {
}
val.sanitize()
}
CrdsData::Version(version) => version.sanitize(),
}
}
}
@ -206,6 +208,33 @@ impl Vote {
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Version {
pub from: Pubkey,
pub wallclock: u64,
pub version: solana_version::Version,
}
impl Sanitize for Version {
fn sanitize(&self) -> Result<(), SanitizeError> {
if self.wallclock >= MAX_WALLCLOCK {
return Err(SanitizeError::ValueOutOfBounds);
}
self.from.sanitize()?;
self.version.sanitize()
}
}
impl Version {
pub fn new(from: Pubkey) -> Self {
Self {
from,
wallclock: timestamp(),
version: solana_version::Version::default(),
}
}
}
/// Type of the replicated value
/// These are labels for values in a record that is associated with `Pubkey`
#[derive(PartialEq, Hash, Eq, Clone, Debug)]
@ -216,6 +245,7 @@ pub enum CrdsValueLabel {
SnapshotHashes(Pubkey),
EpochSlots(EpochSlotsIndex, Pubkey),
AccountsHashes(Pubkey),
Version(Pubkey),
}
impl fmt::Display for CrdsValueLabel {
@ -227,6 +257,7 @@ impl fmt::Display for CrdsValueLabel {
CrdsValueLabel::SnapshotHashes(_) => write!(f, "SnapshotHash({})", self.pubkey()),
CrdsValueLabel::EpochSlots(ix, _) => write!(f, "EpochSlots({}, {})", ix, self.pubkey()),
CrdsValueLabel::AccountsHashes(_) => write!(f, "AccountsHashes({})", self.pubkey()),
CrdsValueLabel::Version(_) => write!(f, "Version({})", self.pubkey()),
}
}
}
@ -240,6 +271,7 @@ impl CrdsValueLabel {
CrdsValueLabel::SnapshotHashes(p) => *p,
CrdsValueLabel::EpochSlots(_, p) => *p,
CrdsValueLabel::AccountsHashes(p) => *p,
CrdsValueLabel::Version(p) => *p,
}
}
}
@ -257,7 +289,7 @@ impl CrdsValue {
value.sign(keypair);
value
}
/// Totally unsecure unverfiable wallclock of the node that generated this message
/// Totally unsecure unverifiable wallclock of the node that generated this message
/// Latest wallclock is always picked.
/// This is used to time out push messages.
pub fn wallclock(&self) -> u64 {
@ -268,6 +300,7 @@ impl CrdsValue {
CrdsData::SnapshotHashes(hash) => hash.wallclock,
CrdsData::AccountsHashes(hash) => hash.wallclock,
CrdsData::EpochSlots(_, p) => p.wallclock,
CrdsData::Version(version) => version.wallclock,
}
}
pub fn pubkey(&self) -> Pubkey {
@ -278,6 +311,7 @@ impl CrdsValue {
CrdsData::SnapshotHashes(hash) => hash.from,
CrdsData::AccountsHashes(hash) => hash.from,
CrdsData::EpochSlots(_, p) => p.from,
CrdsData::Version(version) => version.from,
}
}
pub fn label(&self) -> CrdsValueLabel {
@ -288,6 +322,7 @@ impl CrdsValue {
CrdsData::SnapshotHashes(_) => CrdsValueLabel::SnapshotHashes(self.pubkey()),
CrdsData::AccountsHashes(_) => CrdsValueLabel::AccountsHashes(self.pubkey()),
CrdsData::EpochSlots(ix, _) => CrdsValueLabel::EpochSlots(*ix, self.pubkey()),
CrdsData::Version(_) => CrdsValueLabel::Version(self.pubkey()),
}
}
pub fn contact_info(&self) -> Option<&ContactInfo> {
@ -338,6 +373,13 @@ impl CrdsValue {
}
}
pub fn version(&self) -> Option<&Version> {
match &self.data {
CrdsData::Version(version) => Some(version),
_ => None,
}
}
/// Return all the possible labels for a record identified by Pubkey.
pub fn record_labels(key: &Pubkey) -> Vec<CrdsValueLabel> {
let mut labels = vec![
@ -345,6 +387,7 @@ impl CrdsValue {
CrdsValueLabel::LowestSlot(*key),
CrdsValueLabel::SnapshotHashes(*key),
CrdsValueLabel::AccountsHashes(*key),
CrdsValueLabel::Version(*key),
];
labels.extend((0..MAX_VOTES).map(|ix| CrdsValueLabel::Vote(ix, *key)));
labels.extend((0..MAX_EPOCH_SLOTS).map(|ix| CrdsValueLabel::EpochSlots(ix, *key)));
@ -395,7 +438,7 @@ mod test {
#[test]
fn test_labels() {
let mut hits = [false; 4 + MAX_VOTES as usize + MAX_EPOCH_SLOTS as usize];
let mut hits = [false; 5 + MAX_VOTES as usize + MAX_EPOCH_SLOTS as usize];
// this method should cover all the possible labels
for v in &CrdsValue::record_labels(&Pubkey::default()) {
match v {
@ -403,9 +446,10 @@ mod test {
CrdsValueLabel::LowestSlot(_) => hits[1] = true,
CrdsValueLabel::SnapshotHashes(_) => hits[2] = true,
CrdsValueLabel::AccountsHashes(_) => hits[3] = true,
CrdsValueLabel::Vote(ix, _) => hits[*ix as usize + 4] = true,
CrdsValueLabel::Version(_) => hits[4] = true,
CrdsValueLabel::Vote(ix, _) => hits[*ix as usize + 5] = true,
CrdsValueLabel::EpochSlots(ix, _) => {
hits[*ix as usize + MAX_VOTES as usize + 4] = true
hits[*ix as usize + MAX_VOTES as usize + 5] = true
}
}
}

View File

@ -1465,7 +1465,7 @@ impl RpcSol for RpcSolImpl {
fn get_version(&self, _: Self::Metadata) -> Result<RpcVersionInfo> {
Ok(RpcVersionInfo {
solana_core: solana_clap_utils::version!().to_string(),
solana_core: solana_version::Version::default().to_string(),
})
}
@ -2628,7 +2628,7 @@ pub mod tests {
let expected = json!({
"jsonrpc": "2.0",
"result": {
"solana-core": solana_clap_utils::version!().to_string()
"solana-core": solana_version::version!().to_string()
},
"id": 1
});

View File

@ -46,7 +46,7 @@ fn test_rpc_client() {
assert_eq!(
client.get_version().unwrap().solana_core,
solana_clap_utils::version!()
solana_version::version!()
);
assert!(client.get_account(&bob_pubkey).is_err());

View File

@ -19,6 +19,7 @@ solana-logger = { path = "../logger", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-runtime = { path = "../runtime", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -94,7 +94,7 @@ fn main() {
solana_logger::setup_with_default("solana=info");
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("entrypoint")
.long("entrypoint")

View File

@ -8,9 +8,6 @@ license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
bincode = "1.2.1"
byteorder = "1.3.4"
@ -23,6 +20,7 @@ solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
tokio = "0.1"
tokio-codec = "0.1"

View File

@ -16,7 +16,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
solana_metrics::set_panic_hook("faucet");
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("keypair")
.short("k")

View File

@ -23,13 +23,13 @@ solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-stake-program = { path = "../programs/stake", version = "1.2.0" }
solana-storage-program = { path = "../programs/storage", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
tempfile = "3.1.0"
[[bin]]
name = "solana-genesis"
path = "src/main.rs"
[lib]
name = "solana_genesis"

View File

@ -128,7 +128,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("creation_time")
.long("creation-time")

View File

@ -16,9 +16,7 @@ solana-client = { path = "../client", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -17,7 +17,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(
SubCommand::with_name("rpc-url")

View File

@ -29,6 +29,7 @@ solana-client = { path = "../client", version = "1.2.0" }
solana-config-program = { path = "../programs/config", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
semver = "0.9.0"
tar = "0.4.26"
tempdir = "0.3.7"

View File

@ -84,7 +84,7 @@ pub fn main() -> Result<(), String> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg({
let arg = Arg::with_name("config_file")
@ -268,7 +268,7 @@ pub fn main_init() -> Result<(), String> {
let matches = App::new("solana-install-init")
.about("initializes a new installation")
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg({
let arg = Arg::with_name("config_file")
.short("c")

View File

@ -17,6 +17,7 @@ solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-cli-config = { path = "../cli-config", version = "1.2.0" }
solana-remote-wallet = { path = "../remote-wallet", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
tiny-bip39 = "0.7.0"
[[bin]]

View File

@ -208,7 +208,7 @@ fn grind_parse_args(
fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg({
let arg = Arg::with_name("config_file")

View File

@ -22,6 +22,7 @@ solana-runtime = { path = "../runtime", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-stake-program = { path = "../programs/stake", version = "1.2.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
tempfile = "3.1.0"

View File

@ -631,7 +631,7 @@ fn main() {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("ledger_path")
.short("l")

View File

@ -16,6 +16,7 @@ serde = "1.0.110"
serde_json = "1.0.53"
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[[bin]]
name = "solana-log-analyzer"

View File

@ -200,7 +200,7 @@ fn main() {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.subcommand(
SubCommand::with_name("iftop")
.about("Process iftop log file")

View File

@ -20,6 +20,7 @@ serde_derive = "1.0.103"
socket2 = "0.3.12"
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
tokio = "0.1"
tokio-codec = "0.1"

View File

@ -3,7 +3,7 @@ use clap::{App, Arg};
fn main() {
solana_logger::setup();
let matches = App::new("solana-ip-address")
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("host_port")
.index(1)

View File

@ -4,7 +4,7 @@ use std::net::{SocketAddr, TcpListener};
fn main() {
solana_logger::setup();
let matches = App::new("solana-ip-address-server")
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("port")
.index(1)

View File

@ -22,6 +22,7 @@ solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-stake-program = { path = "../programs/stake", version = "1.2.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[dev-dependencies]
serial_test = "0.4.0"

View File

@ -119,7 +119,7 @@ fn main() {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.setting(AppSettings::SubcommandRequiredElseHelp)
.arg(
Arg::with_name("data_file")

View File

@ -15,6 +15,7 @@ log = "0.4.8"
libc = "0.2.69"
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-logger = { path = "../logger", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[target."cfg(unix)".dependencies]
unix_socket2 = "0.5.4"

View File

@ -101,7 +101,7 @@ fn main() {
solana_logger::setup();
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("user")
.long("user")

View File

@ -27,6 +27,7 @@ solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-net-utils = { path = "../net-utils", version = "1.2.0" }
solana-runtime = { path = "../runtime", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
solana-vote-signer = { path = "../vote-signer", version = "1.2.0" }

View File

@ -472,7 +472,7 @@ pub fn main() {
let default_genesis_archive_unpacked_size = &MAX_GENESIS_ARCHIVE_UNPACKED_SIZE.to_string();
let matches = App::new(crate_name!()).about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name(SKIP_SEED_PHRASE_VALIDATION_ARG.name)
.long(SKIP_SEED_PHRASE_VALIDATION_ARG.long)
@ -1017,7 +1017,7 @@ pub fn main() {
env::set_var("RUST_BACKTRACE", "1")
}
info!("{} {}", crate_name!(), solana_clap_utils::version!());
info!("{} {}", crate_name!(), solana_version::version!());
info!("Starting validator with: {:#?}", std::env::args_os());
solana_metrics::set_host_id(identity_keypair.pubkey().to_string());

2
version/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target/
/farf/

20
version/Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "solana-version"
version = "1.2.0"
description = "Solana Version"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
serde = "1.0.110"
serde_derive = "1.0.103"
solana-sdk = { path = "../sdk", version = "1.2.0" }
[lib]
name = "solana_version"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

49
version/src/lib.rs Normal file
View File

@ -0,0 +1,49 @@
extern crate serde_derive;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::sanitize::Sanitize;
use std::fmt;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Version {
major: u16,
minor: u16,
patch: u16,
commit: Option<u32>, // first 4 bytes of the sha1 commit hash
}
impl Default for Version {
fn default() -> Self {
Self {
major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(),
minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(),
patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(),
commit: option_env!("CI_COMMIT")
.map(|sha1| u32::from_str_radix(&sha1[..8], 16).unwrap()),
}
}
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}.{}.{} {}",
self.major,
self.minor,
self.patch,
match self.commit {
None => "devbuild".to_string(),
Some(commit) => format!("{:08x}", commit),
}
)
}
}
impl Sanitize for Version {}
#[macro_export]
macro_rules! version {
() => {
&*format!("{}", $crate::Version::default())
};
}

View File

@ -18,6 +18,7 @@ serde_json = "1.0.53"
solana-clap-utils = { path = "../clap-utils", version = "1.2.0" }
solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
[lib]
crate-type = ["lib"]

View File

@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.arg(
Arg::with_name("port")
.long("port")

View File

@ -22,6 +22,7 @@ solana-logger = { path = "../logger", version = "1.2.0" }
solana-metrics = { path = "../metrics", version = "1.2.0" }
solana-sdk = { path = "../sdk", version = "1.2.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.2.0" }
solana-version = { path = "../version", version = "1.2.0" }
solana-vote-program = { path = "../programs/vote", version = "1.2.0" }
[[bin]]

View File

@ -38,7 +38,7 @@ struct Config {
fn get_config() -> Config {
let matches = App::new(crate_name!())
.about(crate_description!())
.version(solana_clap_utils::version!())
.version(solana_version::version!())
.after_help("ADDITIONAL HELP:
To receive a Slack, Discord and/or Telegram notification on sanity failure,
define environment variables before running `solana-watchtower`: