Skip to content

Commit

Permalink
GH-1916 Add bls_pub_priv_key_map_t typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 22, 2023
1 parent a512505 commit 05b110b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,7 @@ int64_t controller::set_proposed_producers( vector<producer_authority> producers
return version;
}

void controller::create_pacemaker(std::set<chain::account_name> my_producers, std::map<std::string,std::string> finalizer_keys, fc::logger& hotstuff_logger) {
void controller::create_pacemaker(std::set<chain::account_name> my_producers, hotstuff::bls_pub_priv_key_map_t finalizer_keys, fc::logger& hotstuff_logger) {
EOS_ASSERT( !my->pacemaker, misc_exception, "duplicate chain_pacemaker initialization" );
my->pacemaker.emplace(this, std::move(my_producers), std::move(finalizer_keys), hotstuff_logger);
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace eosio::hotstuff {
struct hs_message;
struct finalizer_state;
enum class hs_message_warning;
using bls_pub_priv_key_map_t = std::map<std::string, std::string>;
}

namespace eosio { namespace chain {
Expand Down Expand Up @@ -302,7 +303,7 @@ namespace eosio { namespace chain {

int64_t set_proposed_producers( vector<producer_authority> producers );

void create_pacemaker(std::set<chain::account_name> my_producers, std::map<std::string,std::string> finalizer_keys, fc::logger& hotstuff_logger);
void create_pacemaker(std::set<chain::account_name> my_producers, hotstuff::bls_pub_priv_key_map_t finalizer_keys, fc::logger& hotstuff_logger);
void register_pacemaker_bcast_function(std::function<void(const std::optional<uint32_t>&, const hotstuff::hs_message&)> bcast_hs_message);
void register_pacemaker_warn_function(std::function<void(uint32_t, hotstuff::hs_message_warning)> warn_hs_message);
// called by host function set_finalizers
Expand Down
2 changes: 1 addition & 1 deletion libraries/hotstuff/chain_pacemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace eosio { namespace hotstuff {
#warning TODO get a data directory str passed into the chain_pacemaker ctor and use it to compose the absolute filepathname that is passed to qc_chain ctor
chain_pacemaker::chain_pacemaker(controller* chain,
std::set<account_name> my_producers,
std::map<std::string,std::string> finalizer_keys,
bls_pub_priv_key_map_t finalizer_keys,
fc::logger& logger)
: _chain(chain),
_qc_chain("default", this, std::move(my_producers), std::move(finalizer_keys), logger, eosio::chain::config::safetydb_filename),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace eosio::hotstuff {

chain_pacemaker(controller* chain,
std::set<account_name> my_producers,
std::map<std::string,std::string> finalizer_keys,
bls_pub_priv_key_map_t finalizer_keys,
fc::logger& logger);
void register_bcast_function(std::function<void(const std::optional<uint32_t>&, const hs_message&)> broadcast_hs_message);
void register_warn_function(std::function<void(uint32_t, const hs_message_warning&)> warning_hs_message);
Expand Down
4 changes: 3 additions & 1 deletion libraries/hotstuff/include/eosio/hotstuff/qc_chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ namespace eosio::hotstuff {
std::set<fc::crypto::blslib::bls_public_key> finalizers; // finalizers that have voted on the proposal
};

using bls_pub_priv_key_map_t = std::map<std::string, std::string>;

// Concurrency note: qc_chain is a single-threaded and lock-free decision engine.
// All thread synchronization, if any, is external.
class qc_chain {
Expand All @@ -153,7 +155,7 @@ namespace eosio::hotstuff {

qc_chain(std::string id, base_pacemaker* pacemaker,
std::set<name> my_producers,
std::map<std::string,std::string> finalizer_keys,
bls_pub_priv_key_map_t finalizer_keys,
fc::logger& logger,
std::string safety_state_file);

Expand Down
2 changes: 1 addition & 1 deletion libraries/hotstuff/qc_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace eosio::hotstuff {
qc_chain::qc_chain(std::string id,
base_pacemaker* pacemaker,
std::set<name> my_producers,
std::map<std::string,std::string> finalizer_keys,
bls_pub_priv_key_map_t finalizer_keys,
fc::logger& logger,
std::string safety_state_file)
: _pacemaker(pacemaker),
Expand Down
2 changes: 1 addition & 1 deletion libraries/hotstuff/test/test_hotstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class hotstuff_test_handler {

for (size_t i = 0 ; i < replicas.size() ; i++){
fc::crypto::blslib::bls_private_key sk = fc::crypto::blslib::bls_private_key(replica_keys[i]);
std::map<std::string,std::string> keys{{sk.get_public_key().to_string(), sk.to_string()}};
eosio::hotstuff::bls_pub_priv_key_map_t keys{{sk.get_public_key().to_string(), sk.to_string()}};
qc_chain *qcc_ptr = new qc_chain(replica_keys[i].to_string(), &tpm, {replicas[i]}, keys, hotstuff_logger, std::string());
std::shared_ptr<qc_chain> qcc_shared_ptr(qcc_ptr);
_qc_chains.push_back( std::make_pair(replicas[i], qcc_shared_ptr) );
Expand Down
6 changes: 3 additions & 3 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin

using signature_provider_type = signature_provider_plugin::signature_provider_type;
std::map<chain::public_key_type, signature_provider_type> _signature_providers;
std::map<std::string ,std::string> _finalizer_keys; // public, private
std::set<chain::account_name> _producers;
boost::asio::deadline_timer _timer;
hotstuff::bls_pub_priv_key_map_t _finalizer_keys; // public, private
std::set<chain::account_name> _producers;
boost::asio::deadline_timer _timer;
block_timing_util::producer_watermarks _producer_watermarks;
pending_block_mode _pending_block_mode = pending_block_mode::speculating;
unapplied_transaction_queue _unapplied_transactions;
Expand Down

0 comments on commit 05b110b

Please sign in to comment.