Skip to content

Commit

Permalink
refactor: make Cosmovisor use cobra (#11823)
Browse files Browse the repository at this point in the history
## Description

Closes: #11789



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
julienrbrt authored May 2, 2022
1 parent c0f65e1 commit 8076144
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 430 deletions.
5 changes: 4 additions & 1 deletion cosmovisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]
<!-- NOTE: when creating a new release, update cosmovisor/cmd/cosmovisor/cmd/version.go:Version -->

* [\#11731](https://github.com/cosmos/cosmos-sdk/pull/11731) `cosmovisor version --json` returns the cosmovisor version and the result of `simd --output json --long` in one JSON object.
### Features

* [\#11823](https://github.com/cosmos/cosmos-sdk/pull/11823) Refactor `cosmovisor` CLI to use `cobra`.
* [\#11731](https://github.com/cosmos/cosmos-sdk/pull/11731) `cosmovisor version -o json` returns the cosmovisor version and the result of `simd --output json --long` in one JSON object.

## v1.1.0 2022-10-02

Expand Down
12 changes: 4 additions & 8 deletions cosmovisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To install a previous version, you can specify the version. IMPORTANT: Chains th
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v0.1.0
```

You can run `cosmovisor --version` to check the Cosmovisor version (works only with Cosmovisor >=1.0.0).
You can run `cosmovisor version` to check the Cosmovisor version (works only with Cosmovisor >1.1.0).

You can also install from source by pulling the cosmos-sdk repository and switching to the correct version and building as follows:

Expand All @@ -62,7 +62,7 @@ The first argument passed to `cosmovisor` is the action for `cosmovisor` to take

* `help`, `--help`, or `-h` - Output `cosmovisor` help information and check your `cosmovisor` configuration.
* `run` - Run the configured binary using the rest of the provided arguments.
* `version`, or `--version` - Output the `cosmovisor` version and also run the binary with the `version` argument.
* `version` - Output the `cosmovisor` version and also run the binary with the `version` argument.

All arguments passed to `cosmovisor run` will be passed to the application binary (as a subprocess). `cosmovisor` will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. For this reason, `cosmovisor run` cannot accept any command-line arguments other than those available to the application binary.

Expand Down Expand Up @@ -209,7 +209,6 @@ You can also use `sha512sum` if you would prefer to use longer hashes, or `md5su

The following instructions provide a demonstration of `cosmovisor` using the simulation application (`simapp`) shipped with the Cosmos SDK's source code. The following commands are to be run from within the `cosmos-sdk` repository.


### Chain Setup

Let's create a new chain using the `v0.44` version of simapp (the Cosmos SDK demo app):
Expand All @@ -234,7 +233,7 @@ Set up app config:
```

Initialize the node and overwrite any previous genesis file (never do this in a production environment):

<!-- TODO: init does not read chain-id from config -->

```sh
Expand Down Expand Up @@ -289,17 +288,15 @@ cp ./build/simd $DAEMON_HOME/cosmovisor/genesis/bin

Now you can run cosmovisor with simapp v0.44:


```sh
cosmovisor run start
```


#### Update App

Update app to the latest version (e.g. v0.45).

Next, we can add a migration - which is defined using `x/upgrade` [upgrade plan](https://github.com/cosmos/cosmos-sdk/blob/main/docs/core/upgrade.md) (you may refer to a past version if you are using an older Cosmos SDK release). In a migration we can do any deterministic state change.
Next, we can add a migration - which is defined using `x/upgrade` [upgrade plan](https://github.com/cosmos/cosmos-sdk/blob/main/docs/core/upgrade.md) (you may refer to a past version if you are using an older Cosmos SDK release). In a migration we can do any deterministic state change.

Build the new version `simd` binary:

Expand All @@ -314,7 +311,6 @@ mkdir -p $DAEMON_HOME/cosmovisor/upgrades/test1/bin
cp ./build/simd $DAEMON_HOME/cosmovisor/upgrades/test1/bin
```


Open a new terminal window and submit an upgrade proposal along with a deposit and a vote (these commands must be run within 20 seconds of each other):

```sh
Expand Down
49 changes: 0 additions & 49 deletions cosmovisor/cmd/cosmovisor/cmd/help.go

This file was deleted.

44 changes: 0 additions & 44 deletions cosmovisor/cmd/cosmovisor/cmd/root.go

This file was deleted.

76 changes: 0 additions & 76 deletions cosmovisor/cmd/cosmovisor/cmd/run_test.go

This file was deleted.

88 changes: 0 additions & 88 deletions cosmovisor/cmd/cosmovisor/cmd/version.go

This file was deleted.

Loading

0 comments on commit 8076144

Please sign in to comment.