Skip to content

Commit

Permalink
Merge branch 'sam/cli-docs' of github.com:cosmos/cosmos-sdk into sam/…
Browse files Browse the repository at this point in the history
…cli-docs
  • Loading branch information
samricotta committed Mar 13, 2023
2 parents 4cbc1b2 + 02e07c2 commit b17be3b
Show file tree
Hide file tree
Showing 22 changed files with 257 additions and 128 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docs/node_modules
docs/docs/modules
docs/docs/spec
docs/docs/architecture
docs/docs/rfc
docs/docs/tooling/01-cosmovisor.md
docs/docs/tooling/02-depinject.md
docs/docs/tooling/03-confix.md
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tooling/00-protobuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 1

It is known that Cosmos SDK uses protocol buffers extensively, this docuemnt is meant to provide a guide on how it is used in the cosmos-sdk.

To generate the proto file, the Cosmos SDK uses a docker image, this image is provided to all to use as well. The latest version is `ghcr.io/cosmos/proto-builder:0.11.2`
To generate the proto file, the Cosmos SDK uses a docker image, this image is provided to all to use as well. The latest version is `ghcr.io/cosmos/proto-builder:0.12.x`

Below is the example of the Cosmos SDK's commands for generating, linting, and formatting protobuf files that can be reused in any applications makefile.

Expand Down
1 change: 1 addition & 0 deletions docs/post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ rm -rf docs/tooling/04-hubl.md
rm -rf docs/run-node/04-rosetta.md
rm -rf docs/architecture
rm -rf docs/spec
rm -rf docs/rfc
rm -rf versioned_docs versioned_sidebars versions.json
5 changes: 4 additions & 1 deletion docs/pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ cp ../tools/rosetta/README.md ./docs/run-node/04-rosetta.md
cp -r ./architecture ./docs

## Add spec documentation
cp -r ./spec ./docs
cp -r ./spec ./docs

## Add rfc documentation
cp -r ./rfc ./docs
38 changes: 38 additions & 0 deletions docs/rfc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 0
---

# Requests for Comments

A Request for Comments (RFC) is a record of discussion on an open-ended topic
related to the design and implementation of the Cosmos SDK, for which no
immediate decision is required.

The purpose of an RFC is to serve as a historical record of a high-level
discussion that might otherwise only be recorded in an ad-hoc way (for example,
via gists or Google docs) that are difficult to discover for someone after the
fact. An RFC _may_ give rise to more specific architectural _decisions_ for
the Cosmos SDK, but those decisions must be recorded separately in
[Architecture Decision Records (ADR)](../architecture/).

As a rule of thumb, if you can articulate a specific question that needs to be
answered, write an ADR. If you need to explore the topic and get input from
others to know what questions need to be answered, an RFC may be appropriate.

## RFC Content

An RFC should provide:

* A **changelog**, documenting when and how the RFC has changed.
* An **abstract**, briefly summarizing the topic so the reader can quickly tell
whether it is relevant to their interest.
* Any **background** a reader will need to understand and participate in the
substance of the discussion (links to other documents are fine here).
* The **discussion**, the primary content of the document.

The [rfc-template.md](./rfc-template.md) file includes placeholders for these
sections.

## Table of Contents

<!-- - [RFC-NNN: Title](./rfc-NNN-title.md) -->
5 changes: 5 additions & 0 deletions docs/rfc/_category.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "RFCs",
"position": 12,
"link": null
}
35 changes: 35 additions & 0 deletions docs/rfc/rfc-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RFC {RFC-NUMBER}: {TITLE}

## Changelog

- {date}: {changelog}

## Abstract

> A brief high-level synopsis of the topic of discussion for this RFC, ideally
> just a few sentences. This should help the reader quickly decide whether the
> rest of the discussion is relevant to their interest.
## Background

> Any context or orientation needed for a reader to understand and participate
> in the substance of the Discussion. If necessary, this section may include
> links to other documentation or sources rather than restating existing
> material, but should provide enough detail that the reader can tell what they
> need to read to be up-to-date.
### References

> Links to external materials needed to follow the discussion may be added here.
>
> In addition, if the discussion in a request for comments leads to any design
> decisions, it may be helpful to add links to the ADR documents here after the
> discussion has settled.
## Discussion

> This section contains the core of the discussion.
>
> There is no fixed format for this section, but ideally changes to this
> section should be updated before merging to reflect any discussion that took
> place on the PR that made those changes.
5 changes: 5 additions & 0 deletions tools/cosmovisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## Features

* [#15361](https://github.com/cosmos/cosmos-sdk/pull/15361) Add `cosmovisor config` command to display the configuration used by cosmovisor.

## Client Breaking Changes

* [#14881](https://github.com/cosmos/cosmos-sdk/pull/14881) Cosmovisor supports only upgrade plan with a checksum. This is enforced by the `x/upgrade` module for better security.
Expand All @@ -44,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* [#14881](https://github.com/cosmos/cosmos-sdk/pull/14881) Refactor Cosmovisor to use `x/upgrade` validation logic.
* [#14881](https://github.com/cosmos/cosmos-sdk/pull/14881) Refactor Cosmovisor to depend only on the `x/upgrade` module.
* [#15362](https://github.com/cosmos/cosmos-sdk/pull/15362) Allow disabling Cosmovisor logs

## v1.4.0 2022-10-23

Expand Down
51 changes: 21 additions & 30 deletions tools/cosmovisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ sidebar_position: 1

`cosmovisor` is a small process manager for Cosmos SDK application binaries that monitors the governance module for incoming chain upgrade proposals. If it sees a proposal that gets approved, `cosmovisor` can automatically download the new binary, stop the current binary, switch from the old binary to the new one, and finally restart the node with the new binary.

* [Design](#design)
* [Contributing](#contributing)
* [Setup](#setup)
* [Installation](#installation)
* [Command Line Arguments And Environment Variables](#command-line-arguments-and-environment-variables)
* [Folder Layout](#folder-layout)
* [Usage](#usage)
* [Initialization](#initialization)
* [Detecting Upgrades](#detecting-upgrades)
* [Auto-Download](#auto-download)
* [Example: SimApp Upgrade](#example-simapp-upgrade)
* [Chain Setup](#chain-setup)
* [Prepare Cosmovisor and Start the Chain](#prepare-cosmovisor-and-start-the-chain)
* [Update App](#update-app)
* [Cosmovisor](#cosmovisor)
* [Design](#design)
* [Contributing](#contributing)
* [Setup](#setup)
* [Installation](#installation)
* [Command Line Arguments And Environment Variables](#command-line-arguments-and-environment-variables)
* [Folder Layout](#folder-layout)
* [Usage](#usage)
* [Initialization](#initialization)
* [Detecting Upgrades](#detecting-upgrades)
* [Auto-Download](#auto-download)
* [Example: SimApp Upgrade](#example-simapp-upgrade)
* [Chain Setup](#chain-setup)
* [Prepare Cosmovisor and Start the Chain](#prepare-cosmovisor-and-start-the-chain)
* [Update App](#update-app)

## Design

Expand Down Expand Up @@ -60,22 +61,11 @@ go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v0.1.0

Run `cosmovisor version` to check the cosmovisor version.

You can also install from source by pulling the cosmos-sdk repository and switching to the correct version and building as follows:
Alternatively, for building from source, simply run `make cosmovisor`. The binary will be located in `tools/cosmovisor`.

```shell
git clone git@github.com:cosmos/cosmos-sdk
cd cosmos-sdk
git checkout cosmovisor/vx.x.x
make cosmovisor
```

This will build cosmovisor in `/cosmovisor` directory. Afterwards you may want to put it into your machine's PATH like as follows:

```shell
cp cosmovisor/cosmovisor ~/go/bin/cosmovisor
```

*Note: If you are using go `v1.15` or earlier, you will need to use `go get`, and you may want to run the command outside a project directory.*
:::warning
Building from source using `make cosmovisor` won't display the correct `cosmovisor` version.
:::

### Command Line Arguments And Environment Variables

Expand All @@ -99,7 +89,8 @@ All arguments passed to `cosmovisor run` will be passed to the application binar
* `DAEMON_POLL_INTERVAL` (*optional*, default 300 milliseconds), is the interval length for polling the upgrade plan file. The value must be a duration (e.g. `1s`).
* `DAEMON_DATA_BACKUP_DIR` option to set a custom backup directory. If not set, `DAEMON_HOME` is used.
* `UNSAFE_SKIP_BACKUP` (defaults to `false`), if set to `true`, upgrades directly without performing a backup. Otherwise (`false`, default) backs up the data before trying the upgrade. The default value of false is useful and recommended in case of failures and when a backup needed to rollback. We recommend using the default backup option `UNSAFE_SKIP_BACKUP=false`.
* `DAEMON_PREUPGRADE_MAX_RETRIES` (defaults to `0`). The maximum number of times to call `pre-upgrade` in the application after exit status of `31`. After the maximum number of retries, cosmovisor fails the upgrade.
* `DAEMON_PREUPGRADE_MAX_RETRIES` (defaults to `0`). The maximum number of times to call `pre-upgrade` in the application after exit status of `31`. After the maximum number of retries, Cosmovisor fails the upgrade.
* `COSMOVISOR_DISABLE_LOGS` (defaults to `false`). If set to true, this will disable Cosmovisor logs (but not the underlying process) completely. This may be useful, for example, when a Cosmovisor subcommand you are executing returns a valid JSON you are then parsing, as logs added by Cosmovisor make this output not a valid JSON.

### Folder Layout

Expand Down
6 changes: 6 additions & 0 deletions tools/cosmovisor/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
EnvDataBackupPath = "DAEMON_DATA_BACKUP_DIR"
EnvInterval = "DAEMON_POLL_INTERVAL"
EnvPreupgradeMaxRetries = "DAEMON_PREUPGRADE_MAX_RETRIES"
EnvDisableLogs = "COSMOVISOR_DISABLE_LOGS"
)

const (
Expand All @@ -51,6 +52,7 @@ type Config struct {
UnsafeSkipBackup bool
DataBackupPath string
PreupgradeMaxRetries int
DisableLogs bool

// currently running upgrade
currentUpgrade upgradetypes.Plan
Expand Down Expand Up @@ -158,6 +160,9 @@ func GetConfigFromEnv() (*Config, error) {
if cfg.UnsafeSkipBackup, err = booleanOption(EnvSkipBackup, false); err != nil {
errs = append(errs, err)
}
if cfg.DisableLogs, err = booleanOption(EnvDisableLogs, false); err != nil {
errs = append(errs, err)
}

interval := os.Getenv(EnvInterval)
if interval != "" {
Expand Down Expand Up @@ -369,6 +374,7 @@ func (cfg Config) DetailString() string {
{EnvSkipBackup, fmt.Sprintf("%t", cfg.UnsafeSkipBackup)},
{EnvDataBackupPath, cfg.DataBackupPath},
{EnvPreupgradeMaxRetries, fmt.Sprintf("%d", cfg.PreupgradeMaxRetries)},
{EnvDisableLogs, fmt.Sprintf("%t", cfg.DisableLogs)},
}

derivedEntries := []struct{ name, value string }{
Expand Down
Loading

0 comments on commit b17be3b

Please sign in to comment.