Until now, atlas has both POC and POS version. Next, the following is a description of how to build private-net with four nodes On two different version.
Prerequisites
Private key and address
Building atlas requires git, Go (version 1.14 or later) and a C compiler. You can install them using your favourite package manager.
Clone repositories
git clone https://github.com/mapprotocol/atlas.git
cd atlas
Build four nodes
We can start four nodes with different ports on one host, or we can start four nodes on multiple hosts. The following will use the node method of starting four different ports on one host to demonstrate.
build atlas of POC version:
git checkout v0.2
make atlas
build atlas of POS version:
git checkout v1.0.0 or git checkout <latest tag>
make atlas
Create four validator accounts
private key and address
Atlas allows developers use the ethereum's account on atlas blockchain. If no account, it's helpful to use the command.
$ ./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 [03-16|14:12:42.713] 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
Address: 0x57d28a6Cb48dc6Da45f6fE13E42757aF56cB0650
PublicKey: 0x04cb8512a050dc66750faabf4a6cace5bbfd70ccaa5e94e986f5062aa5c016a7e9541f266b7289e6e113c9780fbf5d2ad1ff3136576a38e20569f82094c2e47d30
BLS Public key: 0x2a9520c996aaa5bd3222a0cef50ae1420602b4ba836c3e0a590d794107d8d7b51139baefa4645947402dc31d3c69ae96a83f054b0851412892d03ba6d154257126ebfcd6c512f84f19d139749ce760b9f142bd10c9a80b0f6b3086254840a4ee0d9510c2ebfcbbf03d168d62d8b2926edeee70e0e8b6b205e0ac0394370832ec
BLS G1 Public key: 0x0491aa3f6523e253003c02856a4623a163bb11ba9f115ae464c940dd60e64e0b1fff5644ca887928f0c6a29055bfa608103aa19d13edfc1a12f5baaa69d60f7a
BLSProofOfPossession: 0x2866621aa6703c6992299f75ee05b34fb42963ae82173e43c212d891ddc8a94e107fa37f3833e9230deb3078dde2521ea6b833e70ed051ee297734117bec367c
Path of the secret key file: node-1/keystore/UTC--2022-03-17T09-35-15.650368000Z--f930b74d2b1b703b879ab54e225ecc18ab28e61c
- 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!
Generating a genesis.json
Note that there are differences between versions, which the POC version needn't set validator. Only Suitable for the POS version. The validator must be set, because only them are allowed to mine.
Get validator configuration json and generating a genesis.json
We now generate the genesis.json file using the paths of the four accounts generated in the previous step. Fill in the information we output when we created the account into the corresponding key value. The value corresponding to the AdminAddress key can be any of the four accounts we created above or other accounts.
Initialize the node with the genesis file generated in the previous step
./atlas --datadir ./node-1 init ./genesis.json
./atlas --datadir ./node-2 init ./genesis.json
./atlas --datadir ./node-3 init ./genesis.json
./atlas --datadir ./node-4 init ./genesis.json
# Output
INFO [03-16|15:14:56.031] Maximum peer count ETH=50 LES=0 total=50
INFO [03-16|15:14:56.038] Set global gas cap cap=50,000,000
INFO [03-16|15:14:56.038] Allocated cache and file handles database=/Users/alex/atlas/node-1/atlas/chaindata cache=16.00MiB handles=16
INFO [03-16|15:14:56.133] Writing custom genesis block
INFO [03-16|15:14:56.141] Persisted trie from memory database nodes=276 size=31.68KiB time="921.915µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-984.00B
INFO [03-16|15:14:56.142] Successfully wrote genesis state database=chaindata hash=e359b1..ad2642
INFO [03-16|15:14:56.142] Allocated cache and file handles database=/Users/alex/atlas/node-1/atlas/lightchaindata cache=16.00MiB handles=16
INFO [03-16|15:14:56.223] Writing custom genesis block
INFO [03-16|15:14:56.226] Persisted trie from memory database nodes=276 size=31.68KiB time="587.341µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-984.00B
INFO [03-16|15:14:56.227] Successfully wrote genesis state database=lightchaindata hash=e359b1..ad2642
Start four validator nodes
The following command starts four corresponding nodes using the four accounts created earlier。
Type the above command on the command line and press enter, you will see the following prompt:
......
INFO [03-16|20:04:50.659] Starting peer-to-peer node instance=atlas/v0.3.4-stable/darwin-amd64/go1.16.14
INFO [03-16|20:04:50.770] New local node record seq=1,647,431,881,694 id=54a701d30bf05010 ip=127.0.0.1 udp=20201 tcp=20201
INFO [03-16|20:04:50.770] Started P2P networking self=enode://8f8bb96b01be9f76a93b2b54bcaff35b48ace58f0b0f3c85a139048072ff030bcad022a442e49181885f1f0338a5efd2f4807d21d2f88973e18426dee3d8e0b7@127.0.0.1:20201 maxdialed=16 maxinbound=34
INFO [03-16|20:04:50.771] IPC endpoint opened url=/Users/t/go_project/atlas/node-1/node-1
Unlocking account 0x931abadeb878d761cf2df15f0ba0442350c132fc | Attempt 1/3
Password:
At this time, we need to enter the password corresponding to the account and press Enter, congratulations, you have successfully started a node. Then we start the remaining nodes in the same way.
If you want to start an RPC node you can use the following way.
With the bootnode operational and externally reachable (try telnet <ip> <port> to ensure it's indeed reachable), start every subsequent atlas node pointed to the bootnode for peer discovery via the --bootnodes flag. It will probably also be desirable to keep the data directory of your private network separated, so do also specify a custom --datadir flag.
You'll start seeing some output. After a few minutes, you should see lines that look like this. This means your node has connected other nodes and started produce blocks.
INFO [03-16|20:21:27.683] Looking for peers peercount=2 tried=5 static=4
INFO [03-16|20:21:37.582] Reset timer to resend RoundChange msg address=0x2dC45799000ab08E60b7441c36fCC74060Ccbe11 func=resetResendRoundChangeTi
mer cur_seq=23 cur_epoch=1 cur_round=0 des_round=5 state="Waiting for new round" address=0x2dC45799000ab08E60b7441c36fCC74060Ccbe11 timeout=17.5s
INFO [03-16|20:21:39.311] Looking for peers peercount=3 tried=0 static=4