Skip to content

Commit

Permalink
docs: add wasm info to docs; update scripts (#3158)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Philip Offtermatt <[email protected]>
  • Loading branch information
MSalopek and p-offtermatt authored Jun 24, 2024
1 parent 7273079 commit e5d4a7b
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 62 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
ENTRYPOINT ["gaiad", "start"]
41 changes: 20 additions & 21 deletions contrib/single-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 4 additions & 6 deletions docs/DOCS_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,19 @@ git checkout <your_working_branch>
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.

Expand Down
67 changes: 48 additions & 19 deletions docs/docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <latest-release-tag> 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).
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Var children={currentParams.staking.MaxValidators} /> validators, see Proposal <Var children={currentParams.proposals.numberOfValidatorsProp} />, 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 themthe top <Var children={currentParams.staking.MaxValidators} /> 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).

Expand Down
3 changes: 1 addition & 2 deletions e2e.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e5d4a7b

Please sign in to comment.