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

3.0.x #9

Merged
merged 53 commits into from
Oct 17, 2019
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1f3eaeb
update cleos to support eosio.msig new actions
maodaishan May 9, 2019
04f7f93
Merge pull request #110 from boscore/release/3.0.x
Thaipanda Jun 29, 2019
c1387e4
Merge pull request #109 from boscore/release/3.0.x
Thaipanda Jun 29, 2019
36006e9
valid new view before emit
Jul 8, 2019
019f595
add necessary validations before trying to relay new view msgs; optim…
VincentOCL Jul 9, 2019
20e08db
optimise transit_to_new_view; optimise handle pbft messages;
Jul 11, 2019
f4c83c2
net_plugin revert.
Jul 12, 2019
8916700
Add: switch fork reserve prepare and fetch branch from function test …
Frank-AFN Jul 15, 2019
0209353
Refactor reserve prepare testcase and Add two times maybe switch fork…
Frank-AFN Jul 16, 2019
fa2072c
Merge pull request #115 from eosiosg/feature/dpos-pbft-bos-upgrade
Thaipanda Jul 16, 2019
f47911c
optimise for return value.
Jul 22, 2019
f975445
add Tips section into Readme
EOSBIXIN Jul 22, 2019
f6aa4e6
Merge branch 'develop' into release/3.0.x
Thaipanda Jul 22, 2019
c94fa01
Merge branch 'master' into release/3.0.x
Thaipanda Jul 22, 2019
e424ec9
Merge pull request #118 from boscore/release/3.0.x
Thaipanda Jul 22, 2019
ca45e59
Merge pull request #119 from boscore/release/3.0.x
Thaipanda Jul 22, 2019
d47f250
reset timer upon state transition; refactor code;
Jul 25, 2019
99d2ed7
add global object to control pbft behavior; optimise checkpoint logic
Jul 30, 2019
239f484
refactor pbft db persistence
Jul 31, 2019
dac6102
fix tests
Aug 1, 2019
82f00a8
reset view change timer when global timeout is changed.
Aug 15, 2019
2840317
reserve prepare only if my_prepare is on forks
Aug 16, 2019
6efb1a9
reserve prepare only if my_prepare is on forks
Aug 16, 2019
6717cf2
Modify reserve prepare test case
Frank-AFN Aug 19, 2019
889161d
Modify reserve prepare test case
Frank-AFN Aug 19, 2019
a4e89a2
dpos pbft optimise (#121)
oldcold Aug 20, 2019
08ec703
update version info
EOSBIXIN Aug 21, 2019
2680d27
fix issues 111
EOSBIXIN Aug 21, 2019
06fa0e9
Merge pull request #93 from maodaishan/feature_msig_oppose_abstain
Thaipanda Aug 21, 2019
fc3ac9b
Merge pull request #122 from boscore/develop
Thaipanda Aug 21, 2019
22bbfa0
adjust the dockerfile
EOSBIXIN Aug 23, 2019
b097d3e
avoid sending last prepare.
Aug 26, 2019
1b15193
Merge branch 'release/3.0.x' into feature/dpos-pbft-bos-optimise
oldcold Aug 28, 2019
79bf108
Merge pull request #123 from eosiosg/feature/dpos-pbft-bos-optimise
Thaipanda Aug 29, 2019
b24a643
Merge pull request #124 from boscore/release/3.0.x
Thaipanda Aug 29, 2019
5e2cecc
fix pbft cert generation and validation
Sep 17, 2019
4304c51
attempt to fix bad prepared cert
Sep 10, 2019
3144c18
fix longest fork threshold
Sep 18, 2019
3971da5
redo cert validation
Sep 18, 2019
2ce70d7
refactor validation, add comments
Sep 18, 2019
b1ea9fd
clean up longest fork validation
Sep 20, 2019
783ceb7
add watermark check
Sep 20, 2019
144b4a9
Fix pbft certifications (#127)
oldcold Sep 22, 2019
9a09576
prepare 3.0.3-rc1
EOSBIXIN Sep 22, 2019
fbee034
further fix on commit certs generation and validation
Sep 23, 2019
f918d83
Merge branch 'release/3.0.x' into fix-cert-gen
oldcold Sep 24, 2019
2e09750
fix finding max committed certs block num
Sep 25, 2019
e73c333
highest committed cert block id should be strictly equal to the one f…
Sep 25, 2019
6c8470d
merge EOSIO ##7979
EOSBIXIN Sep 25, 2019
91ba180
add missing file
Sep 25, 2019
cad626a
Merge pull request #128 from eosiosg/fix-cert-gen
Thaipanda Oct 3, 2019
4dd9005
PBFT validation fixes
EOSBIXIN Oct 3, 2019
f117534
Merge pull request #129 from boscore/release/3.0.x
Thaipanda Oct 4, 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
Prev Previous commit
Next Next commit
further fix on commit certs generation and validation
  • Loading branch information
oldcold authored and VincentOCL committed Sep 23, 2019
commit fbee0348c05872cb943b1e56dfa410280cd3b7c2
82 changes: 69 additions & 13 deletions libraries/chain/pbft_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,21 +597,41 @@ namespace eosio {
auto highest_pcc = vector<pbft_committed_certificate>{};
auto highest_sc = pbft_stable_checkpoint();

vector<block_num_type> ccb;
auto watermarks = get_updated_watermarks();
for (auto& watermark : watermarks) {
//collecting committed cert on every water mark.
if (watermark > ctrl.last_stable_checkpoint_block_num()) {
ccb.emplace_back(watermark);
}
}

block_num_type highest_lib = 0;
pbft_committed_certificate highest_lib_pcc;
for (const auto& vc: vcc.view_changes) {
if (vc.prepared_cert.block_info.block_num() > highest_ppc.block_info.block_num()) {
highest_ppc = vc.prepared_cert;
}

for (const auto& cc: vc.committed_certs) {
if (cc.block_info.block_num() > highest_lib) {
highest_lib_pcc = cc;
}
auto p_itr = find_if(highest_pcc.begin(), highest_pcc.end(),
[&](const pbft_committed_certificate& ext) { return ext.block_info.block_id == cc.block_info.block_id; });
if (p_itr == highest_pcc.end()) highest_pcc.emplace_back(cc);
[&](const pbft_committed_certificate& ext) {
return ext.block_info.block_id == cc.block_info.block_id;
});
if (p_itr == highest_pcc.end() //unique block num
&& std::find(watermarks.begin(), watermarks.end(), cc.block_info.block_num()) != watermarks.end()) { // and it is a watermark
highest_pcc.emplace_back(cc);
}
}

if (vc.stable_checkpoint.block_info.block_num() > highest_sc.block_info.block_num()) {
highest_sc = vc.stable_checkpoint;
}
}
highest_pcc.emplace_back(highest_lib_pcc);

nv.new_view = new_view;
nv.prepared_cert = highest_ppc;
Expand Down Expand Up @@ -796,8 +816,8 @@ namespace eosio {
bool pbft_database::is_valid_prepared_certificate(const pbft_prepared_certificate& certificate, bool add_to_pbft_db) {
// an empty certificate is valid since it acts as a null digest in pbft.
if (certificate.empty()) return true;
// a certificate under lscb (no longer in fork_db) is also treated as null.
if (certificate.block_info.block_num() <= ctrl.last_stable_checkpoint_block_num()) return true;
// a certificate under lib is also treated as null.
if (certificate.block_info.block_num() <= ctrl.last_irreversible_block_num()) return true;

auto prepares = certificate.prepares;
auto prepares_metadata = vector<pbft_message_metadata<pbft_prepare>>{};
Expand Down Expand Up @@ -910,13 +930,24 @@ namespace eosio {
//add all valid block_infos in to a temp multi_index, this implementation might contains heavier computation
auto local_index = local_state_multi_index_type();
auto& by_block_id_index = local_index.get<by_block_id>();
auto watermark = get_current_pbft_watermark();

vector<block_num_type> ccb;
auto past_watermarks = get_updated_watermarks();
for (auto& w : past_watermarks) {
//adding committed cert on every water mark.
if (w < ctrl.last_irreversible_block_num()) {
ccb.emplace_back(w);
}
}

auto next_watermark = get_current_pbft_watermark();

for (auto &e: block_infos) {

auto current = ctrl.fetch_block_state_by_id(e.second.block_id);

while ( current ) {
if (watermark == 0 || current->block_num <= watermark) {
if (next_watermark == 0 || current->block_num <= next_watermark) {
auto curr_itr = by_block_id_index.find(current->id);

if (curr_itr == by_block_id_index.end()) {
Expand Down Expand Up @@ -959,21 +990,28 @@ namespace eosio {

if (count >= threshold) {
by_block_id_index.modify(curr_itr,
[&](const validation_state_ptr &p) { p->enough = true; });
[&](const validation_state_ptr &p) { p->enough = true; });
}
}
}
}
current = ctrl.fetch_block_state_by_id(current->prev());
}
}
const auto& by_status_and_num_index = local_index.get<by_status_and_num>();
auto itr = by_status_and_num_index.begin();
if (itr == by_status_and_num_index.end()) return false;

validation_state_ptr psp = *itr;
if (std::find(ccb.begin(), ccb.end(), cert_info.block_num()) != ccb.end()) {
auto itr = by_block_id_index.find(cert_info.block_id);
if (itr == by_block_id_index.end()) return false;
return (*itr)->enough;

} else {
const auto &by_status_and_num_index = local_index.get<by_status_and_num>();
auto itr = by_status_and_num_index.begin();
if (itr == by_status_and_num_index.end()) return false;

return psp->enough && psp->block_id == cert_info.block_id;
validation_state_ptr psp = *itr;
return psp->enough && psp->block_id == cert_info.block_id;
}
}

bool pbft_database::is_valid_view_change(const pbft_view_change& vc, const public_key_type& pk) {
Expand Down Expand Up @@ -1041,6 +1079,17 @@ namespace eosio {
auto highest_pcc = vector<pbft_committed_certificate>{};
auto highest_scp = pbft_stable_checkpoint();

vector<block_num_type> ccb;
auto watermarks = get_updated_watermarks();
for (auto& watermark : watermarks) {
//collecting committed cert on every water mark.
if (watermark > ctrl.last_stable_checkpoint_block_num()) {
ccb.emplace_back(watermark);
}
}

block_num_type highest_lib = 0;
pbft_committed_certificate highest_lib_pcc;
for (const auto& vc: nv.view_changed_cert.view_changes) {
if (vc.prepared_cert.block_info.block_num() > highest_ppc.block_info.block_num()
&& is_valid_prepared_certificate(vc.prepared_cert)) {
Expand All @@ -1049,11 +1098,17 @@ namespace eosio {

for (const auto& cc: vc.committed_certs) {
if (is_valid_committed_certificate(cc)) {
if (cc.block_info.block_num() > highest_lib) {
highest_lib_pcc = cc;
}
auto p_itr = find_if(highest_pcc.begin(), highest_pcc.end(),
[&](const pbft_committed_certificate& ext) {
return ext.block_info.block_id == cc.block_info.block_id;
});
if (p_itr == highest_pcc.end()) highest_pcc.emplace_back(cc);
if (p_itr == highest_pcc.end() //unique block num
&& std::find(watermarks.begin(), watermarks.end(), cc.block_info.block_num()) != watermarks.end()) { // and it is a watermark
highest_pcc.emplace_back(cc);
}
}
}

Expand All @@ -1062,6 +1117,7 @@ namespace eosio {
highest_scp = vc.stable_checkpoint;
}
}
highest_pcc.emplace_back(highest_lib_pcc);

EOS_ASSERT(highest_ppc.block_info == nv.prepared_cert.block_info, pbft_exception,
"prepared certificate does not match, should be ${hppc} but ${pc} given",
Expand Down