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

Release/3.0.x #175

Merged
merged 37 commits into from
Jun 15, 2020
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9509dd7
check llvm version >= 7 and install automatically
Thaipanda May 1, 2020
748c377
Merge pull request #21 from boscore/release/3.0.x
Frank-AFN May 2, 2020
c9e6641
Remove bytes in flight
Frank-AFN May 5, 2020
7af85d4
Merge pull request #161 from eosiosg/getinfobusyfix
Thaipanda May 6, 2020
a7e2158
Upgrade: name apply context transaction context and plugins
Frank-AFN May 11, 2020
c8c27f4
FIX: unittests
Frank-AFN May 11, 2020
07e60de
fix a potential crash in fetching lib.
May 13, 2020
e7056d2
emit lib in ascending order.
May 13, 2020
e1cf1f3
Merge pull request #162 from boscore/fix-emit-lib
Frank-AFN May 19, 2020
9e01179
fix a potential crash in fetching lib.
May 13, 2020
483b9ea
emit lib in ascending order.
May 13, 2020
6f51cc1
Change abi-serializer-max-time-us to abi-serializer-max-time-ms
Frank-AFN May 19, 2020
931235f
Fix: TODO
Frank-AFN May 20, 2020
e757b8a
Fix: mongodb plugin
Frank-AFN May 20, 2020
5366d8a
Fix: cleos name issue
Frank-AFN May 20, 2020
982cf82
Fix: tests
Frank-AFN May 20, 2020
20c3c17
Add back get block detail in history plugin
Frank-AFN May 20, 2020
03e03c5
Merge pull request #163 from eosiosg/statehistoryplugin
Thaipanda May 27, 2020
d33bb6c
update connected lib channels of plugins
May 27, 2020
1e7fb89
Fix: state history plugin issues
Frank-AFN Jun 3, 2020
7d432d0
Merge pull request #164 from eosiosg/statehistoryplugin
Thaipanda Jun 3, 2020
58ff806
Change: applied transaction channel for statehistory plugin
Frank-AFN Jun 5, 2020
6f91e2c
fix: exclude invalid cert; shuffle view changes before generation; ad…
Jun 5, 2020
ecc2fb6
Merge pull request #166 from boscore/fix-cert-generation
Thaipanda Jun 6, 2020
68ca592
Merge pull request #165 from boscore/plugins-update-lib-channel
Thaipanda Jun 6, 2020
7d5a128
Fix: state history get block from forkdb null
Frank-AFN Jun 6, 2020
064a989
reset docker file
Frank-AFN Jun 6, 2020
dc3b8e4
Merge pull request #167 from eosiosg/statehistoryplugin
Thaipanda Jun 6, 2020
353d311
prepare v3.0.8
Thaipanda Jun 6, 2020
323586e
prepare v3.0.8 (#168)
Thaipanda Jun 6, 2020
c242cbc
Add: account query database
Frank-AFN Jun 10, 2020
87d1c1f
Merge pull request #171 from eosiosg/accountquerydb
Thaipanda Jun 12, 2020
9397c0c
update the version
Thaipanda Jun 12, 2020
57aa42a
Fix: test build bug
Frank-AFN Jun 12, 2020
a78aa0f
Merge pull request #173 from eosiosg/accountquerydb
Thaipanda Jun 12, 2020
39c7e82
Merge branch 'master' into release/3.0.x
Frank-AFN Jun 15, 2020
b3e2280
Merge branch 'develop' into release/3.0.x
Frank-AFN Jun 15, 2020
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
fix: exclude invalid cert; shuffle view changes before generation; ad…
…d debug functions in pbft api plugin
oldcold committed Jun 5, 2020
commit 6f91e2cf29f2a0071e481e79837d67dabac7efc6
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/pbft_database.hpp
Original file line number Diff line number Diff line change
@@ -519,6 +519,7 @@ namespace eosio {
vector<block_num_type> get_pbft_watermarks() const;
flat_map<public_key_type, uint32_t> get_pbft_fork_schedules() const;

producer_schedule_type lscb_active_producers() const;
private:
controller& ctrl;
pbft_state_multi_index_type pbft_state_index;
@@ -537,7 +538,6 @@ namespace eosio {
bool is_valid_committed_certificate(const pbft_committed_certificate& certificate, bool add_to_pbft_db = false, bool at_the_top = false);
bool is_valid_longest_fork(const vector<producer_and_block_info>& producers, const block_info_type& cert_info, bool at_the_top = false);

producer_schedule_type lscb_active_producers() const;
vector<block_num_type>& get_updated_watermarks();
flat_map<public_key_type, uint32_t>& get_updated_fork_schedules();
block_num_type get_current_pbft_watermark();
25 changes: 18 additions & 7 deletions libraries/chain/pbft_database.cpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
#include <fc/io/fstream.hpp>
#include <fstream>
#include <eosio/chain/global_property_object.hpp>
#include <random>

namespace eosio {
namespace chain {
@@ -597,19 +598,29 @@ namespace eosio {
auto highest_pcc = vector<pbft_committed_certificate>{};
auto highest_sc = pbft_stable_checkpoint();

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;
// shuffle view changes to avoid fixed orders.
std::vector<int> idx_v(vcc.view_changes.size()) ;
std::iota (std::begin(idx_v), std::end(idx_v), 0);
auto seed = std::chrono::system_clock::now().time_since_epoch().count();
std::shuffle( idx_v.begin(), idx_v.end(), std::default_random_engine(seed));
for (const auto i: idx_v) {
auto& prepared_cert = vcc.view_changes[i].prepared_cert;
auto& committed_certs = vcc.view_changes[i].committed_certs;
auto& stable_ckpts = vcc.view_changes[i].stable_checkpoint;
if (prepared_cert.block_info.block_num() > highest_ppc.block_info.block_num()
&& is_valid_prepared_certificate(prepared_cert)) {
highest_ppc = prepared_cert;
}

for (const auto& cc: vc.committed_certs) {
for (const auto& cc:committed_certs ) {
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() && is_valid_committed_certificate(cc)) highest_pcc.emplace_back(cc);
}

if (vc.stable_checkpoint.block_info.block_num() > highest_sc.block_info.block_num()) {
highest_sc = vc.stable_checkpoint;
if (stable_ckpts.block_info.block_num() > highest_sc.block_info.block_num()
&& is_valid_stable_checkpoint(stable_ckpts)) {
highest_sc = stable_ckpts;
}
}

21 changes: 21 additions & 0 deletions plugins/pbft_api_plugin/README.md
Original file line number Diff line number Diff line change
@@ -84,4 +84,25 @@

```
curl --request POST --data uint32_t --url http://localhost:8888/v1/pbft/set_pbft_current_view
```
* **get_view_change_missing_bps**

-- To get missing bp names of a given pbft view on my node, empty will be returned if all have been collected or not in view change state

```
curl --request POST --data uint32_t --url http://localhost:8888/v1/pbft/get_view_change_missing_bps
```
* **get_prepare_missing_bps**

-- To get missing bp names of prepare messages of a given block id at the highest view on my node, empty will be returned if all have been collected or the block id is unreachable

```
curl --request POST --data string --url http://localhost:8888/v1/pbft/get_prepare_missing_bps
```
* **get_commit_missing_bps**

-- To get missing bp names of commit messages of a given block id at the highest view on my node, empty will be returned if all have been collected or the block id is unreachable

```
curl --request POST --data string --url http://localhost:8888/v1/pbft/get_commit_missing_bps
```
3 changes: 3 additions & 0 deletions plugins/pbft_api_plugin/pbft_api_plugin.cpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ void pbft_api_plugin::plugin_startup() {
CALL(pbft, pbft, get_pbft_status, INVOKE_R(pbft, get_pbft_status), 200),
CALL(pbft, pbft, get_pbft_prepared_id, INVOKE_R(pbft, get_pbft_prepared_id), 200),
CALL(pbft, pbft, get_pbft_my_prepare_id, INVOKE_R(pbft, get_pbft_my_prepare_id), 200),
CALL(pbft, pbft, get_view_change_missing_bps, INVOKE_R_P(pbft, get_view_change_missing_bps, pbft_view_type), 200),
CALL(pbft, pbft, get_prepare_missing_bps, INVOKE_R_P(pbft, get_prepare_missing_bps, block_id_type), 200),
CALL(pbft, pbft, get_commit_missing_bps, INVOKE_R_P(pbft, get_commit_missing_bps, block_id_type), 200),
CALL(pbft, pbft, set_pbft_current_view, INVOKE_W_P(pbft, set_pbft_current_view, pbft_view_type), 201),
});
}
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
#include <eosio/chain/pbft.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <eosio/net_plugin/net_plugin.hpp>
#include <eosio/producer_plugin/producer_plugin.hpp>

namespace eosio {

@@ -33,12 +34,15 @@ class pbft_plugin : public appbase::plugin<pbft_plugin> {
const char* get_pbft_status()const;
block_id_type get_pbft_prepared_id()const;
block_id_type get_pbft_my_prepare_id()const;

vector<producer_key> get_view_change_missing_bps(pbft_view_type view)const;
vector<producer_key> get_prepare_missing_bps(const block_id_type& bid)const;
vector<producer_key> get_commit_missing_bps(const block_id_type& bid)const;
void set_pbft_current_view(pbft_view_type view);


private:
std::unique_ptr<class pbft_plugin_impl> my;
chain_plugin* chain_plug = nullptr;
};

}
99 changes: 89 additions & 10 deletions plugins/pbft_plugin/pbft_plugin.cpp
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ namespace eosio {
bool is_replaying();
bool is_syncing();
bool pbft_ready();
bool is_production_paused();
};

void pbft_plugin_impl::on_committed_transition() {
@@ -142,6 +143,10 @@ namespace eosio {
return app().get_plugin<net_plugin>().is_syncing();
}

bool pbft_plugin_impl::is_production_paused() {
return app().get_plugin<producer_plugin>().paused();
}

bool pbft_plugin_impl::pbft_ready() {
// only trigger pbft related logic if I am in sync and replayed.

@@ -162,7 +167,7 @@ namespace eosio {
upgraded = true;
}

return enabled && !is_syncing() && !is_replaying();
return enabled && !is_syncing() && !is_replaying() && !is_production_paused();
}

pbft_plugin::pbft_plugin() : my(new pbft_plugin_impl()) {}
@@ -178,6 +183,7 @@ namespace eosio {
my->commit_timer = std::make_unique<boost::asio::steady_timer>(app().get_io_service());
my->view_change_timer = std::make_unique<boost::asio::steady_timer>(app().get_io_service());
my->checkpoint_timer = std::make_unique<boost::asio::steady_timer>(app().get_io_service());
chain_plug = app().find_plugin<chain_plugin>();
}

void pbft_plugin::plugin_startup() {
@@ -198,53 +204,126 @@ namespace eosio {
void pbft_plugin::plugin_shutdown() {}

pbft_state pbft_plugin::get_pbft_record( const block_id_type& bid ) const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
auto record = pbft_ctrl.pbft_db.get_pbft_state_by_id(bid);
if (record) return *record;
return pbft_state();
}

vector<pbft_checkpoint_state> pbft_plugin::get_pbft_checkpoints_record(block_num_type bnum) const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
auto records = pbft_ctrl.pbft_db.get_checkpoints_by_num(bnum);
if (!records.empty()) return records;
return vector<pbft_checkpoint_state>();
}
pbft_view_change_state pbft_plugin::get_view_change_record(pbft_view_type view) const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
auto record = pbft_ctrl.pbft_db.get_view_changes_by_target_view(view);
if (record) return *record;
return pbft_view_change_state();
}

vector<block_num_type> pbft_plugin::get_watermarks() const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
return pbft_ctrl.pbft_db.get_pbft_watermarks();
}

flat_map<public_key_type, uint32_t> pbft_plugin::get_fork_schedules() const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
return pbft_ctrl.pbft_db.get_pbft_fork_schedules();
}

const char* pbft_plugin::get_pbft_status() const {
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
auto& pbft_ctrl = chain_plug->pbft_ctrl();
return pbft_ctrl.state_machine.get_current()->get_name();
}

block_id_type pbft_plugin::get_pbft_prepared_id() const {
auto& ctrl = app().get_plugin<chain_plugin>().chain();
auto& ctrl = chain_plug->chain();
return ctrl.get_pbft_prepared();
}

block_id_type pbft_plugin::get_pbft_my_prepare_id() const {
auto& ctrl = app().get_plugin<chain_plugin>().chain();
auto& ctrl = chain_plug->chain();
return ctrl.get_pbft_my_prepare();
}

vector<producer_key> pbft_plugin::get_view_change_missing_bps(pbft_view_type view) const {
auto& pbft_ctrl = chain_plug->pbft_ctrl();
auto missing_bps = vector<producer_key>{};
auto records = get_view_change_record(view);
if (!records.view_changes.empty() && !records.is_view_changed) {
auto lscb_bps = pbft_ctrl.pbft_db.lscb_active_producers().producers;
missing_bps.reserve(lscb_bps.size());
for (const auto& bp: lscb_bps) {
auto found = false;
for (const auto& v: records.view_changes) {
if (bp.block_signing_key == v.first) found = true;
}
if (!found) missing_bps.emplace_back(bp);
}
}
return missing_bps;
}

vector<producer_key> pbft_plugin::get_prepare_missing_bps(const block_id_type& bid) const {
auto& ctrl = chain_plug->chain();
auto missing_bps = vector<producer_key>{};
auto blk = ctrl.fetch_block_state_by_id(bid);
if (blk) {
auto records = get_pbft_record(bid);
if (!records.prepares.empty() && !records.is_prepared) {
pbft_view_type highest_view;
for (const auto &p: records.prepares) {
if (p.first.first > highest_view) highest_view = p.first.first;
}
auto active_bps = blk->active_schedule.producers;;
missing_bps.reserve(active_bps.size());
for (const auto &bp: active_bps) {
auto found = false;
for (const auto &p: records.prepares) {
if (p.first.first == highest_view && bp.block_signing_key == p.first.second) {
found = true;
}
}
if (!found) missing_bps.emplace_back(bp);
}
}

}
return missing_bps;
}

vector<producer_key> pbft_plugin::get_commit_missing_bps(const block_id_type& bid) const {
auto& ctrl = chain_plug->chain();
auto missing_bps = vector<producer_key>{};
auto blk = ctrl.fetch_block_state_by_id(bid);
if (blk) {
auto records = get_pbft_record(bid);
if (!records.commits.empty() && !records.is_committed) {
pbft_view_type highest_view;
for (const auto &p: records.commits) {
if (p.first.first > highest_view) highest_view = p.first.first;
}
auto active_bps = blk->active_schedule.producers;;
missing_bps.reserve(active_bps.size());
for (const auto &bp: active_bps) {
auto found = false;
for (const auto &c: records.commits) {
if (c.first.first == highest_view && bp.block_signing_key == c.first.second) {
found = true;
}
}
if (!found) missing_bps.emplace_back(bp);
}
}
}
return missing_bps;
}

void pbft_plugin::set_pbft_current_view(pbft_view_type view) {
auto& pbft_ctrl = chain_plug->pbft_ctrl();
//this is used to boost the recovery from a disaster, do not set this unless you have to do so.
pbft_controller& pbft_ctrl = app().get_plugin<chain_plugin>().pbft_ctrl();
pbft_ctrl.state_machine.manually_set_current_view(view);
}
}