Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Generate Genesis State Command to Prysmctl #11259

Merged
merged 14 commits into from
Aug 19, 2022

Conversation

rauljordan
Copy link
Contributor

@rauljordan rauljordan commented Aug 18, 2022

As part of making Prysm easy to use for running a local devnet, it would be ideal if the tool for generating a genesis state can live under the prysmctl binary, which we are increasingly building to be a really great CLI tool for all things related to Prysm. This will be published as a Docker image under our GCR and will make instructions trivial. This is a refactor of the tool that already existed under tools/genesis-state-gen, but written with cleaner code and smaller functions.

Usage is:

NAME:
   prysmctl testnet generate-genesis - Generate a beacon chain genesis state from specified configs

USAGE:
   prysmctl testnet generate-genesis [command options] [arguments...]

OPTIONS:
   --chain-config-file value  The path to a YAML file with chain config values
   --config-name value        Config kind to be used for generating the genesis state. Default: mainnet. Options include mainnet, interop, minimal, prater, ropsten, sepolia. --chain-config-file will override this flag. (default: "mainnet")
   --deposit-json-file value  Path to deposit_data.json file generated by the staking-deposit-cli tool for optionally specifying validators in genesis state
   --genesis-time value       Unix timestamp seconds used as the genesis time in the genesis state. If unset, defaults to now() (default: 0)
   --num-validators value     Number of validators to deterministically generate in the genesis state (default: 0)
   --output-json value        Output filename of the JSON marshaling of the generated genesis state
   --output-ssz value         Output filename of the SSZ marshaling of the generated genesis state
   --output-yaml value        Output filename of the YAML marshaling of the generated genesis state

@rauljordan rauljordan requested a review from a team as a code owner August 18, 2022 18:23
@rauljordan rauljordan self-assigned this Aug 18, 2022
@rauljordan rauljordan added Ready For Review Cleanup Code health! Tools Tools related tasks labels Aug 18, 2022
rkapka
rkapka previously requested changes Aug 18, 2022
cmd/prysmctl/testnet/generate_genesis.go Outdated Show resolved Hide resolved
cmd/prysmctl/testnet/generate_genesis.go Outdated Show resolved Hide resolved
cmd/prysmctl/testnet/generate_genesis.go Outdated Show resolved Hide resolved
cmd/prysmctl/testnet/generate_genesis.go Outdated Show resolved Hide resolved
cmd/prysmctl/testnet/generate_genesis.go Outdated Show resolved Hide resolved
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
fPath string,
data interface{},
marshalFn func(o interface{}) ([]byte, error),
) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: I don't think you need to break this into multi-line func signature.

kasey
kasey previously approved these changes Aug 18, 2022
Copy link
Contributor

@kasey kasey left a comment

Choose a reason for hiding this comment

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

All my comments are nitpicks, otherwise lgtm!

kasey
kasey previously approved these changes Aug 18, 2022
noOutputFlag := outputSSZ == "" && outputJson == "" && outputYaml == ""
if noOutputFlag {
return errors.New(
"no --output-ssz, --output-json, or --output-yaml flag specified. At least one is required",
Copy link
Contributor

Choose a reason for hiding this comment

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

One last comment: can you parameterize flag names for easier maintenance? In case names change in the future?

@rkapka rkapka dismissed their stale review August 18, 2022 20:07

reviewed and looks ok

@prylabs-bulldozer prylabs-bulldozer bot merged commit 20ed47a into develop Aug 19, 2022
@delete-merged-branch delete-merged-branch bot deleted the move-genesis-tool branch August 19, 2022 09:26
@cshintov
Copy link

cshintov commented Sep 2, 2022

Hi sorry for asking this here. I tried discord, didn't get any reply.
How do I use this tool? Is there any doc for this?

How do I generate equivalent genesis.ssz that exists here:

https://github.com/eth-clients/eth2-networks/tree/master/shared/prater

I'm a noob. Any pointer towards better understanding the genesis file and how to generate it is greatly appreciated. Thanks :)

@rauljordan
Copy link
Contributor Author

Hi @cshintov looks like our tool might not work well for regenerating these testnet states. Instead, I would recommend trying https://github.com/protolambda/eth2-testnet-genesis and passing in the config.yml from the link in your message above as one of the options. I hope this helps

@cshintov
Copy link

cshintov commented Sep 3, 2022

Thanks @rauljordan 🙂
This indeed helps.

I will check out this tool.

@HorcruxAshu
Copy link

HorcruxAshu commented Nov 4, 2022

Unable to find any way to generate equivalent genesis.ssz file for my own devnet? Any help would be highly appreciated!

@lyfsn
Copy link

lyfsn commented Oct 27, 2023

How generate genesis state in 2023.10.27?

@rauljordan
Copy link
Contributor Author

hi @HorcruxAshu and @wangyufsn do you run into any issues when using this command?

NAME:
   prysmctl testnet generate-genesis - Generate a beacon chain genesis state from specified configs

USAGE:
   prysmctl testnet generate-genesis [command options] [arguments...]

OPTIONS:
   --chain-config-file value  The path to a YAML file with chain config values
   --config-name value        Config kind to be used for generating the genesis state. Default: mainnet. Options include mainnet, interop, minimal, prater, ropsten, sepolia. --chain-config-file will override this flag. (default: "mainnet")
   --deposit-json-file value  Path to deposit_data.json file generated by the staking-deposit-cli tool for optionally specifying validators in genesis state
   --genesis-time value       Unix timestamp seconds used as the genesis time in the genesis state. If unset, defaults to now() (default: 0)
   --num-validators value     Number of validators to deterministically generate in the genesis state (default: 0)
   --output-json value        Output filename of the JSON marshaling of the generated genesis state
   --output-ssz value         Output filename of the SSZ marshaling of the generated genesis state
   --output-yaml value        Output filename of the YAML marshaling of the generated genesis state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Code health! Tools Tools related tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants