From e5d4a7bff64dd8b12a8e2fc16b8c16f04301ba88 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Mon, 24 Jun 2024 21:58:00 +0200 Subject: [PATCH] docs: add wasm info to docs; update scripts (#3158) * docs: update docs - add cosmwasm * build: update dockerfiles * scripts: update startup script for single node * Update docs/docs/getting-started/installation.md Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --------- Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --- Dockerfile | 11 +-- contrib/single-node.sh | 41 ++++++------ docs/DOCS_README.md | 10 ++- docs/docs/getting-started/installation.md | 67 +++++++++++++------ .../{quickstart.mdx => quickstart.md} | 6 +- .../validators/{overview.mdx => overview.md} | 5 +- e2e.Dockerfile | 3 +- 7 files changed, 81 insertions(+), 62 deletions(-) rename docs/docs/getting-started/{quickstart.mdx => quickstart.md} (97%) rename docs/docs/validators/{overview.mdx => overview.md} (81%) diff --git a/Dockerfile b/Dockerfile index c0fa9b78579..cc142c895a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,11 +22,12 @@ RUN LEDGER_ENABLED=true LINK_STATICALLY=true BUILD_TAGS=muslc make build RUN echo "Ensuring binary is statically linked ..." \ && file /src/app/build/gaiad | grep "statically linked" -# Add to a distroless container -FROM cgr.dev/chainguard/static:$IMG_TAG +FROM alpine:$IMG_TAG +RUN apk add --no-cache build-base +RUN adduser -D nonroot ARG IMG_TAG -COPY --from=gaiad-builder /src/app/build/gaiad /usr/local/bin/ +COPY --from=gaiad-builder /src/app/build/gaiad /usr/local/bin/ EXPOSE 26656 26657 1317 9090 -USER 0 +USER nonroot -ENTRYPOINT ["gaiad", "start"] \ No newline at end of file +ENTRYPOINT ["gaiad", "start"] diff --git a/contrib/single-node.sh b/contrib/single-node.sh index 38c7d492ec6..8ac5ad3ea2c 100755 --- a/contrib/single-node.sh +++ b/contrib/single-node.sh @@ -2,30 +2,29 @@ set -o errexit -o nounset -CHAINID=$1 -GENACCT=$2 - -if [ -z "$1" ]; then - echo "Need to input chain id..." - exit 1 -fi - -if [ -z "$2" ]; then - echo "Need to input genesis account address..." - exit 1 -fi - -# Build genesis file incl account for passed address -coins="10000000000stake,100000000000samoleans" -gaiad init --chain-id $CHAINID $CHAINID +HOME_DIR="${1:-$HOME}" +CHAINID="test-gaia" +USER_COINS="100000000000stake" +STAKE="100000000stake" +MONIKER="gaia-test-node" + + +echo "Using home dir: $HOME_DIR" +gaiad init --chain-id $CHAINID $MONIKER --home "$HOME_DIR/.gaia" + +echo "Setting up genesis file" +jq ".app_state.gov.params.voting_period = \"20s\" | .app_state.gov.params.expedited_voting_period = \"10s\" | .app_state.staking.params.unbonding_time = \"86400s\"" \ + "${HOME_DIR}/gaia/config/genesis.json" > \ + "${HOME_DIR}/edited_genesis.json" && mv "${HOME_DIR}/edited_genesis.json" "${HOME_DIR}/config/genesis.json" + + gaiad keys add validator --keyring-backend="test" -gaiad genesis add-genesis-account $(gaiad keys show validator -a --keyring-backend="test") $coins -gaiad genesis add-genesis-account $GENACCT $coins -gaiad genesis gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID +gaiad genesis add-genesis-account $(gaiad keys show validator -a --keyring-backend="test") $USER_COINS +gaiad genesis gentx validator $STAKE --keyring-backend="test" --chain-id $CHAINID gaiad genesis collect-gentxs # Set proper defaults and change ports -echo "Setting rpc listen address" +echo "Setting up node configs" # sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml sleep 1 sed -i -r 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml @@ -34,4 +33,4 @@ sed -i -r 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/conf sed -i -r 's/minimum-gas-prices = ""/minimum-gas-prices = "0stake"/g' ~/.gaia/config/app.toml # Start the gaia -gaiad start --pruning=nothing +gaiad start --api.enable=true diff --git a/docs/DOCS_README.md b/docs/DOCS_README.md index 5ddfb8e6fb7..c728bdd26dc 100644 --- a/docs/DOCS_README.md +++ b/docs/DOCS_README.md @@ -82,21 +82,19 @@ git checkout cd docs ``` -Serve the app +Start the app ```bash -npm run serve +npm run start ``` then navigate to `localhost:3000` in your browser. To build documentation as a static website run `npm run build`. You will find the website in `build` directory. +After building the docs website you can start it with `npm run serve`. -## Search -We are using [Algolia](https://www.algolia.com) to power full-text search. This uses a public API search-only key in the `config.js` as well as a [cosmos_network.json](https://github.com/algolia/docsearch-configs/blob/master/configs/cosmos_network.json) configuration file that we can update with PRs. - -### Update and Build the RPC docs +## Update and Build the RPC docs 1. Execute the following command at the root directory to install the swagger-ui generate tool. diff --git a/docs/docs/getting-started/installation.md b/docs/docs/getting-started/installation.md index 52ba392e9b6..c09d901444e 100644 --- a/docs/docs/getting-started/installation.md +++ b/docs/docs/getting-started/installation.md @@ -20,29 +20,33 @@ Install `make` and `gcc`. **Ubuntu:** ```bash -sudo apt-get update +sudo apt update -sudo apt-get install -y make gcc +sudo apt install -y make gcc build-essential ``` ## Install Go :::tip -**Go 1.21+** is required. +**Go 1.22+** is required. ::: We suggest the following two ways to install Go. Check out the [official docs](https://golang.org/doc/install) and Go installer for the correct download for your operating system. Alternatively, you can install Go yourself from the command line. Detailed below are standard default installation locations, but feel free to customize. +Since the introduction of CosmWasm in Gaia v18 it is recommended to build the binaries with `CGO` enabled - simply set `CGO_ENABLED=1` in your terminal befre building the binary. + +Building the `gaiad` binary on Windows is not supported due to [dependency issues](https://github.com/CosmWasm/wasmvm). + **[Go Binary Downloads](https://go.dev/dl/)** **Ubuntu:** -At the time of this writing, the latest release is `1.21.7`. We're going to download the tarball, extract it to `/usr/local`, and export `GOROOT` to our `$PATH` +At the time of this writing, the latest release is `1.22.3`. We're going to download the tarball, extract it to `/usr/local`, and export `GOROOT` to our `$PATH` ```bash -curl -OL https://go.dev/dl/go1.21.7.darwin-amd64.tar.gz +curl -OL https://go.dev/dl/go1.22.3.darwin-amd64.tar.gz -sudo tar -C /usr/local -xvf https://go.dev/dl/go1.21.7.darwin-amd64.tar.gz +sudo tar -C /usr/local -xvf https://go.dev/dl/go1.22.3.darwin-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin @@ -94,31 +98,56 @@ You should see something similar to the following: ```bash name: gaia server_name: gaiad -version: v15.0.0 +version: v18.0.0 commit: 682770f2410ab0d33ac7f0c7203519d7a99fa2b6 -build_tags: netgo,ledger -go: go version go1.21.7 linux/amd64 +build_tags: netgo,ledger,muslc +go: go version go1.22.3 linux/amd64 +``` + +## Docker + +`Dockerfile` is available in the gaia repo. + +Building: + +```shell +git clone -b https://github.com/cosmos/gaia.git +cd gaia +docker build -t cosmos-ics:local -f Dockerfile ./ ``` +## Static linking + +In case you need to build a binary with all dependencies statically linked please check our [Dockerfile](https://github.com/cosmos/gaia/blob/main/Dockerfile). + +You must have `libwasmvm` available on your machine. +Choose the build that matches your platform and OS: +* https://github.com/CosmWasm/wasmvm?tab=readme-ov-file#builds-of-libwasmvm + +For more information, please check `wasmvm` [documentation](https://github.com/CosmWasm/wasmvm). + + ### Build Tags Build tags indicate special features that have been enabled in the binary. -| Build Tag | Description | -| --------- | ----------------------------------------------- | -| netgo | Name resolution will use pure Go code | -| ledger | Ledger devices are supported (hardware wallets) | +| Build Tag | Description | +|-------------------|-------------------------------------------------| +| netgo | Name resolution will use pure Go code | +| ledger | Ledger devices are supported (hardware wallets) | +| static_wasm/muslc | Used for statically linked wasmd dependencies | + ## Work with a Cosmos SDK Clone To work with your own modifications of the Cosmos SDK, make a fork of this repo, and add a `replace` clause to the `go.mod` file. -The `replace` clause you add to `go.mod` must provide the correct import path: - -- Make appropriate changes -- Add `replace github.com/cosmos/cosmos-sdk => /path/to/clone/cosmos-sdk` to `go.mod` -- Run `make clean install` or `make clean build` -- Test changes +The `replace` clause you add to `go.mod` must provide the correct import path. +```shell +go mod edit -replace github.com/cosmos/cosmos-sdk=../cosmos-sdk +go mod tidy +make install # or make build +``` ## Next Now you can [join the mainnet](../hub-tutorials/join-mainnet), [the public testnet](../hub-tutorials/join-testnet). diff --git a/docs/docs/getting-started/quickstart.mdx b/docs/docs/getting-started/quickstart.md similarity index 97% rename from docs/docs/getting-started/quickstart.mdx rename to docs/docs/getting-started/quickstart.md index 0b6388563da..7ea9c8bec85 100644 --- a/docs/docs/getting-started/quickstart.mdx +++ b/docs/docs/getting-started/quickstart.md @@ -2,10 +2,6 @@ title: Quick Start - Join Mainnet sidebar_position: 3 --- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - **Bootstrap a `cosmoshub-4` mainnet node** ### Prerequisites @@ -24,7 +20,7 @@ For reference, the list of `rpc_servers` and `persistent` peers can be found in ```bash # Build gaiad binary and initialize chain cd $HOME -git clone -b v15.0.0 https://github.com/cosmos/gaia --depth=1 +git clone -b v18.0.0 https://github.com/cosmos/gaia --depth=1 cd gaiad make install gaiad init CUSTOM_MONIKER --chain-id cosmoshub-4 diff --git a/docs/docs/validators/overview.mdx b/docs/docs/validators/overview.md similarity index 81% rename from docs/docs/validators/overview.mdx rename to docs/docs/validators/overview.md index d0c08c08e98..af4d16b87b5 100644 --- a/docs/docs/validators/overview.mdx +++ b/docs/docs/validators/overview.md @@ -3,14 +3,11 @@ title: Validator Overview order: 1 --- -import { Var } from '@site/src/js/Var'; -import { currentParams } from '@site/docs/governance/current-parameters.js'; - ## Introduction The Cosmos Hub is based on [CometBFT](https://docs.cometbft.com/v0.37/introduction/what-is-cometbft) that relies on a set of validators that are responsible for committing new blocks in the blockchain. These validators participate in the consensus protocol by broadcasting votes that contain cryptographic signatures signed by each validator's private key. -Validator candidates can bond their own ATOM and have ATOM ["delegated"](../delegators/delegator-guide-cli.md), or staked, to them by token holders. The Cosmos Hub has validators, see Proposal , but over time the number of validators can be increased with governance proposals. The validators are determined by the total number of ATOM tokens delegated to them — the top validator candidates with the most voting power are the current Cosmos validators. +Validator candidates can bond their own ATOM and have ATOM ["delegated"](../delegators/delegator-guide-cli.md), or staked, to them by token holders. The Cosmos Hub has 180 active validators, but over time the number of validators can be changed through governance (`MaxValidators` parameter). Validator voting power is determined by the total number of ATOM tokens delegated to them. Validators that do not have enough voting power to be in the top 180 are considered inactive. Inactive validators can become active if their staked amount increases so that they fall into the top 180 validators. Validators and their delegators earn ATOM as block provisions and tokens as transaction fees through execution of the Tendermint consensus protocol. Note that validators can set a commission percentage on the fees their delegators receive as additional incentive. You can find an overview of all current validators and their voting power on [Mintscan](https://www.mintscan.io/cosmos/validators). diff --git a/e2e.Dockerfile b/e2e.Dockerfile index 6a9c547a659..90bf70bd6f3 100644 --- a/e2e.Dockerfile +++ b/e2e.Dockerfile @@ -3,7 +3,7 @@ ARG IMG_TAG=latest # Compile the gaiad binary FROM golang:1.22-alpine AS gaiad-builder WORKDIR /src/app/ -ENV PACKAGES="curl make git libc-dev bash file gcc linux-headers eudev-dev python3" +ENV PACKAGES="curl make git libc-dev bash file gcc linux-headers eudev-dev" RUN apk add --no-cache $PACKAGES # See https://github.com/CosmWasm/wasmvm/releases @@ -22,7 +22,6 @@ RUN LEDGER_ENABLED=false LINK_STATICALLY=true BUILD_TAGS=muslc make build RUN echo "Ensuring binary is statically linked ..." \ && file /src/app/build/gaiad | grep "statically linked" -# Add to a distroless container FROM alpine:$IMG_TAG RUN apk add --no-cache build-base RUN adduser -D nonroot