Skip to content

Commit

Permalink
Merge branch 'main' into full_config_in_cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ElFantasma authored Mar 19, 2024
2 parents b4ec675 + 67b8c30 commit 2c7089a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 113 deletions.
47 changes: 8 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
.PHONY: node nodes_config docker_nodes_config node_docker consensus_docker_example clean clean_docker addresses_file blank_configs
NODE?=0
DOCKER_IP=172.12.0.10
IP?=127.0.0.1:3054
EXECUTABLE_NODE_DIR=node/tools
NODES=4
SEED_NODES=1

# Locally run commands

node:
export RUST_LOG=INFO && cd ${EXECUTABLE_NODE_DIR}/nodes-config/node_${NODE} && cargo run -- --database ../../database/node_${NODE}
export RUST_LOG=INFO && cd ${EXECUTABLE_NODE_DIR}/nodes-config/${IP} && cargo run -- --database ../../database/node_${NODE}

nodes_config:
cd ${EXECUTABLE_NODE_DIR} && cargo run --bin localnet_config -- --input-addrs addresses.txt --output-dir nodes-config
Expand All @@ -21,22 +20,7 @@ docker_build_executor:
docker_node_image:
docker build -t consensus-node --target=executor-runtime .

docker_nodes_config:
cd ${EXECUTABLE_NODE_DIR} && cargo run --bin localnet_config -- --input-addrs docker-config/addresses.txt --output-dir docker-config

docker_node:
$(MAKE) docker_node_image
docker run -d --name consensus-node-${NODE} --env NODE_ID="consensus-node-${NODE}" consensus-node

consensus_docker_example:
mkdir -p ${EXECUTABLE_NODE_DIR}/docker-config
cd ${EXECUTABLE_NODE_DIR}/docker-config && rm -rf addresses.txt && echo 172.12.0.10:3054 >> addresses.txt && echo 172.12.0.11:3054 >> addresses.txt
$(MAKE) docker_nodes_config
$(MAKE) docker_node_image
docker-compose up -d

stop_docker_nodes:
docker stop consensus-node-1 consensus-node-2
# Kubernetes commands

start_k8s_nodes:
$(MAKE) docker_node_image
Expand All @@ -51,26 +35,11 @@ clean: clean_docker clean_k8s

clean_k8s:
rm -rf ${EXECUTABLE_NODE_DIR}/k8s_configs
kubectl delete deployments --all
kubectl delete pods --all
kubectl delete deployments --all -n consensus
kubectl delete pods --all -n consensus
kubectl delete services --all -n consensus
kubectl delete namespaces consensus

clean_docker:
docker rm -f consensus-node-1
docker rm -f consensus-node-2
docker network rm -f node-net
docker image rm -f consensus-node
docker image rm -f consensus-node:latest
docker image rm -f test-suite

addresses_file:
mkdir -p ${EXECUTABLE_NODE_DIR}/docker-config
cd ${EXECUTABLE_NODE_DIR}/docker-config && \
rm -rf addresses.txt && \
touch addresses.txt && \
for n in $$(seq 0 $$((${NODES} - 1))); do echo 0.0.0.$$n:3054 >> addresses.txt; done

blank_configs: addresses_file docker_node_configs
for n in $$(seq 0 $$((${NODES} - 1))); do \
jq '.publicAddr = "0.0.0.0:3054"' node/tools/docker-config/nodes-config/node_$$n/config.json | \
jq '.gossipStaticOutbound = "[]"' > node/tools/docker-config/nodes-config/node_$$n/config.tmp && \
mv -f node/tools/docker-config/nodes-config/node_$$n/config.tmp node/tools/docker-config/nodes-config/node_$$n/config.json; \
done
34 changes: 0 additions & 34 deletions compose.yaml

This file was deleted.

51 changes: 11 additions & 40 deletions node/tools/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Running Test Consensus Nodes

These instructions guide you through the process of setting up and running a test consensus node in both local and Dockerized environments. Additionally, examples are provided to demonstrate how to run two or more nodes, communicating and doing consensus between them.
These instructions guide you through the process of setting up and running a test consensus node in both local and Clusterized environments.

## Local Setup

Expand All @@ -12,47 +12,13 @@ These instructions guide you through the process of setting up and running a tes
make nodes_config
```

This command creates a directory named `nodes-config` and generates a folder for each address listed in the `.txt` file with the name `node_{NODE_NUMBER}`, providing essential configuration files for the corresponding node. The `NODE_NUMBER` is simply a numerical identifier for each node.
This command creates a directory named `nodes-config` and generates a folder for each address listed in the `.txt` file with the ip as the directory name, providing essential configuration files for the corresponding node.

```bash
make node NODE=<NODE_NUMBER>
make node IP=<NODE_IP>
```

The default value for this command is set to `0` for launching the initial node, and you can increment the number for subsequent nodes. Note that running this command will take control of the terminal.

## Dockerized Setup

To launch a standalone consensus node in a Docker container, run the following command in the project root (era-consensus):

```bash
make node_docker
```

This command creates a container running a single node that advances views and finalizes blocks.

For a simple example with two nodes communicating in different containers, use:

```bash
make consensus_docker_example
```

This sets up two containers, each hosting a consensus node, interlinked and progressing through views to finalize blocks, achieving consensus between them.

To stop the node containers, use:

```bash
make stop_docker_nodes
```

The node will resume the last viewed block from the previous session when initiated again.

To clean all states after running these commands, use:

```bash
make clean_docker
```

> This deletes the generated images and containers, requiring regeneration.
The default value for this command is set to `127.0.0.1:3054` for launching the initial node, to run a different node just use the IP previously detailed in the `addresses.txt` file. Note that running this command will take control of the terminal.


## Running in minikube
Expand Down Expand Up @@ -97,7 +63,12 @@ To start the minikube dashboard in order to inspect the deployed pods. Remember
Finally to clean everything up

```bash
minikube delete --all
make clean
```

will remove all namespaces, deployments and pods from the minikube environment.
This will remove all namespaces, deployments and pods from the minikube environment and the images generated in Docker.
If you want to stop the `minikube` environment just do:

```bash
minikube delete --all
```

0 comments on commit 2c7089a

Please sign in to comment.