Run a Local Network
You can run a local test validator network to test and debug services you are developing for the Diem Blockchain and to build and test Move module code changes. This local test network is not part of the Diem Ecosystem and is only meant for testing and development purposes.
You can use the Diem CLI command dev to compile, publish, and execute Move Intermediate Representation (IR) programs on your local test validator network.
Note: Your local test network of validator nodes will not be connected to the testnet, and will not be using the actual validator nodes on the Diem Blockchain.
#
Getting StartedYou can run a local test validator network in two ways: using the Diem Core source code or Docker. The Diem Core source code is useful when testing modifications to the Diem Core code base. Docker is particularly useful when building services on top of the Diem Blockchain as there is no build overhead and the ledger state persists across restarts of the network by default.
#
Using Diem Core source codeDownload and clone the Diem Core repository from GitHub and prepare your developer environment by running the following commands:
Run the process:
cargo run -p diem-node -- --test
. Note, after starting this process, the config path:/distinct/tmp/path/0/node.yaml
.
You can later restore the ledger state by running
diem-node
with a previously used configuration path:cargo run -p diem-node -- --test --config /distinct/tmp/path
.
#
Using DockerInstall Docker and Docker-Compose.
Create a directory for your local test validator network.
Download the validator testnet docker compose.
Create configuration files in the same directory so that the data can be exported out of the docker container:
#
Interacting with the local test validator networkAfter starting your local test validator network, the following will be output on your terminal:
This will output a lot of information that will be required for starting the Diem CLI tool:
- ChainId - For testing
- Diem root key path - Available in the docker compose folder under
diem_root_key
. - Waypoint - Printed on screen and available in the docker compose folder under waypoint.txt
- JSON-RPC Endpoint -
http://127.0.0.1:8080
.
In another terminal, start a diem-client
using data from the output above:
At the end of this tutorial you will have:
- A single local validator test network
- A Diem CLI client connected to that network
The configuration management of the validator network generates:
- A genesis transaction.
- A waypoint that serves as a verifiable checkpoint into the blockchain.
- A chain id to uniquely distinguish this chain from other chains.
- Diem root key (also known as a mint or faucet key) for the account that's allowed to perform the mint operation.