Skip to content

Commit

Permalink
Merge pull request EOSIO#96 from eosiosg/feature/dpos-pbft-bos-upgrade
Browse files Browse the repository at this point in the history
Feature/dpos-pbft-bos-upgrade upddate tps plugin and bugfix
  • Loading branch information
Thaipanda authored May 13, 2019
2 parents 9407bcf + 3264995 commit 9ee66b4
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 281 deletions.
20 changes: 10 additions & 10 deletions libraries/chain/include/eosio/chain/pbft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,45 +56,45 @@ namespace eosio {

const vector<pbft_prepare> &get_prepares_cache() const;

void set_prepares_cache(const vector<pbft_prepare> &prepares_cache);
void set_prepares_cache(const vector<pbft_prepare> &pcache);

const vector<pbft_commit> &get_commits_cache() const;

void set_commits_cache(const vector<pbft_commit> &commits_cache);
void set_commits_cache(const vector<pbft_commit> &ccache);

const vector<pbft_view_change> &get_view_changes_cache() const;

void set_view_changes_cache(const vector<pbft_view_change> &view_changes_cache);
void set_view_changes_cache(const vector<pbft_view_change> &vc_cache);

const uint32_t &get_current_view() const;

void set_current_view(const uint32_t &cv);

const vector<pbft_prepared_certificate> &get_prepared_certificate() const;

void set_prepared_certificate(const vector<pbft_prepared_certificate> &prepared_certificate);
void set_prepared_certificate(const vector<pbft_prepared_certificate> &pcert);

const vector<vector<pbft_committed_certificate>> &get_committed_certificate() const;

void set_committed_certificate(const vector<vector<pbft_committed_certificate>> &pbft_committed_certificate_vector);
void set_committed_certificate(const vector<vector<pbft_committed_certificate>> &ccert);

const vector<pbft_view_changed_certificate> &get_view_changed_certificate() const;

void set_view_changed_certificate(const vector<pbft_view_changed_certificate> &view_changed_certificate);
void set_view_changed_certificate(const vector<pbft_view_changed_certificate> &vc_cert);

const uint32_t &get_target_view_retries() const;

void set_target_view_retries(const uint32_t &target_view_reties);
void set_target_view_retries(const uint32_t &tv_reties);

const uint32_t &get_target_view() const;

void set_target_view(const uint32_t &target_view);
void set_target_view(const uint32_t &tv);

const uint32_t &get_view_change_timer() const;

void set_view_change_timer(const uint32_t &view_change_timer);
void set_view_change_timer(const uint32_t &vc_timer);

void manually_set_current_view(const uint32_t &current_view);
void manually_set_current_view(const uint32_t &cv);

protected:
psm_cache cache;
Expand Down
40 changes: 20 additions & 20 deletions libraries/chain/pbft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ namespace eosio {
current->on_new_view(this, e, pbft_db);
}

void psm_machine::manually_set_current_view(const uint32_t &current_view) {
current->manually_set_view(this, current_view);
void psm_machine::manually_set_current_view(const uint32_t &cv) {
current->manually_set_view(this, cv);
}

/**
Expand Down Expand Up @@ -575,24 +575,24 @@ namespace eosio {
return this->cache.prepares_cache;
}

void psm_machine::set_prepares_cache(const vector<pbft_prepare> &prepares_cache) {
this->cache.prepares_cache = prepares_cache;
void psm_machine::set_prepares_cache(const vector<pbft_prepare> &pcache) {
this->cache.prepares_cache = pcache;
}

const vector<pbft_commit> &psm_machine::get_commits_cache() const {
return this->cache.commits_cache;
}

void psm_machine::set_commits_cache(const vector<pbft_commit> &commits_cache) {
this->cache.commits_cache = commits_cache;
void psm_machine::set_commits_cache(const vector<pbft_commit> &ccache) {
this->cache.commits_cache = ccache;
}

const vector<pbft_view_change> &psm_machine::get_view_changes_cache() const {
return this->cache.view_changes_cache;
}

void psm_machine::set_view_changes_cache(const vector<pbft_view_change> &view_changes_cache) {
this->cache.view_changes_cache = view_changes_cache;
void psm_machine::set_view_changes_cache(const vector<pbft_view_change> &vc_cache) {
this->cache.view_changes_cache = vc_cache;
}

const uint32_t &psm_machine::get_current_view() const {
Expand All @@ -607,49 +607,49 @@ namespace eosio {
return this->cache.prepared_certificate;
}

void psm_machine::set_prepared_certificate(const vector<pbft_prepared_certificate> &prepared_certificate) {
this->cache.prepared_certificate = prepared_certificate;
void psm_machine::set_prepared_certificate(const vector<pbft_prepared_certificate> &pcert) {
this->cache.prepared_certificate = pcert;
}

const vector<vector<pbft_committed_certificate>> &psm_machine::get_committed_certificate() const {
return this->cache.committed_certificate;
}

void psm_machine::set_committed_certificate(const vector<vector<pbft_committed_certificate>> &pbft_committed_certificate_vector) {
this->cache.committed_certificate = pbft_committed_certificate_vector;
void psm_machine::set_committed_certificate(const vector<vector<pbft_committed_certificate>> &ccert) {
this->cache.committed_certificate = ccert;
}

const vector<pbft_view_changed_certificate> &psm_machine::get_view_changed_certificate() const {
return this->cache.view_changed_certificate;
}

void psm_machine::set_view_changed_certificate(
const vector<pbft_view_changed_certificate> &view_changed_certificate) {
this->cache.view_changed_certificate = view_changed_certificate;
const vector<pbft_view_changed_certificate> &vc_cert) {
this->cache.view_changed_certificate = vc_cert;
}

const uint32_t &psm_machine::get_target_view_retries() const {
return this->target_view_retries;
}

void psm_machine::set_target_view_retries(const uint32_t &target_view_reties) {
this->target_view_retries = target_view_reties;
void psm_machine::set_target_view_retries(const uint32_t &tv_reties) {
this->target_view_retries = tv_reties;
}

const uint32_t &psm_machine::get_target_view() const {
return this->target_view;
}

void psm_machine::set_target_view(const uint32_t &target_view) {
this->target_view = target_view;
void psm_machine::set_target_view(const uint32_t &tv) {
this->target_view = tv;
}

const uint32_t &psm_machine::get_view_change_timer() const {
return this->view_change_timer;
}

void psm_machine::set_view_change_timer(const uint32_t &view_change_timer) {
this->view_change_timer = view_change_timer;
void psm_machine::set_view_change_timer(const uint32_t &vc_timer) {
this->view_change_timer = vc_timer;
}
}
}
6 changes: 4 additions & 2 deletions libraries/chain/pbft_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,11 @@ namespace eosio {
pcc.resize(ctrl.my_signature_providers().size());
const auto &by_commit_and_num_index = pbft_state_index.get<by_commit_and_num>();
auto itr = by_commit_and_num_index.begin();
if (itr == by_commit_and_num_index.end()) return vector<vector<pbft_committed_certificate>>{};

pbft_state_ptr psp = *itr;
if (itr == by_commit_and_num_index.end() || !psp->should_committed) return vector<vector<pbft_committed_certificate>>{};

if (!psp->should_committed) return vector<vector<pbft_committed_certificate>>{};

auto highest_committed_block_num = psp->block_num;

Expand Down Expand Up @@ -1200,7 +1202,7 @@ namespace eosio {
}

if (!pending_checkpoint_block_num.empty()) {
std::sort(pending_checkpoint_block_num.begin(), pending_checkpoint_block_num.begin());
std::sort(pending_checkpoint_block_num.begin(), pending_checkpoint_block_num.end());
for (auto h: pending_checkpoint_block_num) {
for (auto const &my_sp : ctrl.my_signature_providers()) {
auto uuid = boost::uuids::to_string(uuid_generator());
Expand Down
2 changes: 1 addition & 1 deletion plugins/txn_test_gen_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ add_library( txn_test_gen_plugin

add_dependencies(txn_test_gen_plugin eosio.token)

target_link_libraries( txn_test_gen_plugin appbase fc http_plugin chain_plugin )
target_link_libraries( txn_test_gen_plugin appbase fc http_plugin chain_plugin net_plugin)
target_include_directories( txn_test_gen_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
target_include_directories( txn_test_gen_plugin PUBLIC ${CMAKE_BINARY_DIR}/contracts )
22 changes: 21 additions & 1 deletion plugins/txn_test_gen_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,28 @@ $ ./cleos set contract eosio ~/eos/build.release/contracts/eosio.bios/

### Initialize the accounts txn_test_gen_plugin uses
```bash
$ curl --data-binary '["eosio", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]' http://127.0.0.1:8888/v1/txn_test_gen/create_test_accounts
$ curl --data-binary '[<creator>, <creator's private key>, <core_symbol>]' http://127.0.0.1:8888/v1/txn_test_gen/create_test_accounts
example:
$ curl --data-binary '["eosio", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3", "EOS"]' http://127.0.0.1:8888/v1/txn_test_gen/create_test_accounts
```
> **make sure there are more than 4000,0000 <core_symbol>** in creator
This api does:
1. creates following accounts:
aaaaaaaaaaaa
bbbbbbbbbbbb
cccccccccccc
1. delegate 1000,0000 cpu, 100 net, and 100 ram to above accounts using <creator>
1. deploy a token contract to account cccccccccccc and issue a large number of tokens to cccccccccccc, then transfer some tokens to aaaaaaaaaaaa and bbbbbbbbbbbb
1. subsequent trx will be generated using deployed token contract
1. aaaaaaaaaaaa transfer to bbbbbbbbbbbb
1. bbbbbbbbbbbb transfer to aaaaaaaaaaaa
### Start transaction generation, this will submit 20 transactions evey 20ms (total of 1000TPS)
```bash
Expand Down
Loading

0 comments on commit 9ee66b4

Please sign in to comment.