From 695eea83b2cd0f2b5914d8f377e5d6c645675b3a Mon Sep 17 00:00:00 2001 From: m0ssa99 Date: Fri, 28 May 2021 06:04:28 +0000 Subject: [PATCH 1/3] expected_active_witnesses2 --- libraries/chain/witness_schedule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) ); } From cee78fc98d201d976e1caf31e58fdee932bcf2f0 Mon Sep 17 00:00:00 2001 From: m0ssa99 Date: Fri, 28 May 2021 15:04:13 +0000 Subject: [PATCH 2/3] Change max witness to 12 --- libraries/protocol/include/smoke/protocol/config.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/protocol/include/smoke/protocol/config.hpp b/libraries/protocol/include/smoke/protocol/config.hpp index abb9750..2161af0 100644 --- a/libraries/protocol/include/smoke/protocol/config.hpp +++ b/libraries/protocol/include/smoke/protocol/config.hpp @@ -55,7 +55,7 @@ #define SMOKE_BLOCKS_PER_DAY (24*60*60/SMOKE_BLOCK_INTERVAL) #define SMOKE_START_MINER_VOTING_BLOCK (1 * 30) // (SMOKE_BLOCKS_PER_DAY * 30) -#define SMOKE_MAX_WITNESSES 21 +#define SMOKE_MAX_WITNESSES 12 #define SMOKE_INIT_MINER_NAME "initminer" @@ -63,7 +63,7 @@ #define SMOKE_MAX_MINER_WITNESSES 0 #define SMOKE_MAX_RUNNER_WITNESSES 1 -#define SMOKE_HARDFORK_REQUIRED_WITNESSES 17 // 17 of the 21 dpos witnesses (20 elected and 1 virtual time) required for hardfork. This guarantees 75% participation on all subsequent rounds. +#define SMOKE_HARDFORK_REQUIRED_WITNESSES 9 // 17 of the 21 dpos witnesses (20 elected and 1 virtual time) required for hardfork. This guarantees 75% participation on all subsequent rounds. #define SMOKE_MAX_TIME_UNTIL_EXPIRATION (60*60) // seconds, aka: 1 hour #define SMOKE_MAX_MEMO_SIZE 2048 #define SMOKE_MAX_PROXY_RECURSION_DEPTH 4 From 3b571f4d55c04726590f45d41e8daa7795e1b71a Mon Sep 17 00:00:00 2001 From: m0ssa99 Date: Thu, 3 Jun 2021 20:31:20 +0000 Subject: [PATCH 3/3] Change minim witness for LIB --- libraries/chain/database.cpp | 28 +++++++++++++++++-- .../include/smoke/protocol/config.hpp | 6 ++-- 2 files changed, 30 insertions(+), 4 deletions(-) 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/protocol/include/smoke/protocol/config.hpp b/libraries/protocol/include/smoke/protocol/config.hpp index 2161af0..ca655ae 100644 --- a/libraries/protocol/include/smoke/protocol/config.hpp +++ b/libraries/protocol/include/smoke/protocol/config.hpp @@ -55,7 +55,7 @@ #define SMOKE_BLOCKS_PER_DAY (24*60*60/SMOKE_BLOCK_INTERVAL) #define SMOKE_START_MINER_VOTING_BLOCK (1 * 30) // (SMOKE_BLOCKS_PER_DAY * 30) -#define SMOKE_MAX_WITNESSES 12 +#define SMOKE_MAX_WITNESSES 21 #define SMOKE_INIT_MINER_NAME "initminer" @@ -63,7 +63,7 @@ #define SMOKE_MAX_MINER_WITNESSES 0 #define SMOKE_MAX_RUNNER_WITNESSES 1 -#define SMOKE_HARDFORK_REQUIRED_WITNESSES 9 // 17 of the 21 dpos witnesses (20 elected and 1 virtual time) required for hardfork. This guarantees 75% participation on all subsequent rounds. +#define SMOKE_HARDFORK_REQUIRED_WITNESSES 17 // 17 of the 21 dpos witnesses (20 elected and 1 virtual time) required for hardfork. This guarantees 75% participation on all subsequent rounds. #define SMOKE_MAX_TIME_UNTIL_EXPIRATION (60*60) // seconds, aka: 1 hour #define SMOKE_MAX_MEMO_SIZE 2048 #define SMOKE_MAX_PROXY_RECURSION_DEPTH 4 @@ -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() ) /**