Skip to content

Commit e655a8b

Browse files
authored
Merge branch 'develop' into tech-debt/918-add-copilot-instructions
2 parents ab397a3 + 3daa6be commit e655a8b

103 files changed

Lines changed: 1307 additions & 1172 deletions

File tree

Some content is hidden

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

.github/workflows/build.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ jobs:
6868
6969
- name: Cleanup
7070
run: |
71-
sudo apt-get autoremove -y >/dev/null 2>&1
72-
sudo apt-get autoclean -y >/dev/null 2>&1
73-
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1
74-
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1
71+
sudo apt-get autoremove -y >/dev/null 2>&1 || true
72+
sudo apt-get autoclean -y >/dev/null 2>&1 || true
73+
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1 || true
74+
sudo docker system prune -af --volumes >/dev/null 2>&1 || true
7575
7676
- name: Install docker compose
7777
run: |
@@ -175,6 +175,11 @@ jobs:
175175
run: |
176176
cd scripts && ./build.py Debug
177177
178-
- name: run tests
179-
run: cd scripts && export CI_BUILD=1 && ./tests.py && cd ..
178+
- name: run tests (block sizes)
179+
env:
180+
CI_BUILD: "1"
181+
TEST_TRANSACTIONS_PER_BLOCK: "1000"
182+
run: |
183+
cd scripts
184+
./tests.py && cd ..
180185

.github/workflows/buildm.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ jobs:
6868
6969
- name: Cleanup
7070
run: |
71-
sudo apt-get autoremove -y >/dev/null 2>&1
72-
sudo apt-get autoclean -y >/dev/null 2>&1
73-
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1
74-
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1
71+
sudo apt-get autoremove -y >/dev/null 2>&1 || true
72+
sudo apt-get autoclean -y >/dev/null 2>&1 || true
73+
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1 || true
74+
sudo docker system prune -af --volumes >/dev/null 2>&1 || true
7575
7676
- name: Install docker compose
7777
run: |
@@ -174,6 +174,12 @@ jobs:
174174
- name: build consensus Fair
175175
run: |
176176
cd scripts && ./build.py Debug -buildFAIR
177-
- name: run tests
178-
run: cd scripts && export CI_BUILD=1 && ./tests.py && cd ..
177+
178+
- name: run tests (block sizes)
179+
env:
180+
CI_BUILD: "1"
181+
TEST_TRANSACTIONS_PER_BLOCK: "1000"
182+
run: |
183+
cd scripts
184+
./tests.py && cd ..
179185

Agent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ptr< GlobalThreadRegistry > Agent::getThreadRegistry() {
8181

8282
void Agent::logConnectionRefused( ConnectionRefusedException& _e, schain_index _index, const char* _function) {
8383
if ( _e.triedConnect() ) {
84-
LOG(err, string("Connection refused connecting to node:" + to_string(_index) + " in " + _function));
84+
CONS_LOG(err, string("Connection refused connecting to node:" + to_string(_index) + " in " + _function));
8585
SkaleException::logNested( _e );
8686
}
8787
}

CMakeLists.txt

Lines changed: 90 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,18 @@ else ()
6060
message(INFO "---- CMAKE_BUILD_TYPE = ${DEPS_INSTALL_ROOT} is not supported explicitly")
6161
endif ()
6262

63+
64+
###################################
65+
# libBLS #
66+
###################################
67+
# Disable libBLS components we don't need
68+
set(LIBBLS_BUILD_TESTS OFF CACHE BOOL "Don't build libBLS tests")
69+
set(LIBBLS_BUILD_BENCHMARKS OFF CACHE BOOL "Don't build libBLS benchmarks")
70+
set(LIBBLS_BUILD_UTILS OFF CACHE BOOL "Don't build libBLS utils")
71+
set(SKALE_SKIP_INSTALLING_DIRECTIVES ON CACHE BOOL "Skip libBLS install() calls")
6372
add_subdirectory(libBLS)
6473

74+
6575
project(consensus)
6676

6777
include_directories("${DEPS_INSTALL_ROOT}/include" "${DEPS_INSTALL_ROOT}/include/cryptopp"
@@ -104,7 +114,6 @@ endif ()
104114

105115

106116
#Threads package
107-
108117
set(THREADS_PREFER_PTHREAD_FLAG ON)
109118
find_package(Threads REQUIRED)
110119

@@ -218,75 +227,92 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
218227
set(DASH_SUFFIX "-d")
219228
endif ()
220229

221-
222230
SET(LINK_LIBRARIES
223-
backtrace
224-
Threads::Threads
225-
${BOOST_LIBS_FOR_CONSENSUS}
226-
${LIB_NAME_cryptopp}
227-
leveldb
228-
snappy
229-
crc32c
230-
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-client.a"
231-
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-server.a"
232-
"${DEPS_INSTALL_ROOT}/lib/libmicrohttpd.a"
233-
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-stub.a"
234-
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-common.a"
235-
"${DEPS_INSTALL_ROOT}/lib/libzmq.a"
236-
"${DEPS_INSTALL_ROOT}/lib/libsodium.a"
237-
"${DEPS_INSTALL_ROOT}/lib/libcryptopp.a"
238-
gmp
239-
gcov
240-
gnutls
241-
gcrypt
242-
"${DEPS_INSTALL_ROOT}/lib/libjsoncpp.a"
243-
"${DEPS_INSTALL_ROOT}/lib/libssl.a"
244-
"${DEPS_INSTALL_ROOT}/lib/libcrypto.a"
245-
"${DEPS_INSTALL_ROOT}/lib/libcurl.a"
246-
"${DEPS_INSTALL_ROOT}/lib/libssl.a"
247-
"${DEPS_INSTALL_ROOT}/lib/libcrypto.a"
248-
dl
249-
z
250-
pthread
251-
idn2
252-
blake3
253-
"${DEPS_INSTALL_ROOT}/lib/libquicwebtransport.a"
254-
"${DEPS_INSTALL_ROOT}/lib/libproxygenhttpserver.a"
255-
"${DEPS_INSTALL_ROOT}/lib/libproxygen.a"
256-
"${DEPS_INSTALL_ROOT}/lib/libmvfst_exception.a"
257-
"${DEPS_INSTALL_ROOT}/lib/libwangle.a"
258-
"${DEPS_INSTALL_ROOT}/lib/libflatbuffers.a"
259-
"${DEPS_INSTALL_ROOT}/lib/libfizz.a"
260-
"${DEPS_INSTALL_ROOT}/lib/libfolly.a"
261-
"${DEPS_INSTALL_ROOT}/lib/libboost_context.a"
262-
"${DEPS_INSTALL_ROOT}/lib/libevent.a"
263-
"${DEPS_INSTALL_ROOT}/lib/libz.a"
264-
"${DEPS_INSTALL_ROOT}/lib/libzstd.a"
265-
"${DEPS_INSTALL_ROOT}/lib/libdouble-conversion.a"
266-
"${DEPS_INSTALL_ROOT}/lib/libglog.a"
267-
"${DEPS_INSTALL_ROOT}/lib/libgflags.a"
268-
"${DEPS_INSTALL_ROOT}/lib/liblzma.a"
269-
"${DEPS_INSTALL_ROOT}/lib/libfmt.a"
270-
te
231+
backtrace
232+
Threads::Threads
233+
${BOOST_LIBS_FOR_CONSENSUS}
234+
${LIB_NAME_cryptopp}
235+
leveldb
236+
snappy
237+
crc32c
238+
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-client.a"
239+
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-server.a"
240+
"${DEPS_INSTALL_ROOT}/lib/libmicrohttpd.a"
241+
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-stub.a"
242+
"${DEPS_INSTALL_ROOT}/lib/libjsonrpccpp-common.a"
243+
"${DEPS_INSTALL_ROOT}/lib/libzmq.a"
244+
"${DEPS_INSTALL_ROOT}/lib/libsodium.a"
245+
"${DEPS_INSTALL_ROOT}/lib/libcryptopp.a"
246+
gmp
247+
gcov
248+
gnutls
249+
gcrypt
250+
"${DEPS_INSTALL_ROOT}/lib/libjsoncpp.a"
251+
"${DEPS_INSTALL_ROOT}/lib/libcurl.a"
252+
dl
253+
pthread
254+
idn2
255+
blake3
256+
"${DEPS_INSTALL_ROOT}/lib/libquicwebtransport.a"
257+
"${DEPS_INSTALL_ROOT}/lib/libproxygenhttpserver.a"
258+
"${DEPS_INSTALL_ROOT}/lib/libproxygen.a"
259+
"${DEPS_INSTALL_ROOT}/lib/libmvfst_exception.a"
260+
"${DEPS_INSTALL_ROOT}/lib/libwangle.a"
261+
"${DEPS_INSTALL_ROOT}/lib/libflatbuffers.a"
262+
"${DEPS_INSTALL_ROOT}/lib/libfizz.a"
263+
"${DEPS_INSTALL_ROOT}/lib/libfolly.a"
264+
"${DEPS_INSTALL_ROOT}/lib/liblzma.a"
265+
"${DEPS_INSTALL_ROOT}/lib/libz.a"
266+
"${DEPS_INSTALL_ROOT}/lib/libzstd.a"
267+
"${DEPS_INSTALL_ROOT}/lib/libboost_context.a"
268+
"${DEPS_INSTALL_ROOT}/lib/libevent.a"
269+
"${DEPS_INSTALL_ROOT}/lib/libdouble-conversion.a"
270+
"${DEPS_INSTALL_ROOT}/lib/libglog.a"
271+
"${DEPS_INSTALL_ROOT}/lib/libgflags.a"
272+
"${DEPS_INSTALL_ROOT}/lib/libfmt.a"
273+
"${DEPS_INSTALL_ROOT}/lib/libssl.a"
274+
"${DEPS_INSTALL_ROOT}/lib/libcrypto.a"
275+
te
271276
)
272277
if (CMAKE_PROJECT_NAME STREQUAL "consensus")
273278
SET(LINK_LIBRARIES ${LINK_LIBRARIES} "${DEPS_INSTALL_ROOT}/lib/libsecp256k1.a")
274279
else ()
275280
SET(LINK_LIBRARIES ${LINK_LIBRARIES} Secp256k1)
276281
endif ()
277282

278-
# consensus library
283+
###################################
284+
# consensus dependencies #
285+
###################################
279286

280-
add_library(consensus STATIC ${SRC_FILES})
287+
add_library(consensus_dependencies INTERFACE)
288+
target_link_libraries( consensus_dependencies INTERFACE ${LINK_LIBRARIES} )
281289

282-
target_compile_options(consensus PRIVATE -Wno-error=unused-variable)
290+
###################################
291+
# consensus library #
292+
###################################
283293

284-
target_link_libraries(consensus PRIVATE ${LINK_LIBRARIES} PUBLIC bls)
294+
add_library(consensus STATIC ${SRC_FILES})
295+
target_compile_options(consensus PRIVATE -Wno-error=unused-variable)
296+
target_link_libraries(consensus PUBLIC consensus_dependencies PUBLIC bls)
297+
298+
###################################
299+
# consensus executables #
300+
###################################
301+
302+
# Build a consensus wrapper to have both consensus exposed code + all
303+
# consensus dependencies
304+
add_library(consensus_full INTERFACE)
305+
target_link_libraries(consensus_full INTERFACE
306+
"-Wl,--start-group" # makes ld/lld rescan archives until all cross-archive symbols resolve.
307+
consensus consensus_dependencies
308+
"-Wl,--end-group"
309+
)
285310

286-
# consensus test agent
311+
# ---------------------------------
312+
# consensusd - the main consensus node executable
313+
# ---------------------------------
287314

288315
add_executable(consensusd Consensusd.h Consensusd.cpp)
289-
290316
target_compile_options(consensusd PRIVATE -Wno-error=unused-variable)
291317

292318
# # libgoogle-perftools-dev
@@ -295,11 +321,14 @@ target_compile_options(consensusd PRIVATE -Wno-error=unused-variable)
295321
# # sudo apt-get install -qq -yy libgoogle-perftools-dev
296322
# target_link_libraries(consensusd consensus tcmalloc)
297323
# else ()
298-
target_link_libraries(consensusd consensus)
324+
target_link_libraries(consensusd consensus_full)
299325
# endif ()
300326

301327

302-
### consensust executable
328+
# ---------------------------------
329+
# consensust - the main consensus unit
330+
# tests executable
331+
# ---------------------------------
303332

304333
# Automatically discover all test source files in the unittests directory and its subdirectories.
305334
file(GLOB_RECURSE ALL_TEST_SOURCES "unittests/*.cpp")
@@ -328,9 +357,11 @@ add_executable(consensust
328357
${TEST_SOURCES}
329358
)
330359

331-
target_link_libraries(consensust PRIVATE consensus)
360+
target_link_libraries(consensust PRIVATE consensus_full)
332361

333362
target_compile_options(consensust PRIVATE -Wno-error=unused-variable)
363+
# force catch2 macros to be prefixed with CATCH_ to avoid conflicts
364+
target_compile_definitions(consensust PRIVATE CATCH_CONFIG_PREFIX_ALL)
334365

335366
# # libgoogle-perftools-dev
336367
# if (CMAKE_PROJECT_NAME STREQUAL "consensus")

Consensusd.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323

2424

25-
#include "thirdparty/catch.hpp"
2625
#include "SkaleCommon.h"
2726
#include "Consensusd.h"
2827
#include "node/ConsensusEngine.h"

Consensust.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void abort_handler( int ) {
103103

104104
block_id basicRun( int64_t _lastId ) {
105105
try {
106-
REQUIRE( ConsensusEngine::getEngineVersion().size() > 0 );
106+
CATCH_REQUIRE( ConsensusEngine::getEngineVersion().size() > 0 );
107107

108108
engine = new ConsensusEngine( _lastId, 1000000000 );
109109

@@ -123,15 +123,15 @@ block_id basicRun( int64_t _lastId ) {
123123
};
124124
}
125125

126-
REQUIRE( engine->nodesCount() > 0 );
126+
CATCH_REQUIRE( engine->nodesCount() > 0 );
127127
auto lastId = engine->getLargestCommittedBlockID();
128-
REQUIRE( lastId > 0 );
128+
CATCH_REQUIRE( lastId > 0 );
129129

130130
auto [transactions, timestampS, timeStampMs, price, stateRoot] = engine->getBlock( 1 );
131131

132132

133-
REQUIRE( transactions );
134-
REQUIRE( timestampS > 0 );
133+
CATCH_REQUIRE( transactions );
134+
CATCH_REQUIRE( timestampS > 0 );
135135

136136
cerr << price << ":" << stateRoot << endl;
137137
signal( SIGABRT, abort_handler );

Log.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace spdlog {
5252
#define __CLASS_NAME__ className( __PRETTY_FUNCTION__ )
5353

5454

55-
#define LOG( __SEVERITY__, __MESSAGE__ ) \
55+
#define CONS_LOG( __SEVERITY__, __MESSAGE__ ) \
5656
{ \
5757
std::stringstream __TMP__LOG__STREAM__; \
5858
__TMP__LOG__STREAM__ << __MESSAGE__; \
@@ -77,13 +77,13 @@ namespace spdlog {
7777
catch (const std::exception& e) { \
7878
const std::string __catch_msg = std::string(__MESSAGE__) + \
7979
": in " + std::string(__FUNCTION__) + ": " + e.what(); \
80-
ConsensusEngine::log(__LEVEL__, __catch_msg, __CLASS_NAME__); \
81-
throw_with_nested(InvalidStateException(__catch_msg, __CLASS_NAME__)); \
80+
ConsensusEngine::log(__LEVEL__, __catch_msg, __CLASS_NAME__); \
81+
throw_with_nested(InvalidStateException(__catch_msg, __CLASS_NAME__)); \
8282
} catch (...) { \
8383
const std::string __catch_msg = std::string(__MESSAGE__) + \
8484
": in " + std::string(__FUNCTION__) + ": Unknown exception"; \
85-
ConsensusEngine::log(__LEVEL__, __catch_msg, __CLASS_NAME__); \
86-
throw_with_nested(InvalidStateException(__catch_msg, __CLASS_NAME__)); \
85+
ConsensusEngine::log(__LEVEL__, __catch_msg, __CLASS_NAME__); \
86+
throw_with_nested(InvalidStateException(__catch_msg, __CLASS_NAME__)); \
8787
}
8888
#endif
8989

abstracttcpclient/AbstractClientAgent.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ AbstractClientAgent::AbstractClientAgent( Schain& _sChain, port_type _portType )
5454
portType = _portType;
5555

5656

57-
logThreadLocal_ = _sChain.getNode()->getLog();
58-
5957
for ( uint64_t i = 1; i <= _sChain.getNodeCount(); i++ ) {
6058
( itemQueue ).emplace( schain_index( i ), make_shared< queue< ptr< SendableItem > > >() );
6159
( queueCond ).emplace( schain_index( i ), make_shared< condition_variable >() );

abstracttcpserver/AbstractServerAgent.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void AbstractServerAgent::workerThreadConnectionProcessingLoop( void* _params )
8383

8484
server->waitOnGlobalStartBarrier();
8585

86-
LOG( trace, "Started server loop" );
86+
CONS_LOG( trace, "Started server loop" );
8787

8888
while ( !server->getNode()->isExitRequested() ) {
8989
ptr< ServerConnection > connection = nullptr;
@@ -94,7 +94,7 @@ void AbstractServerAgent::workerThreadConnectionProcessingLoop( void* _params )
9494
CHECK_STATE( connection );
9595
server->processNextAvailableConnection( connection );
9696
} catch ( PingException& e ) {
97-
LOG( info, e.what() );
97+
CONS_LOG( info, e.what() );
9898
} catch ( exception& e ) {
9999
SkaleException::logNested( e );
100100
}
@@ -115,7 +115,6 @@ void AbstractServerAgent::send(
115115
AbstractServerAgent::AbstractServerAgent(
116116
const string& _name, Schain& _schain, const ptr< TCPServerSocket >& _socket )
117117
: Agent( _schain, true ), name( _name ), socket( _socket ), networkReadThread( nullptr ) {
118-
logThreadLocal_ = _schain.getNode()->getLog();
119118
}
120119

121120
AbstractServerAgent::~AbstractServerAgent() {
@@ -160,16 +159,16 @@ void AbstractServerAgent::acceptTCPConnectionsLoop() {
160159
}
161160

162161
void AbstractServerAgent::createNetworkReadThread() {
163-
LOG( trace, name << " Starting TCP server network read loop" );
162+
CONS_LOG( trace, name << " Starting TCP server network read loop" );
164163
networkReadThread =
165164
make_shared< thread >( std::bind( &AbstractServerAgent::acceptTCPConnectionsLoop, this ) );
166-
LOG( trace, name << " Started TCP server network read loop" );
165+
CONS_LOG( trace, name << " Started TCP server network read loop" );
167166
}
168167

169168

170169
void AbstractServerAgent::notifyAllConditionVariables() {
171170
Agent::notifyAllConditionVariables();
172-
LOG( trace,
171+
CONS_LOG( trace,
173172
"Notifying TCP cond" << to_string( ( uint64_t )( void* ) &incomingTCPConnectionsCond ) );
174173
incomingTCPConnectionsCond.notify_all();
175174
}

0 commit comments

Comments
 (0)