Skip to content

Commit 9c88279

Browse files
committed
reformat and update readme
1 parent 3505f2e commit 9c88279

File tree

4 files changed

+68
-38
lines changed

4 files changed

+68
-38
lines changed

Diff for: README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ In Validator Lab we can deploy and test new validator features quickly and easil
99

1010
## How to run
1111

12+
### Requirements
13+
1) Docker. Create `docker` group add user to `docker` group
14+
```
15+
sudo usermod -aG docker $USER
16+
newgrp docker
17+
```
18+
2) jq
19+
```
20+
sudo apt install jq
21+
```
22+
1223
### Setup
1324
Ensure you have the proper permissions to connect to the Monogon Kubernetes endpoint. Reach out to Leo on slack if you need the key (you do if you haven't asked him in the past).
1425

@@ -107,6 +118,10 @@ For client Version >= 2.0.0
107118
--bench-tps-args 'tx-count=5000 keypair-multiplier=4 threads=16 num-lamports-per-account=200000000 sustained tpu-connection-pool-size=8 thread-batch-sleep-ms=0 commitment-config=processed'
108119
```
109120

121+
## Baking Validator Stakes into Genesis
122+
- By default, validator stakes are baked into genesis on genesis creation. That way when the cluster boots up, all validators will consistently be in the leader schedule.
123+
- If you do not want this and instead want the stake to warm up after deplyoyment, pass in the flag `--skip-primordial-stakes`.
124+
110125
## Metrics
111126
1) Setup metrics database:
112127
```
@@ -155,7 +170,9 @@ cargo run --bin cluster -- -n <namespace> --registry <registry> --release-channe
155170

156171
For steps (2) and (3), when using `--no-bootstrap`, we assume that the directory at `--cluster-data-path <directory>` has the correct genesis, bootstrap identity, and faucet account stored. These are all created in step (1).
157172

158-
Note: We can't deploy heterogeneous clusters across v1.17 and v1.18 due to feature differences. Hope to fix this in the future. Have something where we can specifically define which features to enable.
173+
Notes:
174+
1) We can't deploy heterogeneous clusters across v1.17 and v1.18 due to feature differences. Hope to fix this in the future. Have something where we can specifically define which features to enable.
175+
2) Heterogenous clusters with primordial stakes baked into genesis is not supported yet
159176

160177
## Querying the RPC from outside the cluster
161178
The cluster now has an external IP/port that can be queried to reach the cluster RPC. The external RPC port will be logged during cluster boot, e.g.:

Diff for: src/genesis.rs

+42-30
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ impl Genesis {
283283
Ok(child)
284284
}
285285

286-
fn setup_genesis_flags(&self, num_validators: usize, image_tag: &str) -> Result<Vec<String>, Box<dyn Error>> {
286+
fn setup_genesis_flags(
287+
&self,
288+
num_validators: usize,
289+
image_tag: &str,
290+
) -> Result<Vec<String>, Box<dyn Error>> {
287291
let mut args = vec![
288292
"--bootstrap-validator-lamports".to_string(),
289293
sol_to_lamports(
@@ -406,11 +410,11 @@ impl Genesis {
406410
let progress_bar = new_spinner_progress_bar();
407411
progress_bar.set_message(format!("{SUN}Building Genesis..."));
408412

409-
info!("genesis args:");
413+
debug!("genesis args:");
410414
for arg in &args {
411-
info!("{arg}");
415+
debug!("{arg}");
412416
}
413-
let executable_path: PathBuf = exec_path.join("solana-genesis");
417+
let executable_path = exec_path.join("solana-genesis");
414418
let output = Command::new(executable_path)
415419
.args(&args)
416420
.output()
@@ -430,67 +434,75 @@ impl Genesis {
430434
Ok(())
431435
}
432436

433-
pub fn create_snapshot(
434-
&self,
435-
exec_path: &Path,
436-
) -> Result<(), Box<dyn Error>> {
437+
pub fn create_snapshot(&self, exec_path: &Path) -> Result<(), Box<dyn Error>> {
437438
let warp_slot = 1;
438439
let executable_path: PathBuf = exec_path.join("agave-ledger-tool");
439440
let args = vec![
440441
"-l".to_string(),
441-
self.config_dir.join("bootstrap-validator").into_os_string().into_string().unwrap(),
442+
self.config_dir
443+
.join("bootstrap-validator")
444+
.into_os_string()
445+
.into_string()
446+
.unwrap(),
442447
"create-snapshot".to_string(),
443448
"0".to_string(),
444-
self.config_dir.join("bootstrap-validator").into_os_string().into_string().unwrap(),
449+
self.config_dir
450+
.join("bootstrap-validator")
451+
.into_os_string()
452+
.into_string()
453+
.unwrap(),
445454
"--warp-slot".to_string(),
446455
warp_slot.to_string(),
447456
];
448457
let output = Command::new(executable_path)
449458
.args(&args)
459+
.stdout(Stdio::null())
460+
.stderr(Stdio::piped())
450461
.output()
451-
.expect("Failed to execute agave-ledger-tool");
462+
.map_err(Box::new)?;
463+
452464
if !output.status.success() {
453-
return Err(format!(
454-
"Failed to create snapshot. err: {:?}",
455-
String::from_utf8(output.stderr)
456-
)
457-
.into());
465+
return Err(String::from_utf8_lossy(&output.stderr).into());
458466
}
459467
info!("Snapshot creation complete");
460468
Ok(())
461469
}
462470

463-
pub fn get_bank_hash(
464-
&self,
465-
) -> Result<String, Box<dyn Error>> {
471+
pub fn get_bank_hash(&self) -> Result<String, Box<dyn Error>> {
466472
let agave_output = Command::new("agave-ledger-tool")
467-
.args(&[
468-
"-l",
469-
self.config_dir.join("bootstrap-validator").into_os_string().into_string().unwrap().as_str(),
473+
.args([
474+
"-l",
475+
self.config_dir
476+
.join("bootstrap-validator")
477+
.into_os_string()
478+
.into_string()
479+
.unwrap()
480+
.as_str(),
470481
"verify",
471-
"--halt-at-slot", "0",
482+
"--halt-at-slot",
483+
"0",
472484
"--print-bank-hash",
473-
"--output", "json"
485+
"--output",
486+
"json",
474487
])
475488
.stdout(Stdio::piped())
476489
.spawn()?
477490
.stdout
478491
.expect("Failed to capture agave-ledger-tool output");
479492

480-
// Use `jq` to filter the JSON output and extract the `.hash` value
493+
// get bank hash
481494
let jq_output = Command::new("jq")
482495
.arg("-r")
483496
.arg(".hash")
484497
.stdin(agave_output)
485498
.output()?;
486499

487-
// Convert the output to a String
488-
let bank_hash = String::from_utf8_lossy(&jq_output.stdout).trim().to_string();
500+
let bank_hash = String::from_utf8_lossy(&jq_output.stdout)
501+
.trim()
502+
.to_string();
489503

490-
// Print or use the bank hash
491-
info!("bankHash: {}", bank_hash);
504+
info!("bankHash: {bank_hash}");
492505

493506
Ok(bank_hash)
494507
}
495-
496508
}

Diff for: src/kubernetes.rs

-4
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,6 @@ impl<'a> Kubernetes<'a> {
303303
let mut command = vec![command_path];
304304
command.extend(self.generate_bootstrap_command_flags());
305305

306-
for c in &command {
307-
info!("command: {:?}", c);
308-
}
309-
310306
k8s_helpers::create_replica_set(
311307
format!("{}-{}", image.node_type(), image.tag()),
312308
self.namespace.clone(),

Diff for: src/main.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
557557
let internal_node_stake_sol = value_t_or_exit!(matches, "internal_node_stake_sol", f64);
558558
let internal_node_sol =
559559
value_t_or_exit!(matches, "internal_node_sol", f64) + internal_node_stake_sol;
560-
560+
561561
let skip_primordial_stakes = matches.is_present("skip_primordial_stakes");
562562

563563
let genesis_flags = GenesisFlags {
@@ -620,7 +620,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
620620
internal_node_stake_sol,
621621
commission,
622622
shred_version: None, // set after genesis created
623-
bank_hash: None, //set after snapshot created
623+
bank_hash: None, //set after snapshot created
624624
max_ledger_size: if limit_ledger_size < DEFAULT_MIN_MAX_LEDGER_SHREDS {
625625
clap::Error::with_description(
626626
format!("The provided --limit-ledger-size value was too small, the minimum value is {DEFAULT_MIN_MAX_LEDGER_SHREDS}"),
@@ -705,7 +705,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
705705

706706
// creates genesis and writes to binary file
707707
genesis
708-
.generate(cluster_data_root.get_root_path(), &exec_path, num_validators, &image_tag)
708+
.generate(
709+
cluster_data_root.get_root_path(),
710+
&exec_path,
711+
num_validators,
712+
&image_tag,
713+
)
709714
.await?;
710715
info!("Genesis created");
711716

0 commit comments

Comments
 (0)