cmd

package
v0.0.0-...-9a91394 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName is the name of the application, the name of the command, and the name of the home directory.
	AppName = "testapp"
)

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   AppName,
	Short: "Testapp is a test application for Evolve, it consists of a simple key-value store and a single sequencer.",
}

RootCmd is the root command for Evolve

View Source
var RunCmd = &cobra.Command{
	Use:     "start",
	Aliases: []string{"node", "run"},
	Short:   "Run the testapp node",
	RunE: func(command *cobra.Command, args []string) error {
		nodeConfig, err := cmd.ParseConfig(command)
		if err != nil {
			return err
		}

		logger := cmd.SetupLogger(nodeConfig.Log)

		kvEndpoint, _ := command.Flags().GetString(flagKVEndpoint)
		if kvEndpoint == "" {
			logger.Info().Msg("KV endpoint flag not set, using default from http_server")
		}

		executor, err := kvexecutor.NewKVExecutor(nodeConfig.RootDir, nodeConfig.DBPath)
		if err != nil {
			return err
		}

		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()

		headerNamespace := da.NamespaceFromString(nodeConfig.DA.GetNamespace())
		dataNamespace := da.NamespaceFromString(nodeConfig.DA.GetDataNamespace())

		logger.Info().Str("headerNamespace", headerNamespace.HexString()).Str("dataNamespace", dataNamespace.HexString()).Msg("namespaces")

		nodeKey, err := key.LoadNodeKey(filepath.Dir(nodeConfig.ConfigPath()))
		if err != nil {
			return err
		}

		datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, testDbName)
		if err != nil {
			return err
		}

		if kvEndpoint != "" {
			httpServer := kvexecutor.NewHTTPServer(executor, kvEndpoint)
			err = httpServer.Start(ctx)
			if err != nil {
				return fmt.Errorf("failed to start KV executor HTTP server: %w", err)
			} else {
				logger.Info().Str("endpoint", kvEndpoint).Msg("KV executor HTTP server started")
			}
		}

		genesisPath := filepath.Join(filepath.Dir(nodeConfig.ConfigPath()), "genesis.json")
		genesis, err := genesis.LoadGenesis(genesisPath)
		if err != nil {
			return fmt.Errorf("failed to load genesis: %w", err)
		}

		if genesis.DAStartHeight == 0 && !nodeConfig.Node.Aggregator {
			logger.Warn().Msg("da_start_height is not set in genesis.json, ask your chain developer")
		}

		sequencer, err := createSequencer(ctx, logger, datastore, nodeConfig, genesis, executor)
		if err != nil {
			return err
		}

		p2pClient, err := p2p.NewClient(nodeConfig.P2P, nodeKey.PrivKey, datastore, genesis.ChainID, logger, p2p.NopMetrics())
		if err != nil {
			return err
		}

		return cmd.StartNode(logger, command, executor, sequencer, p2pClient, datastore, nodeConfig, genesis, node.NodeOptions{})
	},
}

Functions

func InitCmd

func InitCmd() *cobra.Command

InitCmd initializes a new evnode.yml file in the current directory

func NewRollbackCmd

func NewRollbackCmd() *cobra.Command

NewRollbackCmd creates a command to rollback ev-node state by one height.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL