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 genesis delay #6

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ Options:
- `--output` (string): The directory where the chain data and artifacts are stored. It defaults to `local-testnet`.
- `--continue` (bool): Whether to restart the chain from a previous run if the output folder is not empty. It defaults to `false`.
- `--use-bin-path` (bool): Whether to use the binaries from the local path instead of downloading them. It defaults to `false`.
- `--genesis-delay` (int): The delay in seconds before the genesis block is created. It is used to account for the delay between the creation of the artifacts and the running of the services. It defaults to `5` seconds.

Unless the `--continue` flag is set, the playground will delete the output directory and start a new chain from scratch on every run.
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var outputFlag string
var continueFlag bool
var useBinPathFlag bool
var validateFlag bool
var genesisDelayFlag uint64

var rootCmd = &cobra.Command{
Use: "playground",
Expand Down Expand Up @@ -151,6 +152,8 @@ func main() {
rootCmd.Flags().StringVar(&outputFlag, "output", "local-testnet", "")
rootCmd.Flags().BoolVar(&continueFlag, "continue", false, "")
rootCmd.Flags().BoolVar(&useBinPathFlag, "use-bin-path", false, "")
rootCmd.Flags().Uint64Var(&genesisDelayFlag, "genesis-delay", 5, "")

downloadArtifactsCmd.Flags().BoolVar(&validateFlag, "validate", false, "")
validateCmd.Flags().Uint64Var(&numBlocksValidate, "num-blocks", 5, "")

Expand Down Expand Up @@ -219,7 +222,7 @@ func setupArtifacts() error {
return err
}

genesisTime := uint64(time.Now().Unix())
genesisTime := uint64(time.Now().Add(time.Duration(genesisDelayFlag) * time.Second).Unix())
config := params.BeaconConfig()

gen := interop.GethTestnetGenesis(genesisTime, config)
Expand Down
Loading