Skip to content

Commit ec67f12

Browse files
committed
Redirect pruning signature generation/verification to SigManager
1 parent 03192af commit ec67f12

25 files changed

+273
-265
lines changed

.github/workflows/build_and_test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
run: |
2828
mkdir build
2929
cd build
30+
echo $(date +%y-%m-%d_%H-%M-%S) > timestamp
3031
cmake \
3132
${{ matrix.comm_type }} \
3233
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} \
@@ -39,6 +40,11 @@ jobs:
3940
cd build
4041
# many tests require administrative priviliges for running iptables or nc
4142
sudo ctest --output-on-failure
43+
- name: Print failed cases
44+
if: ${{ failure() }}
45+
run: |
46+
FAILED_CASES_FILE=${PWD}/build/apollogs/latest/failed_cases.txt
47+
test -f ${FAILED_CASES_FILE} && echo Failed apollo cases: && cat -n ${FAILED_CASES_FILE}
4248
- name: Prepare artifacts
4349
if: ${{ failure() }}
4450
run: |

Makefile

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,17 @@ else
4949
TCP_ENABLED__:=OFF
5050
endif
5151

52-
CONCORD_BFT_CMAKE_CXX_FLAGS_RELEASE?='-O3 -g'
53-
CONCORD_BFT_CMAKE_USE_LOG4CPP?=ON
54-
CONCORD_BFT_CMAKE_BUILD_UTT?=TRUE
55-
CONCORD_BFT_CMAKE_BUILD_ROCKSDB_STORAGE?=TRUE
56-
CONCORD_BFT_CMAKE_USE_S3_OBJECT_STORE?=TRUE
57-
CONCORD_BFT_CMAKE_USE_OPENTRACING?=TRUE
58-
CONCORD_BFT_CMAKE_USE_PROMETHEUS?=TRUE
59-
CONCORD_BFT_CMAKE_USE_JAEGER?=TRUE
60-
CONCORD_BFT_CMAKE_USE_JSON?=TRUE
61-
CONCORD_BFT_CMAKE_USE_HTTPLIB?=TRUE
62-
CONCORD_BFT_CMAKE_EXPORT_COMPILE_COMMANDS?=TRUE
63-
CONCORD_BFT_CMAKE_OMIT_TEST_OUTPUT?=FALSE
64-
CONCORD_BFT_CMAKE_KEEP_APOLLO_LOGS?=TRUE
65-
CONCORD_BFT_CMAKE_RUN_APOLLO_TESTS?=TRUE
66-
CONCORD_BFT_CMAKE_TRANSACTION_SIGNING_ENABLED?=TRUE
67-
CONCORD_BFT_CMAKE_BUILD_SLOWDOWN?=FALSE
68-
# Only useful with CONCORD_BFT_CMAKE_BUILD_TYPE:=Release
69-
CONCORD_BFT_CMAKE_BUILD_KVBC_BENCH?=TRUE
70-
# Only usefull with CONCORD_BFT_CMAKE_CXX_FLAGS_RELEASE=-O0 -g
71-
CONCORD_BFT_CMAKE_ASAN?=FALSE
72-
CONCORD_BFT_CMAKE_TSAN?=FALSE
73-
CONCORD_BFT_CMAKE_UBSAN?=FALSE
74-
CONCORD_BFT_CMAKE_HEAPTRACK?=FALSE
75-
CONCORD_BFT_CMAKE_CODECOVERAGE?=FALSE
76-
CONCORD_BFT_CMAKE_CCACHE?=TRUE
77-
CONCORD_BFT_CMAKE_USE_FAKE_CLOCK_IN_TIME_SERVICE?=FALSE
78-
ENABLE_RESTART_RECOVERY_TESTS?=FALSE
79-
CONCORD_ENABLE_ALL_METRICS?=FALSE
52+
CONCORD_BFT_CMAKE_BUILD_UTT?=ON
53+
CONCORD_BFT_CMAKE_OMIT_TEST_OUTPUT?=OFF
54+
CONCORD_BFT_CMAKE_KEEP_APOLLO_LOGS?=ON
55+
CONCORD_BFT_CMAKE_RUN_APOLLO_TESTS?=ON
56+
CONCORD_BFT_CMAKE_ASAN?=OFF
57+
CONCORD_BFT_CMAKE_TSAN?=OFF
58+
CONCORD_BFT_CMAKE_UBSAN?=OFF
59+
CONCORD_BFT_CMAKE_HEAPTRACK?=OFF
60+
CONCORD_BFT_CMAKE_CODECOVERAGE?=OFF
61+
CONCORD_BFT_CMAKE_CCACHE?=ON
62+
ENABLE_RESTART_RECOVERY_TESTS?=OFF
8063

8164
# Our CMake logic won't allow more one of these flags to be raised, so having this if/else logic makes sense
8265
ifeq (${CONCORD_BFT_CMAKE_ASAN},ON)

bftengine/include/bftengine/ReplicaConfig.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ class ReplicaConfig : public concord::serialize::SerializableFactory<ReplicaConf
306306
if (auto it = config_params_.find(param); it != config_params_.end()) return concord::util::to<T>(it->second);
307307
return defaultValue;
308308
}
309-
inline std::set<std::pair<const std::string, std::set<uint16_t>>>* getPublicKeysOfClients() {
309+
inline const std::set<std::pair<const std::string, std::set<uint16_t>>>* getPublicKeysOfClients() const {
310310
return (clientTransactionSigningEnabled || !clientsKeysPrefix.empty()) ? &publicKeysOfClients : nullptr;
311311
}
312312

313-
std::string getOperatorPublicKey() {
313+
std::string getOperatorPublicKey() const {
314314
std::ifstream op_key_file(pathToOperatorPublicKey_);
315315
if (!op_key_file.fail()) {
316316
std::stringstream buffer;

bftengine/src/bftengine/ReplicaBase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ReplicaBase {
112112
static const uint16_t ALL_OTHER_REPLICAS = UINT16_MAX;
113113

114114
const ReplicaConfig& config_;
115-
ReplicasInfo* repsInfo = nullptr;
115+
const ReplicasInfo* repsInfo = nullptr;
116116
std::shared_ptr<MsgsCommunicator> msgsCommunicator_;
117117
std::shared_ptr<MsgHandlersRegistrator> msgHandlers_;
118118
std::shared_ptr<IRequestsHandler> bftRequestsHandler_;

bftengine/src/bftengine/ReplicaImp.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4434,16 +4434,7 @@ ReplicaImp::ReplicaImp(bool firstTime,
44344434

44354435
if (firstTime) {
44364436
repsInfo = new ReplicasInfo(config_, dynamicCollectorForPartialProofs, dynamicCollectorForExecutionProofs);
4437-
sigManager_ = SigManager::init(config_.replicaId,
4438-
config_.replicaPrivateKey,
4439-
config_.publicKeysOfReplicas,
4440-
concord::crypto::KeyFormat::HexaDecimalStrippedFormat,
4441-
ReplicaConfig::instance().getPublicKeysOfClients(),
4442-
concord::crypto::KeyFormat::PemFormat,
4443-
{{repsInfo->getIdOfOperator(),
4444-
ReplicaConfig::instance().getOperatorPublicKey(),
4445-
concord::crypto::KeyFormat::PemFormat}},
4446-
*repsInfo);
4437+
sigManager_ = SigManager::owningInstance();
44474438
viewsManager = new ViewsManager(repsInfo);
44484439
} else {
44494440
repsInfo = replicasInfo;

bftengine/src/bftengine/ReplicaLoader.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,14 @@ namespace impl {
4747
namespace {
4848

4949
ReplicaLoader::ErrorCode loadConfig(LoadedReplicaData &ld) {
50-
ld.repsInfo = new ReplicasInfo(ld.repConfig, dynamicCollectorForPartialProofs, dynamicCollectorForExecutionProofs);
5150
auto &config = ld.repConfig;
52-
ld.sigManager = SigManager::init(config.replicaId,
53-
config.replicaPrivateKey,
54-
config.publicKeysOfReplicas,
55-
concord::crypto::KeyFormat::HexaDecimalStrippedFormat,
56-
ReplicaConfig::instance().getPublicKeysOfClients(),
57-
concord::crypto::KeyFormat::PemFormat,
58-
{{ld.repsInfo->getIdOfOperator(),
59-
ReplicaConfig::instance().getOperatorPublicKey(),
60-
concord::crypto::KeyFormat::PemFormat}},
61-
*ld.repsInfo);
62-
63-
std::unique_ptr<Cryptosystem> cryptoSys = std::make_unique<Cryptosystem>(ld.repConfig.thresholdSystemType_,
64-
ld.repConfig.thresholdSystemSubType_,
65-
ld.repConfig.numReplicas,
66-
ld.repConfig.numReplicas);
67-
cryptoSys->loadKeys(ld.repConfig.thresholdPublicKey_, ld.repConfig.thresholdVerificationKeys_);
68-
cryptoSys->loadPrivateKey(ld.repConfig.replicaId, ld.repConfig.thresholdPrivateKey_);
51+
ld.repsInfo = new ReplicasInfo(config, dynamicCollectorForPartialProofs, dynamicCollectorForExecutionProofs);
52+
ld.sigManager = SigManager::owningInstance();
53+
54+
std::unique_ptr<Cryptosystem> cryptoSys = std::make_unique<Cryptosystem>(
55+
config.thresholdSystemType_, config.thresholdSystemSubType_, config.numReplicas, config.numReplicas);
56+
cryptoSys->loadKeys(config.thresholdPublicKey_, config.thresholdVerificationKeys_);
57+
cryptoSys->loadPrivateKey(config.replicaId, config.thresholdPrivateKey_);
6958
bftEngine::CryptoManager::init(std::move(cryptoSys));
7059

7160
return Succ;

bftengine/src/bftengine/ReplicasInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ ReplicasInfo::ReplicasInfo(const ReplicaConfig& config,
146146
}
147147
if (start != end) LOG_INFO(GL, "Principal ids in _idsOfInternalClients: " << start << " to " << end - 1);
148148
return ret;
149-
}()} {
150-
_operator_id = config.operatorEnabled_
151-
? static_cast<PrincipalId>(config.numReplicas + config.numRoReplicas + config.numOfClientProxies +
152-
config.numOfExternalClients + config.numOfClientServices - 1)
153-
: 0;
149+
}()},
150+
151+
_operator_id{static_cast<PrincipalId>(
152+
config.operatorEnabled_ ? config.numReplicas + config.numRoReplicas + config.numOfClientProxies +
153+
config.numOfExternalClients + config.numOfClientServices - 1
154+
: 0)} {
154155
ConcordAssert(_numberOfReplicas == (3 * _fVal + 2 * _cVal + 1));
155156
}
156157

bftengine/src/bftengine/ReplicasInfo.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class ReplicaConfig;
2020

2121
namespace impl {
2222

23+
/**
24+
* An immutable class holding the the ids of all the participants in the network
25+
*/
2326
class ReplicasInfo {
2427
public:
2528
ReplicasInfo(const ReplicaConfig&, bool dynamicCollectorForPartialProofs, bool dynamicCollectorForExecutionProofs);
@@ -110,7 +113,7 @@ class ReplicasInfo {
110113
const std::set<PrincipalId> _idsOfInternalClients;
111114

112115
// Currently we support only a single operator entity in the system
113-
PrincipalId _operator_id;
116+
const PrincipalId _operator_id = 0;
114117
};
115118
} // namespace impl
116119
} // namespace bftEngine

bftengine/src/bftengine/SigManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ SigManager* SigManager::instance() {
4747
return s_sm.get();
4848
}
4949

50+
std::shared_ptr<SigManager> SigManager::owningInstance() {
51+
ConcordAssertNE(s_sm.get(), nullptr);
52+
return s_sm;
53+
}
54+
5055
void SigManager::reset(std::shared_ptr<SigManager> other) { s_sm = other; }
5156

5257
std::shared_ptr<SigManager> SigManager::init(
@@ -457,6 +462,7 @@ SeqNum SigManager::getReplicaLastExecutedSeq() const {
457462
ConcordAssert(replicasInfo_.isIdOfReplica(myId_) || replicasInfo_.isRoReplica());
458463
return replicaLastExecutedSeq_;
459464
}
465+
const ReplicasInfo& SigManager::getReplicasInfo() const { return replicasInfo_; }
460466

461467
} // namespace impl
462468
} // namespace bftEngine

bftengine/src/bftengine/SigManager.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "crypto/signer.hpp"
2020
#include "crypto/verifier.hpp"
2121
#include "SysConsts.hpp"
22+
#include "ReplicasInfo.hpp"
2223
#include <utility>
2324
#include <vector>
2425
#include <map>
@@ -35,15 +36,14 @@ class IThresholdVerifier;
3536
namespace bftEngine {
3637
namespace impl {
3738

38-
class ReplicasInfo;
39-
4039
class SigManager {
4140
public:
4241
using Key = std::string;
4342
using KeyIndex = uint16_t;
4443

4544
virtual ~SigManager() = default;
4645
static SigManager* instance();
46+
static std::shared_ptr<SigManager> owningInstance();
4747
static void reset(std::shared_ptr<SigManager> other);
4848

4949
// It is the caller responsibility to deallocate (delete) the object
@@ -129,6 +129,8 @@ class SigManager {
129129
const concord::crypto::IVerifier& extractVerifierFromMultisig(std::shared_ptr<IThresholdVerifier> thresholdVerifier,
130130
PrincipalId id) const;
131131

132+
const ReplicasInfo& getReplicasInfo() const;
133+
132134
protected:
133135
static constexpr uint16_t updateMetricsAggregatorThresh = 1000;
134136

@@ -153,7 +155,7 @@ class SigManager {
153155
std::unique_ptr<concord::crypto::ISigner> mySigner_;
154156
std::map<PrincipalId, std::shared_ptr<concord::crypto::IVerifier>> verifiers_;
155157
bool clientTransactionSigningEnabled_ = true;
156-
const ReplicasInfo& replicasInfo_;
158+
const ReplicasInfo replicasInfo_;
157159

158160
// The ownership model of a SigManager object depends on its use
159161
static std::shared_ptr<SigManager> s_sm;

0 commit comments

Comments
 (0)