安装go环境

下载并安装go

https://golang.org/dl/

wget https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz // 下载
tar -C $HOME -xzf go$VERSION.$OS-$ARCH.tar.gz // 解压到home/go

配置环境变量

mkdir -p $HOME/go/bin
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile
echo "export PATH=$PATH:$GOBIN" >> ~/.bash_profile
source ~/.bash_profile

安装cosmos

先解决墙内问题

一键解决 go get golang.org/x 包失败

https://shockerli.net/post/go-get-golang-org-x-solution/

export GO111MODULE=on
export GOPROXY=https://goproxy.io
// Go version >= 1.11

下载代码并编译

mkdir -p $GOPATH/src/github.com/cosmos
cd $GOPATH/src/github.com/cosmos
git clone https://github.com/cosmos/cosmos-sdk
cd cosmos-sdk && git checkout v0.35.0
make tools install

那将安装gaiad和gaiacli二进制文件。验证一切正常:

gaiad version --long
gaiacli version --long

安装jq

sudo apt-get install jq

开始配置

设置新节点

gaiad init <your_custom_moniker> // 注意Monikers只能包含ASCII字符。使用Unicode字符将使您的节点无法访问。

您可以moniker稍后在~/.gaiad/config/config.toml文件中进行编辑:

# A custom human readable name for this node
moniker = "<your_custom_moniker>"

您可以编辑该~/.gaiad/config/gaiad.toml文件以启用反垃圾邮件机制并拒绝低于最低汽油价格的传入交易:

# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml

##### main base config options #####

# The minimum gas prices a validator is willing to accept for processing a
# transaction. A transaction's fees must meet the minimum of any denomination
# specified in this config (e.g. 10uatom).

minimum-gas-prices = ""

您的完整节点已初始化!

创建Genesis文件并启动网络

# You can run all of these commands from your home directory
cd $HOME

# Initialize the genesis.json file that will help you to bootstrap the network
gaiad init --chain-id=testing testing

# Create a key to hold your validator account
gaiacli keys add validator

# Add that key into the genesis.app_state.accounts array in the genesis file
# NOTE: this command lets you set the number of coins. Make sure this account has some coins
# with the genesis.app_state.staking.params.bond_denom denom, the default is staking
gaiad add-genesis-account $(gaiacli keys show validator -a) 1000000000stake,1000000000validatortoken

# Generate the transaction that creates your validator
gaiad gentx --name validator

# Add the generated bonding transaction to the genesis file
gaiad collect-gentxs

# Now its safe to start `gaiad`
gaiad start

此设置将所有数据gaiad放入~/.gaiad。您可以检查您创建的创世纪文件~/.gaiad/config/genesis.json。使用此配置gaiacli也可以使用并且具有令牌帐户(包括放样和自定义)。

参考

https://www.jianshu.com/p/38736bdc08d8
https://cosmos.network/docs/cosmos-hub/installation.html#install-gaia
https://github.com/cosmos/cosmos-sdk/issues/4634