Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dpos pbft bos upgrade: fix snapshot compatibility; add pbft_api plugin; fix bugs #98

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a28493e
fix potential crash when calculating integrity hash
VincentOCL May 14, 2019
8dad318
fix snapshot's container reading in different os.
VincentOCL May 14, 2019
37beebe
reformat snapshot sections; reformat getting block state in pbft_db.
VincentOCL May 15, 2019
ec893e6
Merge branch 'develop' into feature/dpos-pbft-bos-upgrade
oldcold May 15, 2019
1cc5e17
re-struct pbft message; compress pbft new view
May 17, 2019
902177a
add new view primary check; add debug info during prepare (commit) in…
May 18, 2019
cf75956
optimise cal in `should_recv_pbft_msg` and `should_send_pbft_msg`; do…
May 21, 2019
3c45326
generate pbft watermark from forkdb.
May 22, 2019
303c12d
generate pbft watermark from forkdb.
May 22, 2019
0f63be7
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
VincentOCL May 28, 2019
f475fa6
add pbft_api_plugin
May 29, 2019
8a1c39c
increase pbft message deadline
May 30, 2019
56110e0
increase new view message deadline; add prepared & my_prepare in pbft…
May 30, 2019
7b241d5
re-struct pbft message; compress pbft new view
May 17, 2019
3b7068b
fix bug in new view decompression.
May 31, 2019
601c8c6
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade-sl…
VincentOCL May 31, 2019
fd444d2
optimise scp sync; move upo creation into `update_pbft_status`;
Jun 2, 2019
a63265f
fix bug in loading old version snapshots.
Jun 3, 2019
45ad108
add message_type in pbft messages; refactor code.
Jun 4, 2019
dde4c39
Merge branch 'feature/dpos-pbft-bos-upgrade-slim' into feature/dpos-p…
VincentOCL Jun 6, 2019
7c9404e
remove pbft controller config; fix net layer bugs.
Jun 6, 2019
74bde5c
bug fix: view change certs generation;
Jun 6, 2019
2ffcf15
retry sending all pending checkpoints;
Jun 7, 2019
299f82f
check all prepares (commits) fall on the same fork during generating …
Jun 8, 2019
01775ea
add pre_prepares in prepared_cert, requesting missing blocks upon vie…
Jun 11, 2019
a3d05a0
bug fix: reset view change state cache properly.
Jun 12, 2019
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
26 changes: 13 additions & 13 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace eosio { namespace chain {
* contain a transaction mroot, action mroot, or new_producers as those components
* are derived from chain state.
*/
block_header_state block_header_state::generate_next( block_timestamp_type when, bool new_version )const {
block_header_state block_header_state::generate_next( block_timestamp_type when, bool pbft_enabled )const {
block_header_state result;

if( when != block_timestamp_type() ) {
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace eosio { namespace chain {
result.pbft_stable_checkpoint_blocknum = pbft_stable_checkpoint_blocknum;


if (new_version) {
if (pbft_enabled) {
result.dpos_irreversible_blocknum = dpos_irreversible_blocknum;
} else {
result.producer_to_last_implied_irb[prokey.producer_name] = result.dpos_proposed_irreversible_blocknum;
Expand All @@ -81,7 +81,7 @@ namespace eosio { namespace chain {
auto num_active_producers = active_schedule.producers.size();
uint32_t required_confs = (uint32_t)(num_active_producers * 2 / 3) + 1;

if (!new_version) {
if (!pbft_enabled) {
if (confirm_count.size() < config::maximum_tracked_dpos_confirmations) {
result.confirm_count.reserve(confirm_count.size() + 1);
result.confirm_count = confirm_count;
Expand All @@ -97,10 +97,10 @@ namespace eosio { namespace chain {
return result;
} /// generate_next

bool block_header_state::maybe_promote_pending( bool new_version ) {
bool block_header_state::maybe_promote_pending( bool pbft_enabled ) {

bool should_promote_pending = pending_schedule.producers.size();
if ( !new_version ) {
if ( !pbft_enabled ) {
should_promote_pending = should_promote_pending && dpos_irreversible_blocknum >= pending_schedule_lib_num;
}

Expand All @@ -115,7 +115,7 @@ namespace eosio { namespace chain {
new_producer_to_last_produced[pro.producer_name] = existing->second;
} else {
//TODO: max of bft and dpos lib
if (new_version) {
if (pbft_enabled) {
new_producer_to_last_produced[pro.producer_name] = bft_irreversible_blocknum;
} else {
new_producer_to_last_produced[pro.producer_name] = dpos_irreversible_blocknum;
Expand All @@ -131,7 +131,7 @@ namespace eosio { namespace chain {
new_producer_to_last_implied_irb[pro.producer_name] = existing->second;
} else {
//TODO: max of bft and dpos lib
if (new_version) {
if (pbft_enabled) {
new_producer_to_last_implied_irb[pro.producer_name] = bft_irreversible_blocknum;
} else {
new_producer_to_last_implied_irb[pro.producer_name] = dpos_irreversible_blocknum;
Expand Down Expand Up @@ -168,13 +168,13 @@ namespace eosio { namespace chain {
*
* If the header specifies new_producers then apply them accordingly.
*/
block_header_state block_header_state::next( const signed_block_header& h, bool skip_validate_signee, bool new_version )const {
block_header_state block_header_state::next( const signed_block_header& h, bool skip_validate_signee, bool pbft_enabled )const {
EOS_ASSERT( h.timestamp != block_timestamp_type(), block_validate_exception, "", ("h",h) );
//EOS_ASSERT( h.header_extensions.size() == 0, block_validate_exception, "no supported extensions" );

EOS_ASSERT( h.timestamp > header.timestamp, block_validate_exception, "block must be later in time" );
EOS_ASSERT( h.previous == id, unlinkable_block_exception, "block must link to current state" );
auto result = generate_next( h.timestamp, new_version);
auto result = generate_next( h.timestamp, pbft_enabled);
EOS_ASSERT( result.header.producer == h.producer, wrong_producer, "wrong producer specified" );
EOS_ASSERT( result.header.schedule_version == h.schedule_version, producer_schedule_exception, "schedule_version in signed block is corrupted" );

Expand All @@ -189,10 +189,10 @@ namespace eosio { namespace chain {
/// must result in header state changes


result.set_confirmed(h.confirmed, new_version);
result.set_confirmed(h.confirmed, pbft_enabled);


auto was_pending_promoted = result.maybe_promote_pending(new_version);
auto was_pending_promoted = result.maybe_promote_pending(pbft_enabled);

if( h.new_producers ) {
EOS_ASSERT( !was_pending_promoted, producer_schedule_exception, "cannot set pending producer schedule in the same block in which pending was promoted to active" );
Expand All @@ -214,15 +214,15 @@ namespace eosio { namespace chain {
return result;
} /// next

void block_header_state::set_confirmed( uint16_t num_prev_blocks, bool new_version ) {
void block_header_state::set_confirmed( uint16_t num_prev_blocks, bool pbft_enabled ) {
/*
idump((num_prev_blocks)(confirm_count.size()));

for( uint32_t i = 0; i < confirm_count.size(); ++i ) {
std::cerr << "confirm_count["<<i<<"] = " << int(confirm_count[i]) << "\n";
}
*/
if (new_version) {
if (pbft_enabled) {
header.confirmed = 0;
return;
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace eosio { namespace chain {

block_state::block_state( const block_header_state& prev, block_timestamp_type when, bool new_version )
:block_header_state( prev.generate_next( when, new_version) ),
block_state::block_state( const block_header_state& prev, block_timestamp_type when, bool pbft_enabled )
:block_header_state( prev.generate_next( when, pbft_enabled) ),
block( std::make_shared<signed_block>() )
{
static_cast<block_header&>(*block) = header;
}

block_state::block_state( const block_header_state& prev, signed_block_ptr b, bool skip_validate_signee, bool new_version )
:block_header_state( prev.next( *b, skip_validate_signee, new_version)), block( move(b) )
block_state::block_state( const block_header_state& prev, signed_block_ptr b, bool skip_validate_signee, bool pbft_enabled )
:block_header_state( prev.next( *b, skip_validate_signee, pbft_enabled)), block( move(b) )
{ }


Expand Down
Loading