Skip to content
Open

Hf5 #424

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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" )
Expand All @@ -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)
5 changes: 4 additions & 1 deletion libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,17 @@ namespace detail {
if( _options->count("checkpoint") )
{
auto cps = _options->at("checkpoint").as<std::vector<std::string>>();
loaded_checkpoints.reserve( cps.size() );
loaded_checkpoints.reserve( cps.size()+1 );
for( auto cp : cps )
{
auto item = fc::json::from_string(cp).as<std::pair<uint32_t,block_id_type> >();
loaded_checkpoints[item.first] = item.second;
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 );

Expand Down
18 changes: 17 additions & 1 deletion libraries/chain/db_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/hardfork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
};

} }
4 changes: 4 additions & 0 deletions libraries/chain/include/graphene/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libraries/chain/include/graphene/chain/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand All @@ -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" )
Expand Down
7 changes: 6 additions & 1 deletion libraries/chain/include/graphene/chain/hardfork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace graphene { namespace chain {

using fork_times_t = std::array<fc::time_point_sec, 4>;
using fork_times_t = std::array<fc::time_point_sec, 5>;
extern fork_times_t fork_times;

} }
Expand All @@ -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
2 changes: 1 addition & 1 deletion libraries/plugins/miner/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down