Injective | Documentation
InjectiveGithub
Injective | 中文文档
Injective | 中文文档
  • 关于 Injective
  • 快速入门
    • 钱包
      • 创建钱包
      • 账户
      • 质押
      • 治理
      • 拍卖
    • 代币标准
      • INJ 代币
      • Token Factory
      • CW20 标准
    • 交易
      • Gas 和 Fees
  • 指南
    • 创建钱包
    • 桥接
      • From Ethereum
      • Using Wormhole
      • Using IBC
      • From Solana
    • 发布代币
    • 发布市场
    • Denom 元数据
    • 获取INJ
  • 工具包
    • injectived
      • 安装 injectived
      • 使用 injectived
      • 指令
    • Injective TS SDK
    • Injective Go SDK
    • Injective Python SDK
    • Injective CW SDK
    • The Graph
  • 参考
  • 术语表
  • 开发者
    • 快速入门
      • 指南
        • 测试网提案
        • 转换地址
        • 计算
          • 最低价格刻度
          • 最低数量刻度
    • 交易所开发者
      • 构建 DEX
      • 预言机提供方
    • Cosmwasm 开发者
      • 您的首个智能合约
      • 指南
        • 本地开发
        • 主网开发
        • 给部署地址白名单
        • 创建您的 Swap 合约
        • 创建 UIs
      • CW20 适配器
      • Injective Test Tube
    • 模块
      • Injective
        • 拍卖(Auction)
          • State
          • 消息
          • EndBlock
          • 事件
          • 参数
        • 交易所(Exchange)
          • 衍生品市场概念
          • 现货市场概念
          • 二元期权市场概念
          • 其他概念
          • 状态
          • 状态转换
          • 消息
          • 提案
          • BeginBlock
          • EndBlock
          • 事件
          • 参数
          • MsgPrivilegedExecuteContract
        • 保险(Insurance)
          • 状态
          • 状态转换
          • 消息
          • EndBlock
          • 事件
          • 参数
          • 改进
        • OCR
          • 概念
          • 状态
          • 消息
          • 提案
          • BeginBlock
          • 钩子(Hooks)
          • 事件
          • 参数
        • 预言机(Oracle)
          • 状态
          • Keeper
          • 消息
          • 提案
          • 事件
          • 改进
        • Peggy
          • 定义
          • 工作流
          • 状态
          • 消息
          • 处罚
          • EndBlock
          • 事件
          • 参数
          • 中继语义
          • 改进
        • 权限(Permissions)
          • 概念
          • 状态
          • 状态转换
        • 代币工厂(TokenFactory)
          • 概念
          • 状态
          • 消息
          • 事件
          • 参数
        • WasmX
          • 概念
          • 数据
          • 提案
          • 消息
          • 参数
      • 核心
        • Auth
        • AuthZ
        • 银行(Bank)
        • 共识(Consensus)
        • 危机(Crisis)
        • 分发(Distribution)
        • 证据(Evidence)
        • 费用授权(Feegrant)
        • 治理(Gov)
        • 群组(Group)
        • 铸造(Mint)
        • NFT
        • 参数(Params)
        • 惩罚(Slashing)
        • 质押(Staking)
        • 升级(Upgrade)
        • Circuit
        • Genutils
    • dApps 开发文档
  • 节点
    • 快速入门
      • 和节点交互
      • 运行节点
        • 设置密钥环
        • 加入网络
        • Cosmovisor
        • 升级您的节点
    • 验证者
      • 主网
        • Peggo
        • 规范链升级
          • Upgrade to 10002-rc1
          • Upgrade to 10002-rc2
          • Upgrade to 10003-rc1
          • Upgrade to 10004-rc1
          • Upgrade to 10004-rc1-patch
          • Upgrade to 10005-rc1
          • Upgrade to 10006-rc1
          • Upgrade to 10007-rc1
          • Upgrade to 10008 - Camelot
          • Upgrade to 10009
          • Upgrade to v1.10
          • Upgrade to v1.11
          • Upgrade to v1.12.0 - Volan
          • Upgrade to v1.12.1
          • Upgrade to v1.13.0 - Altaris
          • Upgrade to v1.13.2
          • Upgrade to v1.13.3
          • Upgrade to v1.14.0
          • Upgrade to v1.14.1
      • 测试网
        • 测试网 Peggo
    • 公共端点
    • 高级端点
    • Injective 索引器设置
  • 交易员
    • 快速入门
    • 文档
    • API 参考
  • 常用链接
    • Injective 101
    • Injective Hub
    • Injective 浏览器
    • Chain API Reference
    • Indexer API Reference
    • 测试网水龙头
Powered by GitBook
On this page
Export as PDF
  1. 节点
  2. 快速入门
  3. 运行节点

加入网络

本指南将引导您完成在本地设置独立网络的过程,以及在主网或测试网上运行节点的步骤。 您还可以在各自的标签中找到每个网络的硬件要求。

要轻松设置本地节点,请下载并运行 setup.sh 脚本。此脚本将初始化您的本地 Injective 网络。

wget https://raw.githubusercontent.com/InjectiveLabs/injective-chain-releases/master/scripts/setup.sh
chmod +x ./setup.sh # Make the script executable
./setup.sh

运行以下命令启动节点:

injectived start # Blocks should start coming in after running this

为了更详细地解释该脚本的功能,并提供对设置过程的更精细控制,请继续阅读下文。

I初始化链

在运行 Injective 节点之前,我们需要初始化链,并生成节点的创世文件:

# The <moniker> argument is the custom username of your node. It should be human-readable.
injectived init <moniker> --chain-id=injective-1

上述命令将创建节点运行所需的所有配置文件,以及默认的创世文件(genesis file),该文件定义了网络的初始状态。所有这些配置文件默认存储在 ~/.injectived 目录中,但您可以通过 --home 标志指定不同的位置。

请注意,如果选择使用 ~/.injectived 以外的目录,则每次运行 injectived 命令时,都必须使用 --home 标志指定该目录的位置。如果您已有创世文件,可以使用 --overwrite 或 -o 标志进行覆盖。

~/.injectived 目录的结构如下:

.                                   # ~/.injectived
  |- data                           # Contains the databases used by the node.
  |- config/
      |- app.toml                   # Application-related configuration file.
      |- config.toml                # Tendermint-related configuration file.
      |- genesis.json               # The genesis file.
      |- node_key.json              # Private key to use for node authentication in the p2p protocol.
      |- priv_validator_key.json    # Private key to use as a validator in the consensus protocol.

修改 genesis.json 文件

此时,需要修改 genesis.json 文件:

  • 将 staking bond_denom、crisis denom、gov denom 和 mint denom 的值更改为 "inj",因为 INJ 是 Injective 的原生代币。

可以使用以下命令轻松完成此修改:

cat $HOME/.injectived/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.json
cat $HOME/.injectived/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.json
cat $HOME/.injectived/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.json
cat $HOME/.injectived/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.json

上述命令仅适用于默认的 .injectived 目录。

如果使用了自定义目录,则需要修改相应命令以适配该目录,或者手动编辑 genesis.json 文件以应用这些更改。

为验证人账户创建密钥

在启动链之前,您需要至少创建一个账户来填充状态。首先,在密钥存储(keyring)中创建一个名为 my_validator 的新账户,并使用 test 作为密钥存储后端(您可以选择其他名称或后端):

injectived keys add my_validator --keyring-backend=test

# Put the generated address in a variable for later use.
MY_VALIDATOR_ADDRESS=$(injectived keys show my_validator -a --keyring-backend=test)

现在,您已经创建了一个本地账户,接下来需要在链的创世文件中为其分配一定数量的 INJ 代币。这样做可以确保链在启动时就识别该账户的存在,并初始化其余额:

injectived add-genesis-account $MY_VALIDATOR_ADDRESS 100000000000000000000000000inj --chain-id=injective-1

$MY_VALIDATOR_ADDRESS 是一个变量,用于保存 my_validator 密钥在密钥存储中的地址。在 Injective 中,代币采用 {amount}{denom} 格式:amount 是一个精确到 18 位的小数数字,denom 是代币的唯一标识符及其面额(例如:inj)。在这里,我们分配 INJ 代币,因为 INJ 是 Injective 中用于质押的代币标识符。

将验证人添加到链中

现在,您的账户已经有了一些代币,接下来需要将一个验证人添加到链中。验证人是参与共识过程的特殊全节点,负责向链中添加新区块。任何账户都可以声明其成为验证人操作员的意图,但只有那些获得足够委托的账户才能进入活动集(active set)。

在本教程中,您将把本地节点(通过上述 init 命令创建)作为链的验证人添加到链中。验证人可以在链首次启动之前,通过创世文件中包含的特殊交易(称为 gentx)进行声明。

# Create a gentx.
injectived gentx my_validator 1000000000000000000000inj --chain-id=injective-1 --keyring-backend=test

# Add the gentx to the genesis file.
injectived collect-gentxs

gentx 执行了三件事:

  1. 注册您创建的验证人账户作为验证人操作员账户(即控制验证人的账户)。

  2. 自我委托(self-delegates)所提供数量的质押代币。

  3. 将操作员账户与 Tendermint 节点的公钥关联,该公钥将用于签署区块。如果未提供 --pubkey 标志,则默认为通过 injectived init 命令创建的本地节点公钥。

欲了解有关 gentx 的更多信息,请使用以下命令:

injectived gentx --help

使用 app.toml 和 config.toml 配置节点

在 ~/.injectived/config 目录下,自动生成了两个配置文件:

  • app.toml:由 Cosmos SDK(Injective 是基于 Cosmos SDK 构建的)生成,用于配置状态修剪策略、遥测、gRPC 和 REST 服务器配置、状态同步等。

这两个文件都有大量注释—请直接参考它们以调整您的节点。

一个需要调整的配置示例是 app.toml 中的 minimum-gas-prices 字段,该字段定义了验证人节点愿意接受的最低 gas 价格来处理交易。如果该字段为空,请确保用某个值进行编辑,例如 10inj,否则节点将在启动时停止。对于本教程,我们将最低 gas 价格设置为 0:

 # 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. 0.25token1;0.0001token2).
 minimum-gas-prices = "0inj"

运行本地网络

现在,一切设置完成,您可以最终启动您的节点:

injectived start # Blocks should start coming in after running this

此命令允许您运行一个单节点,这足以通过该节点与链进行交互,但如果您希望查看多个节点之间是如何达成共识的,可以同时运行多个节点。

硬件规格

节点操作员应部署裸金属服务器,以实现最佳性能。此外,验证人节点必须满足推荐的硬件规格,特别是 CPU 要求,以确保高可用性。

最低配置

推荐配置

RAM Memory 128GB

RAM Memory 128GB

CPU 12 cores

CPU 16 cores

CPU base clock 3.7GHz

CPU base clock 4.2GHz

Storage 2TB NVMe

Storage 2TB NVMe

Network 1Gbps+

Network 1Gbps+

安装 injectived 和 peggo

wget https://github.com/InjectiveLabs/testnet/releases/download/v1.12.9-testnet-1703762556/linux-amd64.zip
unzip linux-amd64.zip
sudo mv peggo /usr/bin
sudo mv injectived /usr/bin
sudo mv libwasmvm.x86_64.so /usr/lib 

初始化一个新的 Injective 链节点

在运行 Injective 节点之前,我们需要初始化链以及节点的创世文件:

# The argument <moniker> is the custom username of your node, it should be human-readable.
export MONIKER=<moniker>
# Injective Testnet has a chain-id of "injective-888"
injectived init $MONIKER --chain-id injective-888

运行 init 命令将会在 ~/.injectived 目录下创建 Injective 默认的配置文件。

准备配置以加入测试网

现在,您应该使用测试网的创世文件(genesis file)和应用配置文件(application config file)更新默认配置,并配置您的持久对等节点(persistent peers)与种子节点(seed nodes)。

git clone https://github.com/InjectiveLabs/testnet.git

# copy genesis file to config directory
aws s3 cp --no-sign-request s3://injective-snapshots/testnet/genesis.json .
mv genesis.json ~/.injectived/config/

# copy config file to config directory
cp testnet/corfu/70001/app.toml  ~/.injectived/config/app.toml
cp testnet/corfu/70001/config.toml ~/.injectived/config/config.toml

您还可以运行命令来验证创世文件的校验和(checksum)。 - a4abe4e1f5511d4c2f821c1c05ecb44b493eec185c0eec13b1dcd03d36e1a779

sha256sum ~/.injectived/config/genesis.json

为 injectived 配置 systemd 服务

编辑位于 /etc/systemd/system/injectived.service 的配置文件:

[Unit]
  Description=injectived

[Service]
  WorkingDirectory=/usr/bin
  ExecStart=/bin/bash -c '/usr/bin/injectived --log-level=error start'
  Type=simple
  Restart=always
  RestartSec=5
  User=root

[Install]
  WantedBy=multi-user.target

启动和重启 systemd 服务

sudo systemctl daemon-reload
sudo systemctl restart injectived
sudo systemctl status injectived

# enable start on system boot
sudo systemctl enable injectived

# To check Logs
journalctl -u injectived -f

同步网络

支持

硬件配置

节点操作员应部署裸金属服务器,以实现最佳性能。此外,验证人节点必须满足推荐的硬件规格,特别是 CPU 要求,以确保高可用性。

最低配置

推荐配置

RAM Memory 128GB

RAM Memory 128GB

CPU 12 cores

CPU 16 cores

CPU base clock 3.7GHz

CPU base clock 4.2GHz

Storage 2TB NVMe

Storage 2TB NVMe

Network 1Gbps+

Network 1Gbps+

安装 injectived 和 peggo

wget https://github.com/InjectiveLabs/injective-chain-releases/releases/download/v1.14.1-1740773301/linux-amd64.zip
unzip linux-amd64.zip
sudo mv peggo /usr/bin
sudo mv injectived /usr/bin
sudo mv libwasmvm.x86_64.so /usr/lib 

初始化新的 Injective 节点

在运行 Injective 节点之前,我们需要初始化链以及节点的创世文件:

# The argument <moniker> is the custom username of your node. It should be human-readable.
export MONIKER=<moniker>
# Injective Mainnet has a chain-id of "injective-1"
injectived init $MONIKER --chain-id injective-1

运行 init 命令将会在 ~/.injectived 目录下创建 Injective 的默认配置文件。

准备配置以加入主网

现在,您应该使用主网的创世文件(genesis file)和应用配置文件(application config file)更新默认配置,并配置您的持久对等节点(persistent peers)与种子节点(seed nodes)。

git clone https://github.com/InjectiveLabs/mainnet-config

# copy genesis file to config directory
cp mainnet-config/10001/genesis.json ~/.injectived/config/genesis.json

# copy config file to config directory
cp mainnet-config/10001/app.toml  ~/.injectived/config/app.toml

您还可以运行命令来验证创世文件的校验和(checksum) - 573b89727e42b41d43156cd6605c0c8ad4a1ce16d9aad1e1604b02864015d528

sha256sum ~/.injectived/config/genesis.json

然后,在 ~/.injectived/config/config.toml 文件中更新 seeds 字段,使用 mainnet-config/10001/seeds.txt 的内容,并将 timeout_commit 设置为 300ms。

cat mainnet-config/10001/seeds.txt
nano ~/.injectived/config/config.toml

为 injectived 配置 systemd 服务

编辑 /etc/systemd/system/injectived.service 配置文件:

[Unit]
  Description=injectived

[Service]
  WorkingDirectory=/usr/bin
  ExecStart=/bin/bash -c '/usr/bin/injectived --log-level=error start'
  Type=simple
  Restart=always
  RestartSec=5
  User=root

[Install]
  WantedBy=multi-user.target

启动和重启 systemd 服务。

sudo systemctl daemon-reload
sudo systemctl restart injectived
sudo systemctl status injectived

# enable start on system boot
sudo systemctl enable injectived

# To check Logs
journalctl -u injectived -f

服务应在快照数据加载到正确目录之前停止,并在加载之后启动。

# to stop the node
sudo systemctl stop injectived

# to start the node
sudo systemctl start injectived

同步网络

选项 1. 状态同步

将很快添加

选项 2. 快照

已修剪

或者,您可以使用来自Injective Labs在AWS S3上的已修剪快照。

systemctl stop injectived
injectived tendermint unsafe-reset-all --home $HOME/.injectived
SNAP=$(aws s3 ls --no-sign-request s3://injective-snapshots/mainnet/pruned/ | grep ".tar.lz4" | sort | tail -n 1 | awk '{print $4}')
aws s3 cp --no-sign-request s3://injective-snapshots/mainnet/pruned/$SNAP .
lz4 -c -d $SNAP  | tar -x -C $HOME/.injectived/
rm $SNAP
systemctl start injectived

如果Injective主网配置中的seeds.txt列表无法工作(节点无法同步区块),ChainLayer、Polkachu和Autostake维护对等节点列表(可用于config.toml中的persistent_peers字段)或地址簿(用于更快的对等节点发现)。 存档(>20TB)

systemctl stop injectived
injectived tendermint unsafe-reset-all --home $HOME/.injectived
aws s3 sync --no-sign-request --delete s3://injective-snapshots/mainnet/injectived/data $HOME/.injectived/data
aws s3 sync --no-sign-request --delete s3://injective-snapshots/mainnet/injectived/wasm $HOME/.injectived/wasm
systemctl start injectived
go install github.com/cosmos/gex@latest
gex

支持

Previous设置密钥环NextCosmovisor

Last updated 2 months ago

config.toml:用于配置 Tendermint(可以在 中了解更多信息),

请查看 Injective 的,以获取最新的版本。非验证人节点操作员无需安装 peggo。

请参考 以下载快照并与网络同步。

如果有任何进一步的问题,您可以通过 、 或电子邮件(contact@injectivelabs.org)随时与 Injective 团队联系。

请查看,以获取最新版本。非验证人节点操作员无需安装 peggo。

.

.

.

.

.

此时,可以使用来监控节点的同步状态。如果快照已正确加载,连接的对等节点数量应从0增加,最新区块应稳定增加,表示节点正在与其对等节点同步。请注意,根据快照的年龄,节点可能需要几个小时或更长时间才能追赶到网络的区块高度。 如果最新区块没有增加且连接的对等节点数量为0或保持较低,seeds.txt中的种子列表可能已过时,可以分别使用验证者的种子或对等节点列表更新seeds或persistent_peers字段,然后再重新启动节点。

如果有任何进一步的问题,您可以通过 、 或电子邮件(contact@injectivelabs.org)随时与 Injective 团队联系。

Tendermint 的文档
发布仓库
Polkachu 指南
Discord
Telegram
Injective 链的发布仓库
Polkachu
HighStakes
AutoStake
Imperator
Bware Labs
GEX
Discord
Telegram