导出状态​

使用以下命令导出状态:
evmd export > new_genesis.json
你也可以从某个指定高度导出状态(在该高度区块处理完成时):
evmd export --height [height] > new_genesis.json
如果你计划基于导出的状态启动一个新的 0 高度网络(即创世状态),请在导出时加上 --for-zero-height 标志:
evmd export --height [height] --for-zero-height > new_genesis.json

手动迁移状态​

如果你希望手动迁移状态,例如用于本地测试。请注意,对于常规链升级,不需要手动执行状态迁移。 将状态导出为 json 文件后,你可以用 new_genesis.json 替换旧的 genesis.json。
cp -f genesis.json new_genesis.jsonmv new_genesis.json genesis.json
此时,你可能需要运行一个脚本,将导出的 genesis 更新为与你的新版本兼容的 genesis 状态。 你可以使用 migrate 命令,将某个给定版本迁移到下一个版本(例如:v0.X.X 到 v1.X.X):
evmd migrate TARGET_VERSION GENESIS_FILE --chain-id=<new_chain_id> --genesis-time=<yyyy-mm-ddThh:mm:ssZ>

Export State​

Export state with:
evmd export > new_genesis.json
You can also export state from a particular height (at the end of processing the block of that height):
evmd export --height [height] > new_genesis.json
If you plan to start a new network for 0 height (i.e genesis) from the exported state, export with the --for-zero-height flag:
evmd export --height [height] --for-zero-height > new_genesis.json

Manually Migrate State​

If you want to migrate state manually, e.g. for local testing purpose. Note that for regular chain upgrades, a manual state migration is not required. After exporting your state into a json file, you can replace the old genesis.json with new_genesis.json.
cp -f genesis.json new_genesis.jsonmv new_genesis.json genesis.json
At this point, you might want to run a script to update the exported genesis into a genesis state that is compatible with your new version. You can use the migrate command to migrate from a given version to the next one (eg: v0.X.X to v1.X.X):
evmd migrate TARGET_VERSION GENESIS_FILE --chain-id=<new_chain_id> --genesis-time=<yyyy-mm-ddThh:mm:ssZ>