Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add bnet support to launcher #3427

Merged
merged 1 commit into from May 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 45 additions & 4 deletions programs/eosio-launcher/main.cpp
Expand Up @@ -322,6 +322,11 @@ struct last_run_def {
};


enum class p2p_plugin {
NET,
BNET
};

enum launch_modes {
LM_NONE,
LM_LOCAL,
Expand All @@ -345,6 +350,7 @@ struct launcher_def {
size_t producers;
size_t next_node;
string shape;
p2p_plugin p2p;
allowed_connection allowed_connections = PC_NONE;
bfs::path genesis;
bfs::path output;
Expand Down Expand Up @@ -429,6 +435,7 @@ launcher_def::set_options (bpo::options_description &cfg) {
("producers",bpo::value<size_t>(&producers)->default_value(21),"total number of non-bios producer instances in this network")
("mode,m",bpo::value<vector<string>>()->multitoken()->default_value({"any"}, "any"),"connection mode, combination of \"any\", \"producers\", \"specified\", \"none\"")
("shape,s",bpo::value<string>(&shape)->default_value("star"),"network topology, use \"star\" \"mesh\" or give a filename for custom")
("p2p-plugin", bpo::value<string>()->default_value("net"),"select a p2p plugin to use (either net or bnet). Defaults to net.")
("genesis,g",bpo::value<bfs::path>(&genesis)->default_value("./genesis.json"),"set the path to genesis.json")
("skip-signature", bpo::bool_switch(&skip_transaction_signatures)->default_value(false), "nodeos does not require transaction signatures.")
("nodeos", bpo::value<string>(&eosd_extra_args), "forward nodeos command line argument(s) to each instance of nodeos, enclose arg in quotes")
Expand Down Expand Up @@ -490,6 +497,20 @@ launcher_def::initialize (const variables_map &vmap) {
host_map_file = src.stem().string() + "_hosts.json";
}

string nc = vmap["p2p-plugin"].as<string>();
if ( !nc.empty() ) {
if (boost::iequals(nc,"net"))
p2p = p2p_plugin::NET;
else if (boost::iequals(nc,"bnet"))
p2p = p2p_plugin::BNET;
else {
p2p = p2p_plugin::NET;
}
}
else {
p2p = p2p_plugin::NET;
}

if( !host_map_file.empty() ) {
try {
fc::json::from_file(host_map_file).as<vector<host_def>>(bindings);
Expand Down Expand Up @@ -962,8 +983,14 @@ launcher_def::write_config_file (tn_node_def &node) {
cfg << "readonly = 0\n";
cfg << "send-whole-blocks = true\n";
cfg << "http-server-address = " << host->host_name << ":" << instance.http_port << "\n";
cfg << "p2p-listen-endpoint = " << host->listen_addr << ":" << instance.p2p_port << "\n";
cfg << "p2p-server-address = " << host->public_name << ":" << instance.p2p_port << "\n";
if (p2p == p2p_plugin::NET) {
cfg << "p2p-listen-endpoint = " << host->listen_addr << ":" << instance.p2p_port << "\n";
cfg << "p2p-server-address = " << host->public_name << ":" << instance.p2p_port << "\n";
} else {
cfg << "bnet-endpoint = " << host->listen_addr << ":" << instance.p2p_port << "\n";
// Include the net_plugin endpoint, because the plugin is always loaded (even if not used).
cfg << "p2p-listen-endpoint = " << host->listen_addr << ":" << instance.p2p_port + 1000 << "\n";
}

if (is_bios) {
cfg << "enable-stale-production = true\n";
Expand All @@ -989,10 +1016,18 @@ launcher_def::write_config_file (tn_node_def &node) {

if(!is_bios) {
auto &bios_node = network.nodes["bios"];
cfg << "p2p-peer-address = " << bios_node.instance->p2p_endpoint<< "\n";
if (p2p == p2p_plugin::NET) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In keeping with the net_plugin default, shouldn't this be reversed? Specific to p2p_plugin::BNET, otherwise anything else gets the other setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRL discussion occurred and this is okay.

cfg << "p2p-peer-address = " << bios_node.instance->p2p_endpoint<< "\n";
} else {
cfg << "bnet-connect = " << bios_node.instance->p2p_endpoint<< "\n";
}
}
for (const auto &p : node.peers) {
cfg << "p2p-peer-address = " << network.nodes.find(p)->second.instance->p2p_endpoint << "\n";
if (p2p == p2p_plugin::NET) {
cfg << "p2p-peer-address = " << network.nodes.find(p)->second.instance->p2p_endpoint << "\n";
} else {
cfg << "bnet-connect = " << network.nodes.find(p)->second.instance->p2p_endpoint << "\n";
}
}
if (instance.has_db || node.producers.size()) {
cfg << "required-participation = 33\n";
Expand All @@ -1008,6 +1043,11 @@ launcher_def::write_config_file (tn_node_def &node) {
if( instance.has_db ) {
cfg << "plugin = eosio::mongo_db_plugin\n";
}
if ( p2p == p2p_plugin::NET ) {
cfg << "plugin = eosio::net_plugin\n";
} else {
cfg << "plugin = eosio::bnet_plugin\n";
}
cfg << "plugin = eosio::chain_api_plugin\n"
<< "plugin = eosio::history_api_plugin\n";
cfg.close();
Expand Down Expand Up @@ -1813,6 +1853,7 @@ int main (int argc, char *argv[]) {
cfg, true), vmap);



if (vmap.count("launch")) {
string l = vmap["launch"].as<string>();
if (boost::iequals(l,"all"))
Expand Down