diff --git a/Makefile b/Makefile index 2fb2848c..f11b97c1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ .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 @@ -8,7 +7,7 @@ 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 @@ -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 @@ -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 diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 46edd5c3..00000000 --- a/compose.yaml +++ /dev/null @@ -1,34 +0,0 @@ -version: "3.9" - -services: - node-1: - build: - context: . - target: runtime - image: consensus-node - container_name: consensus-node-1 - ports: - - "3154:3154" - networks: - node_net: - # This allow us to know the ip of the node-1 container to fill the address in the config file - # Only for test purposes, may be removed in the future - ipv4_address: 172.12.0.10 - node-2: - image: consensus-node - container_name: consensus-node-2 - ports: - - "3155:3154" - networks: - node_net: - # This allow us to know the ip of the node-2 container to fill the address in the config file - # Only for test purposes, may be removed in the future - ipv4_address: 172.12.0.11 - -networks: - node_net: - name: node-net - ipam: - config: - - subnet: "172.12.0.0/24" - gateway: "172.12.0.1" diff --git a/node/tools/README.md b/node/tools/README.md index b6349665..6bf203a0 100644 --- a/node/tools/README.md +++ b/node/tools/README.md @@ -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 @@ -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= + make 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 @@ -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. \ No newline at end of file +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 +```