-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
$ ./node panic: error with code 2 is already registered: "duplicate" goroutine 1 [running]: cosmossdk.io/errors.RegisterWithGRPCCode({0x105b93b3f, 0x3}, 0x2, 0x2, {0x105b9a8f5, 0x9}) /Users/rootulp/go/pkg/mod/cosmossdk.io/[email protected]/errors.go:43 +0x240 cosmossdk.io/errors.Register(...) /Users/rootulp/go/pkg/mod/cosmossdk.io/[email protected]/errors.go:35 github.com/celestiaorg/celestia-app/x/qgb/types.init() /Users/rootulp/go/pkg/mod/github.com/celestiaorg/[email protected]/x/qgb/types/errors.go:8 +0x128
- Loading branch information
Showing
9 changed files
with
161 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/celestiaorg/celestia-app/node/utils" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var cfgFile string | ||
|
||
// rootCmd represents the base command when called without any subcommands | ||
var rootCmd = &cobra.Command{ | ||
Use: "node", | ||
Short: "A brief description of your application", | ||
Long: `A longer description that spans multiple lines and likely contains | ||
examples and usage of using your application. For example: | ||
Cobra is a CLI library for Go that empowers applications. | ||
This application is a tool to generate the needed files | ||
to quickly create a Cobra application.`, | ||
// Uncomment the following line if your bare application | ||
// has an action associated with it: | ||
Run: func(cmd *cobra.Command, args []string) { | ||
currentAppVersion := uint64(1) | ||
apps := utils.GetApps() | ||
multiplexer := utils.NewMultiplexer(currentAppVersion, apps) | ||
|
||
fmt.Printf("%v\n", multiplexer) | ||
}, | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
cobra.OnInitialize(initConfig) | ||
|
||
// Here you will define your flags and configuration settings. | ||
// Cobra supports persistent flags, which, if defined here, | ||
// will be global for your application. | ||
|
||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.node.yaml)") | ||
|
||
// Cobra also supports local flags, which will only run | ||
// when this action is called directly. | ||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} | ||
|
||
// initConfig reads in config file and ENV variables if set. | ||
func initConfig() { | ||
if cfgFile != "" { | ||
// Use config file from the flag. | ||
viper.SetConfigFile(cfgFile) | ||
} else { | ||
// Find home directory. | ||
home, err := os.UserHomeDir() | ||
cobra.CheckErr(err) | ||
|
||
// Search config in home directory with name ".node" (without extension). | ||
viper.AddConfigPath(home) | ||
viper.SetConfigType("yaml") | ||
viper.SetConfigName(".node") | ||
} | ||
|
||
viper.AutomaticEnv() // read in environment variables that match | ||
|
||
// If a config file is found, read it in. | ||
if err := viper.ReadInConfig(); err == nil { | ||
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
v1 "github.com/celestiaorg/celestia-app/app" | ||
v1encoding "github.com/celestiaorg/celestia-app/app/encoding" | ||
v2 "github.com/celestiaorg/celestia-app/v2/app" | ||
v2encoding "github.com/celestiaorg/celestia-app/v2/app/encoding" | ||
"github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmdb "github.com/tendermint/tm-db" | ||
) | ||
import "github.com/celestiaorg/celestia-app/node/cmd" | ||
|
||
func main() { | ||
currentAppVersion := uint64(1) | ||
apps := getApps() | ||
multiplexer := NewMultiplexer(currentAppVersion, apps) | ||
|
||
fmt.Printf("%v\n", multiplexer) | ||
} | ||
|
||
func getApps() []types.Application { | ||
v1 := NewAppV1() | ||
v2 := NewAppV2() | ||
return []types.Application{v1, v2} | ||
} | ||
|
||
func NewAppV1() *v1.App { | ||
logger := log.NewNopLogger() | ||
db := tmdb.NewMemDB() | ||
traceStore := &NoopWriter{} | ||
loadLatest := true | ||
skipUpgradeHeights := make(map[int64]bool) | ||
homePath := "" | ||
invCheckPeriod := uint(1) | ||
encodingConfig := v1encoding.MakeConfig(v1.ModuleEncodingRegisters...) | ||
appOptions := NoopAppOptions{} | ||
|
||
return v1.New(logger, db, traceStore, loadLatest, skipUpgradeHeights, homePath, invCheckPeriod, encodingConfig, appOptions) | ||
} | ||
|
||
func NewAppV2() *v2.App { | ||
logger := log.NewNopLogger() | ||
db := tmdb.NewMemDB() | ||
traceStore := &NoopWriter{} | ||
invCheckPeriod := uint(1) | ||
encodingConfig := v2encoding.MakeConfig(v2.ModuleEncodingRegisters...) | ||
upgradeHeight := int64(0) | ||
appOptions := NoopAppOptions{} | ||
|
||
return v2.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeight, appOptions) | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package utils | ||
|
||
import ( | ||
v1 "github.com/celestiaorg/celestia-app/app" | ||
v1encoding "github.com/celestiaorg/celestia-app/app/encoding" | ||
v2 "github.com/celestiaorg/celestia-app/v2/app" | ||
v2encoding "github.com/celestiaorg/celestia-app/v2/app/encoding" | ||
"github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmdb "github.com/tendermint/tm-db" | ||
) | ||
|
||
func GetApps() []types.Application { | ||
v1 := NewAppV1() | ||
v2 := NewAppV2() | ||
return []types.Application{v1, v2} | ||
} | ||
|
||
func NewAppV1() *v1.App { | ||
logger := log.NewNopLogger() | ||
db := tmdb.NewMemDB() | ||
traceStore := &NoopWriter{} | ||
loadLatest := true | ||
skipUpgradeHeights := make(map[int64]bool) | ||
homePath := "" | ||
invCheckPeriod := uint(1) | ||
encodingConfig := v1encoding.MakeConfig(v1.ModuleEncodingRegisters...) | ||
appOptions := NoopAppOptions{} | ||
|
||
return v1.New(logger, db, traceStore, loadLatest, skipUpgradeHeights, homePath, invCheckPeriod, encodingConfig, appOptions) | ||
} | ||
|
||
func NewAppV2() *v2.App { | ||
logger := log.NewNopLogger() | ||
db := tmdb.NewMemDB() | ||
traceStore := &NoopWriter{} | ||
invCheckPeriod := uint(1) | ||
encodingConfig := v2encoding.MakeConfig(v2.ModuleEncodingRegisters...) | ||
upgradeHeight := int64(0) | ||
appOptions := NoopAppOptions{} | ||
|
||
return v2.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeight, appOptions) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package utils | ||
|
||
import abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package utils | ||
|
||
import ( | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package utils | ||
|
||
import "io" | ||
|
||
|