diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 27c4b4dae2644..4c16ba997c34a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,10 +6,6 @@ on: - master - develop - feature/* - pull_request: - branches: - - master - - develop jobs: build: diff --git a/configure.ac b/configure.ac index d058f58d2233e..8b783270e75f0 100644 --- a/configure.ac +++ b/configure.ac @@ -359,10 +359,13 @@ if test "x$CXXFLAGS_overridden" = "xno"; then fi # fakeit does not work with GCC's devirtualization, which is enabled with -O2 or higher -FAKEIT_CXXFLAGS= +THIRD_PARTY_INCLUDE="-isystem ../third_party/include" + +FAKEIT_CXXFLAGS=$THIRD_PARTY_INCLUDE AX_CHECK_COMPILE_FLAG([-fno-devirtualize],[FAKEIT_CXXFLAGS="$FAKEIT_CXXFLAGS -fno-devirtualize"]) AX_CHECK_COMPILE_FLAG([-Wno-ignored-optimization-argument],[FAKEIT_CXXFLAGS="$FAKEIT_CXXFLAGS -Wno-ignored-optimization-argument"]) AC_SUBST(FAKEIT_CXXFLAGS) +CXXFLAGS="$CXXFLAGS $FAKEIT_CXXFLAGS" enable_hwcrc32=no enable_sse41=no diff --git a/src/Makefile.am b/src/Makefile.am index 5085a58946d50..c66b08d441999 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,9 +10,7 @@ AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps EXTRA_LIBRARIES = -FAKEIT_DIR = $(top_srcdir)/third_party/include -FAKEIT_HEADER = $(FAKEIT_DIR)/fakeit.hpp -THIRD_PARTY_INCLUDE = -isystem $(FAKEIT_DIR) + if EMBEDDED_UNIVALUE LIBUNIVALUE = univalue/libunivalue.la diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index a9827623cfc0c..0eb3d610904a4 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -2,8 +2,6 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -THIRD_PARTY_INCLUDE = -isystem $(top_srcdir)/third_party/include - bin_PROGRAMS += bench/bench_bitcoin BENCH_SRCDIR = bench BENCH_BINARY = bench/bench_bitcoin$(EXEEXT) @@ -46,7 +44,7 @@ bench_bench_bitcoin_SOURCES = \ nodist_bench_bench_bitcoin_SOURCES = $(GENERATED_BENCH_FILES) bench_bench_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CLFAGS) $(EVENT_PTHREADS_CFLAGS) -I$(builddir)/bench/ -bench_bench_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(THIRD_PARTY_INCLUDE) +bench_bench_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(FAKEIT_CXXFLAGS) bench_bench_bitcoin_LDADD = \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_WALLET) \ diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index cf09eee2cbdfb..fb6479caf8dfc 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -314,7 +314,7 @@ qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GRPC_LIBS) qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) qt_bitcoin_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index 8c47fabad9f41..b79bebdc66619 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -56,7 +56,7 @@ endif qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(GRPC_LIBS) qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) qt_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 0cf99149d9359..5da8f123fbd32 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -233,7 +233,7 @@ BITCOIN_TEST_SUITE += \ endif test_test_bitcoin_SOURCES = $(BITCOIN_TEST_SUITE) $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES) -test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS) $(THIRD_PARTY_INCLUDE) +test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS) $(FAKEIT_CXXFLAGS) test_test_bitcoin_LDADD = $(LIBTEST_UTIL) if ENABLE_WALLET test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET) diff --git a/src/Makefile.test_util.include b/src/Makefile.test_util.include index f72ed7897d4ab..e6b4449baecc3 100644 --- a/src/Makefile.test_util.include +++ b/src/Makefile.test_util.include @@ -16,7 +16,7 @@ TEST_UTIL_H = \ test/util/transaction_utils.h \ test/util/wallet.h -libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) $(THIRD_PARTY_INCLUDE) +libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) $(FAKEIT_CXXFLAGS) libtest_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(FAKEIT_CXXFLAGS) libtest_util_a_SOURCES = \ test/util/blockfilter.cpp \ diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 09689e2d2b9b8..91fb24adc2c58 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -111,7 +111,7 @@ static bool AppInit(int argc, char* argv[]) VeriBlock::InitPopService( gArgs.GetArg("-althost", "127.0.0.1"), gArgs.GetArg("-altport", "19012"), - gArgs.GetBoolArg("-altautoconfig", true)); + gArgs.GetBoolArg("-altautoconfig", false)); if (!AppInitBasicSetup()) { @@ -155,8 +155,6 @@ static bool AppInit(int argc, char* argv[]) return false; } fRet = AppInitMain(node); - // connman is initialized in AppInitMain - VeriBlock::InitRpcService(node.connman.get()); } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); diff --git a/src/init.cpp b/src/init.cpp index eeca48c4c2773..d7280ad9e892a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1321,6 +1321,8 @@ bool AppInitMain(NodeContext& node) assert(!node.connman); node.connman = std::unique_ptr(new CConnman(GetRand(std::numeric_limits::max()), GetRand(std::numeric_limits::max()))); + VeriBlock::InitRpcService(node.connman.get()); + node.peer_logic.reset(new PeerLogicValidation(node.connman.get(), node.banman.get(), scheduler)); RegisterValidationInterface(node.peer_logic.get()); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 0021c3dbc7986..642aec3512d4d 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -6,6 +6,9 @@ #include #endif +#include +#include + #include #include @@ -406,6 +409,8 @@ int GuiMain(int argc, char* argv[]) util::WinCmdLineArgs winArgs; std::tie(argc, argv) = winArgs.get(); #endif + VeriBlock::InitUtilService(); + VeriBlock::InitConfig(); SetupEnvironment(); util::ThreadSetInternalName("main"); @@ -521,6 +526,11 @@ int GuiMain(int argc, char* argv[]) PaymentServer::ipcParseCommandLine(*node, argc, argv); #endif + VeriBlock::InitPopService( + gArgs.GetArg("-althost", "127.0.0.1"), + gArgs.GetArg("-altport", "19012"), + gArgs.GetBoolArg("-altautoconfig", false)); + QScopedPointer networkStyle(NetworkStyle::instantiate(Params().NetworkIDString())); assert(!networkStyle.isNull()); // Allow for separate UI settings for testnets diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 4cd9d687df22f..13686de80b9ad 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -176,7 +176,11 @@ TestChain100Setup::TestChain100Setup() // Create a new block with just given transactions, coinbase paying to // scriptPubKey, and try to add it to the current chain. -CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector& txns, const CScript& scriptPubKey) +CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector& txns, const CScript& scriptPubKey) { + return this->CreateAndProcessBlock(txns, scriptPubKey, nullptr); +} + +CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector& txns, const CScript& scriptPubKey, bool* isBlockValid) { const CChainParams& chainparams = Params(); std::unique_ptr pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey); @@ -196,7 +200,11 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector shared_pblock = std::make_shared(block); - ProcessNewBlock(chainparams, shared_pblock, true, nullptr); + + bool isValid = ProcessNewBlock(chainparams, shared_pblock, true, nullptr); + if(isBlockValid != nullptr) { + *isBlockValid = isValid; + } CBlock result = block; return result; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 9248c8e8a9da0..69287bb3cee80 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -123,6 +123,9 @@ struct TestChain100Setup : public RegTestingSetup { CBlock CreateAndProcessBlock(const std::vector& txns, const CScript& scriptPubKey); + CBlock CreateAndProcessBlock(const std::vector& txns, + const CScript& scriptPubKey, bool* isBlockValid); + ~TestChain100Setup() override; std::vector m_coinbase_txns; // For convenience, coinbase transactions diff --git a/src/validation.cpp b/src/validation.cpp index 064b160ace251..6fa64674b2ca7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3328,9 +3328,20 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu // First transaction must be coinbase, the rest must not be if (block.vtx.empty() || !block.vtx[0]->IsCoinBase()) return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-missing", "first tx is not coinbase"); - for (unsigned int i = 1; i < block.vtx.size(); i++) + + size_t totalPopTxes = 0; + for (unsigned int i = 1; i < block.vtx.size(); i++) { + if(VeriBlock::isPopTx(*block.vtx[i])) + ++totalPopTxes; + if (block.vtx[i]->IsCoinBase()) return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-multiple", "more than one coinbase"); + } + + auto& config = VeriBlock::getService(); + if(totalPopTxes > config.max_pop_tx_amount) { + return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "too many pop txes", "number of pop vtx in a block is too high"); + } // Check transactions // Must check for duplicate inputs (see CVE-2018-17144) diff --git a/src/vbk/config.hpp b/src/vbk/config.hpp index e8c08d339435f..74d1d09b62f35 100644 --- a/src/vbk/config.hpp +++ b/src/vbk/config.hpp @@ -45,8 +45,6 @@ struct Config { /// The maximum allowed number of PoP transaction in a block uint32_t max_pop_tx_amount = 50; - /// The maximum allowed number of "UpdateContext" transactions in a block - uint32_t max_update_context_tx_amount = 1; /////// Pop Rewards section start diff --git a/src/vbk/pop_service/pop_service_impl.cpp b/src/vbk/pop_service/pop_service_impl.cpp index 5938bafaae07e..65071f773e5b4 100644 --- a/src/vbk/pop_service/pop_service_impl.cpp +++ b/src/vbk/pop_service/pop_service_impl.cpp @@ -14,8 +14,8 @@ #include