From 54b2bc6d6b263723bbf66450250b9edc59598bc5 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Tue, 30 Jul 2024 16:07:30 +0100 Subject: [PATCH] Add a genesis delay --- README.md | 1 + main.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a9ded6..7deb3ef 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/main.go b/main.go index e985894..f453934 100644 --- a/main.go +++ b/main.go @@ -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", @@ -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, "") @@ -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)