You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->
The pull request fixes the staking amount, adds the auto-restart option, and improves the user flow for the simd example. This pull request also fixes spelling and grammar, updates content for clarity, and applies consistent formatting.
---
### 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 `docs:` prefix in the PR title
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [x] followed the [documentation writing guidelines](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOC_WRITING_GUIDELINES.md)
- [x] reviewed "Files changed" and left comments if necessary
- [x] 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 `docs:` prefix in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] confirmed that this PR only changes documentation
- [ ] reviewed content for consistency
- [ ] reviewed content for thoroughness
- [ ] reviewed content for spelling and grammar
- [ ] tested instructions (if applicable)
Copy file name to clipboardExpand all lines: cosmovisor/README.md
+77-94
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,29 @@
1
1
# Cosmosvisor Quick Start
2
2
3
-
`cosmovisor` is a small process manager around Cosmos SDK binaries that monitors the governance module via stdout to see if there's a chain upgrade proposal coming in. If it see a proposal that gets approved it can be run manually or automatically to download the new code, stop the node, run the migration script, replace the node binary, and start with the new genesis file.
3
+
`cosmovisor` is a small process manager for Cosmos SDK binaries that monitors the governance module via stdout for incoming chain upgrade proposals. If it sees a proposal that gets approved, it can be run manually or automatically to download the new binary, stop the current binary, run the migration script, replace the old node binary with the new one, and finally restart the node with the new genesis file.
4
4
5
5
## Installation
6
6
7
-
Run:
7
+
To install `cosmovisor`, run the following command:
8
8
9
-
`go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor`
9
+
```
10
+
go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor
11
+
```
10
12
11
13
## Command Line Arguments And Environment Variables
12
14
13
-
All arguments passed to the `cosmovisor` program will be passed to the current daemon binary (as a subprocess).
14
-
It will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. Because of that, it cannot accept
15
-
any command line arguments, nor print anything to output (unless it terminates unexpectedly before executing a
16
-
binary).
15
+
All arguments passed to the `cosmovisor` program will be passed to the current daemon binary (as a subprocess). `cosmovisor` will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. For this reason, `cosmovisor` cannot accept any command line arguments, nor print anything to output (unless it terminates unexpectedly before executing a binary).
17
16
18
17
`cosmovisor` reads its configuration from environment variables:
19
18
20
-
*`DAEMON_HOME` is the location where upgrade binaries should be kept (e.g. `$HOME/.gaiad` or `$HOME/.xrnd`).
21
-
*`DAEMON_NAME` is the name of the binary itself (eg. `xrnd`, `gaiad`, `simd`, etc).
22
-
*`DAEMON_ALLOW_DOWNLOAD_BINARIES` (*optional*) if set to `true` will enable auto-downloading of new binaries
23
-
(for security reasons, this is intended for full nodes rather than validators).
24
-
*`DAEMON_RESTART_AFTER_UPGRADE` (*optional*) if set to `true` it will restart the sub-process with the same
25
-
command line arguments and flags (but new binary) after a successful upgrade. By default, `cosmovisor` dies
26
-
afterwards and allows the supervisor to restart it if needed. Note that this will not auto-restart the child
27
-
if there was an error.
19
+
*`DAEMON_HOME` is the location where the `cosmovisor/` directory is kept that contains the upgrade binaries (e.g. `$HOME/.gaiad`, `$HOME/.regend`, `$HOME/.simd`, etc.).
20
+
*`DAEMON_NAME` is the name of the binary itself (e.g. `gaiad`, `regend`, `simd`, etc.).
21
+
*`DAEMON_ALLOW_DOWNLOAD_BINARIES` (*optional*), if set to `true`, will enable auto-downloading of new binaries (for security reasons, this is intended for full nodes rather than validators). By default, `cosmovisor` will not auto-download new binaries.
22
+
*`DAEMON_RESTART_AFTER_UPGRADE` (*optional*), if set to `true`, will restart the subprocess with the same command line arguments and flags (but with the new binary) after a successful upgrade. By default, `cosmovisor` stops running after an upgrade and requires the system administrator to manually restart it. Note that `cosmovisor` will not auto-restart the subprocess if there was an error.
28
23
29
24
## Data Folder Layout
30
25
31
-
`$DAEMON_HOME/cosmovisor` is expected to belong completely to `cosmovisor` and
32
-
subprocesses that are controlled by it. The folder content is organised as follows:
26
+
`$DAEMON_HOME/cosmovisor` is expected to belong completely to `cosmovisor` and the subprocesses that are controlled by it. The folder content is organized as follows:
33
27
34
28
```
35
29
.
@@ -43,18 +37,11 @@ subprocesses that are controlled by it. The folder content is organised as follo
43
37
└── $DAEMON_NAME
44
38
```
45
39
46
-
Each version of the Cosmos SDK application is stored under either `genesis` or `upgrades/<name>`, which holds `bin/$DAEMON_NAME`
47
-
along with any other needed files such as auxiliary client programs or libraries. `current` is a symbolic link to the currently
48
-
active folder (so `current/bin/$DAEMON_NAME` is the currently active binary).
40
+
Each version of the Cosmos SDK application is stored under either `genesis` or `upgrades/<name>`, which holds `bin/$DAEMON_NAME` along with any other needed files such as auxiliary client programs or libraries. `current` is a symbolic link to the currently active folder and `current/bin/$DAEMON_NAME` is the currently active binary.
49
41
50
-
*Note: the`name` variable in `upgrades/<name>` holds the URI-encoded name of the upgrade as specified in the upgrade module plan.*
42
+
*Note: The`name` variable in `upgrades/<name>` holds the URI-encoded name of the upgrade as specified in the upgrade module plan.*
51
43
52
-
Please note that `$DAEMON_HOME/cosmovisor` just stores the *binaries* and associated *program code*.
53
-
The `cosmovisor` binary can be stored in any typical location (eg `/usr/local/bin`). The actual blockchain
54
-
program will store it's data under their default data directory (e.g. `$HOME/.gaiad`) which is independent of
55
-
the `$DAEMON_HOME`. You can choose to set `$DAEMON_HOME` to the actual binary's home directory and then end up
56
-
with a configuation like the following, but this is left as a choice to the system admininstrator for best
57
-
directory layout:
44
+
Please note that `$DAEMON_HOME/cosmovisor` just stores the *binaries* and associated *program code*. The `cosmovisor` binary can be stored in any typical location (e.g. `/usr/local/bin`). The actual blockchain program will store its data under the default data directory (e.g. `$HOME/.gaiad`) which is independent of `$DAEMON_HOME`. `$DAEMON_HOME` can be set to any location. If you set `$DAEMON_HOME` to the default data directory, you will end up with a configuation like the following:
58
45
59
46
```
60
47
.gaiad
@@ -65,37 +52,27 @@ directory layout:
65
52
66
53
## Usage
67
54
68
-
The system administrator admin is responsible for:
55
+
The system administrator is responsible for:
69
56
70
-
* installing the `cosmovisor` binary and configure the host's init system (e.g. `systemd`, `launchd`, etc) along with the environmental variables appropriately;
71
-
* installing the `genesis` folder manually;
72
-
* installing the `upgrades/<name>` folders manually.
57
+
- installing the `cosmovisor` binary
58
+
- configuring the host's init system (e.g. `systemd`, `launchd`, etc.)
59
+
- appropriately setting the environmental variables
60
+
- installing the `genesis` folder manually
61
+
- installing the `upgrades/<name>` folders manually
73
62
74
-
`cosmovisor` will set the `current` link to point to `genesis` at first start (when no `current` link exists) and handles
75
-
binaries switch overs at the correct points in time, so that the system administrator can prepare days in advance and relax at upgrade time.
63
+
`cosmovisor` will set the `current` link to point to `genesis` at first start (when no `current` link exists) and will handle switching binaries at the correct points in time so that the system administrator can prepare days in advance and relax at upgrade time.
76
64
77
-
Note that blockchain applications that wish to support upgrades may package up a genesis `cosmovisor` tarball with this information,
78
-
just as they prepare the genesis binary tarball. In fact, they may offer a tarball will all upgrades up to current point for easy download
79
-
for those who wish to sync a fullnode from start.
65
+
Note that blockchain applications that wish to support upgrades may package up a genesis `cosmovisor` tarball with this information, just as they prepare the genesis binary tarball. In fact, they may package up a tarball with all upgrades up to a current point so that the upgrades can be easily downloaded for others who wish to sync a fullnode from start.
80
66
81
-
The `DAEMON` specific code and operations (e.g. tendermint config, the application db, syncing blocks, etc) are performed as normal.
82
-
Application binaries' directives such as command-line flags and environment variables work normally.
67
+
The `DAEMON` specific code and operations (e.g. tendermint config, the application db, syncing blocks, etc.) all work as expected. The application binaries' directives such as command-line flags and environment variables also work as expected.
83
68
84
69
## Auto-Download
85
70
86
-
Generally, the system requires that the system administrator place all relevant binaries
87
-
on the disk before the upgrade happens. However, for people who don't need such
88
-
control and want an easier setup (maybe they are syncing a non-validating fullnode
89
-
and want to do little maintenance), there is another option.
71
+
Generally, the system requires that the system administrator place all relevant binaries on the disk before the upgrade happens. However, for people who don't need such control and want an easier setup (maybe they are syncing a non-validating fullnode and want to do little maintenance), there is another option.
90
72
91
-
If you set `DAEMON_ALLOW_DOWNLOAD_BINARIES=on` then when an upgrade is triggered and no local binary
92
-
can be found, the `cosmovisor` will attempt to download and install the binary itself.
93
-
The plan stored in the upgrade module has an info field for arbitrary json.
94
-
This info is expected to be outputed on the halt log message. There are two
95
-
valid format to specify a download in such a message:
73
+
If you set `DAEMON_ALLOW_DOWNLOAD_BINARIES=on`, and no local binary can be found when an upgrade is triggered, `cosmovisor` will attempt to download and install the binary itself. The plan stored in the upgrade module has an info field for arbitrary JSON. This info is expected to be outputed on the halt log message. There are two valid formats to specify a download in such a message:
96
74
97
-
1. Store an os/architecture -> binary URI map in the upgrade plan info field
98
-
as JSON under the `"binaries"` key, eg:
75
+
1. Store an os/architecture -> binary URI map in the upgrade plan info field as JSON under the `"binaries"` key. For example:
99
76
100
77
```json
101
78
{
@@ -105,74 +82,76 @@ as JSON under the `"binaries"` key, eg:
105
82
}
106
83
```
107
84
108
-
2. Store a link to a file that contains all information in the above format (eg. if you want
109
-
to specify lots of binaries, changelog info, etc without filling up the blockchain).
85
+
2. Store a link to a file that contains all information in the above format (e.g. if you want to specify lots of binaries, changelog info, etc. without filling up the blockchain). For example:
e.g. `https://example.com/testnet-1001-info.json?checksum=sha256:deaaa99fda9407c4dbe1d04bd49bab0cc3c1dd76fa392cd55a9425be074af01e`
91
+
This file contained in the link will be retrieved by [go-getter](https://github.com/hashicorp/go-getter) and the `"binaries"` field will be parsed as above.
112
92
113
-
This file contained in the link will be retrieved by [go-getter](https://github.com/hashicorp/go-getter)
114
-
and the `"binaries"` field will be parsed as above.
93
+
If there is no local binary, `DAEMON_ALLOW_DOWNLOAD_BINARIES=on`, and we can access a canonical url for the new binary, then the `cosmovisor` will download it with [go-getter](https://github.com/hashicorp/go-getter) and unpack it into the `upgrades/<name>` folder to be run as if we installed it manually.
115
94
116
-
If there is no local binary, `DAEMON_ALLOW_DOWNLOAD_BINARIES=on`, and we can access a canonical url for the new binary,
117
-
then the `cosmovisor` will download it with [go-getter](https://github.com/hashicorp/go-getter) and
118
-
unpack it into the `upgrades/<name>` folder to be run as if we installed it manually.
95
+
Note that for this mechanism to provide strong security guarantees, all URLs should include a SHA 256/512 checksum. This ensures that no false binary is run, even if someone hacks the server or hijacks the DNS. `go-getter` will always ensure the downloaded file matches the checksum if it is provided. `go-getter` will also handle unpacking archives into directories (in this case the download link should point to a `zip` file of all data in the `bin` directory).
96
+
97
+
To properly create a sha256 checksum on linux, you can use the `sha256sum` utility. For example:
98
+
99
+
```
100
+
sha256sum ./testdata/repo/zip_directory/autod.zip
101
+
```
119
102
120
-
Note that for this mechanism to provide strong security guarantees, all URLS should include a
121
-
sha{256,512} checksum. This ensures that no false binary is run, even if someone hacks the server
122
-
or hijacks the DNS. go-getter will always ensure the downloaded file matches the checksum if it
123
-
is provided. go-getter will also handle unpacking archives into directories (so these download links should be
124
-
a zip of all data in the `bin` directory).
103
+
The result will look something like the following: `29139e1381b8177aec909fab9a75d11381cab5adf7d3af0c05ff1c9c117743a7`.
125
104
126
-
To properly create a checksum on linux, you can use the `sha256sum` utility. e.g.
which should return `29139e1381b8177aec909fab9a75d11381cab5adf7d3af0c05ff1c9c117743a7`.
129
-
You can also use `sha512sum` if you like longer hashes, or `md5sum` if you like to use broken hashes.
130
-
Make sure to set the hash algorithm properly in the checksum argument to the url.
105
+
You can also use `sha512sum` if you would prefer to use longer hashes, or `md5sum` if you would prefer to use broken hashes. Whichever you choose, make sure to set the hash algorithm properly in the checksum argument to the URL.
131
106
132
107
## Example: simd
133
108
134
-
The following instructions provide a demonstration of `cosmovisor`'s integration with the `simd` application
135
-
shipped along the Cosmos SDK's source code.
109
+
The following instructions provide a demonstration of `cosmovisor`'s integration with the `simd` application shipped along the Cosmos SDK's source code. The following commands are to be run from within the `cosmos-sdk` repository.
For the sake of this demonstration, we would amend `voting_params.voting_period` in `.simapp/config/genesis.json` to a reduced time ~5 minutes (300s) and eventually launch`cosmosvisor`:
148
+
For the sake of this demonstration, amend `voting_params.voting_period` in `$HOME/.simapp/config/genesis.json` to a reduced time of ~5 minutes (`300s`) and then start`cosmosvisor`:
170
149
171
150
```
172
151
cosmovisor start
173
152
```
174
153
175
-
Submit a software upgrade proposal:
154
+
Open a new terminal window and submit a software upgrade proposal:
For the sake of this demonstration, we will hardcode a modification in `simapp` to simulate a code change. In `simapp/app.go`, find the line containing the `UpgradeKeeper` initialization. It should look like the following:
Now recompile a new binary and place it in `$DAEMON_HOME/cosmosvisor/upgrades/test1/bin`:
194
+
Now recompile a new binary and make a copy of it in `$DAEMON_HOME/cosmosvisor/upgrades/test1/bin` (you may need to run `export DAEMON_HOME=$HOME/.simapp` again if you are using a new window):
0 commit comments