diff --git a/engines/tendermint-v34/tendermint.go b/engines/tendermint-v34/tendermint.go index e92eae9..a01e0cc 100644 --- a/engines/tendermint-v34/tendermint.go +++ b/engines/tendermint-v34/tendermint.go @@ -719,6 +719,14 @@ func (engine *Engine) BootstrapState(value []byte) error { return fmt.Errorf("failed to unmarshal tendermint-ssync bundle: %w", err) } + // if TimeIotaMs is zero we set it to 1 else the app would panic. + // in rare circumstances this can be zero if the snapshot got + // created with the engine cometbft-v0.37 or cometbft-v0.38 but the + // height is still for tendermint-v0.34 + if bundle[0].Value.State.ConsensusParams.Block.TimeIotaMs == 0 { + bundle[0].Value.State.ConsensusParams.Block.TimeIotaMs = 1 + } + err := engine.stateStore.Bootstrap(*bundle[0].Value.State) if err != nil { return fmt.Errorf("failed to bootstrap state: %s\"", err) diff --git a/sources/version.go b/sources/version.go index 3f324ea..dbb84dd 100644 --- a/sources/version.go +++ b/sources/version.go @@ -60,7 +60,7 @@ func SelectCosmovisorVersion(binaryPath, homePath, registryUrl, source string, c } func IsBinaryRecommendedVersion(binaryPath, registryUrl, source string, continuationHeight int64, userInput bool) error { - if source == "" || !userInput { + if binaryPath == "" || source == "" || !userInput { return nil } @@ -69,16 +69,17 @@ func IsBinaryRecommendedVersion(binaryPath, registryUrl, source string, continua return fmt.Errorf("failed to lookup binary path: %w", err) } - startArgs := make([]string, 0) + cmd := exec.Command(cmdPath) // if we run with cosmovisor we start with the cosmovisor run command if strings.HasSuffix(binaryPath, "cosmovisor") { - startArgs = append(startArgs, "run") + cmd.Args = append(cmd.Args, "run") + cmd.Env = append(os.Environ(), "COSMOVISOR_DISABLE_LOGS=true") } - startArgs = append(startArgs, "version") + cmd.Args = append(cmd.Args, "version") - out, err := exec.Command(cmdPath, startArgs...).Output() + out, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("failed to get output of binary: %w", err) } @@ -118,8 +119,7 @@ func IsBinaryRecommendedVersion(binaryPath, registryUrl, source string, continua } if strings.ToLower(answer) != "y" { - logger.Error().Msg("abort") - return nil + return fmt.Errorf("abort") } return nil diff --git a/utils/binaries.go b/utils/binaries.go index de67bb5..251416f 100644 --- a/utils/binaries.go +++ b/utils/binaries.go @@ -16,14 +16,15 @@ func GetHomePathFromBinary(binaryPath string) string { os.Exit(1) } - startArgs := make([]string, 0) + cmd := exec.Command(cmdPath) // if we run with cosmovisor we start with the cosmovisor run command if strings.HasSuffix(binaryPath, "cosmovisor") { - startArgs = append(startArgs, "run") + cmd.Args = append(cmd.Args, "run") + cmd.Env = append(os.Environ(), "COSMOVISOR_DISABLE_LOGS=true") } - out, err := exec.Command(cmdPath, startArgs...).Output() + out, err := cmd.CombinedOutput() if err != nil { logger.Error().Msg("failed to get output of binary") os.Exit(1) @@ -55,16 +56,17 @@ func GetEnginePathFromBinary(binaryPath string) string { os.Exit(1) } - startArgs := make([]string, 0) + cmd := exec.Command(cmdPath) // if we run with cosmovisor we start with the cosmovisor run command if strings.HasSuffix(binaryPath, "cosmovisor") { - startArgs = append(startArgs, "run") + cmd.Args = append(cmd.Args, "run") + cmd.Env = append(os.Environ(), "COSMOVISOR_DISABLE_LOGS=true") } - startArgs = append(startArgs, "version", "--long") + cmd.Args = append(cmd.Args, "version", "--long") - out, err := exec.Command(cmdPath, startArgs...).CombinedOutput() + out, err := cmd.CombinedOutput() if err != nil { logger.Error().Msg("failed to get output of binary") os.Exit(1) @@ -103,27 +105,27 @@ func StartBinaryProcessForDB(engine types.Engine, binaryPath string, debug bool, return processId, fmt.Errorf("failed to lookup binary path: %w", err) } - startArgs := make([]string, 0) + cmd := exec.Command(cmdPath) // if we run with cosmovisor we start with the cosmovisor run command if strings.HasSuffix(binaryPath, "cosmovisor") { - startArgs = append(startArgs, "run") + cmd.Args = append(cmd.Args, "run") + cmd.Env = append(os.Environ(), "COSMOVISOR_DISABLE_LOGS=true") } if err := engine.LoadConfig(); err != nil { return processId, fmt.Errorf("failed to load engine config: %w", err) } - baseArgs := append([]string{ - "start", + cmd.Args = append(cmd.Args, "start", "--home", engine.GetHomePath(), "--with-tendermint=false", "--address", engine.GetProxyAppAddress(), - }, args...) + ) - cmd := exec.Command(cmdPath, append(startArgs, baseArgs...)...) + cmd.Args = append(cmd.Args, args...) if debug { cmd.Stdout = os.Stdout @@ -148,15 +150,15 @@ func StartBinaryProcessForP2P(engine types.Engine, binaryPath string, debug bool return processId, fmt.Errorf("failed to lookup binary path: %w", err) } - startArgs := make([]string, 0) + cmd := exec.Command(cmdPath) // if we run with cosmovisor we start with the cosmovisor run command if strings.HasSuffix(binaryPath, "cosmovisor") { - startArgs = append(startArgs, "run") + cmd.Args = append(cmd.Args, "run") + cmd.Env = append(os.Environ(), "COSMOVISOR_DISABLE_LOGS=true") } - baseArgs := append([]string{ - "start", + cmd.Args = append(cmd.Args, "start", "--home", engine.GetHomePath(), "--p2p.pex=false", @@ -166,9 +168,9 @@ func StartBinaryProcessForP2P(engine types.Engine, binaryPath string, debug bool "", "--p2p.unconditional_peer_ids", "", - }, args...) + ) - cmd := exec.Command(cmdPath, append(startArgs, baseArgs...)...) + cmd.Args = append(cmd.Args, args...) if debug { cmd.Stdout = os.Stdout