From 1b3919e43ba092fc48000167426ab66f41a9b6d3 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 22 Nov 2024 12:26:17 +0900 Subject: [PATCH] add statesync flags --- cmd/flags/comet.go | 24 ++++++++++++++++++++++++ cmd/initiad/root.go | 10 +++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 cmd/flags/comet.go diff --git a/cmd/flags/comet.go b/cmd/flags/comet.go new file mode 100644 index 00000000..5a4a7a9f --- /dev/null +++ b/cmd/flags/comet.go @@ -0,0 +1,24 @@ +package flags + +import ( + "github.com/spf13/cobra" + + cfg "github.com/cometbft/cometbft/config" +) + +var ( + defaultCometConfig = cfg.DefaultConfig() +) + +// AddCometBFTFlags adds flags for cometbft to the provided command +func AddCometBFTFlags(cmd *cobra.Command) { + cmd.Flags().Bool("statesync.enable", defaultCometConfig.StateSync.Enable, "enable state sync") + cmd.Flags().StringArray("statesync.rpc_servers", defaultCometConfig.StateSync.RPCServers, "state sync rpc servers") + cmd.Flags().Int64("statesync.trust_height", defaultCometConfig.StateSync.TrustHeight, "state sync trust height") + cmd.Flags().String("statesync.trust_hash", defaultCometConfig.StateSync.TrustHash, "state sync trust hash") + cmd.Flags().Duration("statesync.trust_period", defaultCometConfig.StateSync.TrustPeriod, "state sync trust period") + cmd.Flags().Duration("statesync.discovery_time", defaultCometConfig.StateSync.DiscoveryTime, "state sync discovery time") + cmd.Flags().String("statesync.temp_dir", defaultCometConfig.StateSync.TempDir, "state sync temp dir") + cmd.Flags().Duration("statesync.chunk_request_timeout", defaultCometConfig.StateSync.ChunkRequestTimeout, "state sync chunk request timeout") + cmd.Flags().Int32("statesync.chunk_fetchers", defaultCometConfig.StateSync.ChunkFetchers, "state sync chunk fetchers") +} diff --git a/cmd/initiad/root.go b/cmd/initiad/root.go index ef4c2d4a..861d7bdf 100644 --- a/cmd/initiad/root.go +++ b/cmd/initiad/root.go @@ -37,6 +37,7 @@ import ( initiaapp "github.com/initia-labs/initia/app" "github.com/initia-labs/initia/app/params" + initiacmdflags "github.com/initia-labs/initia/cmd/flags" movecmd "github.com/initia-labs/initia/cmd/move" cryptokeyring "github.com/initia-labs/initia/crypto/keyring" "github.com/initia-labs/initia/x/genutil" @@ -161,7 +162,10 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b a.newApp, a.appExport, server.StartCmdOptions{ - AddFlags: addModuleInitFlags, + AddFlags: func(startCmd *cobra.Command) { + crisis.AddModuleInitFlags(startCmd) + initiacmdflags.AddCometBFTFlags(startCmd) + }, PostSetup: func(svrCtx *server.Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error { g.Go(func() error { errCh := make(chan error, 1) @@ -196,10 +200,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b rootCmd.AddCommand(movecmd.MoveCommand(encodingConfig.InterfaceRegistry.SigningContext().AddressCodec(), false)) } -func addModuleInitFlags(startCmd *cobra.Command) { - crisis.AddModuleInitFlags(startCmd) -} - func genesisCommand(encodingConfig params.EncodingConfig, basicManager module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "genesis",