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

perpare to release the batch-pbft version #88

Merged
merged 80 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
1e95f15
resolve conflicts of net message sending, enqueue pbft msgs into sync…
VincentOCL Mar 19, 2019
c20cee9
merge pbft feature into bos, resolve conflicts in block extension usage
VincentOCL Mar 20, 2019
7bda6a3
fix merge error in get_table_tests
VincentOCL Mar 20, 2019
22acbf9
txn plugin now use system newaccount to create account and support cu…
qianxiaofeng Mar 5, 2019
a1ee007
don't stop if push transaction failed
qianxiaofeng Mar 21, 2019
cb89b32
don't stop if push transaction failed
qianxiaofeng Mar 22, 2019
037dbb6
bug fix: cannot find block, use block state ptr to mark pbft prepare …
VincentOCL Mar 25, 2019
f564829
Merge branch 'feature/dpos-pbft-bos-v2.0.2' into feature/bos-dpos-pbf…
qianxiaofeng Mar 25, 2019
5679479
clear prepared (my prepare) id when it becomes invalid.
VincentOCL Mar 28, 2019
1977fc0
init commit for upgrade solution
VincentOCL Mar 29, 2019
1ec967e
add migration function, hack load function for forkdb.dat
qianxiaofeng Mar 30, 2019
55fcd20
hardcoded consensus upgrade at 1000.
VincentOCL Apr 2, 2019
0493444
disable proposed schedule promotion during upgrading
VincentOCL Apr 3, 2019
8b737cc
add system contract support
VincentOCL Apr 3, 2019
35ce2cf
add upo assertion, target block num must be at least 100 more than cu…
VincentOCL Apr 4, 2019
2e96766
some code reformat
VincentOCL Apr 4, 2019
d424438
add newly built system contract to `contracts/eosio.system` folder
VincentOCL Apr 4, 2019
458be93
add pbft_plugin as default plugins
VincentOCL Apr 5, 2019
dab790e
revert eosio.system contract; upgrade version can be found from a for…
VincentOCL Apr 5, 2019
5d90ba1
txn plugin now use system newaccount to create account and support cu…
qianxiaofeng Mar 22, 2019
1d02e6f
Merge branch 'feature/dpos-pbft-bos-upgrade' into test_bos_master
qianxiaofeng Apr 10, 2019
434385f
try to fix gpo propose block num inconsistent bug
qianxiaofeng Apr 10, 2019
e61b533
solve consensus chosen conflict when upgrade
qianxiaofeng Apr 12, 2019
28605a3
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
Apr 12, 2019
4ab5c0f
bug fix: shouldn't print upgrade log when chain is fresh started
qianxiaofeng Apr 12, 2019
6d68dc3
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
Apr 12, 2019
2d60f58
reject target setting when it is upgrading or has just upgraded.
VincentOCL Apr 15, 2019
83427a1
add new view related log.
VincentOCL Apr 15, 2019
c9cfa3e
add new view sending related log.
VincentOCL Apr 15, 2019
387d55a
add new view transition raw bytes.
VincentOCL Apr 16, 2019
1f27be4
print all error raw bytes.
VincentOCL Apr 17, 2019
9ebb308
add error net message length.
VincentOCL Apr 17, 2019
e87b2d1
move local buf vector into connection
VincentOCL Apr 17, 2019
d11e76e
Revert "move local buf vector into connection"
VincentOCL Apr 17, 2019
6f0f7b9
add new view transition raw bytes.
VincentOCL Apr 17, 2019
58e5f39
reformat some functions
VincentOCL Apr 18, 2019
48f54b6
Merge branch 'feature/dpos-pbft-bos-upgrade' into feature/bos-dpos-pb…
qianxiaofeng Apr 18, 2019
1b16811
remove debug logs.
VincentOCL Apr 18, 2019
52ec637
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
qianxiaofeng Apr 18, 2019
ebf8d3b
stop setting head as my prepare during switching fork
VincentOCL Apr 18, 2019
b6382fc
mark pbft prepared (my prepared) with previous block's attr upon adding
VincentOCL Apr 18, 2019
59c4aef
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
qianxiaofeng Apr 18, 2019
06ebc4a
wait a while for edge case when conn reset
qianxiaofeng Apr 19, 2019
9514546
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
qianxiaofeng Apr 19, 2019
f10f136
Merge branch 'feature/bos-dpos-pbft-tps' into feature/dpos-pbft-bos-u…
qianxiaofeng Apr 22, 2019
2ef3770
merge develop
qianxiaofeng Apr 22, 2019
08b5ba5
resolve conflicts in fork db prune
VincentOCL Apr 22, 2019
55a94a7
attempt switching forks upon new view.
VincentOCL Apr 22, 2019
19f0894
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
qianxiaofeng Apr 22, 2019
a540740
stop switching upon new view
VincentOCL Apr 22, 2019
8094eeb
skip watermark check in new version
VincentOCL Apr 22, 2019
8679765
remove all my prepare mark upon new view; using transit_to_committed …
VincentOCL Apr 23, 2019
c8092f7
bug fix: itr bug during removing marks
VincentOCL Apr 23, 2019
5093652
Merge branch 'feature/dpos-pbft-bos-upgrade' into feature/dpos-pbft-b…
qianxiaofeng Apr 24, 2019
c5bea21
Merge branch 'feature/dpos-pbft-bos-upgrade' into feature/dpos-pbft-b…
qianxiaofeng Apr 24, 2019
06aa979
fix unit_test
qianxiaofeng Apr 24, 2019
3b48e8e
Merge remote-tracking branch 'remotes/origin/feature/dpos-pbft-bos-up…
VincentOCL Apr 25, 2019
9f1e648
add prepare watermarks
VincentOCL Apr 25, 2019
de03c3d
bug fix: only request checkpoints in new version
VincentOCL Apr 25, 2019
ef0ccfa
resolve inconsistency in `is_upgrading` calculation.
VincentOCL Apr 26, 2019
1231a2b
bug fix: return empty if upgrade target block equals to default.
VincentOCL Apr 26, 2019
4a637f6
bug fix: compare schedule between pending checkpoint & lscb (instead …
VincentOCL Apr 26, 2019
8f305f5
bug fix: modified the start of new version
VincentOCL Apr 27, 2019
9f44c2e
bug fix: add null ptr check during fetching scp from blk extn.
VincentOCL Apr 27, 2019
d9c9a54
add upgrade related log.
VincentOCL Apr 27, 2019
d1a9009
migration support for snapshot
qianxiaofeng Apr 27, 2019
b4bdc9e
Merge branch 'feature/dpos-pbft-bos-upgrade' of https://github.com/eo…
qianxiaofeng Apr 27, 2019
66e7de2
upgrade log formatted
VincentOCL Apr 27, 2019
b85b91e
change type of ucb in upo.
VincentOCL Apr 28, 2019
4c24d23
bugfix: snapshot migration prefer vector<char> to string
qianxiaofeng Apr 28, 2019
630154a
add new version debug log
VincentOCL Apr 28, 2019
0490bff
mark fork_db regardless of the version; new version now is when head …
VincentOCL Apr 29, 2019
be6c4f5
add more log , to be revert soon
qianxiaofeng Apr 29, 2019
bff6990
bug fix: force generate upo if not found.
VincentOCL Apr 29, 2019
4eebe6a
fix unit test
qianxiaofeng Apr 29, 2019
ee63bfa
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
qianxiaofeng Apr 29, 2019
9f0cde3
remove debug log; reformat new view validation; revert txn_test_gen_p…
VincentOCL Apr 30, 2019
cd99520
Merge remote-tracking branch 'origin/feature/dpos-pbft-bos-upgrade' i…
VincentOCL Apr 30, 2019
57e14e4
Merge branch 'develop' into feature/dpos-pbft-bos-upgrade
qianxiaofeng Apr 30, 2019
d3e4f5f
Merge pull request #87 from eosiosg/feature/dpos-pbft-bos-upgrade
Thaipanda Apr 30, 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
2 changes: 1 addition & 1 deletion contracts/eosio.system/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace eosiosystem {

auto fee = ( tokens_out.amount + 199 ) / 200; /// .5% fee (round up)
// since tokens_out.amount was asserted to be at least 2 earlier, fee.amount < tokens_out.amount

if( fee > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {account,N(active)},
{ account, N(eosio.ramfee), asset(fee), std::string("sell ram fee") } );
Expand Down
2 changes: 1 addition & 1 deletion contracts/eosio.system/eosio.system.abi
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,4 @@
],
"ricardian_clauses": [],
"abi_extensions": []
}
}
2 changes: 1 addition & 1 deletion contracts/eosio.system/exchange_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace eosiosystem {

uint64_t primary_key()const { return supply.symbol; }

asset convert_to_exchange( connector& c, asset in );
asset convert_to_exchange( connector& c, asset in );
asset convert_from_exchange( connector& c, asset in );
asset convert( asset from, symbol_type to );

Expand Down
7 changes: 7 additions & 0 deletions contracts/eosiolib/eosiolib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ namespace eosio {
ds >> params;
}

void set_upgrade_parameters(const eosio::upgrade_parameters& params) {
char buf[sizeof(eosio::upgrade_parameters)];
eosio::datastream<char *> ds( buf, sizeof(buf) );
ds << params;
set_upgrade_parameters_packed( buf, ds.tellp() );
}

using ::memset;
using ::memcpy;

Expand Down
1 change: 1 addition & 0 deletions contracts/eosiolib/privileged.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ extern "C" {
*/
uint32_t get_blockchain_parameters_packed(char* data, uint32_t datalen);

void set_upgrade_parameters_packed(char* data, uint32_t datalen);
/**
* @brief Activate new feature
* Activate new feature
Expand Down
10 changes: 10 additions & 0 deletions contracts/eosiolib/privileged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ namespace eosio {
)
};

struct upgrade_parameters {
uint32_t target_block_num;

EOSLIB_SERIALIZE(upgrade_parameters,
(target_block_num)
)
};

/**
* @brief Set the blockchain parameters
* Set the blockchain parameters
Expand All @@ -122,6 +130,8 @@ namespace eosio {
*/
void get_blockchain_parameters(eosio::blockchain_parameters& params);

void set_upgrade_parameters(const eosio::upgrade_parameters& params);

///@} priviledgedcppapi

/**
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ add_library( eosio_chain
block_header_state.cpp
block_state.cpp
fork_database.cpp
pbft_database.cpp
pbft.cpp
controller.cpp
authorization_manager.cpp
resource_limits.cpp
Expand Down
77 changes: 55 additions & 22 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 )const {
block_header_state block_header_state::generate_next( block_timestamp_type when, bool new_version )const {
block_header_state result;

if( when != block_timestamp_type() ) {
Expand Down Expand Up @@ -62,9 +62,17 @@ namespace eosio { namespace chain {
result.pending_schedule = pending_schedule;
result.dpos_proposed_irreversible_blocknum = dpos_proposed_irreversible_blocknum;
result.bft_irreversible_blocknum = bft_irreversible_blocknum;
result.pbft_stable_checkpoint_blocknum = pbft_stable_checkpoint_blocknum;


if (new_version) {
result.dpos_irreversible_blocknum = dpos_irreversible_blocknum;
} else {
result.producer_to_last_implied_irb[prokey.producer_name] = result.dpos_proposed_irreversible_blocknum;
result.dpos_irreversible_blocknum = result.calc_dpos_last_irreversible();
}


result.producer_to_last_implied_irb[prokey.producer_name] = result.dpos_proposed_irreversible_blocknum;
result.dpos_irreversible_blocknum = result.calc_dpos_last_irreversible();

/// grow the confirmed count
static_assert(std::numeric_limits<uint8_t>::max() >= (config::max_producers * 2 / 3) + 1, "8bit confirmations may not be able to hold all of the needed confirmations");
Expand All @@ -73,23 +81,30 @@ 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( confirm_count.size() < config::maximum_tracked_dpos_confirmations ) {
result.confirm_count.reserve( confirm_count.size() + 1 );
result.confirm_count = confirm_count;
result.confirm_count.resize( confirm_count.size() + 1 );
result.confirm_count.back() = (uint8_t)required_confs;
} else {
result.confirm_count.resize( confirm_count.size() );
memcpy( &result.confirm_count[0], &confirm_count[1], confirm_count.size() - 1 );
result.confirm_count.back() = (uint8_t)required_confs;
if (!new_version) {
if (confirm_count.size() < config::maximum_tracked_dpos_confirmations) {
result.confirm_count.reserve(confirm_count.size() + 1);
result.confirm_count = confirm_count;
result.confirm_count.resize(confirm_count.size() + 1);
result.confirm_count.back() = (uint8_t) required_confs;
} else {
result.confirm_count.resize(confirm_count.size());
memcpy(&result.confirm_count[0], &confirm_count[1], confirm_count.size() - 1);
result.confirm_count.back() = (uint8_t) required_confs;
}
}

return result;
} /// generate_next

bool block_header_state::maybe_promote_pending() {
if( pending_schedule.producers.size() &&
dpos_irreversible_blocknum >= pending_schedule_lib_num )
bool block_header_state::maybe_promote_pending( bool new_version ) {

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

if (should_promote_pending)
{
active_schedule = move( pending_schedule );

Expand All @@ -99,7 +114,13 @@ namespace eosio { namespace chain {
if( existing != producer_to_last_produced.end() ) {
new_producer_to_last_produced[pro.producer_name] = existing->second;
} else {
new_producer_to_last_produced[pro.producer_name] = dpos_irreversible_blocknum;
//TODO: max of bft and dpos lib
if (new_version) {
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 @@ -109,7 +130,13 @@ namespace eosio { namespace chain {
if( existing != producer_to_last_implied_irb.end() ) {
new_producer_to_last_implied_irb[pro.producer_name] = existing->second;
} else {
new_producer_to_last_implied_irb[pro.producer_name] = dpos_irreversible_blocknum;
//TODO: max of bft and dpos lib
if (new_version) {
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 @@ -141,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 )const {
block_header_state block_header_state::next( const signed_block_header& h, bool skip_validate_signee, bool new_version )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 );
auto result = generate_next( h.timestamp, new_version);
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 @@ -161,9 +188,11 @@ namespace eosio { namespace chain {
/// below this point is state changes that cannot be validated with headers alone, but never-the-less,
/// must result in header state changes

result.set_confirmed( h.confirmed );

auto was_pending_promoted = result.maybe_promote_pending();
result.set_confirmed(h.confirmed, new_version);


auto was_pending_promoted = result.maybe_promote_pending(new_version);

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 @@ -185,14 +214,18 @@ namespace eosio { namespace chain {
return result;
} /// next

void block_header_state::set_confirmed( uint16_t num_prev_blocks ) {
void block_header_state::set_confirmed( uint16_t num_prev_blocks, bool new_version ) {
/*
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) {
header.confirmed = 0;
return;
}
header.confirmed = num_prev_blocks;

int32_t i = (int32_t)(confirm_count.size() - 1);
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 )
:block_header_state( prev.generate_next( when ) ),
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( 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 )
:block_header_state( prev.next( *b, skip_validate_signee )), block( move(b) )
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) )
{ }


Expand Down
Loading