diff --git a/CMakeLists.txt b/CMakeLists.txt index e1586fe4..ff2cc9b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if (POLICY CMP0048) endif() cmake_minimum_required( VERSION 3.10.2 FATAL_ERROR ) -project( DCore VERSION 1.5.0 LANGUAGES CXX ) +project( DCore VERSION 1.5.2 LANGUAGES CXX ) if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1 ) @@ -165,7 +165,7 @@ set_property( TARGET gmp PROPERTY IMPORTED_LOCATION "${GMP_LIBRARIES}" ) set_property( TARGET gmp PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}" ) find_path( PBC_INCLUDE_DIR NAMES "pbc.h" "pbc/pbc.h" ) -find_library( PBC_LIBRARIES NAMES "pbc" "pbclib.lib" ) +find_library( PBC_LIBRARIES NAMES "libpbc.a" "pbc" "pbclib.lib" ) if( NOT PBC_INCLUDE_DIR ) message( FATAL_ERROR "PBC includes not found" ) @@ -177,10 +177,16 @@ endif() mark_as_advanced( PBC_LIBRARIES PBC_INCLUDE_DIR ) message( STATUS "Found PBC: ${PBC_INCLUDE_DIR}, ${PBC_LIBRARIES}" ) -add_library( pbc UNKNOWN IMPORTED ) +add_library( pbc STATIC IMPORTED ) set_property( TARGET pbc PROPERTY IMPORTED_LOCATION "${PBC_LIBRARIES}" ) set_property( TARGET pbc PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${PBC_INCLUDE_DIR}" ) add_subdirectory( libraries ) add_subdirectory( programs ) add_subdirectory( tests ) + + +SET(CPACK_GENERATOR "DEB") +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libreadline8,libcrypto++6,libgmp10,libssl1.1,libcurl4,zlib1g") +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "decent") #required +INCLUDE(CPack) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 89427dda..e4a67132 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -358,7 +358,7 @@ namespace detail { if( _options->count("checkpoint") ) { auto cps = _options->at("checkpoint").as>(); - loaded_checkpoints.reserve( cps.size() ); + loaded_checkpoints.reserve( cps.size()+1 ); for( auto cp : cps ) { auto item = fc::json::from_string(cp).as >(); @@ -366,6 +366,9 @@ namespace detail { ilog ( "loaded checkpoint ${s} at ${n}", ("s",loaded_checkpoints[item.first])("n", item.first)); } } + // Add default checkpoint - HF5 + loaded_checkpoints[27651520] = block_id_type("01a5edc06b20df0874258b360583f057f5777ebc"); + ilog ( "loaded HF5 checkpoint ${s} at ${n}", ("s",loaded_checkpoints[27651520])("n", 27651520)); _chain_db->add_checkpoints( loaded_checkpoints ); diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index a7a0d5cb..0c8af79e 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -158,12 +158,14 @@ void database::update_last_irreversible_block() wit_objs.push_back( &(wid(*this)) ); static_assert( GRAPHENE_IRREVERSIBLE_THRESHOLD > 0, "irreversible threshold must be nonzero" ); + static_assert( GRAPHENE_IRREVERSIBLE_THRESHOLD_HF5 > 0, "irreversible threshold must be nonzero" ); // 1 1 1 2 2 2 2 2 2 2 -> 2 .7*10 = 7 // 1 1 1 1 1 1 1 2 2 2 -> 1 // 3 3 3 3 3 3 3 3 3 3 -> 3 - size_t offset = ((GRAPHENE_100_PERCENT - GRAPHENE_IRREVERSIBLE_THRESHOLD) * wit_objs.size() / GRAPHENE_100_PERCENT); + size_t irreversible_threshold = head_block_time() > HARDFORK_5_TIME ? GRAPHENE_IRREVERSIBLE_THRESHOLD_HF5 : GRAPHENE_IRREVERSIBLE_THRESHOLD; + size_t offset = ((GRAPHENE_100_PERCENT - irreversible_threshold) * wit_objs.size() / GRAPHENE_100_PERCENT); std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(), []( const miner_object* a, const miner_object* b ) @@ -173,6 +175,20 @@ void database::update_last_irreversible_block() uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num; + // add check that there is not only one miner for last DECENT_MAX_BLOCKS_SINGLE_MINER_GROUP + // where DECENT_SINGLE_MINER_GROUP_SIZE + size_t miner_group_size_offset = wit_objs.size() - DECENT_SINGLE_MINER_GROUP_SIZE; + size_t max_blocks_group= DECENT_MAX_BLOCKS_SINGLE_MINER_GROUP; + std::nth_element( wit_objs.begin(), wit_objs.begin() + miner_group_size_offset, wit_objs.end(), + []( const miner_object* a, const miner_object* b ) + { + return a->last_confirmed_block_num < b->last_confirmed_block_num; + } ); + + FC_VERIFY_AND_THROW( head_block_num() <= max_blocks_group + wit_objs[miner_group_size_offset]->last_confirmed_block_num, + too_many_blocks_by_single_group_exception, "Too many unconfirmed blocks by single miner group", ("head_block_num", head_block_num()) + ("nth miner last confirmed block", wit_objs[miner_group_size_offset]->last_confirmed_block_num)); + if( new_last_irreversible_block_num > dpo.last_irreversible_block_num ) { modify( dpo, [&]( dynamic_global_property_object& _dpo ) diff --git a/libraries/chain/hardfork.cpp b/libraries/chain/hardfork.cpp index e6e3e097..7315f843 100644 --- a/libraries/chain/hardfork.cpp +++ b/libraries/chain/hardfork.cpp @@ -6,7 +6,8 @@ fork_times_t fork_times = { fc::time_point_sec::from_iso_string("2017-11-08T12:00:00"), fc::time_point_sec::from_iso_string("2018-04-23T08:00:00"), fc::time_point_sec::from_iso_string("2018-09-13T08:00:00"), - fc::time_point_sec::from_iso_string("2019-07-11T08:00:00") + fc::time_point_sec::from_iso_string("2019-07-11T08:00:00"), + fc::time_point_sec::from_iso_string("2022-03-17T08:00:00") }; } } diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 0b4bffa1..fd52390e 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -74,6 +74,9 @@ #define GRAPHENE_MIN_UNDO_HISTORY 10 #define GRAPHENE_MAX_UNDO_HISTORY 10000 +#define DECENT_MAX_BLOCKS_SINGLE_MINER_GROUP 500 +#define DECENT_SINGLE_MINER_GROUP_SIZE 2 + #define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block @@ -105,6 +108,7 @@ #define GRAPHENE_CURRENT_DB_VERSION "DCT1.5.0" #define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) +#define GRAPHENE_IRREVERSIBLE_THRESHOLD_HF5 (55 * GRAPHENE_1_PERCENT) /** * Reserved Account IDs with special meaning diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index 5d81d1b5..3383cc89 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -86,7 +86,8 @@ namespace graphene { namespace chain { insufficient_fee_code = 11, trx_must_have_at_least_one_op_code = 12, invalid_pts_address_code = 13, - pop_empty_chain_code = 14 + pop_empty_chain_code = 14, + too_many_blocks_by_single_group_code = 15, }; FC_DECLARE_EXCEPTION( chain_exception, 400, "blockchain exception" ) @@ -112,6 +113,7 @@ namespace graphene { namespace chain { FC_DECLARE_CHAIN_EXCEPTION( trx_must_have_at_least_one_op_exception, trx_must_have_at_least_one_op_code, "Transaction must have at least one operation.") FC_DECLARE_CHAIN_EXCEPTION( invalid_pts_address_exception, invalid_pts_address_code, "Invalid pts address." ) FC_DECLARE_CHAIN_EXCEPTION( pop_empty_chain_exception, pop_empty_chain_code, "There are no blocks to pop." ) + FC_DECLARE_CHAIN_EXCEPTION( too_many_blocks_by_single_group_exception, too_many_blocks_by_single_group_code, "There are too many unfonfirmed blocks by single group." ) GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( account_create ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_create, 1, "Exceeds max authority fan-out" ) diff --git a/libraries/chain/include/graphene/chain/hardfork.hpp b/libraries/chain/include/graphene/chain/hardfork.hpp index b35cea27..a630459b 100644 --- a/libraries/chain/include/graphene/chain/hardfork.hpp +++ b/libraries/chain/include/graphene/chain/hardfork.hpp @@ -5,7 +5,7 @@ namespace graphene { namespace chain { -using fork_times_t = std::array; +using fork_times_t = std::array; extern fork_times_t fork_times; } } @@ -29,3 +29,8 @@ extern fork_times_t fork_times; #ifndef HARDFORK_4_TIME #define HARDFORK_4_TIME graphene::chain::fork_times[3] #endif + +// #5 - Change irreversible threshold +#ifndef HARDFORK_5_TIME +#define HARDFORK_5_TIME graphene::chain::fork_times[4] +#endif diff --git a/libraries/plugins/miner/miner.cpp b/libraries/plugins/miner/miner.cpp index 3347080b..cee56203 100644 --- a/libraries/plugins/miner/miner.cpp +++ b/libraries/plugins/miner/miner.cpp @@ -140,7 +140,7 @@ void miner_plugin::plugin_startup() { if( d.head_block_num() == 0 ) new_chain_banner(d); - _production_skip_flags |= graphene::chain::database::skip_undo_history_check; + //_production_skip_flags |= graphene::chain::database::skip_undo_history_check; _production_skip_flags |= graphene::chain::database::skip_transaction_signatures; } schedule_production_loop();