Repository: celestiaorg/celestia-node
Pull request #264 (2021-12-06 10:38:32)

cmd, cmd/celestia: Remove `dev` mode
We no longer need dev mode in its current form. Instead, we can test real nodes against small testnets as was done in Devnet and will be automated by @jbowen93, or via an in-memory test suite as will be implemented by @Bidon15 (Ref #262).

We may later introduce a `--dev` flag that runs a modified version of the node type, but that will be scoped out in later iterations.

Related to #250. 




Patch:
diff --git a/cmd/celestia/dev.go b/cmd/celestia/dev.go
deleted file mode 100644
index 7244fc23..00000000
--- a/cmd/celestia/dev.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package main
-
-import (
-	"github.com/spf13/cobra"
-
-	"github.com/celestiaorg/celestia-node/cmd"
-	"github.com/celestiaorg/celestia-node/node"
-)
-
-func init() {
-	devCmd.AddCommand(
-		cmd.Start("", node.Dev),
-	)
-}
-
-var devCmd = &cobra.Command{
-	Use:   "dev start",
-	Short: "Run a full node in dev mode",
-	Long: `Dev mode starts a full-featured Celestia Node alongside a mock embedded Core node process
-to simulate block production for testing/development purposes only. Dev mode disables p2p and manages node/chain data 
-in memory.`,
-	Args: cobra.NoArgs,
-}
diff --git a/cmd/celestia/main.go b/cmd/celestia/main.go
index 55e9ebea..281cbde2 100644
--- a/cmd/celestia/main.go
+++ b/cmd/celestia/main.go
@@ -15,7 +15,6 @@ func init() {
 	rootCmd.AddCommand(
 		fullCmd,
 		lightCmd,
-		devCmd,
 		versionCmd,
 	)
 }
diff --git a/cmd/start.go b/cmd/start.go
index 3e0ad46e..fa3b7ddc 100644
--- a/cmd/start.go
+++ b/cmd/start.go
@@ -21,7 +21,7 @@ func Start(repoFlagName string, tp node.Type) *cobra.Command {
 	if !tp.IsValid() {
 		panic("cmd: Start: invalid Node Type")
 	}
-	if len(repoFlagName) == 0 && tp != node.Dev { // repository path not necessary for **DEV MODE**
+	if len(repoFlagName) == 0 {
 		panic("parent command must specify a persistent flag name for repository path")
 	}
 
@@ -46,17 +46,6 @@ func Start(repoFlagName string, tp node.Type) *cobra.Command {
 			}
 			logs.SetAllLoggers(level)
 
-			// **DEV MODE** needs separate configuration
-			if tp == node.Dev {
-				repo := node.NewMemRepository()
-				cfg := node.DefaultConfig(tp)
-				if err := repo.PutConfig(cfg); err != nil {
-					return err
-				}
-
-				return start(cmd, tp, repo)
-			}
-
 			var opts []node.Option
 
 			trustedHash := cmd.Flag(trustedHashFlag.Name).Value.String()
diff --git a/node/config.go b/node/config.go
index af2207c6..4468e72b 100644
--- a/node/config.go
+++ b/node/config.go
@@ -41,12 +41,6 @@ func DefaultConfig(tp Type) *Config {
 			Core:     core.DefaultConfig(),
 			Services: services.DefaultConfig(),
 		}
-	case Dev:
-		return &Config{
-			// disable p2p for **DEV MODE**
-			P2P:  p2p.Config{},
-			Core: core.DefaultConfig(),
-		}
 	default:
 		panic("node: unknown Node Type")
 	}
diff --git a/node/node.go b/node/node.go
index 7d123c95..aa6b583a 100644
--- a/node/node.go
+++ b/node/node.go
@@ -83,8 +83,6 @@ func New(tp Type, repo Repository, options ...Option) (*Node, error) {
 		return newNode(tp, fullComponents(cfg, repo))
 	case Light:
 		return newNode(tp, lightComponents(cfg, repo))
-	case Dev:
-		return newNode(tp, mockFullComponents(cfg, repo))
 	default:
 		panic("node: unknown Node Type")
 	}
diff --git a/node/type.go b/node/type.go
index 631c856c..58469bb9 100644
--- a/node/type.go
+++ b/node/type.go
@@ -10,10 +10,6 @@ const (
 	// Light is a stripped-down Celestia Node which aims to be lightweight while preserving highest possible
 	// security guarantees.
 	Light
-	// Dev is a full-featured Celestia Node running alongside a mock embedded Core node process,
-	// designed to simulate block production (for testing/dev purposes only). Dev uses an in-memory
-	// Repository to manage node/chain data and disables p2p functionality.
-	Dev
 )
 
 // String converts Type to its string representation.
@@ -44,12 +40,10 @@ func ParseType(str string) Type {
 var typeToString = map[Type]string{
 	Full:  "Full",
 	Light: "Light",
-	Dev:   "Dev",
 }
 
 // typeToString maps strings representations of all valid Types.
 var stringToType = map[string]Type{
 	"Full":  Full,
 	"Light": Light,
-	"Dev":   Dev,
 }


Test patch:
diff --git a/node/testing.go b/node/testing.go
index c6d94dd6..fe429462 100644
--- a/node/testing.go
+++ b/node/testing.go
@@ -4,10 +4,8 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/require"
-	"go.uber.org/fx"
 
 	"github.com/celestiaorg/celestia-node/core"
-	"github.com/celestiaorg/celestia-node/service/block"
 )
 
 // MockRepository provides mock in memory Repository for testing purposes.
@@ -22,19 +20,3 @@ func MockRepository(t *testing.T, cfg *Config) Repository {
 	require.NoError(t, err)
 	return repo
 }
-
-// mockFullComponents keeps all components as DI options required to build a
-// Full Node in **DEV MODE**:
-// Dev mode constructs a mock embedded Core process that simulates block
-// production for testing purposes.
-func mockFullComponents(cfg *Config, repo Repository) fx.Option {
-	return fx.Options(
-		lightComponents(cfg, repo),
-		fx.Provide(repo.Core),
-		fx.Provide(core.MockEmbeddedClient),
-		fx.Provide(func(client core.Client) block.Fetcher {
-			return core.NewBlockFetcher(client)
-		}),
-		fx.Provide(block.NewBlockService),
-	)
-}