Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed Seeds #678

Closed
4 tasks
faddat opened this issue Feb 22, 2021 · 3 comments
Closed
4 tasks

Embed Seeds #678

faddat opened this issue Feb 22, 2021 · 3 comments

Comments

@faddat
Copy link
Contributor

faddat commented Feb 22, 2021

Summary

Finding seeds is a pain.

Problem Definition

  • Chasing down seeds increases "time to fully operational node".

Proposal

We can modify gaia to pass seeds when it sets up then init command, and for the sdk to accept seeds then, as well. The seeds need to go to InterceptSeedsPreRunHandler, I think. During the init step, it seems that we can override default values in config.toml.

// InterceptConfigsPreRunHandler performs a pre-run function for the root daemon
// application command. It will create a Viper literal and a default server
// Context. The server Tendermint configuration will either be read and parsed
// or created and saved to disk, where the server Context is updated to reflect
// the Tendermint configuration. The Viper literal is used to read and parse
// the application configuration. Command handlers can fetch the server Context
// to get the Tendermint configuration or to get access to Viper.
func InterceptConfigsPreRunHandler(cmd *cobra.Command) error {
	serverCtx := NewDefaultContext()

	// Get the executable name and configure the viper instance so that environmental
	// variables are checked based off that name. The underscore character is used
	// as a separator
	executableName, err := os.Executable()
	if err != nil {
		return err
	}

	basename := path.Base(executableName)

	// Configure the viper instance
	serverCtx.Viper.BindPFlags(cmd.Flags())
	serverCtx.Viper.BindPFlags(cmd.PersistentFlags())
	serverCtx.Viper.SetEnvPrefix(basename)
	serverCtx.Viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
	serverCtx.Viper.AutomaticEnv()

	// intercept configuration files, using both Viper instances separately
	config, err := interceptConfigs(serverCtx.Viper)
	if err != nil {
		return err
	}

	// return value is a tendermint configuration object
	serverCtx.Config = config
	if err = bindFlags(basename, cmd, serverCtx.Viper); err != nil {
		return err
	}

	var logWriter io.Writer
	if strings.ToLower(serverCtx.Viper.GetString(flags.FlagLogFormat)) == tmcfg.LogFormatPlain {
		logWriter = zerolog.ConsoleWriter{Out: os.Stderr}
	} else {
		logWriter = os.Stderr
	}

	logLvlStr := serverCtx.Viper.GetString(flags.FlagLogLevel)
	logLvl, err := zerolog.ParseLevel(logLvlStr)
	if err != nil {
		return fmt.Errorf("failed to parse log level (%s): %w", logLvlStr, err)
	}

	serverCtx.Logger = ZeroLogWrapper{zerolog.New(logWriter).Level(logLvl).With().Timestamp().Logger()}

	return SetCmdServerContext(cmd, serverCtx)
}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@faddat faddat mentioned this issue Feb 22, 2021
4 tasks
@cosmos cosmos deleted a comment from workshub bot Feb 24, 2021
@cosmos cosmos deleted a comment from workshub bot Feb 25, 2021
@faddat
Copy link
Contributor Author

faddat commented Feb 27, 2021

Discussion moved here:

cosmos/cosmos-sdk#8720

@faddat
Copy link
Contributor Author

faddat commented Sep 17, 2021

I did this totally backwards when I first laid it out.

The right way was to call InitCmd from root.go with a custom init.go.

@faddat
Copy link
Contributor Author

faddat commented Dec 11, 2021

closing in favor of #943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@faddat and others