> ## Documentation Index
> Fetch the complete documentation index at: https://injectivelabs-docs-ai-sdk.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 测试网 Peggo

## Equinox 测试网

## 步骤 1：配置你的 Peggo 中继器

```bash theme={null}
mkdir ~/.peggo
cp testnet-config/staking/40014/peggo-config.env ~/.peggo/.env
cd ~/.peggo
```

首先，使用有效的 Sepolia EVM RPC 端点更新 `.env` 文件中的 `PEGGO_ETH_RPC`。

要设置你自己的 Sepolia 全节点，请按照[这里](https://ethereum.org/en/developers/docs/nodes-and-clients/run-a-node/)的说明操作。可以使用 Alchemy 或 Infura RPC，但请记住，Peggo 桥接仍在开发中，它向 RPC 发出的请求量尚未优化。请确保它不会在你的账户上产生高成本。

Peggo 还需要访问你的验证者的 Cosmos 和以太坊凭证来为相应的网络签署交易。

## **Cosmos 密钥**

有两种提供凭证访问的方式 - 带有加密密钥的 keyring，或明文私钥。

### **1. Cosmos Keyring**

将 `PEGGO_COSMOS_FROM` 更新为你的验证者密钥名称（或账户地址），将 `PEGGO_COSMOS_FROM_PASSPHRASE` 更新为你的 Cosmos Keyring 密码。请注意，默认的 keyring 后端是 `file`，它将尝试在磁盘上定位密钥。

如果你想重用那里的密钥，Keyring 路径必须指向你的 injectived 节点的主目录。

在[这里](https://docs.cosmos.network/v0.46/run-node/keyring.html)了解更多关于 Keyring 设置的信息。

### **2. Cosmos 私钥（不安全）**

只需使用你的验证者账户私钥更新 `PEGGO_COSMOS_PK`。

要获取你的验证者的 Cosmos 私钥，运行 `injectived keys unsafe-export-eth-key $VALIDATOR_KEY_NAME`。

此方法不安全，不推荐使用。

## **以太坊密钥**

有两种提供凭证访问的方式 - 带有加密密钥的 Geth keystore，或明文私钥。

### **1. Geth Keystore**

只需创建一个新的私钥存储并更新以下环境变量：

* `PEGGO_ETH_KEYSTORE_DIR`
* `PEGGO_ETH_FROM`
* `PEGGO_ETH_PASSPHRASE`

你可以在 Geth 文档[这里](https://geth.ethereum.org/docs/interface/managing-your-accounts)找到使用 keystore 安全创建新以太坊账户的说明。

下面提供了一个示例。

```bash theme={null}
geth account new --datadir=/home/ec2-user/.peggo/data/

INFO [03-23|18:18:36.407] Maximum peer count                       ETH=50 LES=0 total=50
Your new account is locked with a password. Please give a password. Do not forget this password.
Password:
Repeat password:

Your new key was generated

Public address of the key:   0x9782dc957DaE6aDc394294954B27e2118D05176C
Path of the secret key file: /home/ec2-user/.peggo/data/keystore/UTC--2021-03-23T15-18-44.284118000Z--9782dc957dae6adc394294954b27e2118d05176c

- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
```

现在，你可以像这样设置环境变量：

```ini theme={null}
PEGGO_ETH_KEYSTORE_DIR=/home/ec2-user/.peggo/data/keystore
PEGGO_ETH_FROM=0x9782dc957DaE6aDc394294954B27e2118D05176C
PEGGO_ETH_PASSPHRASE=12345678
```

接下来，确保你的以太坊地址有 Sepolia ETH。你可以从公共水龙头[这里](https://www.alchemy.com/faucets/ethereum-sepolia)请求 Sepolia ETH。

### **2. 以太坊私钥（不安全）**

只需使用新账户的新以太坊私钥更新 `PEGGO_ETH_PK`。

接下来，确保你的以太坊地址有 Sepolia ETH。你可以从公共水龙头[这里](https://www.alchemy.com/faucets/ethereum-sepolia)请求 Sepolia ETH。

### 步骤 2：注册你的编排者和以太坊地址

你只能注册一次编排者和以太坊地址。之后**无法**更新。所以在运行以下命令之前请仔细检查。

```bash theme={null}
injectived tx peggy set-orchestrator-address $VALIDATOR_INJ_ADDRESS $ORCHESTRATOR_INJ_ADDRESS $ETHEREUM_ADDRESS --from $VALIDATOR_KEY_NAME --chain-id=injective-888 --keyring-backend=file --yes --node=tcp://localhost:26657 --gas-prices=160000000inj

```

* 要获取你的验证者的 inj 地址，运行 `injectived keys list $VALIDATOR_KEY_NAME`
* 要获取你的编排者的 inj 地址，运行 `injectived keys list $ORCHESTRATOR_KEY_NAME`

示例：

```bash theme={null}
injectived tx peggy set-orchestrator-address inj10m247khat0esnl0x66vu9mhlanfftnvww67j9n inj1x7kvxlz2epqx3hpq6v8j8w859t29pgca4z92l2 0xf79D16a79130a07e77eE36e8067AeA783aBdA3b6 --from validator-key-name --chain-id=injective-888 --keyring-backend=file --yes --node=tcp://localhost:26657 --gas-prices=160000000inj
```

你可以通过在 [https://testnet.sentry.lcd.injective.network/peggy/v1/valset/current](https://testnet.sentry.lcd.injective.network/peggy/v1/valset/current) 检查你的验证者映射的以太坊地址来验证注册是否成功。

<Callout icon="info" color="#07C1FF" iconType="regular">
  **注意：** 一旦你使用 `set-orchestrator-address` 消息注册了你的编排者，你就**无法**再次注册。完成此步骤后，你的 `Validator` 将绑定到提供的以太坊地址（以及你可能提供的委托地址）。换句话说，你的 peggo 必须始终使用你为注册提供的地址运行。
</Callout>

## 步骤 3：启动中继器

```bash theme={null}
peggo orchestrator
```

这将启动 Peggo 桥接（中继器/编排者）。

## 步骤 4：创建 Peggo systemd 服务

在 `/etc/systemd/system/peggo.service` 下添加包含以下内容的 `peggo.service` 文件

```ini theme={null}
[Unit]
  Description=peggo

[Service]
  WorkingDirectory=/home/ec2-user/.peggo
  ExecStart=/bin/bash -c 'peggo orchestrator '
  Type=simple
  Restart=always
  RestartSec=1
  User=ec2-user

[Install]
  WantedBy=multi-user.target
```

然后，运行以下命令配置环境变量，启动和停止 peggo 中继器。

```bash theme={null}
sudo systemctl start peggo
sudo systemctl stop peggo
sudo systemctl restart peggo
sudo systemctl status peggo

# 启用系统启动时自动启动
sudo systemctl enable peggo

# 检查日志
journalctl -f -u peggo
```

## 步骤 5：（可选）保护 Cosmos Keyring 免受未授权访问

<Callout icon="warning" color="#07C1FF" iconType="regular">
  这是一个高级 DevOps 主题，请咨询你的系统管理员。
</Callout>

在[这里](https://docs.cosmos.network/v0.46/run-node/keyring.html)了解更多关于 Cosmos Keyring 设置的信息。一旦你启动了节点，默认的 keyring 将以加密形式将验证者操作员密钥存储在磁盘上。通常，keyring 位于节点的主目录中，即 `~/.injectived/keyring-file`。

Injective 质押文档的某些部分将指导你使用此密钥进行治理目的，即提交交易和设置以太坊桥接。为了保护密钥免受未授权访问，即使 keyring 密码通过配置泄露，你也可以设置操作系统权限，仅允许 `injectived` / `peggo` 进程访问磁盘。

在 Debian、Ubuntu 和 RHEL 等 Linux 系统中，可以使用 POSIX 访问控制列表（ACL）来实现。在开始使用 ACL 之前，必须在启用 ACL 的情况下挂载文件系统。每个发行版都有一些官方指南：

* [Ubuntu](https://help.ubuntu.com/community/FilePermissionsACLs)
* [Debian](https://wiki.debian.org/Permissions)
* [Amazon Linux (RHEL)](https://www.redhat.com/sysadmin/linux-access-control-lists)

## 贡献

如果你想检查 Peggo 编排者源代码并做出贡献，可以在 [https://github.com/InjectiveLabs/peggo](https://github.com/InjectiveLabs/peggo) 进行。
