-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add summary for Programs page. (#296)"
This reverts commit 095bbd1.
- Loading branch information
1 parent
095bbd1
commit b6058d3
Showing
2 changed files
with
157 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,172 +1,214 @@ | ||
--- | ||
title: "Spin up a devnet for Entropy" | ||
lead: "A developer network (devnet) is a private blockchain network that mimics the mainnet but is isolated for testing and development purposes. This allows developers to make mistakes and iterate quickly without impacting real users or risking real-world assets. This guide will walk you through setting up a local devnet for the Entropy." | ||
title: "Spin up a devnet" | ||
lead: "A developer network (devnet) is a private, isolated blockchain network that developers use to test and experiment with features and programs without affecting other Entropy networks or risking real-world assets. This guide will walk you through creating a local devnet on your machine." | ||
--- | ||
|
||
A devnet is an essential tool for devs working with Entropy. It provides a safe and controlled environment to: | ||
Developers should use a devnet when testing new features, experimenting with network parameters, or during initial development stages. However, developers should avoid using it for final production deployments, security audits requiring mainnet conditions, or when real-world economic incentives need to be tested. | ||
|
||
- Test new features and functionalities. | ||
- Experiment with network parameters. | ||
- Debug and troubleshoot issues. | ||
- Develop and test Entropy Programs without impacting mainnet. | ||
## Docker image | ||
|
||
This guide will cover two primary methods for setting up a local Entropy devnet: | ||
Spinning up a devnet using the Docker images supplied in the Entropy Core repo is the easiest way to get up and running. The requirements are fairly minimal, and everything should work straight out of the box. | ||
|
||
- [Using Docker containers]({{< relref "#docker-containers" >}}): The recommended method for most users due to its ease of use and simplicity. | ||
- [Building from source]({{< relref "building-from-source" >}}): For developers who require more control or are unable to use Docker. | ||
### Prerequisites | ||
|
||
## Docker containers | ||
You need to have [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) installed. Verify you have them both installed by running: | ||
|
||
This method leverages pre-built Docker images to quickly and easily spin up a local devnet. | ||
```shell | ||
docker version && docker compose version | ||
``` | ||
|
||
### Prerequisites | ||
```output | ||
Client: | ||
Cloud integration: v1.0.35+desktop.13 | ||
Version: 26.1.1 | ||
- [Docker](https://docs.docker.com/engine/install/). | ||
- [Docker Compose](https://docs.docker.com/compose/install/). | ||
- Basic understanding of Docker commands. | ||
... | ||
Docker Compose version v2.27.0-desktop.2 | ||
``` | ||
|
||
### Steps | ||
|
||
1. Clone the Entropy Core repo: | ||
1. Clone the Entropy Core repository and move into the new `entropy-core` directory: | ||
|
||
```bash | ||
git clone https://github.com/entropyxyz/entropy-core.git | ||
cd entropy-core | ||
``` | ||
```shell | ||
git clone https://github.com/entropyxyz/entropy-core.git | ||
cd entropy-core | ||
``` | ||
|
||
1. Start the Docker daemon: | ||
1. Add the Alice and Bob threshold-signing services (TSS) to your local `hosts` file: | ||
|
||
{{< tabs items="MacOS, Linux" >}} | ||
{{< tab >}} | ||
```shell | ||
sudo systemctl start docker | ||
``` | ||
{{< /tab >}} | ||
```shell | ||
echo "127.0.0.1 alice-tss-server bob-tss-server" | sudo tee -a /etc/hosts | ||
``` | ||
|
||
{{< tab >}} | ||
```shell | ||
dockerd | ||
``` | ||
{{< /tab >}} | ||
{{< /tabs >}} | ||
You may need to enter your computer's password when prompted. | ||
1. Start the Docker containers: | ||
```bash | ||
docker compose up --detach | ||
``` | ||
1. Verify container status: | ||
```shell | ||
docker compose up --detach # Detaching is optional. | ||
``` | ||
```output | ||
[+] Running 0/17 | ||
⠸ bob-tss-server [⠀] Pulling | ||
⠏ b3d3cc4a5268 Waiting | ||
⠏ dec0c2d4580b Waiting | ||
... | ||
✔ Container entropy-devnet-local-bob-chain-node-1 Started | ||
✔ Container entropy-devnet-local-alice-tss-server-1 Started | ||
✔ Container entropy-devnet-local-bob-tss-server-1 Started | ||
``` | ||
1. Confirm that the containers are up and running: | ||
```shell | ||
docker ps | ||
``` | ||
```output | ||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
23116711e503 entropyxyz/entropy-tss "/usr/local/bin/entr…" 1 minutes ago Up 4 seconds 9615/tcp, 9944/tcp, 127.0.0.1:3001->3001/tcp, 30333/tcp entropy-devnet-local-alice-tss-server-1 | ||
c83c2ae9da20 entropyxyz/entropy "/usr/local/bin/entr…" 1 minutes ago Up 4 seconds 3001/tcp, 9615/tcp, 30333/tcp, 127.0.0.1:9944->9944/tcp entropy-devnet-local-alice-chain-node-1 | ||
5088bb75951c entropyxyz/entropy-tss "/usr/local/bin/entr…" 1 minutes ago Up 4 seconds 3001/tcp, 9615/tcp, 9944/tcp, 30333/tcp, 127.0.0.1:3002->3002/tcp entropy-devnet-local-bob-tss-server-1 | ||
3b0048bcaa00 entropyxyz/entropy "/usr/local/bin/entr…" 1 minutes ago Up 4 seconds 3001/tcp, 9615/tcp, 30333/tcp, 127.0.0.1:9945->9944/tcp entropy-devnet-local-bob-chain-node-1 | ||
``` | ||
1. Confirm that the local devnet is functioning by using the Rust test interface within the Entropy Core repo: | ||
```shell | ||
cargo run -p entropy-test-cli -- --chain-endpoint="ws://127.0.0.1:9944" status | ||
``` | ||
```bash | ||
docker ps | ||
``` | ||
```output | ||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.60s | ||
Running `target/debug/entropy-test-cli '--chain-endpoint=ws://127.0.0.1:9944' status` | ||
This command lists all running Docker containers. Look for containers like `entropy-devnet-local-alice-chain-node-1`. | ||
... | ||
1. (Optional) Check server logs: | ||
Hash Stored by: Times used: Size in bytes: Configurable? Has auxiliary? | ||
0x0000…0000 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 10 300498 true true | ||
Success: Got status | ||
That took 224.958542ms | ||
``` | ||
```bash | ||
docker compose logs | ||
``` | ||
If this is the first time you are running the Rust testing interface, the `cargo` command above will take a few minutes to complete. | ||
While optional, this command shows logs from running containers which can be helpful for troubleshooting. | ||
1. You can also verify that things are working as expected by checking the server logs: | ||
1. Stop all running containers: | ||
```shell | ||
docker compose logs | ||
``` | ||
```bash | ||
docker stop $(docker ps -a -q) | ||
``` | ||
```output | ||
alice-chain-node-1 | 2024-06-24 19:41:06 Unexpected status code: 204 | ||
alice-chain-node-1 | 2024-06-24 19:41:06 💤 Idle (1 peers), best: #116 (0xd68c…bfed), finalized #113 (0x06df…be36), ⬇ 0.6kiB/s ⬆ 0.6kiB/s | ||
alice-chain-node-1 | 2024-06-24 19:41:11 💤 Idle (1 peers), best: #116 (0xd68c…bfed), finalized #114 (0xb994…0299), ⬇ 0.6kiB/s ⬆ 0.5kiB/s | ||
``` | ||
## Building from Source | ||
1. To stop the network, simply use the `docker stop` command followed by the ID of each Docker container: | ||
```shell | ||
docker stop $(docker ps -a -q) | ||
``` | ||
```output | ||
23116711e503 | ||
c83c2ae9da20 | ||
5088bb75951c | ||
3b0048bcaa00 | ||
``` | ||
Alternatively, you can stop each container individually. | ||
```shell | ||
docker stop 23116711 | ||
docker stop c83c2... | ||
... | ||
``` | ||
1. That's it! | ||
|
||
## Build from source | ||
|
||
It is possible to build the chain node and threshold-signature scheme server binaries. However, the process for spinning up a devnet with this method is slightly more involved than the Docker method outlined above. We recommend that you only follow this method if you have a specific reason to _not_ run Docker. | ||
|
||
### Prerequisites | ||
|
||
- [Latest LTS version of Rust](https://www.rust-lang.org/) | ||
- [Substrate dependencies](https://docs.substrate.io/install/) | ||
You must have the latest LTS version of [Rust](https://www.rust-lang.org/tools/install) installed, along with all the [Substrate dependencies](https://docs.substrate.io/install/) for your operating system. | ||
|
||
### Steps | ||
|
||
1. Clone the Entropy Core repository: | ||
1. Clone the Entropy Core repository and move into the new `entropy-core` directory: | ||
|
||
```bash | ||
git clone https://github.com/entropyxyz/entropy-core.git | ||
cd entropy-core | ||
``` | ||
```shell | ||
git clone https://github.com/entropyxyz/entropy-core.git | ||
cd entropy-core | ||
``` | ||
|
||
1. Compile the source into an executable binary: | ||
1. Build the chain node and threshold signature scheme server binaries: | ||
|
||
```bash | ||
cargo build --release | ||
``` | ||
```shell | ||
cargo build --release | ||
``` | ||
|
||
```output | ||
Downloaded asn1-rs-derive v0.4.0 | ||
Downloaded byte-tools v0.3.1 | ||
Downloaded const-random-macro v0.1.16 | ||
```output | ||
Downloaded asn1-rs-derive v0.4.0 | ||
Downloaded byte-tools v0.3.1 | ||
Downloaded const-random-macro v0.1.16 | ||
... | ||
``` | ||
... | ||
``` | ||
|
||
Cargo is downloading and compiling a lot of tooling for the binaries. This process may take upwards of 10 minutes, depending on your system. | ||
Cargo is downloading and compiling a lot of tooling for the binaries. This process may take upwards of 10 minutes, depending on your system. | ||
|
||
1. Run the node binary: | ||
|
||
```bash | ||
./target/release/entropy --dev --rpc-external | ||
``` | ||
```shell | ||
./target/release/entropy --dev --rpc-external | ||
``` | ||
|
||
```output | ||
2024-06-24 18:36:10 💤 Idle (0 peers), best: #4 (0xe3da…d11b), finalized #0 (0xe938…3b8f), ⬇ 0 ⬆ 0 | ||
2024-06-24 18:36:12 🙌 Starting consensus session on top of parent 0xe3da43079cb427b60ca77cee0fe206b933ec9df57ece549ad46a5681ea95d11b | ||
2024-06-24 18:36:12 🎁 Prepared block for proposing at 5 (2 ms) [hash: 0x636c606f7d66d8c25bc64956c14b1a9c209d035279ff4f7dccd629c346d81047; parent_hash: 0xe3da…d11b; extrinsics (1): [0x7f45…6999 | ||
``` | ||
```output | ||
2024-06-24 18:36:10 💤 Idle (0 peers), best: #4 (0xe3da…d11b), finalized #0 (0xe938…3b8f), ⬇ 0 ⬆ 0 | ||
2024-06-24 18:36:12 🙌 Starting consensus session on top of parent 0xe3da43079cb427b60ca77cee0fe206b933ec9df57ece549ad46a5681ea95d11b | ||
2024-06-24 18:36:12 🎁 Prepared block for proposing at 5 (2 ms) [hash: 0x636c606f7d66d8c25bc64956c14b1a9c209d035279ff4f7dccd629c346d81047; parent_hash: 0xe3da…d11b; extrinsics (1): [0x7f45…6999 | ||
``` | ||
|
||
4. (Optional) Test with the Rust test interface: | ||
1. Confirm that the local devnet is functioning by using the Rust test interface within the Entropy Core repo: | ||
|
||
```bash | ||
cargo run -p entropy-test-cli -- --chain-endpoint="ws://127.0.0.1:9944" status | ||
```shell | ||
cargo run -p entropy-test-cli -- --chain-endpoint="ws://127.0.0.1:9944" status | ||
``` | ||
|
||
```output | ||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.83s | ||
Running `target/debug/entropy-test-cli '--chain-endpoint=ws://127.0.0.1:9944' status` | ||
Running `target/debug/entropy-test-cli '--chain-endpoint=ws://127.0.0.1:9944' status` | ||
... | ||
Hash Stored by: Times used: Size in bytes: Configurable? Has auxiliary? | ||
0x0000…0000 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 10 300498 true true | ||
Hash Stored by: Times used: Size in bytes: Configurable? Has auxiliary? | ||
0x0000…0000 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY 10 300498 true true | ||
Success: Got status | ||
That took 182.155ms | ||
``` | ||
|
||
If this is the first time you are running the Rust testing interface, the `cargo` command above will take a few minutes to complete. | ||
If this is the first time you are running the Rust testing interface, the `cargo` command above will take a few minutes to complete. | ||
|
||
1. That's it! | ||
## Best Practices | ||
It's important to regularly reset the network to maintain a clean testing environment, thoroughly document all configuration settings for reproducibility, and simulate various network conditions to ensure robustness. | ||
It's important to regularly reset the network to maintain a clean testing environment, thoroughly document all configuration settings for reproducibility, and simulate various network conditions to ensure robustness. | ||
|
||
Developers should strive to mirror the mainnet environment as closely as possible while still maintaining flexibility for rapid iteration. If you plan to share access to the devnet, it's essential to establish a clear protocol for managing and distributing test tokens, implement monitoring and logging systems to track network behaviour, and regularly update the devnet software to match planned mainnet upgrades. | ||
Developers should strive to mirror the mainnet environment as closely as possible while still maintaining flexibility for rapid iteration. If you plan to share access to the devnet, it's essential to establish a clear protocol for managing and distributing test tokens, implement monitoring and logging systems to track network behaviour, and regularly update the devnet software to match planned mainnet upgrades. | ||
## Troubleshooting | ||
**Cannot connect to the Docker daemon**: If you see the error message `Cannot connect to the Docker daemon at unix:///Users/johnny/.docker/run/docker.sock. Is the docker daemon running?` it's likely because your Docker daemon isn't running. Double-check that you've opened the Docker application. | ||
|
||
**I can't build from source**: there are quite a few dependencies for building Substrate-based nodes. Run through the [official Substrate documentation](https://docs.substrate.io/install/) and make sure you have everything installed. | ||
|
||
**Permission denied while trying to connect to the Docker daemon socket**: you likely don't have the correct permissions and user-groups set. Verify that the Docker socket file /var/run/docker.sock has the correct permissions. It should be owned by the `root` user and have appropriate permissions for the `docker` group: | ||
```shell | ||
sudo chown root:docker /var/run/docker.sock | ||
sudo chmod 0660 /var/run/docker.sock | ||
``` | ||
Also, make sure that your current user is in the `docker` group: | ||
```shell | ||
sudo su | ||
usermod -aG docker your_username | ||
``` |