Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 2c8d6f8

Browse files
author
Tyera Eulberg
authored
Add validator-info CLI (#4970)
* Add validator-info CLI * Add GetProgramAccounts method to solana-client * Update validator-info args, and add get subcommand * Update ValidatorInfo lengths * Add account filter for get --all * Update testnet participation doc to reflect validator-info * Flesh out tests * Review comments
1 parent 08f6de0 commit 2c8d6f8

File tree

9 files changed

+580
-0
lines changed

9 files changed

+580
-0
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ members = [
4343
"runtime",
4444
"sdk",
4545
"upload-perf",
46+
"validator-info",
4647
"vote-signer",
4748
"wallet",
4849
]

book/src/testnet-participation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,18 @@ A local InfluxDB and Grafana instance is now running on your machine. Define
240240
`start.sh` output and restart your validator.
241241

242242
Metrics should now be streaming and visible from your local Grafana dashboard.
243+
244+
#### Publishing Validator Info
245+
246+
You can publish your validator information to the chain to be publicly visible
247+
to other users.
248+
249+
Run the solana-validator-info CLI to populate a validator-info account:
250+
```bash
251+
$ solana-validator-info publish -k ~/validator-keypair.json <VALIDATOR_INFO_ARGS>
252+
```
253+
Available fields for VALIDATOR_INFO_ARGS:
254+
* Name (required)
255+
* Website
256+
* Keybase ID
257+
* Details

client/src/rpc_client.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,40 @@ impl RpcClient {
274274
self.get_account(pubkey).map(|account| account.lamports)
275275
}
276276

277+
pub fn get_program_accounts(&self, pubkey: &Pubkey) -> io::Result<Vec<(Pubkey, Account)>> {
278+
let params = json!([format!("{}", pubkey)]);
279+
let response = self
280+
.client
281+
.send(&RpcRequest::GetProgramAccounts, Some(params), 0)
282+
.map_err(|err| {
283+
io::Error::new(
284+
io::ErrorKind::Other,
285+
format!("AccountNotFound: pubkey={}: {}", pubkey, err),
286+
)
287+
})?;
288+
289+
let accounts: Vec<(String, Account)> =
290+
serde_json::from_value::<Vec<(String, Account)>>(response).map_err(|err| {
291+
io::Error::new(
292+
io::ErrorKind::Other,
293+
format!("GetProgramAccounts parse failure: {:?}", err),
294+
)
295+
})?;
296+
println!("{:?}", accounts);
297+
298+
let mut pubkey_accounts: Vec<(Pubkey, Account)> = Vec::new();
299+
for (string, account) in accounts.into_iter() {
300+
let pubkey = string.parse().map_err(|err| {
301+
io::Error::new(
302+
io::ErrorKind::Other,
303+
format!("GetProgramAccounts parse failure: {:?}", err),
304+
)
305+
})?;
306+
pubkey_accounts.push((pubkey, account));
307+
}
308+
Ok(pubkey_accounts)
309+
}
310+
277311
/// Request the transaction count. If the response packet is dropped by the network,
278312
/// this method will try again 5 times.
279313
pub fn get_transaction_count(&self) -> io::Result<u64> {

client/src/rpc_request.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub enum RpcRequest {
1010
GetBalance,
1111
GetClusterNodes,
1212
GetNumBlocksSinceSignatureConfirmation,
13+
GetProgramAccounts,
1314
GetRecentBlockhash,
1415
GetSignatureStatus,
1516
GetSlot,
@@ -39,6 +40,7 @@ impl RpcRequest {
3940
RpcRequest::GetNumBlocksSinceSignatureConfirmation => {
4041
"getNumBlocksSinceSignatureConfirmation"
4142
}
43+
RpcRequest::GetProgramAccounts => "getProgramAccounts",
4244
RpcRequest::GetRecentBlockhash => "getRecentBlockhash",
4345
RpcRequest::GetSignatureStatus => "getSignatureStatus",
4446
RpcRequest::GetSlot => "getSlot",

scripts/cargo-install-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ BIN_CRATES=(
3838
ledger-tool
3939
replicator
4040
validator
41+
validator-info
4142
wallet
4243
bench-exchange
4344
bench-tps

validator-info/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

validator-info/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "solana-validator-info"
3+
version = "0.17.0"
4+
description = "Solana validator registration tool"
5+
authors = ["Solana Maintainers <maintainers@solana.com>"]
6+
repository = "https://github.com/solana-labs/solana"
7+
license = "Apache-2.0"
8+
homepage = "https://solana.com/"
9+
edition = "2018"
10+
11+
[features]
12+
cuda = []
13+
14+
15+
[dependencies]
16+
bincode = "1.1.4"
17+
clap = "2.33"
18+
dirs = "2.0.1"
19+
serde = "1.0.94"
20+
serde_derive = "1.0.94"
21+
serde_json = "1.0.40"
22+
solana-client = { path = "../client", version = "0.17.0" }
23+
solana-config-api = { path = "../programs/config_api", version = "0.17.0" }
24+
solana-sdk = { path = "../sdk", version = "0.17.0" }
25+
url = "1.7.2"
26+
27+
[[bin]]
28+
name = "solana-validator-info"
29+
path = "src/validator_info.rs"

0 commit comments

Comments
 (0)