From d40efe9d4a9632aa2eb963235d36f914c649f795 Mon Sep 17 00:00:00 2001 From: Nacho Date: Thu, 22 Jun 2023 16:43:55 -0300 Subject: [PATCH 1/2] add docker stuff --- CMakeLists.txt | 13 +++++++----- Dockerfile | 24 ++++++++++++++++++++++ docker-compose.yml | 41 ++++++++++++++++++++++++++++++++++++++ hotstuff.conf | 8 ++++---- log | 1 + scripts/run_demo.sh | 18 ++++++----------- scripts/run_demo_client.sh | 2 +- 7 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 log diff --git a/CMakeLists.txt b/CMakeLists.txt index c6af4bd5..18357680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/salticidae/cmake/Modules/") -add_subdirectory(salticidae) include_directories(salticidae/include) +include_directories(/opt/homebrew/opt/salticidae@31/include) find_package(OpenSSL REQUIRED) find_package(Threads REQUIRED) @@ -46,6 +46,9 @@ add_dependencies(secp256k1 libsecp256k1) include_directories(./) include_directories(include) +include_directories(/opt/homebrew/opt/openssl@3/include/) +include_directories(/opt/homebrew/opt/libuv/include/) + add_library(hotstuff OBJECT src/util.cpp @@ -61,11 +64,11 @@ if(BUILD_SHARED) set_property(TARGET hotstuff PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(hotstuff_shared SHARED $) set_target_properties(hotstuff_shared PROPERTIES OUTPUT_NAME "hotstuff") - target_link_libraries(hotstuff_shared salticidae_static secp256k1 crypto ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(hotstuff_shared secp256k1 crypto ${CMAKE_THREAD_LIBS_INIT} /opt/homebrew/opt/salticidae@31/lib/libsalticidae.a) endif() add_library(hotstuff_static STATIC $) set_target_properties(hotstuff_static PROPERTIES OUTPUT_NAME "hotstuff") -target_link_libraries(hotstuff_static salticidae_static secp256k1 crypto ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(hotstuff_static secp256k1 crypto ${CMAKE_THREAD_LIBS_INIT} /opt/homebrew/opt/salticidae@31/lib/libsalticidae.a) add_subdirectory(test) @@ -91,11 +94,11 @@ endif() # build tools add_executable(hotstuff-keygen src/hotstuff_keygen.cpp) -target_link_libraries(hotstuff-keygen hotstuff_static) +target_link_libraries(hotstuff-keygen hotstuff_static /opt/homebrew/opt/salticidae@31/lib/libsalticidae.a) add_executable(hotstuff-tls-keygen src/hotstuff_tls_keygen.cpp) -target_link_libraries(hotstuff-tls-keygen hotstuff_static) +target_link_libraries(hotstuff-tls-keygen hotstuff_static /opt/homebrew/opt/salticidae@31/lib/libsalticidae.a) find_package(Doxygen) if (DOXYGEN_FOUND) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3aa237c7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM debian:bullseye-slim as hotstuff +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install git gcc g++ make cmake libuv1-dev libssl-dev libsodium-dev autoconf libnet1-dev libtool pastebinit python3 bash gdb dnsutils nano inetutils-ping net-tools sudo iproute2 +RUN git clone https://github.com/aixoss/gmp && cd gmp && ./configure && make install +RUN git clone https://github.com/hot-stuff/libhotstuff.git && cd libhotstuff && git submodule update --init --recursive && git submodule update --recursive --remote +RUN cd libhotstuff && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED=ON -DHOTSTUFF_PROTO_LOG=ON && make + +ADD ./scripts / +COPY ./scripts /libhotstuff/examples +COPY ./hotstuff.conf /libhotstuff +ENTRYPOINT ["/run_demo.sh"] + + +FROM debian:bullseye-slim as hotstuff_client +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install git gcc g++ make cmake libuv1-dev libssl-dev libsodium-dev autoconf libnet1-dev libtool pastebinit python3 bash gdb dnsutils nano inetutils-ping net-tools sudo iproute2 +RUN git clone https://github.com/aixoss/gmp && cd gmp && ./configure && make install +RUN git clone https://github.com/hot-stuff/libhotstuff.git && cd libhotstuff && git submodule update --init --recursive && git submodule update --recursive --remote +RUN cd libhotstuff && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED=ON -DHOTSTUFF_PROTO_LOG=ON && make + +ADD ./scripts / +COPY ./scripts /libhotstuff/examples +COPY ./hotstuff.conf /libhotstuff +ENTRYPOINT ["/run_demo_client.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..96d6e34b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +version: '1' +services: + hotstuff_container1: + image: hotstuff + environment: + - IMAGE_IDX=0 + networks: + hotstuff_network: + ipv4_address: 172.18.0.2 + hotstuff_container2: + image: hotstuff + environment: + - IMAGE_IDX=1 + networks: + hotstuff_network: + ipv4_address: 172.18.0.3 + hotstuff_container3: + image: hotstuff + environment: + - IMAGE_IDX=2 + networks: + hotstuff_network: + ipv4_address: 172.18.0.4 + hotstuff_container4: + image: hotstuff + environment: + - IMAGE_IDX=3 + networks: + hotstuff_network: + ipv4_address: 172.18.0.5 + hotstuff_client: + image: hotstuff_client + networks: + hotstuff_network: + ipv4_address: 172.18.0.6 +networks: + hotstuff_network: + ipam: + driver: default + config: + - subnet: 172.18.0.0/16 diff --git a/hotstuff.conf b/hotstuff.conf index cadf3aef..0e4ab9a8 100644 --- a/hotstuff.conf +++ b/hotstuff.conf @@ -1,6 +1,6 @@ block-size = 1 pace-maker = rr -replica = 127.0.0.1:10000;20000, 039f89215177475ac408d079b45acef4591fc477dd690f2467df052cf0c7baba23, 542865a568784c4e77c172b82e99cb8a1a53b7bee5f86843b04960ea4157f420 -replica = 127.0.0.1:10001;20001, 0278740a5bec75e333b3c93965b1609163b15d2e3c2fdef141d4859ec70c238e7a, c261250345ebcd676a0edeea173526608604f626b2e8bc4fd2142d3bde1d44d5 -replica = 127.0.0.1:10002;20002, 0269eb606576a315a630c2483deed35cc4bd845abae1c693f97c440c89503fa92e, 065b010aed5629edfb5289e8b22fc6cc6b33c4013bfdd128caba80c3c02d6d78 -replica = 127.0.0.1:10003;20003, 03e6911bf17e632eecdfa0dc9fc6efc9ddca60c0e3100db469a3d3d62008044a53, 6540a0fea67efcb08f53ec3a952df4c3f0e2e07c2778fd92320807717e29a651 +replica = 172.18.0.2:10000;20000, 039f89215177475ac408d079b45acef4591fc477dd690f2467df052cf0c7baba23, 542865a568784c4e77c172b82e99cb8a1a53b7bee5f86843b04960ea4157f420 +replica = 172.18.0.3:10001;20001, 0278740a5bec75e333b3c93965b1609163b15d2e3c2fdef141d4859ec70c238e7a, c261250345ebcd676a0edeea173526608604f626b2e8bc4fd2142d3bde1d44d5 +replica = 172.18.0.4:10002;20002, 0269eb606576a315a630c2483deed35cc4bd845abae1c693f97c440c89503fa92e, 065b010aed5629edfb5289e8b22fc6cc6b33c4013bfdd128caba80c3c02d6d78 +replica = 172.18.0.5:10003;20003, 03e6911bf17e632eecdfa0dc9fc6efc9ddca60c0e3100db469a3d3d62008044a53, 6540a0fea67efcb08f53ec3a952df4c3f0e2e07c2778fd92320807717e29a651 diff --git a/log b/log new file mode 100644 index 00000000..9f24263f --- /dev/null +++ b/log @@ -0,0 +1 @@ +zsh: no such file or directory: ./libhotstuff/examples/hotstuff-app diff --git a/scripts/run_demo.sh b/scripts/run_demo.sh index bda33cf3..01c95552 100755 --- a/scripts/run_demo.sh +++ b/scripts/run_demo.sh @@ -1,17 +1,11 @@ #!/bin/bash -rep=({0..3}) -if [[ $# -gt 0 ]]; then - rep=($@) -fi - +i=${IMAGE_IDX:=1} # avoid stack overflow as in our simple demo the bootstrapping replica will # potentially have a long chain of promise resolution ulimit -s unlimited -for i in "${rep[@]}"; do - echo "starting replica $i" - #valgrind --leak-check=full ./examples/hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 & - #gdb -ex r -ex bt -ex q --args ./examples/hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 & - ./examples/hotstuff-app --conf ./hotstuff-sec${i}.conf > log${i} 2>&1 & -done -wait +echo "starting replica $i" +#valgrind --leak-check=full ./examples/hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 & +#gdb -ex r -ex bt -ex q --args ./examples/hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 & +cd libhotstuff +./examples/hotstuff-app --conf "./hotstuff-sec${i}.conf" > "logs" 2>&1 diff --git a/scripts/run_demo_client.sh b/scripts/run_demo_client.sh index 09fafebd..11f57b11 100755 --- a/scripts/run_demo_client.sh +++ b/scripts/run_demo_client.sh @@ -4,5 +4,5 @@ # rotation will be scheduled. Try to kill and run run_demo_client.sh again, new # commands should still get through (be replicated) once the new leader becomes # stable. - +cd libhotstuff ./examples/hotstuff-client --idx 0 --iter -1 --max-async 4 From fbf8f6111fc6ddf65054e0e41804f29c4c9c07e2 Mon Sep 17 00:00:00 2001 From: igamigo Date: Thu, 22 Jun 2023 17:45:10 -0300 Subject: [PATCH 2/2] Delete log --- log | 1 - 1 file changed, 1 deletion(-) delete mode 100644 log diff --git a/log b/log deleted file mode 100644 index 9f24263f..00000000 --- a/log +++ /dev/null @@ -1 +0,0 @@ -zsh: no such file or directory: ./libhotstuff/examples/hotstuff-app