Totaloutput
SSDE
Published in
3 min readJul 3, 2019

--

How to run a Libra validator node yourself:

Everyone knows Facebook announced Libra, and its testnet. If you follow the instruction of it, you can run a client and connect to testnet, create account Alice and Bob, send 10 unit between them in 15 minutes.

This post is NOT about how to do that, this post is about how to run a local validator and connect your client to yourself.

If you look at the code structure, FB actually released a validator with it, it’s just undocumented (not talking about how to run it yourself). Here is the detailed steps on how to crack it.

You need to have docker installed on your system, because it's not ONE validator, it's actually 4.. They are running from docker containers.Once you download code from Libra:
git clone https://github.com/libra/libra.git
The code of building validator is there under: /docker/validator/Please run the following command from your libra folder (this is very important, otherwise it will fail)./docker/validator/build.sh #<==this take very long time to finish, go get a coffee!After that, you should have the following from your docker images:REPOSITORY TAG IMAGE ID CREATED SIZElibra_e2e latest your_image-ID 26 hours ago 666MBThen you can run the following file from the same folder:
./docker/validator/run.sh
This will start all 4 docker images, your docker ps should see something similar:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
52204840f3c8 libra_e2e:latest "/bin/sh -c 'cd /opt…" 26 hours ago Up 26 hours 14297/tcp, 30303/tcp, 0.0.0.0:30307->30307/tcp ecstatic_meitner0ed5897a9456 libra_e2e:latest "/bin/sh -c 'cd /opt…" 26 hours ago Up 26 hours 14297/tcp, 30303/tcp, 30307/tcp mystifying_nobelc3b2a4b203d2 libra_e2e:latest "/bin/sh -c 'cd /opt…" 26 hours ago Up 26 hours 14297/tcp, 30303/tcp, 30307/tcp distracted_lederbergb9e08bc763a4 libra_e2e:latest "/bin/sh -c 'cd /opt…" 26 hours ago Up 26 hours 14297/tcp, 30303/tcp, 30307/tcp flamboyant_torvalds

Now your validator is running. It’s actually not too difficult.. The trick is to connect to it with your client. Here is how:

From your client, if you just run :
./scripts/cli/start_cli_testnet.sh
It will by default connect to facebook's pre-setup testnet. Because it's using the RUN_PARAMS in this file:
./scripts/cli/start_cli_testnet.shRUN_PARAMS="--host ac.testnet.libra.org --port 8000 -s $SCRIPT_PATH/trusted_peers.config.toml"#fun fact, all the IPs behind ac.testnet.libra.org is in aws... Now you can change the RUN_PARAMS to connect to your IP and your PORT.. Default port is 30307. For example:
RUN_PARAMS="--host your-validator-ip --port 30307 -s $SCRIPT_PATH/trusted_peers.config.toml"
If you just run it, it will still fail because the `trusted_peers.config.toml` is different..Now you need to:#backup your original file:
mv ./scripts/cli/trusted_peers.config.toml ./scripts/cli/trusted_peers.config.toml.backup
#replace it with the dev file:
cp ./terraform/validator-sets/dev/trusted_peers.config.toml ./scripts/cli/

Now you can run it, for example:
$ ./scripts/cli/start_cli_testnet.shBuilding and running client in debug mode.Finished dev [unoptimized + debuginfo] target(s) in 1.27sRunning `target/debug/client --host publictest2 --port 30307 -s ./scripts/cli/trusted_peers.config.toml`Connected to validator at: your-validator-ip:30307

Done, you now have 4 validators running and your local client connect to it..

OK, all the technical stuff is done now, the biggest question is: Why do you need a local validator?

First of all, if you don’t pay $10 million, there is no way you become a validator in Libra, so this blog post is not a $10 million hack. LOL

First of all, I just don’t like the fact that I always have to connect to a full-node or validator that someone ELSE host for me. I want to connect to my own and see the logs and debugging myself.

Secondly, FB redeploy testnet everyday, so your Alice and Bob account become 0 tomorrow, any serious testing you are doing needs some local setup.

Last, please note, Libra mentioned they included the code of validator, they just didn’t document how to use it, once the official documentation is available, please follow it and through away this hack.

Thank you for reading and happy foosing.. https://www.facebook.com/itsfworldcup/

--

--