gaiad 全节点升级到新版本。
Cosmovisor
Cosmos SDK 提供了一个便捷的进程管理器,它封装在gaiad 二进制之上,并且可以在治理升级提案成功通过后自动切换到新的二进制文件。Cosmovisor 完全是可选的,但推荐使用。更多信息请参阅 cosmos.network 文档 和 cosmos-sdk/cosmovisor/readme。
设置
要开始使用 Cosmovisor,先下载它gaiad
为升级做准备
Cosmovisor 会持续轮询$DAEMON_HOME/data/upgrade-info.json 以获取新的升级指令。当升级准备就绪时,节点运营者可以下载新的二进制文件,并将其放到 $DAEMON_HOME/cosmovisor/upgrades/<name>/bin 目录下,其中 <name> 是升级模块计划中指定的、经过 URI 编码的升级名称。
也可以让 Cosmovisor 自动下载新的二进制文件。为此请设置以下环境变量。
手动软件升级
先停止你的gaiad 实例。然后升级软件:
升级 genesis 文件
要升级 genesis 文件,你可以从可信来源获取它,或在本地导出它。从可信来源获取
如果你要加入主网,请从 主网仓库 获取 genesis。如果你要加入公共测试网,请从 测试网仓库 中对应的测试网获取 genesis。否则,请从你信任的来源获取。 将新的 genesis 保存为new_genesis.json。然后用 new_genesis.json 替换旧的 genesis.json
在本地将状态导出为新的 genesis
如果你此前在该网络的旧版本上运行节点,并且希望基于该旧网络的状态在本地构建新的 genesis,请使用以下命令:<export-height> 的状态,并将其转换为一个新的 genesis 文件,用于启动新网络。
然后,用 new_genesis.json 替换旧的 genesis.json。
Account 类型的属性发生了变化,那么脚本应从账户存储中查询已编码的账户数据,对其进行反序列化,更新其类型,然后重新序列化并写回存储。你可以在这里找到此类脚本的示例。
重置数据
::: danger 重要 确保每个节点都有唯一的priv_validator.json。不要把旧节点的 priv_validator.json 复制到多个新节点。运行两个使用相同 priv_validator.json 的节点会导致你因双签而被罚没!
首先,删除过期文件并重置数据。如果你运行的是验证者节点,请务必先确认你完全理解重置操作的影响再执行。
priv_validator.json 和 config.toml。如果你之前配置了任何哨兵节点或全节点,你的节点仍会尝试连接它们,但如果它们也尚未完成升级,连接可能会失败。
:::
重启
如果没有破坏性变更,你只需运行以下命令重新启动节点:This document describes the upgrade procedure of a
gaiad full-node to a new version.
Cosmovisor
The Cosmos SDK provides a convenient process manager that wraps around thegaiad binary and can automatically swap in new binaries upon a successful governance upgrade proposal. Cosmovisor is entirely optional but recommended. More information can be found in cosmos.network docs and cosmos-sdk/cosmovisor/readme.
Setup
To get started with Cosmovisor first download itgaiad can start by running
Preparing an Upgrade
Cosmovisor will continually poll the$DAEMON_HOME/data/upgrade-info.json for new upgrade instructions. When an upgrade is ready, node operators can download the new binary and place it under $DAEMON_HOME/cosmovisor/upgrades/<name>/bin where <name> is the URI-encoded name of the upgrade as specified in the upgrade module plan.
It is possible to have Cosmovisor automatically download the new binary. To do this set the following environment variable.
Manual Software Upgrade
First, stop your instance ofgaiad. Next, upgrade the software:
Upgrade Genesis File
To upgrade the genesis file, you can either fetch it from a trusted source or export it locally.Fetching from a Trusted Source
If you are joining the mainnet, fetch the genesis from the mainnet repo. If you are joining a public testnet, fetch the genesis from the appropriate testnet in the testnet repo. Otherwise, fetch it from your trusted source. Save the new genesis asnew_genesis.json. Then replace the old genesis.json with new_genesis.json
Exporting State to a New Genesis Locally
If you were running a node in the previous version of the network and want to build your new genesis locally from a state of this previous network, use the following command:<export-height> and turns it into a new genesis file that can be used to start a new network.
Then, replace the old genesis.json with new_genesis.json.
Account type changed, a script should query encoded account from the account store, unmarshal them, update their type, re-marshal and re-store them. You can find an example of such script here.
Reset Data
::: danger IMPORTANT Make sure that every node has a uniquepriv_validator.json. Do not copy the priv_validator.json from an old node to multiple new nodes. Running two nodes with the same priv_validator.json will cause you to get slashed due to double signing!
First, remove the outdated files and reset the data. If you are running a validator node, make sure you understand what you are doing before resetting.
priv_validator.json and config.toml. If you had any sentry nodes or full nodes setup before, your node will still try to connect to them, but may fail if they haven’t also been upgraded.