Skip to content

Commit

Permalink
add statesync flags (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 authored Nov 22, 2024
1 parent a58daf9 commit b03adf9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
24 changes: 24 additions & 0 deletions cmd/flags/comet.go
Original file line number Diff line number Diff line change
@@ -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")
}
10 changes: 5 additions & 5 deletions cmd/initiad/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit b03adf9

Please sign in to comment.