Add feature set identifier to gossiped version information

This commit is contained in:
Michael Vines
2020-09-21 19:54:43 -07:00
parent 93259f0bae
commit 35f5f9fc7b
8 changed files with 128 additions and 28 deletions

View File

@@ -1945,14 +1945,19 @@ impl RpcSol for RpcSolImpl {
if my_shred_version == contact_info.shred_version
&& ContactInfo::is_valid_address(&contact_info.gossip)
{
let (version, feature_set) =
if let Some(version) = cluster_info.get_node_version(&contact_info.id) {
(Some(version.to_string()), Some(version.feature_set))
} else {
(None, None)
};
Some(RpcContactInfo {
pubkey: contact_info.id.to_string(),
gossip: Some(contact_info.gossip),
tpu: valid_address_or_none(&contact_info.tpu),
rpc: valid_address_or_none(&contact_info.rpc),
version: cluster_info
.get_node_version(&contact_info.id)
.map(|v| v.to_string()),
version,
feature_set,
})
} else {
None // Exclude spy nodes
@@ -2299,8 +2304,10 @@ impl RpcSol for RpcSolImpl {
fn get_version(&self, _: Self::Metadata) -> Result<RpcVersionInfo> {
debug!("get_version rpc request received");
let version = solana_version::Version::default();
Ok(RpcVersionInfo {
solana_core: solana_version::Version::default().to_string(),
solana_core: version.to_string(),
feature_set: Some(version.feature_set),
})
}
@@ -2843,7 +2850,7 @@ pub mod tests {
.expect("actual response deserialization");
let expected = format!(
r#"{{"jsonrpc":"2.0","result":[{{"pubkey": "{}", "gossip": "127.0.0.1:1235", "tpu": "127.0.0.1:1234", "rpc": "127.0.0.1:{}", "version": null}}],"id":1}}"#,
r#"{{"jsonrpc":"2.0","result":[{{"pubkey": "{}", "gossip": "127.0.0.1:1235", "tpu": "127.0.0.1:1234", "rpc": "127.0.0.1:{}", "version": null, "featureSet": null}}],"id":1}}"#,
leader_pubkey,
rpc_port::DEFAULT_RPC_PORT
);
@@ -4394,10 +4401,12 @@ pub mod tests {
let req = r#"{"jsonrpc":"2.0","id":1,"method":"getVersion"}"#;
let res = io.handle_request_sync(&req, meta);
let version = solana_version::Version::default();
let expected = json!({
"jsonrpc": "2.0",
"result": {
"solana-core": solana_version::version!().to_string()
"solana-core": version.to_string(),
"feature-set": version.feature_set,
},
"id": 1
});