Skip to content

Commit

Permalink
Merge pull request #1 from PastaPastaPasta/llmq-thresholds
Browse files Browse the repository at this point in the history
Llmq thresholds
  • Loading branch information
ogabrielides authored Nov 30, 2021
2 parents 8d2b6bb + a8f4143 commit bb056da
Show file tree
Hide file tree
Showing 105 changed files with 1,034 additions and 297 deletions.
15 changes: 14 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ after_success:
script:
- set -o errexit; source .travis/lint_06_script.sh

- stage: extended-lint
name: 'extended lint [runtime >= 60 seconds]'
env:
cache: false
language: python
python: '3.5'
install:
- set -o errexit; source .travis/extended_lint_04_install.sh
before_script:
- set -o errexit; source .travis/lint_05_before_script.sh
script:
- set -o errexit; source .travis/extended_lint_06_script.sh

- stage: test
name: 'ARM [GOAL: install] [no unit or functional tests]'
env: >-
Expand Down Expand Up @@ -284,7 +297,7 @@ after_success:
RUN_FUNCTIONAL_TESTS=false
RUN_FUZZ_TESTS=true
GOAL="install"
BITCOIN_CONFIG="--disable-wallet --disable-bench --with-utils=no --with-daemon=no --with-libs=no --with-gui=no --enable-fuzz --with-sanitizers=fuzzer,address CC=clang CXX=clang++"
BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address CC=clang CXX=clang++"
- stage: test
env: >-
Expand Down
12 changes: 12 additions & 0 deletions .travis/extended_lint_04_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
#
# Copyright (c) 2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C

CPPCHECK_VERSION=1.86
curl -s https://codeload.github.com/danmar/cppcheck/tar.gz/${CPPCHECK_VERSION} | tar -zxf - --directory /tmp/
(cd /tmp/cppcheck-${CPPCHECK_VERSION}/ && make CFGDIR=/tmp/cppcheck-${CPPCHECK_VERSION}/cfg/ > /dev/null)
export PATH="$PATH:/tmp/cppcheck-${CPPCHECK_VERSION}/"
9 changes: 9 additions & 0 deletions .travis/extended_lint_06_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
#
# Copyright (c) 2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C

test/lint/extended-lint-all.sh
1 change: 1 addition & 0 deletions ci/build_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [ "$CHECK_DOC" = 1 ]; then
test/lint/check-rpc-mappings.py .
# Run all linters
test/lint/lint-all.sh
test/lint/extended-lint-all.sh
fi

ccache --max-size=$CCACHE_SIZE
Expand Down
47 changes: 33 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ AC_ARG_ENABLE([extended-functional-tests],
[use_extended_functional_tests=no])

AC_ARG_ENABLE([fuzz],
AS_HELP_STRING([--enable-fuzz],[enable building of fuzz targets (default no)]),
AS_HELP_STRING([--enable-fuzz],
[enable building of fuzz targets (default no). enabling this will disable all other targets]),
[enable_fuzz=$enableval],
[enable_fuzz=no])

Expand Down Expand Up @@ -1118,6 +1119,37 @@ dnl it would break GCC's #include_next.
AC_DEFUN([SUPPRESS_WARNINGS],
[$(echo $1 |${SED} -E -e 's/(^| )-I/\1-isystem /g' -e 's;-isystem /usr/include([/ ]|$);-I/usr/include\1;g')])

dnl enable-fuzz should disable all other targets
if test "x$enable_fuzz" = "xyes"; then
AC_MSG_WARN(enable-fuzz will disable all other targets)
build_bitcoin_utils=no
build_bitcoin_cli=no
build_bitcoin_tx=no
build_bitcoin_wallet=no
build_bitcoind=no
build_bitcoin_libs=no
bitcoin_enable_qt=no
bitcoin_enable_qt_test=no
bitcoin_enable_qt_dbus=no
enable_wallet=no
use_bench=no
use_upnp=no
use_zmq=no
else
BITCOIN_QT_INIT

dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
BITCOIN_QT_CONFIGURE([5.5.1])

dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc
QT_INCLUDES_UNSUPPRESSED=$QT_INCLUDES
if test x$suppress_external_warnings != xno ; then
QT_INCLUDES=SUPPRESS_WARNINGS($QT_INCLUDES)
QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES)
QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
fi
fi

if test x$enable_wallet != xno; then
dnl Check for libdb_cxx only if wallet enabled
BITCOIN_FIND_BDB48
Expand Down Expand Up @@ -1155,19 +1187,6 @@ if test x$have_miniupnpc != xno; then
fi
fi

BITCOIN_QT_INIT

dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
BITCOIN_QT_CONFIGURE([5.5.1])

dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc
QT_INCLUDES_UNSUPPRESSED=$QT_INCLUDES
if test x$suppress_external_warnings != xno ; then
QT_INCLUDES=SUPPRESS_WARNINGS($QT_INCLUDES)
QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES)
QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
fi

if test x$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnonononononono; then
use_boost=no
else
Expand Down
8 changes: 4 additions & 4 deletions depends/packages/expat.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package=expat
$(package)_version=2.2.6
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_6/
$(package)_version=2.2.7
$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_2_2_7/
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2
$(package)_sha256_hash=cbc9102f4a31a8dafd42d642e9a3aa31e79a0aedaa1f6efd2795ebc83174ec18

define $(package)_set_vars
$(package)_config_opts=--disable-static --without-docbook
$(package)_config_opts=--disable-static --without-docbook --without-tests --without-examples
endef

define $(package)_config_cmds
Expand Down
4 changes: 2 additions & 2 deletions doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = src dash-docs doc/release-notes/dash
INPUT = src dash-docs doc/release-notes/dash doc/README_doxygen.md

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -989,7 +989,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.

USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = doc/README_doxygen.md

#---------------------------------------------------------------------------
# Configuration options related to source browsing
Expand Down
15 changes: 15 additions & 0 deletions doc/README_doxygen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\mainpage notitle

\section intro_sec Introduction

This is the developer documentation of the reference client for an experimental new digital currency called Dash,
which enables instant payments to anyone, anywhere in the world. Dash uses peer-to-peer technology to operate
with no central authority: managing transactions and issuing money are carried out collectively by the network.

The software is a community-driven open source project, released under the MIT license.

See https://github.com/dashpay/dash and https://dash.org/ for further information about the project.

\section Navigation
Use <a href="modules.html"><code>Modules</code></a>, <a href="namespaces.html"><code>Namespaces</code></a>, <a href="classes.html"><code>Classes</code></a>, or <a href="files.html"><code>Files</code></a> at the top of the page to start navigating the code.

6 changes: 3 additions & 3 deletions doc/bips.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.18.0**):

* [`BIP 9`](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki): The changes allowing multiple soft-forks to be deployed in parallel have been implemented since **v0.12.1** ([PR #7575](https://github.com/bitcoin/bitcoin/pull/7575))
* [`BIP 11`](https://github.com/bitcoin/bips/blob/master/bip-0011.mediawiki): Multisig outputs are standard since **v0.6.0** ([PR #669](https://github.com/bitcoin/bitcoin/pull/669)).
Expand All @@ -19,7 +19,7 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
* [`BIP 65`](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki): The CHECKLOCKTIMEVERIFY softfork was merged in **v0.12.0** ([PR #6351](https://github.com/bitcoin/bitcoin/pull/6351)), and backported to **v0.11.2** and **v0.10.4**. Mempool-only CLTV was added in [PR #6124](https://github.com/bitcoin/bitcoin/pull/6124).
* [`BIP 66`](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki): The strict DER rules and associated version 3 blocks have been implemented since **v0.10.0** ([PR #5713](https://github.com/bitcoin/bitcoin/pull/5713)).
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been activated since *block 419328*.
* [`BIP 70`](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) [`71`](https://github.com/bitcoin/bips/blob/master/bip-0071.mediawiki) [`72`](https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki): Payment Protocol support has been available in Bitcoin Core GUI since **v0.9.0** ([PR #5216](https://github.com/bitcoin/bitcoin/pull/5216)).
* [`BIP 70`](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) [`71`](https://github.com/bitcoin/bips/blob/master/bip-0071.mediawiki) [`72`](https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki): Payment Protocol support has been available in Bitcoin Core GUI since **v0.9.0** ([PR #5216](https://github.com/bitcoin/bitcoin/pull/5216)). Support can be optionally disabled at build time since **v0.18.0** ([PR 4350](https://github.com/dashpay/dash/pull/4350)).
* [`BIP 90`](https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki): Trigger mechanism for activation of BIPs 34, 65, and 66 has been simplified to block height checks since **v0.14.0** ([PR #8391](https://github.com/bitcoin/bitcoin/pull/8391)).
* [`BIP 111`](https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki): `NODE_BLOOM` service bit added, and enforced for all peer versions as of **v0.13.0** ([PR #6579](https://github.com/bitcoin/bitcoin/pull/6579) and [PR #6641](https://github.com/bitcoin/bitcoin/pull/6641)).
* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki): The CHECKSEQUENCEVERIFY opcode has been implemented since **v0.12.1** ([PR #7524](https://github.com/bitcoin/bitcoin/pull/7524)) and has been activated since *block 419328*.
Expand All @@ -28,4 +28,4 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
* [`BIP 130`](https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki): direct headers announcement is negotiated with peer versions `>=70012` as of **v0.12.0** ([PR 6494](https://github.com/bitcoin/bitcoin/pull/6494)).
* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)).
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The NODE_NETWORK_LIMITED service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of v0.17.0 ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The NODE_NETWORK_LIMITED service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
4 changes: 2 additions & 2 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For macOS you may need to ignore x86 compilation checks when running `make`:
To build Dash Core using AFL instrumentation (this assumes that the
`AFLPATH` was set as above):
```
./configure --disable-ccache --disable-shared --enable-tests --enable-fuzz --disable-wallet --disable-bench --with-utils=no --with-daemon=no --with-libs=no --with-gui=no CC=${AFLPATH}/afl-gcc CXX=${AFLPATH}/afl-g++
./configure --disable-ccache --disable-shared --enable-tests --enable-fuzz CC=${AFLPATH}/afl-gcc CXX=${AFLPATH}/afl-g++
export AFL_HARDEN=1
make
```
Expand Down Expand Up @@ -102,7 +102,7 @@ libFuzzer is needed (all found in the `compiler-rt` runtime libraries package).
To build all fuzz targets with libFuzzer, run

```
./configure --disable-ccache --disable-wallet --disable-bench --with-utils=no --with-daemon=no --with-libs=no --with-gui=no --enable-fuzz --with-sanitizers=fuzzer,address CC=clang CXX=clang++
./configure --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address CC=clang CXX=clang++
make
```

Expand Down
12 changes: 6 additions & 6 deletions src/bench/bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ static void BLS_Verify_Normal(benchmark::Bench& bench)
bool valid = sigs[i].VerifyInsecure(pubKeys[i], msgHashes[i]);
if (valid && invalid[i]) {
std::cout << "expected invalid but it is valid" << std::endl;
assert(false);
assert(!"expected invalid but it is valid");
} else if (!valid && !invalid[i]) {
std::cout << "expected valid but it is invalid" << std::endl;
assert(false);
assert(!"expected valid but it is invalid");
}
i = (i + 1) % pubKeys.size();
});
Expand Down Expand Up @@ -290,10 +290,10 @@ static void BLS_Verify_Batched(benchmark::Bench& bench)
for (size_t k = 0; k < batchSize; k++) {
if (valid[k] && invalid[(startI + k) % pubKeys.size()]) {
std::cout << "expected invalid but it is valid" << std::endl;
assert(false);
assert(!"expected invalid but it is valid");
} else if (!valid[k] && !invalid[(startI + k) % pubKeys.size()]) {
std::cout << "expected valid but it is invalid" << std::endl;
assert(false);
assert(!"expected valid but it is invalid");
}
}
});
Expand Down Expand Up @@ -337,10 +337,10 @@ static void BLS_Verify_BatchedParallel(benchmark::Bench& bench)

if (valid && invalid[j]) {
std::cout << "expected invalid but it is valid" << std::endl;
assert(false);
assert(!"expected invalid but it is valid");
} else if (!valid && !invalid[j]) {
std::cout << "expected valid but it is invalid" << std::endl;
assert(false);
assert(!"expected valid but it is invalid");
}
});

Expand Down
77 changes: 42 additions & 35 deletions src/bls/bls_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,48 +75,55 @@ void CBLSWorker::Stop()

bool CBLSWorker::GenerateContributions(int quorumThreshold, const BLSIdVector& ids, BLSVerificationVectorPtr& vvecRet, BLSSecretKeyVector& skSharesRet)
{
auto svec = std::make_shared<BLSSecretKeyVector>((size_t)quorumThreshold);
// const size_t batchSize = 8;
auto svec = BLSSecretKeyVector((size_t)quorumThreshold);
vvecRet = std::make_shared<BLSVerificationVector>((size_t)quorumThreshold);
skSharesRet.resize(ids.size());

for (int i = 0; i < quorumThreshold; i++) {
(*svec)[i].MakeNewKey();
svec[i].MakeNewKey();
}
std::list<std::future<bool> > futures;
size_t batchSize = 8;
// std::vector<std::future<bool>> futures;
// const auto max_futures_size = (quorumThreshold / batchSize + ids.size() / batchSize) + 2;
// futures.reserve(max_futures_size);

for (size_t i = 0; i < quorumThreshold; i += batchSize) {
size_t start = i;
size_t count = std::min(batchSize, quorumThreshold - start);
auto f = [&, start, count](int threadId) {
for (size_t j = start; j < start + count; j++) {
(*vvecRet)[j] = (*svec)[j].GetPublicKey();
}
return true;
};
futures.emplace_back(workerPool.push(f));
}

for (size_t i = 0; i < ids.size(); i += batchSize) {
size_t start = i;
size_t count = std::min(batchSize, ids.size() - start);
auto f = [&, start, count](int threadId) {
for (size_t j = start; j < start + count; j++) {
if (!skSharesRet[j].SecretKeyShare(*svec, ids[j])) {
return false;
}
}
return true;
};
futures.emplace_back(workerPool.push(f));
}
bool success = true;
for (auto& f : futures) {
if (!f.get()) {
success = false;
for (size_t i = 0; i < ids.size(); i ++) {
if (!skSharesRet[i].SecretKeyShare(svec, ids[i])) {
return false;
}
}
return success;

// size_t start = i;
// size_t count = std::min(batchSize, ids.size() - start);
//// auto f = [&, start, count](int threadId) {
// for (size_t j = start; j < start + count; j++) {
// if (!skSharesRet[j].SecretKeyShare(svec, ids[j])) {
// return false;
// }
// }
// return true;
// };
// futures.emplace_back(workerPool.push(f));
}

for (size_t i = 0; i < quorumThreshold; i++) {
(*vvecRet)[i] = svec[i].GetPublicKey();

// size_t start = i;
// size_t count = std::min(batchSize, quorumThreshold - start);
//// auto f = [&, start, count](int threadId) {
// for (size_t j = start; j < start + count; j++) {
// (*vvecRet)[j] = svec[j].GetPublicKey();
// }
//// return true;
//// };
//// futures.emplace_back(workerPool.push(f));
}

// ASSERT_IF_DEBUG(futures.size() <= max_futures_size);
// return std::all_of(futures.begin(), futures.end(), [](auto& f){
// return f.get();
// });
return true;
}

// aggregates a single vector of BLS objects in parallel
Expand Down
Loading

0 comments on commit bb056da

Please sign in to comment.