From 89106809d8ce8fc49a60e9c3ef9de001abf75f86 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 28 May 2018 08:38:38 -0500 Subject: [PATCH 01/42] add parameterized constructor --- include/fc/bloom_filter.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/fc/bloom_filter.hpp b/include/fc/bloom_filter.hpp index 67aa5cb..3728d9c 100644 --- a/include/fc/bloom_filter.hpp +++ b/include/fc/bloom_filter.hpp @@ -57,6 +57,20 @@ class bloom_parameters random_seed(0xA5A5A5A55A5A5A5AULL) {} + bloom_parameters(unsigned long long int projected_element_count, + double false_positive_probability, + unsigned long long int maximum_size) : + minimum_size(1), + maximum_size(maximum_size), + minimum_number_of_hashes(1), + maximum_number_of_hashes(std::numeric_limits::max()), + projected_element_count(projected_element_count), + false_positive_probability(false_positive_probability), + random_seed(0xA5A5A5A55A5A5A5AULL) + { + compute_optimal_parameters(); + } + virtual ~bloom_parameters() {} From 0fc569cbfc8056617cc3d96575c4b6302b250ca6 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 29 May 2018 16:36:31 +0200 Subject: [PATCH 02/42] Remove unused "smaz" compression --- CMakeLists.txt | 1 - include/fc/compress/smaz.hpp | 9 -- src/compress/smaz.cpp | 223 ----------------------------------- tests/compress/compress.cpp | 32 ----- 4 files changed, 265 deletions(-) delete mode 100644 include/fc/compress/smaz.hpp delete mode 100644 src/compress/smaz.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f0dac6..318b2bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,7 +280,6 @@ set( fc_sources src/network/rate_limiting.cpp src/network/resolve.cpp src/network/url.cpp - src/compress/smaz.cpp src/compress/zlib.cpp ) diff --git a/include/fc/compress/smaz.hpp b/include/fc/compress/smaz.hpp deleted file mode 100644 index ad60292..0000000 --- a/include/fc/compress/smaz.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include - -namespace fc { - - std::string smaz_compress( const std::string& in ); - std::string smaz_decompress( const std::string& compressed ); - -} // namespace fc diff --git a/src/compress/smaz.cpp b/src/compress/smaz.cpp deleted file mode 100644 index da1521a..0000000 --- a/src/compress/smaz.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include -#include -#include -namespace fc { - -typedef const char* const_char_ptr; -/* Our compression codebook, used for compression */ -static const_char_ptr Smaz_cb[241] = { -"\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS", -"\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277", -"\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336", -"\001 \000\003 (\002nc\344", "\002nd=\003 on\312", -"\002ne\213\003hat\276\003re q", "", "\002ngT\003herz\004have\306\003s o\225", -"", "\003ionk\003s a\254\002ly\352", "\003hisL\003 inN\003 be\252", "", -"\003 fo\325\003 of \003 ha\311", "", "\002of\005", -"\003 co\241\002no\267\003 ma\370", "", "", "\003 cl\356\003enta\003 an7", -"\002ns\300\001\"e", "\003n t\217\002ntP\003s, \205", -"\002pe\320\003 we\351\002om\223", "\002on\037", "", "\002y G", "\003 wa\271", -"\003 re\321\002or*", "", "\002=\"\251\002ot\337", "\003forD\002ou[", -"\003 toR", "\003 th\r", "\003 it\366", -"\003but\261\002ra\202\003 wi\363\002<\346", "\002to\024", "\003arew", "\001d\030", -"\002tr\303", "", "\001\n1\003 a \222", "\003f tv\002veo", "\002un\340", "", -"\003e o\242", "\002a \243\002wa\326\001e\002", "\002ur\226\003e a\274", -"\002us\244\003\n\r\n\247", "\002ut\304\003e c\373", "\002we\221", "", "", -"\002wh\302", "\001f,", "", "", "", "\003d t\206", "", "", "\003th \343", -"\001g;", "", "", "\001\r9\003e s\265", "\003e t\234", "", "\003to Y", -"\003e\r\n\236", "\002d \036\001h\022", "", "\001,Q", "\002 a\031", "\002 b^", -"\002\r\n\025\002 cI", "\002 d\245", "\002 e\253", "\002 fh\001i\b\002e \v", -"", "\002 hU\001-\314", "\002 i8", "", "", "\002 l\315", "\002 m{", -"\002f :\002 n\354", "\002 o\035", "\002 p}\001.n\003\r\n\r\250", "", -"\002 r\275", "\002 s>", "\002 t\016", "", "\002g \235\005which+\003whi\367", -"\002 w5", "\001/\305", "\003as \214", "\003at \207", "", "\003who\331", "", -"\001l\026\002h \212", "", "\002, $", "", "\004withV", "", "", "", "\001m-", "", -"", "\002ac\357", "\002ad\350", "\003TheH", "", "", "\004this\233\001n\t", -"", "\002. y", "", "\002alX\003e, \365", "\003tio\215\002be\\", -"\002an\032\003ver\347", "", "\004that0\003tha\313\001o\006", "\003was2", -"\002arO", "\002as.", "\002at'\003the\001\004they\200\005there\322\005theird", -"\002ce\210", "\004were]", "", "\002ch\231\002l \264\001p<", "", "", -"\003one\256", "", "\003he \023\002dej", "\003ter\270", "\002cou", "", -"\002by\177\002di\201\002eax", "", "\002ec\327", "\002edB", "\002ee\353", "", -"", "\001r\f\002n )", "", "", "", "\002el\262", "", "\003in i\002en3", "", -"\002o `\001s\n", "", "\002er\033", "\003is t\002es6", "", "\002ge\371", -"\004.com\375", "\002fo\334\003our\330", "\003ch \301\001t\003", "\002hab", "", -"\003men\374", "", "\002he\020", "", "", "\001u&", "\002hif", "", -"\003not\204\002ic\203", "\003ed @\002id\355", "", "", "\002ho\273", -"\002r K\001vm", "", "", "", "\003t t\257\002il\360", "\002im\342", -"\003en \317\002in\017", "\002io\220", "\002s \027\001wA", "", "\003er |", -"\003es ~\002is%", "\002it/", "", "\002iv\272", "", -"\002t #\ahttp://C\001x\372", "\002la\211", "\001<\341", "\003, a\224" -}; - - -/* Reverse compression codebook, used for decompression */ -static const_char_ptr Smaz_rcb[254] = { -" ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th", -" t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an", -"er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at", -" ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en", -" ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ", -"w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his", -"st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ", -"b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"", -"hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ", -"ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p", -"es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la", -"h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o", -"ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere", -" co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e", -"s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no", -"ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr", -"ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ", -"pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z", -"fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad", -" we", "ly", "ee", " n", "id", " cl", "ac", "il", " 1) h2 += in[1]; - if (inlen > 2) h3 = h2^in[2]; - if (j > inlen) j = inlen; - - /* Try to lookup substrings into the hash table, starting from the - * longer to the shorter substrings */ - for (; j > 0; j--) { - switch(j) { - case 1: slot = Smaz_cb[h1%241]; break; - case 2: slot = Smaz_cb[h2%241]; break; - default: slot = Smaz_cb[h3%241]; break; - } - while(slot[0]) { - if (slot[0] == j && memcmp(slot+1,in,j) == 0) { - /* Match found in the hash table, - * prepare a verbatim bytes flush if needed */ - if (verblen) { - needed = (verblen == 1) ? 2 : 2+verblen; - flush = out; - out += needed; - outlen -= needed; - } - /* Emit the byte */ - if (outlen <= 0) return _outlen+1; - out[0] = slot[slot[0]+1]; - out++; - outlen--; - inlen -= j; - in += j; - goto out; - } else { - slot += slot[0]+2; - } - } - } - /* Match not found - add the byte to the verbatim buffer */ - verb[verblen] = in[0]; - verblen++; - inlen--; - in++; -out: - /* Prepare a flush if we reached the flush length limit, and there - * is not already a pending flush operation. */ - if (!flush && (verblen == 256 || (verblen > 0 && inlen == 0))) { - needed = (verblen == 1) ? 2 : 2+verblen; - flush = out; - out += needed; - outlen -= needed; - if (outlen < 0) return _outlen+1; - } - /* Perform a verbatim flush if needed */ - if (flush) { - if (verblen == 1) { - flush[0] = (signed char)254; - flush[1] = verb[0]; - } else { - flush[0] = (signed char)255; - flush[1] = (signed char)(verblen-1); - memcpy(flush+2,verb,verblen); - } - flush = NULL; - verblen = 0; - } - } - return out-_out; -} - -void smaz_decompress(const char *in, uint32_t inlen, std::stringstream& ss ) { - const unsigned char *c = (const unsigned char*) in; -// char *_out = out; -// int _outlen = outlen; - - while(inlen) { - if (*c == 254) { - /* Verbatim byte */ - //if (outlen < 1) return _outlen+1; - //*out = *(c+1); - ss.put( *(c+1) ); - //out++; - //outlen--; - c += 2; - inlen -= 2; - } else if (*c == 255) { - /* Verbatim string */ - int len = (*(c+1))+1; - //if (outlen < len) return _outlen+1; - ss.write( (const char*)(c+2),len ); - - //memcpy(out,c+2,len); - //out += len; - //outlen -= len; - c += 2+len; - inlen -= 2+len; - } else { - /* Codebook entry */ - const char *s = Smaz_rcb[*c]; - int len = strlen(s); - - //if (outlen < len) return _outlen+1; - //memcpy(out,s,len); - ss.write( s, len ); - //out += len; - //outlen -= len; - c++; - inlen--; - } - } -} - - - - std::string smaz_compress( const std::string& in ) - { - std::string out; - out.resize(in.size()); - auto out_len = smaz_compress( in.c_str(), in.size(), &out[0], out.size() ); - FC_ASSERT( out_len <= out.size() ); - out.resize(out_len); - return out; - } - std::string smaz_decompress( const std::string& compressed ) - { - std::stringstream ss; - smaz_decompress( compressed.c_str(), compressed.length(), ss ); - return ss.str(); - } - -} // namespace fc diff --git a/tests/compress/compress.cpp b/tests/compress/compress.cpp index a30255e..bc5d3aa 100644 --- a/tests/compress/compress.cpp +++ b/tests/compress/compress.cpp @@ -2,43 +2,11 @@ #include #include -#include #include #include BOOST_AUTO_TEST_SUITE(compress) -BOOST_AUTO_TEST_CASE(smaz_test) -{ - std::ifstream testfile; - testfile.open("README.md"); - - std::stringstream buffer; - std::string line; - std::getline( testfile, line ); - while( testfile.good() ) - { - buffer << line << "\n"; - try { - std::string compressed = fc::smaz_compress( line ); - std::string decomp = fc::smaz_decompress( compressed ); - BOOST_CHECK_EQUAL( decomp, line ); - } - catch ( fc::exception& e ) - { - std::cout< Date: Wed, 30 May 2018 21:59:06 -0300 Subject: [PATCH 03/42] Remove fc bz2 unused linkage --- CMakeLists.txt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 318b2bd..107b805 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,15 +366,6 @@ else() set( ZLIB_LIBRARIES "" ) endif( ZLIB_FOUND ) -find_package( BZip2 ) -if( BZIP2_FOUND ) - MESSAGE( STATUS "bzip2 found" ) - add_definitions( -DHAS_BZIP2 ) -else() - MESSAGE( STATUS "bzip2 not found" ) - set( BZIP2_LIBRARIES "" ) -endif( BZIP2_FOUND ) - # This will become unnecessary once we update to websocketpp which fixes upstream issue #395 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWEBSOCKETPP_STRICT_MASKING") @@ -405,11 +396,10 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp ) -#target_link_libraries( fc PUBLIC ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) IF(NOT WIN32) set(LINK_USR_LOCAL_LIB -L/usr/local/lib) ENDIF() -target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${editline_libraries} ${ECC_LIB} ) +target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${editline_libraries} ${ECC_LIB} ) if(MSVC) set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) From 59f503d6436e31a21e2a2f5fffd640253f4147db Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 1 Jun 2018 19:00:48 -0500 Subject: [PATCH 04/42] adjust asserts in fc/crypto --- src/crypto/elliptic_common.cpp | 4 ++-- src/crypto/pke.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/elliptic_common.cpp b/src/crypto/elliptic_common.cpp index b736e24..7d8b6ed 100644 --- a/src/crypto/elliptic_common.cpp +++ b/src/crypto/elliptic_common.cpp @@ -140,7 +140,7 @@ namespace fc { namespace ecc { std::string public_key::to_base58( const public_key_data &key ) { uint32_t check = (uint32_t)sha256::hash(key.data, sizeof(key))._hash[0]; - assert(key.size() + sizeof(check) == 37); + static_assert(sizeof(key) + sizeof(check) == 37, "Elliptic public key size (or its hash) is incorrect"); array data; memcpy(data.data, key.begin(), key.size()); memcpy(data.begin() + key.size(), (const char*)&check, sizeof(check)); @@ -192,7 +192,7 @@ namespace fc { namespace ecc { BN_mod(secexp, secexp, order, ctx); fc::sha256 secret; - assert(BN_num_bytes(secexp) <= int64_t(sizeof(secret))); + FC_ASSERT(BN_num_bytes(secexp) <= int64_t(sizeof(secret))); auto shift = sizeof(secret) - BN_num_bytes(secexp); BN_bn2bin(secexp, ((unsigned char*)&secret)+shift); return regenerate( secret ); diff --git a/src/crypto/pke.cpp b/src/crypto/pke.cpp index 3ec0199..28cd60d 100644 --- a/src/crypto/pke.cpp +++ b/src/crypto/pke.cpp @@ -75,13 +75,13 @@ namespace fc { bool public_key::verify( const sha1& digest, const signature& sig )const { - assert( sig.size() == 2048/8 ); + static_assert( sig.size() == 2048/8, "Invalid signature size" ); return 0 != RSA_verify( NID_sha1, (const uint8_t*)&digest, 20, (uint8_t*)sig.data(), 2048/8, my->rsa ); } bool public_key::verify( const sha256& digest, const signature& sig )const { - assert( sig.size() == 2048/8 ); + static_assert( sig.size() == 2048/8, "Invalid signature size" ); return 0 != RSA_verify( NID_sha256, (const uint8_t*)&digest, 32, (uint8_t*)sig.data(), 2048/8, my->rsa ); } From ac982cae2a6c50592846389e0695c1682b1ac8f6 Mon Sep 17 00:00:00 2001 From: cwyy Date: Sat, 30 Jun 2018 14:10:38 +0800 Subject: [PATCH 05/42] fix compile error with vs2017 and boost 1.67 --- CMakeLists.txt | 6 +++++- src/network/tcp_socket.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 107b805..fa3fcbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -511,7 +511,11 @@ ENDIF() IF("${OPENSSL_ROOT_DIR}" STREQUAL "") get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_INCLUDE_DIR}/.." REALPATH) ENDIF() - SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf") + IF("${OPENSSL_ROOT_DIR}" STREQUAL "C:/Program Files/OpenSSL") + SET(OPENSSL_CONF_SOURCE "C:/Program Files/Common Files/SSL/openssl.cnf") + ELSE() + SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf") + ENDIF() IF(MINGW) SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/openssl.cnf") ENDIF(MINGW) diff --git a/src/network/tcp_socket.cpp b/src/network/tcp_socket.cpp index e521c41..0012ba6 100644 --- a/src/network/tcp_socket.cpp +++ b/src/network/tcp_socket.cpp @@ -177,7 +177,7 @@ namespace fc { keepalive_settings.keepaliveinterval = (ULONG)(interval.count() / fc::milliseconds(1).count()); DWORD dwBytesRet = 0; - if (WSAIoctl(my->_sock.native(), SIO_KEEPALIVE_VALS, &keepalive_settings, sizeof(keepalive_settings), + if (WSAIoctl(my->_sock.native_handle(), SIO_KEEPALIVE_VALS, &keepalive_settings, sizeof(keepalive_settings), NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR) wlog("Error setting TCP keepalive values"); #elif !defined(__clang__) || (__clang_major__ >= 6) From e609d7033426e8d3c0574979fcfc7fae1ecba735 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Thu, 5 Jul 2018 12:30:56 +0800 Subject: [PATCH 06/42] Remove unnecessary structure definition in static_variant.hpp --- include/fc/static_variant.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index c9d5115..02fb5dc 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -338,11 +338,6 @@ class static_variant { tag_type which() const {return _tag;} }; -template -struct visitor { - typedef Result result_type; -}; - struct from_static_variant { variant& var; From 6d3184ff44e845d198c183b6b86cd900d21da42f Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Thu, 5 Jul 2018 12:31:59 +0800 Subject: [PATCH 07/42] Fix two typo in variant.hpp --- include/fc/variant.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 9736423..fd286ea 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -173,7 +173,7 @@ namespace fc * and variant_object's. * * variant's allocate everything but strings, arrays, and objects on the - * stack and are 'move aware' for values allcoated on the heap. + * stack and are 'move aware' for values allocated on the heap. * * Memory usage on 64 bit systems is 16 bytes and 12 bytes on 32 bit systems. */ @@ -352,7 +352,7 @@ namespace fc void clear(); private: void init(); - double _data; ///< Alligned according to double requirements + double _data; ///< Aligned according to double requirements char _type[sizeof(void*)]; ///< pad to void* size }; typedef optional ovariant; From 650c0a3c620eef4d81fa1a9fafb3c761e6b33d26 Mon Sep 17 00:00:00 2001 From: cwyy Date: Thu, 5 Jul 2018 17:34:10 +0800 Subject: [PATCH 08/42] fix hardcode of OPENSSL_CONF_SOURCE in CMakeLists.txt --- CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa3fcbc..7b76491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -511,14 +511,12 @@ ENDIF() IF("${OPENSSL_ROOT_DIR}" STREQUAL "") get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_INCLUDE_DIR}/.." REALPATH) ENDIF() - IF("${OPENSSL_ROOT_DIR}" STREQUAL "C:/Program Files/OpenSSL") - SET(OPENSSL_CONF_SOURCE "C:/Program Files/Common Files/SSL/openssl.cnf") - ELSE() - SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf") - ENDIF() - IF(MINGW) - SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/openssl.cnf") - ENDIF(MINGW) + IF("${OPENSSL_CONF_SOURCE}" STREQUAL "") + SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf") + IF(MINGW) + SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/openssl.cnf") + ENDIF(MINGW) + ENDIF() SET(POST_BUILD_STEP_COMMANDS ${POST_BUILD_STEP_COMMANDS} COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_CONF_SOURCE}" "${OPENSSL_CONF_TARGET}/openssl.cnf") ENDIF(WIN32) From 20724f7eccdf68aa755a6cad65c7f0781cd87849 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Mon, 9 Jul 2018 17:17:32 +0300 Subject: [PATCH 09/42] fixed issue #809 --- include/fc/io/fstream.hpp | 9 +++-- src/filesystem.cpp | 2 +- src/io/fstream.cpp | 6 ++-- src/log/file_appender.cpp | 8 ++--- tests/CMakeLists.txt | 1 + tests/logging_tests.cpp | 72 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 tests/logging_tests.cpp diff --git a/include/fc/io/fstream.hpp b/include/fc/io/fstream.hpp index 8344ce9..481c051 100644 --- a/include/fc/io/fstream.hpp +++ b/include/fc/io/fstream.hpp @@ -3,16 +3,19 @@ #include #include +#include + +using namespace std; + namespace fc { class path; class ofstream : virtual public ostream { public: - enum mode { out, binary }; ofstream(); - ofstream( const fc::path& file, int m = binary ); + ofstream( const fc::path& file, std::ios_base::openmode m = std::ios_base::out | std::ios_base::binary ); ~ofstream(); - void open( const fc::path& file, int m = binary ); + void open( const fc::path& file, std::ios_base::openmode m = std::ios_base::out | std::ios_base::binary ); size_t writesome( const char* buf, size_t len ); size_t writesome(const std::shared_ptr& buffer, size_t len, size_t offset); void put( char c ); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index fc200bf..eb3d685 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -364,7 +364,7 @@ namespace fc { } if (create) { - fc::ofstream ofs(*_path, fc::ofstream::out | fc::ofstream::binary); + fc::ofstream ofs(*_path, std::ios_base::out | std::ios_base::binary); ofs.close(); } } diff --git a/src/io/fstream.cpp b/src/io/fstream.cpp index a40bbeb..031026b 100644 --- a/src/io/fstream.cpp +++ b/src/io/fstream.cpp @@ -23,13 +23,13 @@ namespace fc { ofstream::ofstream() :my( new impl() ){} - ofstream::ofstream( const fc::path& file, int m ) + ofstream::ofstream( const fc::path& file, std::ios_base::openmode m ) :my( new impl() ) { this->open( file, m ); } ofstream::~ofstream(){} - void ofstream::open( const fc::path& file, int m ) { + void ofstream::open( const fc::path& file, std::ios_base::openmode m ) { const boost::filesystem::path& bfp = file; - my->ofs.open( bfp, std::ios::binary ); + my->ofs.open( bfp, std::ios_base::out | std::ios_base::binary | m ); } size_t ofstream::writesome( const char* buf, size_t len ) { my->ofs.write(buf,len); diff --git a/src/log/file_appender.cpp b/src/log/file_appender.cpp index 49ae357..8e5c44c 100644 --- a/src/log/file_appender.cpp +++ b/src/log/file_appender.cpp @@ -42,7 +42,7 @@ namespace fc { - _rotation_task = async( [this]() { rotate_files( true ); }, "rotate_files(1)" ); + _rotation_task = fc::async( [this]() { rotate_files( true ); }, "rotate_files(1)" ); } } @@ -83,11 +83,7 @@ namespace fc { out.close(); } remove_all(link_filename); // on windows, you can't delete the link while the underlying file is opened for writing - if( fc::exists( log_filename ) ) - out.open( log_filename, std::ios_base::out | std::ios_base::app ); - else - out.open( log_filename, std::ios_base::out | std::ios_base::app); - + out.open( log_filename, std::ios_base::out | std::ios_base::app ); create_hard_link(log_filename, link_filename); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d000013..153067e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,5 +59,6 @@ add_executable( all_tests all_tests.cpp time_test.cpp utf8_test.cpp variant_test.cpp + logging_tests.cpp ) target_link_libraries( all_tests fc ) diff --git a/tests/logging_tests.cpp b/tests/logging_tests.cpp new file mode 100644 index 0000000..659c80d --- /dev/null +++ b/tests/logging_tests.cpp @@ -0,0 +1,72 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +BOOST_AUTO_TEST_SUITE(logging_tests) + +BOOST_AUTO_TEST_CASE(log_reboot) +{ + BOOST_TEST_MESSAGE("Setting up logger"); + fc::file_appender::config conf; + conf.filename = "/tmp/my.log"; + conf.format = "${timestamp} ${thread_name} ${context} ${file}:${line} ${method} ${level}] ${message}"; + conf.flush = true; + conf.rotate = true; + conf.rotation_interval = fc::seconds(5); // rotate every 5 seconds + conf.rotation_limit = fc::seconds(20); // Don't keep files older than 20 seconds + conf.max_object_depth = 200; + + fc::appender::ptr fa = fc::appender::create("file", "file", fc::variant(conf, 200)); + + fc::path prev_log_filename = ""; + + BOOST_TEST_MESSAGE("Starting Loop"); + for(int i = 0; i < conf.rotation_limit.to_seconds(); i++) + { + fc::log_context ctx(fc::log_level::all, "my_file.cpp", i, "my_method()"); + fc::log_message my_log_message( ctx, "${message}", {"message","This is a test"} ); + fa->log(my_log_message); + + fc::time_point now = fc::time_point::now(); + int64_t interval_seconds = conf.rotation_interval.to_seconds(); + int64_t file_number = now.sec_since_epoch() / interval_seconds; + fc::time_point_sec start_time = fc::time_point_sec( (uint32_t)(file_number * interval_seconds) ); + fc::string timestamp_string = start_time.to_non_delimited_iso_string(); + fc::path link_filename = conf.filename; + fc::path log_filename = link_filename.parent_path() / (link_filename.filename().string() + "." + timestamp_string); + + if (prev_log_filename != log_filename) { + if (i > conf.rotation_interval.to_seconds()) { + std::string rez; + fc::read_file_contents(prev_log_filename, rez); + std::size_t found = rez.find("my_file.cpp:" + std::to_string(i - 1)); + BOOST_CHECK(found != std::string::npos); + + fc::read_file_contents(log_filename, rez); + found = rez.find("my_file.cpp:" + std::to_string(i)); + BOOST_CHECK(found != std::string::npos); + } + prev_log_filename = log_filename; + } + + fc::usleep(fc::seconds(1)); + } + BOOST_TEST_MESSAGE("Loop complete"); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file From ce2e62f535d54359e091c05d050c7dbae398ffe6 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 16 Jul 2018 06:37:25 -0500 Subject: [PATCH 10/42] fix editline sigsev --- vendor/editline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/editline b/vendor/editline index 5be965d..405f091 160000 --- a/vendor/editline +++ b/vendor/editline @@ -1 +1 @@ -Subproject commit 5be965deec0527b48b393b7aca9cb2a76aec2a99 +Subproject commit 405f09188868eb69483c2efc55b9837c9ce04494 From 1169c2d966d87244e8cab31857e36f6fcab05d1a Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 17 Jul 2018 19:46:43 +0300 Subject: [PATCH 11/42] removed using statement from header file --- include/fc/io/fstream.hpp | 3 --- src/io/fstream.cpp | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/fc/io/fstream.hpp b/include/fc/io/fstream.hpp index 481c051..9a0c99d 100644 --- a/include/fc/io/fstream.hpp +++ b/include/fc/io/fstream.hpp @@ -2,11 +2,8 @@ #include #include #include - #include -using namespace std; - namespace fc { class path; class ofstream : virtual public ostream { diff --git a/src/io/fstream.cpp b/src/io/fstream.cpp index 031026b..042791d 100644 --- a/src/io/fstream.cpp +++ b/src/io/fstream.cpp @@ -10,6 +10,8 @@ #include #include +using namespace std; + namespace fc { class ofstream::impl : public fc::retainable { public: From da5f2c39146d3fb421ae2e7babe6065bc75ed08c Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 17 Jul 2018 13:16:17 +0300 Subject: [PATCH 12/42] fixed issue #929 --- src/network/http/websocket.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 7f26b4d..9e9daf8 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -226,6 +226,7 @@ namespace fc { namespace http { fc::async([current_con, request_body, con] { std::string response = current_con->on_http(request_body); + idump((response)); con->set_body( response ); con->set_status( websocketpp::http::status_code::ok ); con->send_http_response(); From ee25279db65f6a7968edfcffa2a33a066e0731e2 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 17 Jul 2018 20:43:34 +0300 Subject: [PATCH 13/42] added idump for websocket_tls_server_impl --- src/network/http/websocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 9e9daf8..0246c0b 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -349,7 +349,7 @@ namespace fc { namespace http { auto con = _server.get_con_from_hdl(hdl); wdump(("server")(con->get_request_body())); auto response = current_con->on_http( con->get_request_body() ); - + idump((response)); con->set_body( response ); con->set_status( websocketpp::http::status_code::ok ); } catch ( const fc::exception& e ) From 0486a5f1e9058313e370c5f8dc2c258c2f3404f8 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 18 Jul 2018 18:02:26 +0300 Subject: [PATCH 14/42] fixed issue #1050 --- src/rpc/cli.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index add2f6a..5ca1447 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -103,6 +103,11 @@ void cli::run() } else std::cout << itr->second( result, args ) << "\n"; + + if (method == "quit") + { + stop(); + } } catch ( const fc::exception& e ) { From 535fc869b505af528043760adbe5a9424ca2c485 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Thu, 19 Jul 2018 09:48:47 +0300 Subject: [PATCH 15/42] remove hard coded method check to result check from quit command --- src/rpc/cli.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index 5ca1447..2788f49 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -14,6 +14,12 @@ # endif #endif +#ifdef WIN32 +# include +#else +# include +#endif + namespace fc { namespace rpc { static std::vector& cli_commands() @@ -104,9 +110,9 @@ void cli::run() else std::cout << itr->second( result, args ) << "\n"; - if (method == "quit") + if (result.is_integer() && result.as_int64() == SIGQUIT) { - stop(); + break; } } catch ( const fc::exception& e ) From 18206552fc60450a628056646eeabd0618868e61 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 20 Jul 2018 16:44:31 +0300 Subject: [PATCH 16/42] throwing fc:canceled_exception for quit cli wallet command --- src/rpc/cli.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index 2788f49..0021ada 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -14,12 +14,6 @@ # endif #endif -#ifdef WIN32 -# include -#else -# include -#endif - namespace fc { namespace rpc { static std::vector& cli_commands() @@ -109,15 +103,15 @@ void cli::run() } else std::cout << itr->second( result, args ) << "\n"; - - if (result.is_integer() && result.as_int64() == SIGQUIT) - { - break; - } } catch ( const fc::exception& e ) { std::cout << e.to_detail_string() << "\n"; + + if (e.code() == fc::canceled_exception_code) + { + break; + } } } } From 82987bb55e3bb69387e9330182c02ceb3d789994 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 23 Jul 2018 16:26:54 -0500 Subject: [PATCH 17/42] Bump for websocketpp, bitshares-core issue 999 --- vendor/websocketpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/websocketpp b/vendor/websocketpp index e6c4e3c..792cb45 160000 --- a/vendor/websocketpp +++ b/vendor/websocketpp @@ -1 +1 @@ -Subproject commit e6c4e3c54bf9cf1892c85a6ed6289486bba36fa1 +Subproject commit 792cb455bec45837d8d801e82c6fd86c38e1dbdb From 2105bc0ee7d599fbf9c18ab20f8172c61f929202 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 23 Jul 2018 19:50:54 -0500 Subject: [PATCH 18/42] Add header --- src/stacktrace.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stacktrace.cpp b/src/stacktrace.cpp index 2504bb1..0e00044 100644 --- a/src/stacktrace.cpp +++ b/src/stacktrace.cpp @@ -2,6 +2,7 @@ // A stacktrace handler for bitshares // #include +#include // only include stacktrace stuff if boost >= 1.65 #if BOOST_VERSION / 100000 >= 1 && ((BOOST_VERSION / 100) % 1000) >= 65 From 9e043fb7bcd7e5795f2d7a6c2ae5ec60df072731 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 27 Jul 2018 10:27:28 +0300 Subject: [PATCH 19/42] fc::time_point_sec::to_iso_string is broken - issue #597 --- tests/time_test.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/time_test.cpp b/tests/time_test.cpp index dee272d..690d66c 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -1,5 +1,5 @@ #include - +#include #include using namespace fc; @@ -38,8 +38,11 @@ BOOST_AUTO_TEST_CASE(time_point_sec_test) time_point_sec tp3g(0xc0000000U); // commented next 2 tests as they will only work with boost >= 1.64 - //BOOST_CHECK_EQUAL( "2072-01-28T16:51:12", tp3g.to_iso_string() ); - //BOOST_CHECK_EQUAL( "20720128T165112", tp3g.to_non_delimited_iso_string() ); + + if (BOOST_VERSION >= BOOST_VERSION_NUMBER(1,64,0)) { + BOOST_CHECK_EQUAL( "2072-01-28T16:51:12", tp3g.to_iso_string() ); + BOOST_CHECK_EQUAL( "20720128T165112", tp3g.to_non_delimited_iso_string() ); + } BOOST_CHECK( tp0 == time_point_sec() ); BOOST_CHECK( tp0 < tp1 ); From 0077926a7c55a6df64a353a0e8f7caef7c36652f Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 27 Jul 2018 15:00:10 +0300 Subject: [PATCH 20/42] removed comment --- tests/time_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/time_test.cpp b/tests/time_test.cpp index 690d66c..4c45720 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -37,8 +37,6 @@ BOOST_AUTO_TEST_CASE(time_point_sec_test) BOOST_CHECK_EQUAL( "20380119T031408", tp2g.to_non_delimited_iso_string() ); time_point_sec tp3g(0xc0000000U); - // commented next 2 tests as they will only work with boost >= 1.64 - if (BOOST_VERSION >= BOOST_VERSION_NUMBER(1,64,0)) { BOOST_CHECK_EQUAL( "2072-01-28T16:51:12", tp3g.to_iso_string() ); BOOST_CHECK_EQUAL( "20720128T165112", tp3g.to_non_delimited_iso_string() ); From 40d928e57c8cfe7cad898fe321f236696b2e8162 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Mon, 30 Jul 2018 16:48:37 +0300 Subject: [PATCH 21/42] raise SIGINT instead of throwing exception in cli_wallet quit command --- src/rpc/cli.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index 0021ada..add2f6a 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -107,11 +107,6 @@ void cli::run() catch ( const fc::exception& e ) { std::cout << e.to_detail_string() << "\n"; - - if (e.code() == fc::canceled_exception_code) - { - break; - } } } } From ec41a06300fa820731ecb36ff74203c0745f628e Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Mon, 30 Jul 2018 17:52:56 +0300 Subject: [PATCH 22/42] reverting throw exception instead of raising SIGINT in order not to terminate cli_test early --- src/rpc/cli.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index add2f6a..0021ada 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -107,6 +107,11 @@ void cli::run() catch ( const fc::exception& e ) { std::cout << e.to_detail_string() << "\n"; + + if (e.code() == fc::canceled_exception_code) + { + break; + } } } } From 1eca4959e7e70f5f0eacd54d14c156be973733dd Mon Sep 17 00:00:00 2001 From: liukunyu Date: Thu, 24 May 2018 15:46:07 +0800 Subject: [PATCH 23/42] fix import_key crash for wallet --- src/filesystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index eb3d685..625f7f2 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -241,7 +241,8 @@ namespace fc { void remove_all( const path& p ) { boost::filesystem::remove_all(p); } void copy( const path& f, const path& t ) { try { - boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); + boost::system::error_code ec; + boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t), ec ); } catch ( boost::system::system_error& e ) { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}", ("srcfile",f)("dstfile",t)("reason",e.what() ) ); From ce7cb0dd06df4995cefee51ba61c3b690b5d0518 Mon Sep 17 00:00:00 2001 From: BITSG-Jerry Date: Thu, 9 Aug 2018 12:28:42 -0400 Subject: [PATCH 24/42] Check error after called boost::filesystem::copy() and rethrow if found an error. This is to get around boost 1.67 issue https://svn.boost.org/trac10/ticket/13585 --- src/filesystem.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 625f7f2..bd98e57 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -243,6 +243,11 @@ namespace fc { try { boost::system::error_code ec; boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t), ec ); + if( ec ) + { + FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}:${value}", + ("srcfile",f)("dstfile",t)("reason",ec.category().name())("value",ec.value()) ); + } } catch ( boost::system::system_error& e ) { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}", ("srcfile",f)("dstfile",t)("reason",e.what() ) ); From 35cb63d3ead1447e7e6cd3b6e7acedd6a86ae8cf Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 9 Aug 2018 12:57:08 -0400 Subject: [PATCH 25/42] Call FC wrappers of copy and remove in rename() to get around boost 1.67 boost::filesystem::copy() null pointer dereferencing issue --- src/filesystem.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index bd98e57..8185fc3 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -303,13 +303,14 @@ namespace fc { void rename( const path& f, const path& t ) { try { boost::filesystem::rename( boost::filesystem::path(f), boost::filesystem::path(t) ); - } catch ( boost::system::system_error& ) { - try{ - boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); - boost::filesystem::remove( boost::filesystem::path(f)); - } catch ( boost::system::system_error& e ) { - FC_THROW( "Rename from ${srcfile} to ${dstfile} failed because ${reason}", - ("srcfile",f)("dstfile",t)("reason",e.what() ) ); + } catch ( boost::system::system_error& er ) { + try { + copy( f, t ); + remove( f ); + } catch ( fc::exception& e ) { + FC_RETHROW_EXCEPTION( e, error, + "Rename from ${srcfile} to ${dstfile} failed due to ${reason}, trying to copy then remove", + ("srcfile",f)("dstfile",t)("reason",er.what()) ); } } catch ( ... ) { FC_THROW( "Rename from ${srcfile} to ${dstfile} failed", From 64b4bd4900875ee8fe611c7a31a4925cd495fe9e Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 9 Aug 2018 16:31:56 -0400 Subject: [PATCH 26/42] Wrap system_error::what() in a string --- src/filesystem.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 8185fc3..5b89102 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -245,12 +245,12 @@ namespace fc { boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t), ec ); if( ec ) { - FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}:${value}", - ("srcfile",f)("dstfile",t)("reason",ec.category().name())("value",ec.value()) ); + FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${code} : ${message}", + ("srcfile",f)("dstfile",t)("code",ec.value())("message",ec.message()) ); } } catch ( boost::system::system_error& e ) { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed because ${reason}", - ("srcfile",f)("dstfile",t)("reason",e.what() ) ); + ("srcfile",f)("dstfile",t)("reason",std::string(e.what()) ) ); } catch ( ... ) { FC_THROW( "Copy from ${srcfile} to ${dstfile} failed", ("srcfile",f)("dstfile",t)("inner", fc::except_str() ) ); @@ -264,7 +264,7 @@ namespace fc { catch ( boost::system::system_error& e ) { FC_THROW( "Resize file '${f}' to size ${s} failed: ${reason}", - ("f",f)("s",t)( "reason", e.what() ) ); + ("f",f)("s",t)( "reason", std::string(e.what()) ) ); } catch ( ... ) { @@ -310,7 +310,7 @@ namespace fc { } catch ( fc::exception& e ) { FC_RETHROW_EXCEPTION( e, error, "Rename from ${srcfile} to ${dstfile} failed due to ${reason}, trying to copy then remove", - ("srcfile",f)("dstfile",t)("reason",er.what()) ); + ("srcfile",f)("dstfile",t)("reason",std::string(er.what())) ); } } catch ( ... ) { FC_THROW( "Rename from ${srcfile} to ${dstfile} failed", From 48901cd1a43949c64fcfbdddc1e774147d8d74ad Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 10 Aug 2018 14:40:47 -0500 Subject: [PATCH 27/42] correct templating of static variant --- include/fc/static_variant.hpp | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 02fb5dc..88efeda 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -382,5 +382,46 @@ class static_variant { s.visit( to_static_variant(ar[1], max_depth - 1) ); } - template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; + template< typename... T > struct get_comma_separated_typenames; + + template<> + struct get_comma_separated_typenames<> + { + static const char* names() { return ""; } + }; + + template< typename T > + struct get_comma_separated_typenames + { + static const char* names() + { + static const std::string n = get_typename::name(); + return n.c_str(); + } + }; + + template< typename T, typename... Ts > + struct get_comma_separated_typenames + { + static const char* names() + { + static const std::string n = + std::string( get_typename::name() )+","+ + std::string( get_comma_separated_typenames< Ts... >::names() ); + return n.c_str(); + } + }; + + template< typename... T > + struct get_typename< static_variant< T... > > + { + static const char* name() + { + static const std::string n = std::string( "fc::static_variant<" ) + + get_comma_separated_typenames::names() + + ">"; + return n.c_str(); + } + }; + } // namespace fc From da33edc384db1da6c31ff1c28c04c1aca442278d Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 10 Aug 2018 15:33:25 -0500 Subject: [PATCH 28/42] additional typenames --- include/fc/reflect/typename.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 5cd55c9..5777f34 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -69,6 +70,22 @@ namespace fc { return n.c_str(); } }; + template struct get_typename< std::set > + { + static const char* name() + { + static std::string n = std::string("std::set<") + std::string(get_typename::name()) + std::string(">"); + return n.c_str(); + } + }; + template struct get_typename< std::pair > + { + static const char* name() + { + static std::string n = std::string("std::pair<") + get_typename::name() + "," + get_typename::name() + ">"; + return n.c_str(); + } + }; struct signed_int; struct unsigned_int; From e8961888752c7203d67cd64c7a712b30e35dd21b Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 10 Aug 2018 20:40:21 -0500 Subject: [PATCH 29/42] additional templates for get_typename --- include/fc/reflect/typename.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 5777f34..c5bba19 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -86,10 +87,19 @@ namespace fc { return n.c_str(); } }; + template struct get_typename< fc::smart_ref > + { + static const char* name() + { + return (std::string("fc::smart_ref<") + get_typename::name() + std::string(">")).c_str(); + } + }; struct signed_int; struct unsigned_int; + struct variant_object; template<> struct get_typename { static const char* name() { return "signed_int"; } }; template<> struct get_typename { static const char* name() { return "unsigned_int"; } }; + template<> struct get_typename { static const char* name() { return "fc::variant_object"; } }; } From 9ba8886c8bb36905d4fbdcc38ebfcd67beb9915e Mon Sep 17 00:00:00 2001 From: John Jones Date: Sun, 12 Aug 2018 19:57:43 -0500 Subject: [PATCH 30/42] Change string to static --- include/fc/reflect/typename.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index c5bba19..55695c2 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -91,7 +91,8 @@ namespace fc { { static const char* name() { - return (std::string("fc::smart_ref<") + get_typename::name() + std::string(">")).c_str(); + static std::string n = std::string("fc::smart_ref<") + get_typename::name() + std::string(">"); + return n.c_str(); } }; From f8940a686a809eefb9424b2428a149879cf947ae Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 18 Jul 2018 17:55:46 +0200 Subject: [PATCH 31/42] Added unit test for serialization/deserialization of unsigned_int --- tests/CMakeLists.txt | 1 + tests/io/varint_tests.cpp | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/io/varint_tests.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 153067e..600f6f8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,6 +49,7 @@ add_executable( all_tests all_tests.cpp io/json_tests.cpp io/stream_tests.cpp io/tcp_test.cpp + io/varint_tests.cpp network/http/websocket_test.cpp thread/task_cancel.cpp thread/thread_tests.cpp diff --git a/tests/io/varint_tests.cpp b/tests/io/varint_tests.cpp new file mode 100644 index 0000000..4309d0f --- /dev/null +++ b/tests/io/varint_tests.cpp @@ -0,0 +1,53 @@ +#include + +#include +#include +#include + +BOOST_AUTO_TEST_SUITE(varint_tests) + +#define UINT_LENGTH (1 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 3 + 3 + 3 + 4 + 4 + 4 + 5 + 5) +static const std::string EXPECTED_UINTS( "\020" // 16 = length of array + "\0\1\2\020\177\200\1\200\2\377\177" + "\200\200\1\200\200\2\377\377\177" + "\200\200\200\1\200\200\200\2" + "\377\377\377\177\200\200\200\200\1" + "\252\325\252\325\012", UINT_LENGTH ); +static const std::vector TEST_U = { + 0, // \0 + 1, // \1 + 2, // \2 + 0x10, // \020 + 0x7f, // \177 + 0x80, // \200\1 + 0x100, // \200\2 + 0x3fff, // \377\177 + 0x4000, // \200\200\1 + 0x8000, // \200\200\2 + 0x1fffff, // \377\377\177 + 0x200000, // \200\200\200\1 + 0x400000, // \200\200\200\2 + 0xfffffff, // \377\377\377\177 + 0x10000000, // \200\200\200\200\1 + 0xaaaaaaaa // \252\325\252\325\012 + }; +BOOST_AUTO_TEST_CASE( test_unsigned ) +{ + const std::vector packed_u = fc::raw::pack>( TEST_U, 3 ); + BOOST_CHECK_EQUAL( UINT_LENGTH, packed_u.size() ); + BOOST_CHECK_EQUAL( EXPECTED_UINTS, std::string( packed_u.data(), packed_u.size() ) ); + std::vector unpacked_u; + fc::raw::unpack>( packed_u, unpacked_u, 3 ); + BOOST_CHECK_EQUAL( TEST_U.size(), unpacked_u.size() ); + for( size_t i = 0; i < TEST_U.size(); i++ ) + BOOST_CHECK_EQUAL( TEST_U[i].value, unpacked_u[i].value ); + + const std::string json_u = fc::json::to_string(fc::variant( TEST_U, 3 )); + BOOST_CHECK_EQUAL( "[0,1,2,16,127,128,256,16383,16384,32768,2097151,2097152,4194304,268435455,268435456,2863311530]", json_u ); + std::vector unjson_u = fc::json::from_string( json_u ).as>( 3 ); + BOOST_CHECK_EQUAL( TEST_U.size(), unjson_u.size() ); + for( size_t i = 0; i < TEST_U.size(); i++ ) + BOOST_CHECK_EQUAL( TEST_U[i].value, unjson_u[i].value ); +} + +BOOST_AUTO_TEST_SUITE_END() From 9483935d6446657ffc1c8d329307e08f2eb1ab05 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 18 Jul 2018 18:13:48 +0200 Subject: [PATCH 32/42] Support 64 bit values in unsigned_int object --- include/fc/container/flat.hpp | 6 +++--- include/fc/interprocess/container.hpp | 2 +- include/fc/io/raw.hpp | 18 +++++++++--------- include/fc/io/raw_variant.hpp | 2 +- include/fc/io/varint.hpp | 27 ++++++++++++--------------- src/io/varint.cpp | 2 +- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/include/fc/container/flat.hpp b/include/fc/container/flat.hpp index 2eca459..5e6a363 100644 --- a/include/fc/container/flat.hpp +++ b/include/fc/container/flat.hpp @@ -11,7 +11,7 @@ namespace fc { inline void pack( Stream& s, const flat_set& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -38,7 +38,7 @@ namespace fc { inline void pack( Stream& s, const flat_map& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -67,7 +67,7 @@ namespace fc { void pack( Stream& s, const bip::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + pack( s, unsigned_int(value.size()), _max_depth ); if( !std::is_fundamental::value ) { auto itr = value.begin(); auto end = value.end(); diff --git a/include/fc/interprocess/container.hpp b/include/fc/interprocess/container.hpp index 7ede74b..a00346e 100644 --- a/include/fc/interprocess/container.hpp +++ b/include/fc/interprocess/container.hpp @@ -113,7 +113,7 @@ namespace fc { inline void pack( Stream& s, const bip::vector& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 9ef61ec..c7035ec 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -273,9 +273,9 @@ namespace fc { // std::vector template inline void pack( Stream& s, const std::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth - 1 ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth - 1 ); if( value.size() ) - s.write( &value.front(), (uint32_t)value.size() ); + s.write( &value.front(), value.size() ); } template inline void unpack( Stream& s, std::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); @@ -289,7 +289,7 @@ namespace fc { // fc::string template inline void pack( Stream& s, const fc::string& v, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); - fc::raw::pack( s, unsigned_int((uint32_t)v.size()), _max_depth - 1 ); + fc::raw::pack( s, unsigned_int(v.size()), _max_depth - 1 ); if( v.size() ) s.write( v.c_str(), v.size() ); } @@ -433,7 +433,7 @@ namespace fc { inline void pack( Stream& s, const std::unordered_set& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -478,7 +478,7 @@ namespace fc { inline void pack( Stream& s, const std::unordered_map& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -506,7 +506,7 @@ namespace fc { inline void pack( Stream& s, const std::map& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -534,7 +534,7 @@ namespace fc { inline void pack( Stream& s, const std::deque& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -562,7 +562,7 @@ namespace fc { inline void pack( Stream& s, const std::vector& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { @@ -590,7 +590,7 @@ namespace fc { inline void pack( Stream& s, const std::set& value, uint32_t _max_depth ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - fc::raw::pack( s, unsigned_int((uint32_t)value.size()), _max_depth ); + fc::raw::pack( s, unsigned_int(value.size()), _max_depth ); auto itr = value.begin(); auto end = value.end(); while( itr != end ) { diff --git a/include/fc/io/raw_variant.hpp b/include/fc/io/raw_variant.hpp index b07fbaa..59b93d9 100644 --- a/include/fc/io/raw_variant.hpp +++ b/include/fc/io/raw_variant.hpp @@ -128,7 +128,7 @@ namespace fc { namespace raw { { FC_ASSERT( _max_depth > 0 ); --_max_depth; - unsigned_int vs = (uint32_t)v.size(); + unsigned_int vs = v.size(); pack( s, vs, _max_depth ); for( auto itr = v.begin(); itr != v.end(); ++itr ) { diff --git a/include/fc/io/varint.hpp b/include/fc/io/varint.hpp index 00a8023..80082f2 100644 --- a/include/fc/io/varint.hpp +++ b/include/fc/io/varint.hpp @@ -4,35 +4,32 @@ namespace fc { struct unsigned_int { - unsigned_int( uint32_t v = 0 ):value(v){} + unsigned_int( uint64_t v = 0 ):value(v){} template unsigned_int( T v ):value(v){} - //operator uint32_t()const { return value; } - //operator uint64_t()const { return value; } - template operator T()const { return static_cast(value); } - unsigned_int& operator=( int32_t v ) { value = v; return *this; } + unsigned_int& operator=( uint64_t v ) { value = v; return *this; } - uint32_t value; + uint64_t value; - friend bool operator==( const unsigned_int& i, const uint32_t& v ) { return i.value == v; } - friend bool operator==( const uint32_t& i, const unsigned_int& v ) { return i == v.value; } + friend bool operator==( const unsigned_int& i, const uint64_t& v ) { return i.value == v; } + friend bool operator==( const uint64_t& i, const unsigned_int& v ) { return i == v.value; } friend bool operator==( const unsigned_int& i, const unsigned_int& v ) { return i.value == v.value; } - friend bool operator!=( const unsigned_int& i, const uint32_t& v ) { return i.value != v; } - friend bool operator!=( const uint32_t& i, const unsigned_int& v ) { return i != v.value; } + friend bool operator!=( const unsigned_int& i, const uint64_t& v ) { return i.value != v; } + friend bool operator!=( const uint64_t& i, const unsigned_int& v ) { return i != v.value; } friend bool operator!=( const unsigned_int& i, const unsigned_int& v ) { return i.value != v.value; } - friend bool operator<( const unsigned_int& i, const uint32_t& v ) { return i.value < v; } - friend bool operator<( const uint32_t& i, const unsigned_int& v ) { return i < v.value; } + friend bool operator<( const unsigned_int& i, const uint64_t& v ) { return i.value < v; } + friend bool operator<( const uint64_t& i, const unsigned_int& v ) { return i < v.value; } friend bool operator<( const unsigned_int& i, const unsigned_int& v ) { return i.value < v.value; } - friend bool operator>=( const unsigned_int& i, const uint32_t& v ) { return i.value >= v; } - friend bool operator>=( const uint32_t& i, const unsigned_int& v ) { return i >= v.value; } + friend bool operator>=( const unsigned_int& i, const uint64_t& v ) { return i.value >= v; } + friend bool operator>=( const uint64_t& i, const unsigned_int& v ) { return i >= v.value; } friend bool operator>=( const unsigned_int& i, const unsigned_int& v ) { return i.value >= v.value; } }; @@ -95,7 +92,7 @@ namespace std public: size_t operator()(const fc::signed_int &a) const { - return std::hash()(a.value); + return std::hash()(a.value); } }; } diff --git a/src/io/varint.cpp b/src/io/varint.cpp index 6d5df6c..6384eec 100644 --- a/src/io/varint.cpp +++ b/src/io/varint.cpp @@ -6,5 +6,5 @@ namespace fc void to_variant( const signed_int& var, variant& vo, uint32_t max_depth ) { vo = var.value; } void from_variant( const variant& var, signed_int& vo, uint32_t max_depth ) { vo.value = static_cast(var.as_int64()); } void to_variant( const unsigned_int& var, variant& vo, uint32_t max_depth ) { vo = var.value; } -void from_variant( const variant& var, unsigned_int& vo, uint32_t max_depth ) { vo.value = static_cast(var.as_uint64()); } +void from_variant( const variant& var, unsigned_int& vo, uint32_t max_depth ) { vo.value = var.as_uint64(); } } From 58ac6ae20812deb5acc77d1546665fd3b00c2d60 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 18 Aug 2018 21:13:32 +0200 Subject: [PATCH 33/42] Changed some casts to uint64_t --- include/fc/io/raw.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index c7035ec..8bd0163 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -193,10 +193,10 @@ namespace fc { uint64_t v = 0; char b = 0; uint8_t by = 0; do { s.get(b); - v |= uint32_t(uint8_t(b) & 0x7f) << by; + v |= uint64_t(uint8_t(b) & 0x7f) << by; by += 7; } while( uint8_t(b) & 0x80 ); - vi.value = static_cast(v); + vi.value = static_cast(v); } template inline void unpack( Stream& s, const T& vi, uint32_t _max_depth ) From 72bcc8a926f518a1dfba4255ec2bee196d53fde0 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 18 Aug 2018 21:24:58 +0200 Subject: [PATCH 34/42] Fix #993 - limit unpacking length of signed_int and unsigned_int --- include/fc/io/raw.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 8bd0163..e254cd3 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -184,7 +184,7 @@ namespace fc { s.get(b); v |= uint32_t(uint8_t(b) & 0x7f) << by; by += 7; - } while( uint8_t(b) & 0x80 ); + } while( (uint8_t(b) & 0x80) && by < 32 ); vi.value = ((v>>1) ^ (v>>31)) + (v&0x01); vi.value = v&0x01 ? vi.value : -vi.value; vi.value = -vi.value; @@ -195,7 +195,7 @@ namespace fc { s.get(b); v |= uint64_t(uint8_t(b) & 0x7f) << by; by += 7; - } while( uint8_t(b) & 0x80 ); + } while( (uint8_t(b) & 0x80) && by < 64 ); vi.value = static_cast(v); } From a39e0d1a8ffedf00713af0319218d3321be893da Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 18 Aug 2018 22:16:36 +0200 Subject: [PATCH 35/42] Expanded tests for unsigned_int to 64 bits --- tests/io/varint_tests.cpp | 51 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/tests/io/varint_tests.cpp b/tests/io/varint_tests.cpp index 4309d0f..e7b606f 100644 --- a/tests/io/varint_tests.cpp +++ b/tests/io/varint_tests.cpp @@ -6,13 +6,29 @@ BOOST_AUTO_TEST_SUITE(varint_tests) -#define UINT_LENGTH (1 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 3 + 3 + 3 + 4 + 4 + 4 + 5 + 5) -static const std::string EXPECTED_UINTS( "\020" // 16 = length of array - "\0\1\2\020\177\200\1\200\2\377\177" +#define UINT_LENGTH (1 + 5*1 + 3*2 + 3*3 + 3*4 + 2*5 + 3*6 + 3*7 + 3*8 + 3*9 + 2*10) +static const std::string EXPECTED_UINTS( "\036" // 30 = length of array + "\0\1\2\020\177" + "\200\1\200\2\377\177" "\200\200\1\200\200\2\377\377\177" - "\200\200\200\1\200\200\200\2" - "\377\377\377\177\200\200\200\200\1" - "\252\325\252\325\012", UINT_LENGTH ); + "\200\200\200\1\200\200\200\2\377\377\377\177" + "\200\200\200\200\1" + "\252\325\252\325\012" + "\200\200\200\200\200\1" + "\200\200\200\200\200\2" + "\377\377\377\377\377\177" + "\200\200\200\200\200\200\1" + "\200\200\200\200\200\200\2" + "\377\377\377\377\377\377\177" + "\200\200\200\200\200\200\200\1" + "\200\200\200\200\200\200\200\2" + "\377\377\377\377\377\377\377\177" + "\200\200\200\200\200\200\200\200\1" + "\200\200\200\200\200\200\200\200\2" + "\377\377\377\377\377\377\377\377\177" + "\200\200\200\200\200\200\200\200\200\1" + "\377\377\377\377\377\377\377\377\377\1", + UINT_LENGTH ); static const std::vector TEST_U = { 0, // \0 1, // \1 @@ -29,7 +45,21 @@ static const std::vector TEST_U = { 0x400000, // \200\200\200\2 0xfffffff, // \377\377\377\177 0x10000000, // \200\200\200\200\1 - 0xaaaaaaaa // \252\325\252\325\012 + 0xaaaaaaaa, // \252\325\252\325\012 + 0x800000000ULL, // \200\200\200\200\200\1 + 0x1000000000ULL, // \200\200\200\200\200\2 + 0x3ffffffffffULL, // \377\377\377\377\377\177 + 0x40000000000ULL, // \200\200\200\200\200\200\1 + 0x80000000000ULL, // \200\200\200\200\200\200\2 + 0x1ffffffffffffULL, // \377\377\377\377\377\377\177 + 0x2000000000000ULL, // \200\200\200\200\200\200\200\1 + 0x4000000000000ULL, // \200\200\200\200\200\200\200\2 + 0xffffffffffffffULL, // \377\377\377\377\377\377\377\177 + 0x100000000000000ULL, // \200\200\200\200\200\200\200\200\1 + 0x200000000000000ULL, // \200\200\200\200\200\200\200\200\2 + 0x7fffffffffffffffULL, // \377\377\377\377\377\377\377\377\177 + 0x8000000000000000ULL, // \200\200\200\200\200\200\200\200\200\1 + 0xffffffffffffffffULL // \377\377\377\377\377\377\377\377\377\1 }; BOOST_AUTO_TEST_CASE( test_unsigned ) { @@ -43,7 +73,12 @@ BOOST_AUTO_TEST_CASE( test_unsigned ) BOOST_CHECK_EQUAL( TEST_U[i].value, unpacked_u[i].value ); const std::string json_u = fc::json::to_string(fc::variant( TEST_U, 3 )); - BOOST_CHECK_EQUAL( "[0,1,2,16,127,128,256,16383,16384,32768,2097151,2097152,4194304,268435455,268435456,2863311530]", json_u ); + BOOST_CHECK_EQUAL( "[0,1,2,16,127,128,256,16383,16384,32768,2097151,2097152,4194304,268435455,268435456,2863311530," + "\"34359738368\",\"68719476736\",\"4398046511103\",\"4398046511104\"," + "\"8796093022208\",\"562949953421311\",\"562949953421312\"," + "\"1125899906842624\",\"72057594037927935\",\"72057594037927936\"," + "\"144115188075855872\",\"9223372036854775807\",\"9223372036854775808\"," + "\"18446744073709551615\"]", json_u ); std::vector unjson_u = fc::json::from_string( json_u ).as>( 3 ); BOOST_CHECK_EQUAL( TEST_U.size(), unjson_u.size() ); for( size_t i = 0; i < TEST_U.size(); i++ ) From 0c22469090a376352fec748362451d90ff27d73a Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 Aug 2018 10:26:52 +0200 Subject: [PATCH 36/42] #993 - unit test --- tests/io/varint_tests.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/io/varint_tests.cpp b/tests/io/varint_tests.cpp index e7b606f..ea0ef58 100644 --- a/tests/io/varint_tests.cpp +++ b/tests/io/varint_tests.cpp @@ -85,4 +85,40 @@ BOOST_AUTO_TEST_CASE( test_unsigned ) BOOST_CHECK_EQUAL( TEST_U[i].value, unjson_u[i].value ); } +BOOST_AUTO_TEST_CASE( test_limits ) +{ try { + static const std::string PACKED_U = "\04" + "\200\1" + "\200\200\200\200\200\200\200\200\100" + "\200\200\200\200\200\200\200\200\200\201" // not terminated + "\200\200\200\200\200\200\200\200\300\201"; // not terminated + std::vector unpacked_u; + fc::raw::unpack( std::vector( PACKED_U.begin(), PACKED_U.end() ), unpacked_u, 3 ); + BOOST_REQUIRE_EQUAL( 4, unpacked_u.size() ); + BOOST_CHECK_EQUAL( 0x80, unpacked_u[0].value ); + BOOST_CHECK_EQUAL( 0x4000000000000000ULL, unpacked_u[1].value ); + BOOST_CHECK_EQUAL( 0x8000000000000000ULL, unpacked_u[2].value ); + BOOST_CHECK_EQUAL( 0xc000000000000000ULL, unpacked_u[3].value ); + + /* Hm, seems that signed_int is broken, see below + static const std::string PACKED_S = "\04" + "\200\1" + "\200\200\200\200\04" + "\200\200\200\200\210" // not terminated + "\200\200\200\200\214"; // not terminated + std::vector unpacked_s; + fc::raw::unpack( std::vector( PACKED_S.begin(), PACKED_S.end() ), unpacked_s, 3 ); + BOOST_REQUIRE_EQUAL( 4, unpacked_s.size() ); + BOOST_CHECK_EQUAL( 0x40, unpacked_s[0].value ); + BOOST_CHECK_EQUAL( 0x20000000, unpacked_s[1].value ); + BOOST_CHECK_EQUAL( 0x40000000, unpacked_s[2].value ); + BOOST_CHECK_EQUAL( 0x60000000, unpacked_s[3].value ); + */ + + std::vector packed_s = fc::raw::pack( fc::signed_int(0x40000000), 3 ); + fc::signed_int tmp = fc::raw::unpack( packed_s, 3 ); + BOOST_CHECK_EQUAL( 0x40000000, tmp.value ); + +} FC_LOG_AND_RETHROW() } + BOOST_AUTO_TEST_SUITE_END() From 4b61f3ca3dba952a982f9d6102acc8956e33f54d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 Aug 2018 10:42:27 +0200 Subject: [PATCH 37/42] Fixed alleged c&p bug --- include/fc/io/varint.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/io/varint.hpp b/include/fc/io/varint.hpp index 80082f2..fe8e82e 100644 --- a/include/fc/io/varint.hpp +++ b/include/fc/io/varint.hpp @@ -90,7 +90,7 @@ namespace std struct hash { public: - size_t operator()(const fc::signed_int &a) const + size_t operator()(const fc::unsigned_int &a) const { return std::hash()(a.value); } From 1dcacbafc9e85552e8bd9b8b5082e1ce3364fe43 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 Aug 2018 18:26:46 +0200 Subject: [PATCH 38/42] Removed signed_int --- include/fc/io/raw.hpp | 21 ---------------- include/fc/io/raw_fwd.hpp | 3 --- include/fc/io/varint.hpp | 43 --------------------------------- include/fc/reflect/typename.hpp | 2 -- src/io/varint.cpp | 2 -- tests/io/varint_tests.cpp | 20 --------------- 6 files changed, 91 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index e254cd3..48811c2 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -158,16 +158,6 @@ namespace fc { fc::raw::unpack( s, *v, _max_depth - 1 ); } FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr", ("type",fc::get_typename::name()) ) } - template inline void pack( Stream& s, const signed_int& v, uint32_t _max_depth ) { - uint32_t val = (v.value<<1) ^ (v.value>>31); - do { - uint8_t b = uint8_t(val) & 0x7f; - val >>= 7; - b |= ((val > 0) << 7); - s.write((char*)&b,1);//.put(b); - } while( val ); - } - template inline void pack( Stream& s, const unsigned_int& v, uint32_t _max_depth ) { uint64_t val = v.value; do { @@ -178,17 +168,6 @@ namespace fc { }while( val ); } - template inline void unpack( Stream& s, signed_int& vi, uint32_t _max_depth ) { - uint32_t v = 0; char b = 0; int by = 0; - do { - s.get(b); - v |= uint32_t(uint8_t(b) & 0x7f) << by; - by += 7; - } while( (uint8_t(b) & 0x80) && by < 32 ); - vi.value = ((v>>1) ^ (v>>31)) + (v&0x01); - vi.value = v&0x01 ? vi.value : -vi.value; - vi.value = -vi.value; - } template inline void unpack( Stream& s, unsigned_int& vi, uint32_t _max_depth ) { uint64_t v = 0; char b = 0; uint8_t by = 0; do { diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 157a745..87a9208 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -116,9 +116,6 @@ namespace fc { template inline void pack( Stream& s, const std::vector& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, std::vector& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template inline void pack( Stream& s, const signed_int& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template inline void unpack( Stream& s, signed_int& vi, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template inline void pack( Stream& s, const unsigned_int& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, unsigned_int& vi, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); diff --git a/include/fc/io/varint.hpp b/include/fc/io/varint.hpp index fe8e82e..30e42bb 100644 --- a/include/fc/io/varint.hpp +++ b/include/fc/io/varint.hpp @@ -33,42 +33,8 @@ struct unsigned_int { friend bool operator>=( const unsigned_int& i, const unsigned_int& v ) { return i.value >= v.value; } }; -/** - * @brief serializes a 32 bit signed interger in as few bytes as possible - * - * Uses the google protobuf algorithm for seralizing signed numbers - */ -struct signed_int { - signed_int( int32_t v = 0 ):value(v){} - operator int32_t()const { return value; } - template - signed_int& operator=( const T& v ) { value = v; return *this; } - signed_int operator++(int) { return value++; } - signed_int& operator++(){ ++value; return *this; } - - int32_t value; - - friend bool operator==( const signed_int& i, const int32_t& v ) { return i.value == v; } - friend bool operator==( const int32_t& i, const signed_int& v ) { return i == v.value; } - friend bool operator==( const signed_int& i, const signed_int& v ) { return i.value == v.value; } - - friend bool operator!=( const signed_int& i, const int32_t& v ) { return i.value != v; } - friend bool operator!=( const int32_t& i, const signed_int& v ) { return i != v.value; } - friend bool operator!=( const signed_int& i, const signed_int& v ) { return i.value != v.value; } - - friend bool operator<( const signed_int& i, const int32_t& v ) { return i.value < v; } - friend bool operator<( const int32_t& i, const signed_int& v ) { return i < v.value; } - friend bool operator<( const signed_int& i, const signed_int& v ) { return i.value < v.value; } - - friend bool operator>=( const signed_int& i, const int32_t& v ) { return i.value >= v; } - friend bool operator>=( const int32_t& i, const signed_int& v ) { return i >= v.value; } - friend bool operator>=( const signed_int& i, const signed_int& v ) { return i.value >= v.value; } -}; - class variant; -void to_variant( const signed_int& var, variant& vo, uint32_t max_depth = 1 ); -void from_variant( const variant& var, signed_int& vo, uint32_t max_depth = 1 ); void to_variant( const unsigned_int& var, variant& vo, uint32_t max_depth = 1 ); void from_variant( const variant& var, unsigned_int& vo, uint32_t max_depth = 1 ); @@ -77,15 +43,6 @@ void from_variant( const variant& var, unsigned_int& vo, uint32_t max_depth = 1 #include namespace std { - template<> - struct hash - { - public: - size_t operator()(const fc::signed_int &a) const - { - return std::hash()(a.value); - } - }; template<> struct hash { diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 55695c2..7223d83 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -96,10 +96,8 @@ namespace fc { } }; - struct signed_int; struct unsigned_int; struct variant_object; - template<> struct get_typename { static const char* name() { return "signed_int"; } }; template<> struct get_typename { static const char* name() { return "unsigned_int"; } }; template<> struct get_typename { static const char* name() { return "fc::variant_object"; } }; diff --git a/src/io/varint.cpp b/src/io/varint.cpp index 6384eec..a5c6bbb 100644 --- a/src/io/varint.cpp +++ b/src/io/varint.cpp @@ -3,8 +3,6 @@ namespace fc { -void to_variant( const signed_int& var, variant& vo, uint32_t max_depth ) { vo = var.value; } -void from_variant( const variant& var, signed_int& vo, uint32_t max_depth ) { vo.value = static_cast(var.as_int64()); } void to_variant( const unsigned_int& var, variant& vo, uint32_t max_depth ) { vo = var.value; } void from_variant( const variant& var, unsigned_int& vo, uint32_t max_depth ) { vo.value = var.as_uint64(); } } diff --git a/tests/io/varint_tests.cpp b/tests/io/varint_tests.cpp index ea0ef58..1d5c67c 100644 --- a/tests/io/varint_tests.cpp +++ b/tests/io/varint_tests.cpp @@ -99,26 +99,6 @@ BOOST_AUTO_TEST_CASE( test_limits ) BOOST_CHECK_EQUAL( 0x4000000000000000ULL, unpacked_u[1].value ); BOOST_CHECK_EQUAL( 0x8000000000000000ULL, unpacked_u[2].value ); BOOST_CHECK_EQUAL( 0xc000000000000000ULL, unpacked_u[3].value ); - - /* Hm, seems that signed_int is broken, see below - static const std::string PACKED_S = "\04" - "\200\1" - "\200\200\200\200\04" - "\200\200\200\200\210" // not terminated - "\200\200\200\200\214"; // not terminated - std::vector unpacked_s; - fc::raw::unpack( std::vector( PACKED_S.begin(), PACKED_S.end() ), unpacked_s, 3 ); - BOOST_REQUIRE_EQUAL( 4, unpacked_s.size() ); - BOOST_CHECK_EQUAL( 0x40, unpacked_s[0].value ); - BOOST_CHECK_EQUAL( 0x20000000, unpacked_s[1].value ); - BOOST_CHECK_EQUAL( 0x40000000, unpacked_s[2].value ); - BOOST_CHECK_EQUAL( 0x60000000, unpacked_s[3].value ); - */ - - std::vector packed_s = fc::raw::pack( fc::signed_int(0x40000000), 3 ); - fc::signed_int tmp = fc::raw::unpack( packed_s, 3 ); - BOOST_CHECK_EQUAL( 0x40000000, tmp.value ); - } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END() From 79ff75423fb177db4efdc6428efccfcc2602133d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 Aug 2018 18:51:45 +0200 Subject: [PATCH 39/42] Throw overflow_exception instead of silently cutting off data --- include/fc/io/raw.hpp | 4 +++- tests/io/varint_tests.cpp | 22 ++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 48811c2..fb3abb7 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -172,9 +172,11 @@ namespace fc { uint64_t v = 0; char b = 0; uint8_t by = 0; do { s.get(b); + if( by >= 64 || (by == 63 && b > 1) ) + FC_THROW_EXCEPTION( overflow_exception, "Invalid packed unsigned_int!" ); v |= uint64_t(uint8_t(b) & 0x7f) << by; by += 7; - } while( (uint8_t(b) & 0x80) && by < 64 ); + } while( uint8_t(b) & 0x80 ); vi.value = static_cast(v); } diff --git a/tests/io/varint_tests.cpp b/tests/io/varint_tests.cpp index 1d5c67c..f1f1536 100644 --- a/tests/io/varint_tests.cpp +++ b/tests/io/varint_tests.cpp @@ -62,7 +62,7 @@ static const std::vector TEST_U = { 0xffffffffffffffffULL // \377\377\377\377\377\377\377\377\377\1 }; BOOST_AUTO_TEST_CASE( test_unsigned ) -{ +{ try { const std::vector packed_u = fc::raw::pack>( TEST_U, 3 ); BOOST_CHECK_EQUAL( UINT_LENGTH, packed_u.size() ); BOOST_CHECK_EQUAL( EXPECTED_UINTS, std::string( packed_u.data(), packed_u.size() ) ); @@ -83,22 +83,16 @@ BOOST_AUTO_TEST_CASE( test_unsigned ) BOOST_CHECK_EQUAL( TEST_U.size(), unjson_u.size() ); for( size_t i = 0; i < TEST_U.size(); i++ ) BOOST_CHECK_EQUAL( TEST_U[i].value, unjson_u[i].value ); -} +} FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( test_limits ) { try { - static const std::string PACKED_U = "\04" - "\200\1" - "\200\200\200\200\200\200\200\200\100" - "\200\200\200\200\200\200\200\200\200\201" // not terminated - "\200\200\200\200\200\200\200\200\300\201"; // not terminated - std::vector unpacked_u; - fc::raw::unpack( std::vector( PACKED_U.begin(), PACKED_U.end() ), unpacked_u, 3 ); - BOOST_REQUIRE_EQUAL( 4, unpacked_u.size() ); - BOOST_CHECK_EQUAL( 0x80, unpacked_u[0].value ); - BOOST_CHECK_EQUAL( 0x4000000000000000ULL, unpacked_u[1].value ); - BOOST_CHECK_EQUAL( 0x8000000000000000ULL, unpacked_u[2].value ); - BOOST_CHECK_EQUAL( 0xc000000000000000ULL, unpacked_u[3].value ); + static const std::string overflow = "\200\200\200\200\200\200\200\200\200\2"; // = 2^64 + static const std::string overlong = "\200\200\200\200\200\200\200\200\300\200\1"; + + fc::unsigned_int dest; + BOOST_CHECK_THROW( fc::raw::unpack( std::vector( overflow.begin(), overflow.end() ), dest, 3 ), fc::overflow_exception ); + BOOST_CHECK_THROW( fc::raw::unpack( std::vector( overlong.begin(), overlong.end() ), dest, 3 ), fc::overflow_exception ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END() From fcfa7b69b0c0be0982533dda734f539b0a3a14a2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 20 Aug 2018 16:10:13 +0200 Subject: [PATCH 40/42] Relabelling to SounDAC --- .travis.yml | 8 +++++--- README.md | 2 +- sonar-project.properties | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc23682..4840cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: c++ +cache: ccache + git: depth: 1 @@ -14,15 +16,15 @@ install: addons: sonarcloud: - organization: "djxeo0smpujky4mpro50l67fsv74ijvt" + organization: "soundac" token: - secure: "aJ1aXr7JCsd7EwN0GQDJibKK24SW27AYrc5RDS7+MIJ5CCSX8e/cZ8v0Se6JmaXqt4t/VKAuVtv9JW2HZMMv2c2ACDpGWysKftS0Nb3JJCDHth+NZKGWhl9rFGQ90BigL3qQu2c9haJ77uCXko2BudcSqd9ejfSpQLA0tLrT7QGr/iS+pdmEQOVAsNWF4157hYSSxwz1WIHX2uxci2y9zCiE0ckmkpxwmI6qFiIExC6Y7LAATBeE1fT4KocPYZSAbeYx6D0C1llaWnw0ICf1jVF9ZEG79GDlnM9Uqj9rAAWIhgJFie15gYFvsfsv/W1R7u4xh0204/86HEfHCaV5JLUKGuxWRvtHhMmOC4LRf4siscT52R28AUq+QIak4dgL1H4QL6AvhpCK4SeeZj644XA8VJUp7skjpk2cNJ6RZA4TdOY/qSAGSSf/wHizftRdjb7oPn0nHgadr3biDI2LrhGI4N4lAZdxrBjUODkzENsgR4vQ4RtFw62gpxvUpqMwFkNIEYxWo9bVNXmqYzBKJqqL/lHsm7QZHJgpOcn/jFow+R9n73LjKGGDbJcCZ7TUbWWFzhaGiw7aDyYFuZgGVkEuT81KQdxaLjG6X5hMrLGaB8No9T8Vj+4121rcCxX3r8MK0uvVzcaKt9Md51zCJ6GoF4FcQbI8TkOj2O7i4ZM=" + secure: "Cr3q74yHUsS+kcAsAtB+yB2AyDptL8Rpmw+Q8HR+1MIEnIqyp5BLGNzOZnlucNQwUSUeVF81MpVTRgJT7zzVRa3XbVIngT25a3mm7zgULtG+RJG2rIFoeFWmgmj8kf+1HAis2lsJNUDylhrdumRQS3fMXBA/5Hz4Sbrve/TUg40RutAOsaXipwxqsanxnt/vwFndbb8Y/wprmgHrj45IMG+5bdJ6+DjaahJ9c1QDtWhtn9kPVYCJlO+XRzbHoVCOJOw8+r3FW8I5bDKMxbwGnAcAt4h0ZaxWtUSvt/iECpZqmOgirmVKQ9FJFzcCWBw+PY5Z+bnjwLjDCm2HqoNDk08cWLTn4Na/ZFO5AbBjS9L2VYC5PLpboTJnAygKcEcFDxsNDpnJK5mbcyV/Yzcmwwu5bIEfaDJS4aE1hVCqKhWP7Ecg2QxLtDSG4NHmyrG0CCUorhSemgUK5XvZ9QsSMqnBYl5ee9y/mc6swjHTK3DshJOHzWHO0QpoHg+fv5At7CXWvF/0F7/l24RvCweSni6/eT40MsM6tQCAEJRe6RFBeZAXs1RW+uh+A/CVeTKjNOtJNsV8AmJyu3bR3C7Kug3t+jbZ7cqms+wxyeIt01nYkgJM84kAnnJI51x+c3YtdJ4zK7dic7XWfy0jWdGVb9/JydPmhxI2PEKpPqnFmyk=" script: - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON . - 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 || make -j 2' - set -o pipefail - - tests/run-parallel-tests.sh tests/all_tests + - tests/all_tests 2>&1 | cat - tests/api 2>&1 | cat - tests/ecc_test README.md 2>&1 | cat - tests/log_test 2>&1 | cat diff --git a/README.md b/README.md index 2416021..bcd6f6b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ fc == -[![](https://travis-ci.org/themuseblockchain/Muse-FC.svg?branch=master)](https://travis-ci.org/themuseblockchain/Muse-FC) +[![](https://travis-ci.org/soundac/SounDAC-FC.svg?branch=master)](https://travis-ci.org/soundac/SounDAC-FC) FC stands for fast-compiling c++ library and provides a set of utility libraries useful for the development of asynchronous libraries. Some of the highlights include: diff --git a/sonar-project.properties b/sonar-project.properties index 22ffcdc..694c191 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,10 +1,10 @@ -sonar.projectKey=MUSE-FC -sonar.projectName=MUSE-FC +sonar.projectKey=SounDAC-FC +sonar.projectName=SounDAC-FC sonar.links.homepage=https://peertracks.com/ -sonar.links.ci=https://travis-ci.org/themuseblockchain/Muse-FC -sonar.links.issue=https://github.com/themuseblockchain/Muse-FC/issues -sonar.links.scm=https://github.com/themuseblockchain/Muse-FC +sonar.links.ci=https://travis-ci.org/soundac/SounDAC-FC +sonar.links.issue=https://github.com/soundac/SounDAC-FC/issues +sonar.links.scm=https://github.com/soundac/SounDAC-FC sonar.tests=tests sonar.exclusions=vendor/**/*,tests/**/* From 814bb4e81dfa6e728e33f8c7bab48b204c62a6bc Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 20 Aug 2018 16:26:53 +0200 Subject: [PATCH 41/42] Use newer ccache, add some ccache settings to environment --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4840cf3..c1439fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ sudo: true install: - echo "deb http://de.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - - sudo apt-get install --allow-unauthenticated g++ libboost-all-dev cmake libreadline-dev libssl-dev autoconf parallel + - sudo apt-get install --allow-unauthenticated g++ libboost-all-dev cmake libreadline-dev libssl-dev autoconf parallel ccache addons: sonarcloud: @@ -20,6 +20,12 @@ addons: token: secure: "Cr3q74yHUsS+kcAsAtB+yB2AyDptL8Rpmw+Q8HR+1MIEnIqyp5BLGNzOZnlucNQwUSUeVF81MpVTRgJT7zzVRa3XbVIngT25a3mm7zgULtG+RJG2rIFoeFWmgmj8kf+1HAis2lsJNUDylhrdumRQS3fMXBA/5Hz4Sbrve/TUg40RutAOsaXipwxqsanxnt/vwFndbb8Y/wprmgHrj45IMG+5bdJ6+DjaahJ9c1QDtWhtn9kPVYCJlO+XRzbHoVCOJOw8+r3FW8I5bDKMxbwGnAcAt4h0ZaxWtUSvt/iECpZqmOgirmVKQ9FJFzcCWBw+PY5Z+bnjwLjDCm2HqoNDk08cWLTn4Na/ZFO5AbBjS9L2VYC5PLpboTJnAygKcEcFDxsNDpnJK5mbcyV/Yzcmwwu5bIEfaDJS4aE1hVCqKhWP7Ecg2QxLtDSG4NHmyrG0CCUorhSemgUK5XvZ9QsSMqnBYl5ee9y/mc6swjHTK3DshJOHzWHO0QpoHg+fv5At7CXWvF/0F7/l24RvCweSni6/eT40MsM6tQCAEJRe6RFBeZAXs1RW+uh+A/CVeTKjNOtJNsV8AmJyu3bR3C7Kug3t+jbZ7cqms+wxyeIt01nYkgJM84kAnnJI51x+c3YtdJ4zK7dic7XWfy0jWdGVb9/JydPmhxI2PEKpPqnFmyk=" +env: + global: + - CCACHE_COMPRESS=exists_means_true + - CCACHE_MAXSIZE=1Gi + - CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros + script: - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON . - 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 || make -j 2' From 02a45166102305e34d968077baa54a8b8ba903a9 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 21 Aug 2018 16:48:00 +0200 Subject: [PATCH 42/42] Handle b<0 --- include/fc/io/raw.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index fb3abb7..c12abb1 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -172,7 +172,7 @@ namespace fc { uint64_t v = 0; char b = 0; uint8_t by = 0; do { s.get(b); - if( by >= 64 || (by == 63 && b > 1) ) + if( by >= 64 || (by == 63 && uint8_t(b) > 1) ) FC_THROW_EXCEPTION( overflow_exception, "Invalid packed unsigned_int!" ); v |= uint64_t(uint8_t(b) & 0x7f) << by; by += 7;