Skip to content

Commit 9f834e6

Browse files
author
Evgeniy Dzhurov
authored
Merge pull request #2790 from evdzhurov/utt
Merge rebased utt development branch into master
2 parents 01db4f4 + 0cbe3c7 commit 9f834e6

File tree

238 files changed

+153550
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+153550
-2
lines changed

.github/workflows/build_and_test_clang_debug.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
use_s3_obj_store:
2222
- "-DUSE_S3_OBJECT_STORE=ON"
2323
- "-DUSE_S3_OBJECT_STORE=OFF"
24+
utt:
25+
- "-DBUILD_UTT=ON"
2426
steps:
2527
- name: Cleanup pre-installed tools
2628
run: |
@@ -59,6 +61,7 @@ jobs:
5961
-DUSE_OPENTRACING=ON \
6062
-DOMIT_TEST_OUTPUT=OFF\
6163
-DKEEP_APOLLO_LOGS=TRUE\
64+
${{ matrix.utt }} \
6265
-DUSE_FAKE_CLOCK_IN_TIME_SERVICE=TRUE\" "\
6366
&& script -q -e -c "make simple-test" \
6467
&& script -q -e -c "make test"

.github/workflows/build_and_test_clang_release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
use_s3_obj_store:
2323
- "-DUSE_S3_OBJECT_STORE=ON"
2424
- "-DUSE_S3_OBJECT_STORE=OFF"
25+
utt:
26+
- "-DBUILD_UTT=ON"
2527
steps:
2628
- name: Cleanup pre-installed tools
2729
run: |
@@ -60,6 +62,7 @@ jobs:
6062
-DUSE_OPENTRACING=ON \
6163
-DOMIT_TEST_OUTPUT=OFF\
6264
-DKEEP_APOLLO_LOGS=TRUE\
65+
${{ matrix.utt }} \
6366
-DUSE_FAKE_CLOCK_IN_TIME_SERVICE=TRUE\" "\
6467
&& script -q -e -c "make test"
6568
- name: Prepare artifacts

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ option(USE_OPENSSL "Enable use of OpenSSL" ON)
4646
option(BUILD_THIRDPARTY "Wheter to build third party librarie or use preinstalled ones" OFF)
4747
option(CODECOVERAGE "Enable Code Coverage Metrics in Clang" OFF)
4848
option(ENABLE_RESTART_RECOVERY_TESTS "Enable tests for restart recovery" OFF)
49+
option(BUILD_UTT "Build UTT library" OFF)
4950

5051
if(USE_OPENSSL AND NOT BUILD_THIRDPARTY)
5152
set(OPENSSL_ROOT_DIR /usr/local/ssl) # not to confuse with system ssl libs
@@ -221,6 +222,10 @@ if(USE_GRPC)
221222
add_subdirectory(thin-replica-server)
222223
endif()
223224
add_subdirectory(ccron)
225+
# [TODO-UTT] Compile libutt on GCC
226+
if (BUILD_UTT AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
227+
add_subdirectory(utt)
228+
endif()
224229

225230
#
226231
# Setup testing

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CONCORD_BFT_EXAMPLE_CMF_PATHS?=${CONCORD_BFT_TARGET_SOURCE_PATH}/build/examples/
1515
CONCORD_BFT_CLIENT_PROTO_PATH?=${CONCORD_BFT_TARGET_SOURCE_PATH}/build/client/proto
1616
CONCORD_BFT_THIN_REPLICA_PROTO_PATH?=${CONCORD_BFT_TARGET_SOURCE_PATH}/build/thin-replica-server/proto
1717
CONCORD_BFT_KVBC_PROTO_PATH?=${CONCORD_BFT_TARGET_SOURCE_PATH}/build/kvbc/proto
18+
CONCORD_BFT_UTT_PATH?=${CONCORD_BFT_TARGET_SOURCE_PATH}/build/utt
1819
CONCORD_BFT_CONTAINER_SHELL?=/bin/bash
1920
CONCORD_BFT_CONTAINER_CC?=clang
2021
CONCORD_BFT_CONTAINER_CXX?=clang++
@@ -39,6 +40,7 @@ endif
3940

4041
CONCORD_BFT_CMAKE_CXX_FLAGS_RELEASE?='-O3 -g'
4142
CONCORD_BFT_CMAKE_USE_LOG4CPP?=TRUE
43+
CONCORD_BFT_CMAKE_BUILD_UTT?=FALSE
4244
CONCORD_BFT_CMAKE_BUILD_ROCKSDB_STORAGE?=TRUE
4345
CONCORD_BFT_CMAKE_USE_S3_OBJECT_STORE?=TRUE
4446
CONCORD_BFT_CMAKE_USE_OPENTRACING?=TRUE
@@ -88,6 +90,7 @@ CONCORD_BFT_CMAKE_FLAGS?= \
8890
-DBUILD_COMM_TCP_TLS=${TLS_ENABLED__} \
8991
-DCMAKE_CXX_FLAGS_RELEASE=${CONCORD_BFT_CMAKE_CXX_FLAGS_RELEASE} \
9092
-DUSE_LOG4CPP=${CONCORD_BFT_CMAKE_USE_LOG4CPP} \
93+
-DBUILD_UTT=${CONCORD_BFT_CMAKE_BUILD_UTT} \
9194
-DBUILD_ROCKSDB_STORAGE=${CONCORD_BFT_CMAKE_BUILD_ROCKSDB_STORAGE} \
9295
-DUSE_S3_OBJECT_STORE=${CONCORD_BFT_CMAKE_USE_S3_OBJECT_STORE} \
9396
-DUSE_OPENTRACING=${CONCORD_BFT_CMAKE_USE_OPENTRACING} \
@@ -219,6 +222,7 @@ tidy-check: gen-cmake ## Run clang-tidy
219222
make -C ${CONCORD_BFT_CLIENT_PROTO_PATH} &> /dev/null && \
220223
make -C ${CONCORD_BFT_THIN_REPLICA_PROTO_PATH} &> /dev/null && \
221224
make -C ${CONCORD_BFT_KVBC_PROTO_PATH} &> /dev/null && \
225+
(make -C ${CONCORD_BFT_UTT_PATH} &> /dev/null || true) && \
222226
${CONCORD_BFT_CLANG_TIDY_PATH} -ignore ../.clang-tidy-ignore 2>&1 | tee clang-tidy-report.txt | ( ! grep 'error:\|note:' ) && \
223227
../scripts/check-forbidden-usage.sh .." \
224228
&& (printf "\nClang-tidy finished successfully.\n") \

client/bftclient/include/bftclient/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ struct ClientConfig {
6363
ClientId id;
6464
std::set<ReplicaId> all_replicas;
6565
std::set<ReplicaId> ro_replicas;
66-
uint16_t f_val;
67-
uint16_t c_val;
66+
uint16_t f_val = 0;
67+
uint16_t c_val = 0;
6868
RetryTimeoutConfig retry_timeout_config;
6969
bool use_unified_certs = false;
7070
std::optional<std::string> transaction_signing_private_key_file_path = std::nullopt;

utt/CMakeLists.txt

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
cmake_minimum_required (VERSION 3.2)
2+
# project(<name> VERSION <ver> LANGUAGES CXX)
3+
project(libutt VERSION 0.1.0.0 LANGUAGES CXX)
4+
message(STATUS "Building UTT")
5+
#
6+
# Configuration options
7+
#
8+
set(
9+
CURVE
10+
"BN128"
11+
CACHE
12+
STRING
13+
"Default curve: one of ALT_BN128, BN128, EDWARDS, MNT4, MNT6"
14+
)
15+
16+
option(
17+
BINARY_OUTPUT
18+
"In serialization of elliptic curve points, output raw binary data (instead of decimal), which is smaller and faster."
19+
OFF
20+
)
21+
22+
add_definitions(
23+
-DCURVE_${CURVE}
24+
)
25+
26+
option(
27+
USE_MULTITHREADING
28+
"Enable parallelized execution of DKG protocols using OpenMP"
29+
OFF
30+
)
31+
32+
if(${CURVE} STREQUAL "BN128")
33+
add_definitions(
34+
-DBN_SUPPORT_SNARK=1
35+
)
36+
endif()
37+
38+
#
39+
# Configure CCache if available
40+
#
41+
# find_program(CCACHE_FOUND ccache)
42+
# if(CCACHE_FOUND)
43+
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
44+
# set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
45+
# endif(CCACHE_FOUND)
46+
47+
#find_package(Threads REQUIRED)
48+
#find_package(Boost 1.65 COMPONENTS program_options REQUIRED)
49+
#include_directories(${Boost_INCLUDE_DIR})
50+
51+
# OS X Catalina fix
52+
include_directories(SYSTEM "/usr/local/include")
53+
link_directories("/usr/local/lib")
54+
55+
# Note: xassert and xutils are part of utt source code
56+
# set(utt_packages
57+
# xassert
58+
# xutils
59+
# )
60+
61+
#
62+
# Dependencies
63+
#
64+
# TODO: Find ate-pairing, libff, libfqfft too or issue error with pointer to install script
65+
# foreach(package ${utt_packages})
66+
# find_package(${package} QUIET)
67+
68+
# if(${package}_FOUND)
69+
# message("${package} library is installed!")
70+
# else()
71+
# message("${package} library not installed locally, please download from https//github.com/alinush/lib${package}")
72+
# endif()
73+
# endforeach()
74+
75+
#
76+
# C++ options
77+
# TODO: change to set_target_properties?
78+
# https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/
79+
#
80+
set(CMAKE_CXX_STANDARD 17)
81+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
82+
set(CMAKE_CXX_EXTENSIONS OFF)
83+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
84+
#
85+
# Compiler flags
86+
#
87+
88+
# When you do 'a > b in 'C/C++, if a is unsigned and b is signed and equal to -1, C/C++
89+
# actually casts b to unsigned (probably because casting unsigned to signed would require a bigger data type)
90+
# Thus, 1 > -1 will evaluate to false because during the cast -1 will be set to to 2^32 - 1
91+
#
92+
# WARNING: For the love of god, do not remove this flag or you will regret it. Instead,
93+
# just use signed types everywhere and cast your unsigned to signed when mixing unsigned
94+
# variables with signed ones. See: http://soundsoftware.ac.uk/c-pitfall-unsigned
95+
set(CXX_FLAGS_INTEGER_CORRECTNESS
96+
"-Wconversion -Wsign-conversion -Wsign-compare")
97+
set(CXX_FLAGS_FORMAT
98+
"-Wformat-y2k -Wno-format-extra-args -Wno-format-zero-length -Wformat-nonliteral -Wformat-security -Wformat=2")
99+
set(CXX_FLAGS_OPTIMIZATIONS "-O3")
100+
101+
string(APPEND CXX_FLAGS " ${CXX_FLAGS_OPTIMIZATIONS}")
102+
string(APPEND CXX_FLAGS " ${CXX_FLAGS_FORMAT}")
103+
string(APPEND CXX_FLAGS " ${CXX_FLAGS_INTEGER_CORRECTNESS}")
104+
# TODO: use target_compile_features instead:
105+
# https://cmake.org/cmake/help/v3.1/command/target_compile_features.html#command:target_compile_features
106+
# https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
107+
string(APPEND CXX_FLAGS " -Wall")
108+
string(APPEND CXX_FLAGS " -Werror")
109+
string(APPEND CXX_FLAGS " -Wextra")
110+
111+
112+
# TODO: Figure out right way to deal with -fstrict-overflow / -Wstrict-overflow related errors
113+
string(APPEND CXX_FLAGS
114+
" -fno-strict-overflow")
115+
string(APPEND CXX_FLAGS_DEBUG
116+
" -O1")
117+
# "It turns out that some gcc builds (depends on the distro) set _FORTIFY_SOURCE internally, so you need to undefine it first. So if you used CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2", it might go better."
118+
# https://github.com/neovim/neovim/issues/2557
119+
string(APPEND CXX_FLAGS_DEBUG
120+
" -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2")
121+
122+
if("${USE_MULTITHREADING}")
123+
add_definitions(-DUSE_MULTITHREADING)
124+
string(APPEND CMAKE_CXX_FLAGS " -fopenmp")
125+
endif()
126+
127+
# GNU and Clang-specific flags
128+
string(APPEND CMAKE_CXX_FLAGS
129+
" ${CXX_FLAGS}")
130+
string(APPEND CMAKE_CXX_FLAGS_DEBUG
131+
" ${CXX_FLAGS_DEBUG} -DUTT_LOG_DEBUG")
132+
# When building with 'cmake -DCMAKE_BUILD_TYPE=Trace'
133+
string(APPEND CMAKE_CXX_FLAGS_TRACE
134+
" ${CXX_FLAGS_DEBUG} -DUTT_LOG_TRACE")
135+
136+
# using Clang
137+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
138+
# Clang-specific options
139+
string(APPEND CMAKE_CXX_FLAGS
140+
" -ferror-limit=3")
141+
string(APPEND CMAKE_CXX_FLAGS_DEBUG
142+
# " -fstack-protector-all -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
143+
" -fstack-protector-all -fno-omit-frame-pointer -fno-optimize-sibling-calls -ggdb -O0")
144+
# TODO: doesn't seem to work on MacOS, getting strange linking errors
145+
#string(APPEND CMAKE_CXX_FLAGS_DEBUG
146+
# " -D_LIBCPP_DEBUG=0")
147+
#string(APPEND CMAKE_CXX_FLAGS_DEBUG
148+
# " -D_LIBCPP_DEBUG=1")
149+
150+
# using GCC
151+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
152+
# GCC-specific options
153+
string(APPEND CMAKE_CXX_FLAGS
154+
" -fmax-errors=3")
155+
string(APPEND CMAKE_CXX_FLAGS_DEBUG
156+
" -fstack-protector-all")
157+
# NOTE: define _GLIBCXX_DEBUG if you want bounds checking for std::vector::operator[] (but it seems to cause a segfault at the end of execution)
158+
# only works for libstdc++ from the GNU compiler, I think
159+
string(APPEND CMAKE_CXX_FLAGS_DEBUG
160+
" -D_GLIBCXX_DEBUG")
161+
162+
# TODO: using Intel C++
163+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
164+
165+
# TODO: using Visual Studio C++
166+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
167+
168+
endif()
169+
170+
#
171+
# Testing flags
172+
#
173+
enable_testing()
174+
175+
include(dependencies.cmake)
176+
# Subdirectories
177+
add_subdirectory(libutt)
178+
add_subdirectory(libxassert)
179+
add_subdirectory(libxutils)
180+
add_subdirectory(wallet-cli)
181+
182+
set(newutt_src
183+
libutt/src/api/UTTParams.cpp
184+
libutt/src/api/commitment.cpp
185+
libutt/src/api/client.cpp
186+
libutt/src/api/coinsSigner.cpp
187+
libutt/src/api/mint.cpp
188+
libutt/src/api/coin.cpp
189+
libutt/src/api/registrator.cpp
190+
libutt/src/api/common.cpp
191+
libutt/src/api/burn.cpp
192+
libutt/src/api/transaction.cpp
193+
libutt/src/api/budget.cpp
194+
)
195+
add_library(utt_api STATIC ${newutt_src})
196+
target_link_libraries(utt_api PUBLIC utt)
197+
target_include_directories(utt_api PUBLIC include)
198+
add_subdirectory(tests)
199+
200+
201+

utt/LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020, Alin Tomescu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

utt/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# libutt
2+
3+
Steps:
4+
5+
1. Fork
6+
2. Rename the repository to `libwhatever`
7+
3. Run `rename-library.sh whatever`
8+
4. Update this README file
9+
5. Enjoy developing your `libwhatever` library based on [libff](http://github.com/scipr-lab/libff/) and [libfqfft](http://github.com/scipr-lab/libfqfft)
10+
11+
12+
## Build on Linux
13+
14+
Step zero is to clone this repo and `cd` to the right directory:
15+
16+
cd <wherever-you-cloned-libutt>
17+
18+
If you're running OS X, make sure you have the Xcode **and** the Xcode developer tools installed:
19+
20+
xcode-select --install
21+
22+
First, install deps using:
23+
24+
scripts/linux/install-libs.sh
25+
scripts/linux/install-deps.sh
26+
27+
Then, set up the environment. This **will store the built code in ~/builds/utt/**:
28+
29+
. scripts/linux/set-env.sh release
30+
31+
...you can also use `debug`, `relwithdebug` or `trace` as an argument for `set-env.sh`.
32+
33+
To build:
34+
35+
make.sh
36+
37+
..tests, benchmarks and any other binaries are automatically added to `PATH` but can also be found in
38+
39+
cd ~/builds/utt/master/release/libutt/bin/
40+
41+
(or replace `release` with `debug` or whatever you used in `set-env.sh`)
42+
43+
## Useful scripts
44+
45+
There's a bunch of useful scripts in `scripts/linux/`:
46+
47+
- `cols.sh` for viewing CSV data in the terminal
48+
- `generate-qsbdh-params.sh` for generating $q$-SDH public parameters (e.g., for the Kate-Zaveruch-Goldberg polynomial commitments)
49+
50+
## Git submodules
51+
52+
This is just for reference purposes.
53+
No need to execute these.
54+
To fetch the submodules, just do:
55+
56+
git submodule init
57+
git submodule update
58+
59+
For historical purposes, (i.e., don't execute these), when I set up the submodules, I did:
60+
61+
cd depends/
62+
git submodule add git://github.com/herumi/ate-pairing.git
63+
git submodule add git://github.com/herumi/xbyak.git
64+
git submodule add git://github.com/scipr-lab/libff.git
65+
git submodule add https://github.com/alinush/libfqfft.git
66+
67+
To update your submodules with changes from their upstream github repos, do:
68+
69+
git submodule foreach git pull origin master
70+

utt/bank-demo/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
run/

0 commit comments

Comments
 (0)