diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 304e39a..2e7234d 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2505,7 +2505,30 @@ void database::update_last_irreversible_block() wit_objs.reserve( wso.num_scheduled_witnesses ); for( int i = 0; i < wso.num_scheduled_witnesses; i++ ) wit_objs.push_back( &get_witness( wso.current_shuffled_witnesses[i] ) ); + + if (head_block_num() > 27654722) + { + static_assert( SMOKE_IRREVERSIBLE_THRESHOLD_0_1 > 0, "irreversible threshold must be nonzero" ); + size_t offset = ((SMOKE_100_PERCENT - SMOKE_IRREVERSIBLE_THRESHOLD_0_1) * wit_objs.size() / SMOKE_100_PERCENT); + std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(), + []( const witness_object* a, const witness_object* b ) + { + return a->last_confirmed_block_num < b->last_confirmed_block_num; + } ); + uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num; + + if( new_last_irreversible_block_num > dpo.last_irreversible_block_num ) + { + modify( dpo, [&]( dynamic_global_property_object& _dpo ) + { + _dpo.last_irreversible_block_num = new_last_irreversible_block_num; + } ); + } + } + else + { + static_assert( SMOKE_IRREVERSIBLE_THRESHOLD > 0, "irreversible threshold must be nonzero" ); // 1 1 1 2 2 2 2 2 2 2 -> 2 .7*10 = 7 @@ -2513,8 +2536,7 @@ void database::update_last_irreversible_block() // 3 3 3 3 3 3 3 3 3 3 -> 3 size_t offset = ((SMOKE_100_PERCENT - SMOKE_IRREVERSIBLE_THRESHOLD) * wit_objs.size() / SMOKE_100_PERCENT); - - std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(), + std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(), []( const witness_object* a, const witness_object* b ) { return a->last_confirmed_block_num < b->last_confirmed_block_num; @@ -2529,6 +2551,8 @@ void database::update_last_irreversible_block() _dpo.last_irreversible_block_num = new_last_irreversible_block_num; } ); } + } + } commit( dpo.last_irreversible_block_num ); diff --git a/libraries/chain/witness_schedule.cpp b/libraries/chain/witness_schedule.cpp index fff4de1..473a229 100644 --- a/libraries/chain/witness_schedule.cpp +++ b/libraries/chain/witness_schedule.cpp @@ -168,7 +168,7 @@ void update_witness_schedule4( database& db ) } size_t expected_active_witnesses = std::min( size_t(SMOKE_MAX_WITNESSES), widx.size() ); - if (db.head_block_num() > 12000000) { + if (db.head_block_num() > 52000000) { FC_ASSERT( active_witnesses.size() == expected_active_witnesses, "number of active witnesses does not equal expected_active_witnesses=${expected_active_witnesses}", ("active_witnesses.size()",active_witnesses.size()) ("SMOKE_MAX_WITNESSES",SMOKE_MAX_WITNESSES) ("expected_active_witnesses", expected_active_witnesses) ); } diff --git a/libraries/protocol/include/smoke/protocol/config.hpp b/libraries/protocol/include/smoke/protocol/config.hpp index abb9750..ca655ae 100644 --- a/libraries/protocol/include/smoke/protocol/config.hpp +++ b/libraries/protocol/include/smoke/protocol/config.hpp @@ -141,6 +141,8 @@ #define SMOKE_MIN_TRANSACTION_EXPIRATION_LIMIT (SMOKE_BLOCK_INTERVAL * 5) // 5 transactions per block #define SMOKE_IRREVERSIBLE_THRESHOLD (75 * SMOKE_1_PERCENT) + +#define SMOKE_IRREVERSIBLE_THRESHOLD_0_1 (40 * SMOKE_1_PERCENT) #define VIRTUAL_SCHEDULE_LAP_LENGTH ( fc::uint128::max_value() ) /**