搭建私有网络

前提条件

  • 私钥和地址

  • 构建 atlas 需要 git、Go(1.14 或更高版本)和 C 编译器

  • 克隆代码仓库

git clone https://github.com/mapprotocol/atlas.git

构建

我们可以在一个主机上启动四个不同端口的节点,也可以在多个主机上启动四个节点。以下将使用在一个主机上启动四个不同端口的节点的方法来进行演示。

git checkout v1.1.5

make atlas

创建账号

Atlas 允许开发者在 Atlas 区块链上使用以太坊的账户。如果没有账户,可以使用下面的命令创建。

$ ./atlas --datadir ./node-1 account new
$ ./atlas --datadir ./node-2 account new
$ ./atlas --datadir ./node-3 account new
$ ./atlas --datadir ./node-4 account new

# Output
INFO [10-09|17:37:36.179] Maximum peer count                       ETH=100 LES=0 total=100
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

Address:   0x...
PublicKey:   0x...
BLS Public key:   0x...
BLS G1 Public key:   0x...
BLSProofOfPossession:   0x...
Path of the secret key file: node-1/keystore/UTC--2023-10-09T09-37-38.019902000Z--...

- 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!

生成 genesis.json 文件

如何生成 genesis.json 文件,请参考 这里

我们现在使用上一步生成的四个账号的信息来生成 genesis.json 文件。将我们创建账户时输出的信息填入到 markerConfig.json 文件相应的键值中。AdminAddress 对应的值可以是我们上面创建的四个账户之一,也可以是其他账户。

然后使用我们上面的的 markerConfig.json 文件生成 genesis.json 文件,像下面这样:

等待命令执行完成后就可以在当前目录下找到 genesis.json 文件

初始化节点

使用在前一步骤中生成的创世文件初始化四个验证节点

启动节点

通过以下命令使用之前创建的四个账号启动四个相应的节点

在命令行输入上述命令,然后按回车键,您将看到以下提示:

此时,我们需要输入与账号对应的密码并按下回车键,恭喜,您已成功启动一个节点。然后我们以同样的方式启动剩余的节点。

如果你想启动一个 RPC 节点,可以使用以下方法。

连接节点

在启动节点之前,请确保引导节点已经运行并且可以从外部访问(尝试 telnet 以确保它确实可以访问)。 然后,通过 --bootnodes 将每个后续的 atlas 节点指向引导节点以进行对等节点发现。通过 --datadir 指定数据存储目录。

查询你的节点的 enode 信息:

在控制台使用以下命令连接节点

检查节点状态

输入连接节点的命令后开始看到一些输出。几分钟后,你应该会看到像这样的行。这意味着你的节点已经连接了其他节点并将开始生成区块。

你也可以通过在控制台中输入 admin.peers 来查看连接的节点。

Last updated