Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Build genesis and add genesis cli flags#5

Merged
gregcusack merged 1 commit intoanza-xyz:mainfrom
gregcusack:build-genesis
Apr 8, 2024
Merged

Build genesis and add genesis cli flags#5
gregcusack merged 1 commit intoanza-xyz:mainfrom
gregcusack:build-genesis

Conversation

@gregcusack
Copy link
Copy Markdown
Contributor

@gregcusack gregcusack commented Mar 28, 2024

Summary of Changes

  1. Add genesis build
  2. Add genesis cli flags

5th PR in a series of PRs that will build out the mongon testing framework for deploying validator clusters on Kubernetes
Previous PRs:

  1. PR: add PROGRESS.md and connect to k8s endpoint to check namespace exists #1
  2. PR: Add in ability to build solana binary from local repo on host #2
  3. PR: Add pull specific solana-release version #3
  4. PR: Create genesis struct. and generate bootstrap and faucet accounts #4

@gregcusack gregcusack force-pushed the build-genesis branch 2 times, most recently from c14d31e to 65fe5b4 Compare March 29, 2024 16:57
This was referenced Mar 29, 2024
@gregcusack gregcusack force-pushed the build-genesis branch 2 times, most recently from 6812bdc to f2c63b7 Compare April 4, 2024 21:05
Copy link
Copy Markdown
Member

@yihau yihau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪖

@gregcusack gregcusack merged commit 3df6f4b into anza-xyz:main Apr 8, 2024
@gregcusack gregcusack deleted the build-genesis branch April 8, 2024 16:03
Copy link
Copy Markdown

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late fly-by review, but a few questions / suggestions

Comment thread src/main.rs
Comment on lines +76 to +81
Arg::with_name("enable_warmup_epochs")
.long("enable-warmup-epochs")
.takes_value(true)
.possible_values(&["true", "false"])
.default_value("true")
.help("Genesis config. enable warmup epoch. defaults to true"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it's a bit of an anti-pattern to have a flag that also takes "true" or "false" -- if it's present, it's true!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear why i wrote it this way. good catch

Comment thread src/main.rs
Comment on lines +58 to +61
Arg::with_name("slots_per_epoch")
.long("slots-per-epoch")
.takes_value(true)
.help("override the number of slots in an epoch"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this flag can be omitted and doesn't have a default documented anywhere, can you say what it will be here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is defined internally in genesis library and depends on cluster_type. But added a note here as well with those values.

Comment thread src/main.rs
Comment on lines +64 to +67
Arg::with_name("target_lamports_per_signature")
.long("target-lamports-per-signature")
.takes_value(true)
.help("Genesis config. target lamports per signature"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, can you specify the default?

Comment thread src/main.rs
Comment on lines +70 to +73
Arg::with_name("faucet_lamports")
.long("faucet-lamports")
.takes_value(true)
.help("Override the default 500000000000000000 lamports minted in genesis"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify .default_value("500000000000000000")? then you'll be able to parse this more easily.

Even better, you can pass in &DEFAULT_FAUCET_LAMPORTS.to_string() to avoid the copying, but it does make this function a bit goofier

Comment thread src/main.rs
Comment on lines +84 to +87
Arg::with_name("max_genesis_archive_unpacked_size")
.long("max-genesis-archive-unpacked-size")
.takes_value(true)
.help("Genesis config. max_genesis_archive_unpacked_size"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the default value, similar to DEFAULT_FAUCET_LAMPORTS

Comment thread src/main.rs
Comment on lines +100 to +103
Arg::with_name("bootstrap_validator_sol")
.long("bootstrap-validator-sol")
.takes_value(true)
.help("Genesis config. bootstrap validator sol"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can have a default value with DEFAULT_BOOTSTRAP_NODE_SOL

Comment thread src/main.rs
Comment on lines +106 to +109
Arg::with_name("bootstrap_validator_stake_sol")
.long("bootstrap-validator-stake-sol")
.takes_value(true)
.help("Genesis config. bootstrap validator stake sol"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And finally here, you can use DEFAULT_BOOTSTRAP_NODE_STAKE_SOL

Comment thread fetch-spl.sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will very likely forget to update this 😞 and it's currently out of date. Is there a way to move this functionality into solana-genesis or link to it from the solana repo?

Or maybe better, do the logic in some file here rather than relying on a bash script? You're pretty much just fetching files and outputting strings. That might be more portable.

Note: this isn't urgent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh ok ya i can move this over to its own rust function or something. will add that.

Comment thread src/genesis.rs
Comment on lines +55 to +68
while let Some(token) = tokens_iter.next() {
args.push(token.to_string());
// Find flag delimiters
if token.starts_with("--") {
for next_token in tokens_iter.by_ref() {
if next_token.starts_with("--") {
args.push(next_token.to_string());
} else {
args.push(next_token.to_string());
break;
}
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm being dense, but why is this logic needed? Shouldn't you be able to just take the Vec<String> after the whitespace has been removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. i had a different (ultimately wrong) understanding of how solana-genesis took in these commands. And when I figured out it was wrong, I didn't change this function. But even now realize this function just doesn't really do anything that isn't done by just taking the Vec.

Comment thread src/genesis.rs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants