diff --git a/cmd/ksync/commands/blocksync.go b/cmd/ksync/commands/blocksync.go index 95bdc14..f649326 100644 --- a/cmd/ksync/commands/blocksync.go +++ b/cmd/ksync/commands/blocksync.go @@ -41,7 +41,7 @@ func init() { blockSyncCmd.Flags().StringVarP(&appFlags, "app-flags", "f", "", "custom flags which are applied to the app binary start command. Example: --app-flags=\"--x-crisis-skip-assert-invariants,--iavl-disable-fastnode\"") - blockSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", false, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") + blockSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", true, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") blockSyncCmd.Flags().BoolVarP(&reset, "reset-all", "r", false, "reset this node's validator to genesis state") blockSyncCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") blockSyncCmd.Flags().BoolVarP(&debug, "debug", "d", false, "show logs from tendermint app") diff --git a/cmd/ksync/commands/heightsync.go b/cmd/ksync/commands/heightsync.go index bc8a368..56231ea 100644 --- a/cmd/ksync/commands/heightsync.go +++ b/cmd/ksync/commands/heightsync.go @@ -35,7 +35,7 @@ func init() { heightSyncCmd.Flags().Int64VarP(&targetHeight, "target-height", "t", 0, "target height (including), if not specified it will sync to the latest available block height") - heightSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", false, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") + heightSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", true, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") heightSyncCmd.Flags().BoolVarP(&reset, "reset-all", "r", false, "reset this node's validator to genesis state") heightSyncCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") heightSyncCmd.Flags().BoolVarP(&debug, "debug", "d", false, "show logs from tendermint app") diff --git a/cmd/ksync/commands/serveblocks.go b/cmd/ksync/commands/serveblocks.go index 7eb4acf..d600881 100644 --- a/cmd/ksync/commands/serveblocks.go +++ b/cmd/ksync/commands/serveblocks.go @@ -39,7 +39,7 @@ func init() { serveBlocksCmd.Flags().StringVarP(&source, "source", "s", "", "chain-id of the source") serveBlocksCmd.Flags().StringVar(®istryUrl, "registry-url", utils.DefaultRegistryURL, "URL to fetch latest KYVE Source-Registry") - serveBlocksCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", false, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") + serveBlocksCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", true, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") serveBlocksCmd.Flags().BoolVarP(&reset, "reset-all", "r", false, "reset this node's validator to genesis state") serveBlocksCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") serveBlocksCmd.Flags().BoolVarP(&debug, "debug", "d", false, "show logs from tendermint app") diff --git a/cmd/ksync/commands/servesnapshots.go b/cmd/ksync/commands/servesnapshots.go index b8c1b44..6750f33 100644 --- a/cmd/ksync/commands/servesnapshots.go +++ b/cmd/ksync/commands/servesnapshots.go @@ -46,7 +46,7 @@ func init() { servesnapshotsCmd.Flags().StringVarP(&appFlags, "app-flags", "f", "", "custom flags which are applied to the app binary start command. Example: --app-flags=\"--x-crisis-skip-assert-invariants,--iavl-disable-fastnode\"") - servesnapshotsCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", false, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") + servesnapshotsCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", true, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") servesnapshotsCmd.Flags().BoolVarP(&reset, "reset-all", "r", false, "reset this node's validator to genesis state") servesnapshotsCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") servesnapshotsCmd.Flags().BoolVarP(&debug, "debug", "d", false, "show logs from tendermint app") diff --git a/cmd/ksync/commands/statesync.go b/cmd/ksync/commands/statesync.go index 56a526c..7546a6f 100644 --- a/cmd/ksync/commands/statesync.go +++ b/cmd/ksync/commands/statesync.go @@ -32,7 +32,7 @@ func init() { stateSyncCmd.Flags().Int64VarP(&targetHeight, "target-height", "t", 0, "snapshot height, if not specified it will use the latest available snapshot height") - stateSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", false, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") + stateSyncCmd.Flags().BoolVarP(&autoselectBinaryVersion, "autoselect-binary-version", "a", true, "if provided binary is cosmovisor KSYNC will automatically change the \"current\" symlink to the correct upgrade version") stateSyncCmd.Flags().BoolVarP(&reset, "reset-all", "r", false, "reset this node's validator to genesis state") stateSyncCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") stateSyncCmd.Flags().BoolVarP(&debug, "debug", "d", false, "show logs from tendermint app") diff --git a/sources/version.go b/sources/version.go index d7678de..3f324ea 100644 --- a/sources/version.go +++ b/sources/version.go @@ -16,7 +16,7 @@ var ( func SelectCosmovisorVersion(binaryPath, homePath, registryUrl, source string, continuationHeight int64) error { if !strings.HasSuffix(binaryPath, "cosmovisor") { - return fmt.Errorf("--autoselect-binary-version only works if the specified --binary is cosmovisor with all installed upgrades") + return nil } var upgradeName string @@ -39,6 +39,10 @@ func SelectCosmovisorVersion(binaryPath, homePath, registryUrl, source string, c upgradeName = upgrade.Name } + if _, err := os.Stat(fmt.Sprintf("%s/cosmovisor/upgrades/%s", homePath, upgradeName)); err != nil { + return fmt.Errorf("upgrade \"%s\" not installed in cosmovisor", upgradeName) + } + symlinkPath := fmt.Sprintf("%s/cosmovisor/current", homePath) if _, err := os.Lstat(symlinkPath); err == nil { @@ -51,7 +55,7 @@ func SelectCosmovisorVersion(binaryPath, homePath, registryUrl, source string, c return fmt.Errorf("failed to create symlink: %w", err) } - logger.Info().Msgf("selected binary version \"%s\" for cosmovisor", upgradeName) + logger.Info().Msgf("selected binary version \"%s\" from height %d for cosmovisor", upgradeName, continuationHeight) return nil }