提交 190ea1ee 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #290 from EOSIO/networkfixes

Network Fixes 
......@@ -225,12 +225,12 @@ bool chain_controller::_push_block(const signed_block& new_block)
for (const auto& cycle : new_block.cycles)
for (const auto& thread : cycle)
trxcount += thread.user_input.size();
ilog( "producer=[${prod}], blocktime=${bktm}, blocknum=${bknu}, trxcount=${txco}, pendingcount=${pend}, exectime_ms=${extm}",
("prod", new_block.producer)
("bktm", new_block.timestamp)
("bknu", new_block.block_num())
("txco", trxcount)
("pend", _pending_transactions.size())
ilog( "${producer} #${num} @${time} | ${trxcount} trx, ${pending} pending, exectime_ms=${extm}",
("producer", new_block.producer)
("time", new_block.timestamp)
("num", new_block.block_num())
("trxcount", trxcount)
("pending", _pending_transactions.size())
("extm", exec_ms.count())
);
}
......@@ -279,7 +279,7 @@ ProcessedTransaction chain_controller::_push_transaction(const SignedTransaction
temp_session.squash();
// notify anyone listening to pending transactions
on_pending_transaction(trx); /// TODO move this to apply...
on_pending_transaction(trx); /// TODO move this to apply... ??? why...
return pt;
}
......@@ -720,7 +720,7 @@ void chain_controller::_apply_block(const signed_block& next_block)
void chain_controller::check_transaction_authorization(const SignedTransaction& trx, bool allow_unused_signatures)const {
if ((_skip_flags & skip_transaction_signatures) && (_skip_flags & skip_authority_check)) {
ilog("Skipping auth and sigs checks");
//ilog("Skipping auth and sigs checks");
return;
}
......@@ -1147,7 +1147,7 @@ void chain_controller::replay() {
const auto last_block_num = last_block->block_num();
ilog("Replaying blocks...");
ilog("Replaying ${n} blocks...", ("n", last_block_num) );
for (uint32_t i = 1; i <= last_block_num; ++i) {
if (i % 5000 == 0)
std::cerr << " " << double(i*100)/last_block_num << "% "<<i << " of " <<last_block_num<<" \n";
......
......@@ -184,7 +184,7 @@ bool chain_plugin::accept_block(const chain::signed_block& block, bool currently
("p", block.producer));
}
return chain().push_block(block);
return chain().push_block(block, my->skip_flags);
}
void chain_plugin::accept_transaction(const chain::SignedTransaction& trx) {
......
......@@ -40,12 +40,7 @@ namespace eos {
uint32_t end_block;
};
struct peer_message {
vector<fc::sha256> peers;
};
using net_message = static_variant<handshake_message,
peer_message,
notice_message,
request_message,
sync_request_message,
......@@ -67,7 +62,6 @@ FC_REFLECT( eos::block_summary_message, (block)(trx_ids) )
FC_REFLECT( eos::notice_message, (known_trx)(known_blocks) )
FC_REFLECT( eos::request_message, (req_trx)(req_blocks) )
FC_REFLECT( eos::sync_request_message, (start_block)(end_block) )
FC_REFLECT( eos::peer_message, (peers) )
/**
*
......
......@@ -414,23 +414,6 @@ namespace eos {
return fc::ip::endpoint (addr,ep.port());
}
void send_peer_message () {
peer_message pm;
for (auto &c : connections) {
if ( (c->remote_node_id._hash[0] | c->remote_node_id._hash[1] | c->remote_node_id._hash[2] | c->remote_node_id._hash[0]) == 0 ) {
return;
}
pm.peers.push_back(c->remote_node_id);
}
if (!pm.peers.empty()) {
for (auto &c : connections) {
if (c->out_sync_state.size() == 0) {
c->send(pm);
}
}
}
}
// template<typename T>
void send_all (const SignedTransaction &msg) {
for (auto &c : connections) {
......@@ -544,33 +527,10 @@ namespace eos {
}
c->remote_node_id = msg.node_id;
send_peer_message();
}
c->last_handshake = msg;
}
void handle_message (connection_ptr c, const peer_message &msg) {
dlog ("got a peer message with ${pc} from ${r}", ("pc", msg.peers.size())("r",c->last_handshake.p2p_address));
c->shared_peers.clear();
for (auto pnode : msg.peers) {
if (pnode == node_id) {
dlog ("skipping self peernode");
continue;
}
if (pnode == c->remote_node_id) {
dlog ("skipping received connection's node");
continue;
}
for (auto &conn : connections) {
if (conn->remote_node_id == pnode) {
c->mutual_peers.insert (conn);
break;
}
}
c->shared_peers.insert (pnode);
}
}
void handle_message (connection_ptr c, const notice_message &msg) {
dlog ("got a notice message");
notice_message fwd;
......@@ -694,7 +654,7 @@ namespace eos {
node_transaction_state nts = {msg.id(),time_point::now(),msg.expiration,
msg,bn, true};
local_txns.insert(nts);
forward (c, msg);
forward(c, msg);
}
}
......@@ -704,12 +664,12 @@ namespace eos {
chain_controller &cc = chain_plug->chain();
if (cc.is_known_block(msg.id())) {
// dlog ("block id ${id} is known", ("id", msg.id()) );
dlog ("block id ${id} is known", ("id", msg.id()) );
return;
}
uint32_t num = 0;
for( auto ss = c->in_sync_state.begin(); ss != c->in_sync_state.end(); ) {
for( auto ss = c->in_sync_state.begin(); ss != c->in_sync_state.end(); ++ss ) {
if (msg.block_num() == ss->last + 1 && msg.block_num() <= ss->end_block) {
num = msg.block_num();
ss.get_node()->value().last = num;
......@@ -922,7 +882,7 @@ namespace eos {
my->acceptor->set_option(tcp::acceptor::reuse_address(true));
my->acceptor->bind(my->listen_endpoint);
my->acceptor->listen();
my->chain_plug->chain().on_pending_transaction.connect (&net_plugin_impl::pending_txn);
my->chain_plug->chain().on_pending_transaction.connect( &net_plugin_impl::pending_txn );
my->start_listen_loop();
}
......
......@@ -143,6 +143,7 @@ void create_account(Name creator, Name newaccount, public_key_type owner, public
int main( int argc, char** argv ) {
CLI::App app{"Command Line Interface to Eos Daemon"};
app.require_subcommand();
app.add_option( "-p,--port", port, "the port where eosd is running", true );
// Create subcommand
auto create = app.add_subcommand("create", "Create various items, on and off the blockchain", false);
......
[toc]
#EOS Testnet
# EOS Testnet
To date, all work done to experiment with the EOS blockchain has been performed using a single instance of eosd hosting all 21 block producers. While this is a perfectly valid solution for validating features of the blockchain, developing new contracts, or whatever, it does not scale. Nor does it expose the sort of issues raised when contract and block data must be shared across multiple instances. Providing the ability to scale involves deploying multiple eosd nodes across many hosts and lining then into a peer-to-peer (p2p) network. Composing this network involves tailoring and distributing configuration files, coordinating starts and stops and other tasks.
Doing this manually is a tedious task and easily error prone. Fortunately a solution is provided, in the form of the Launcher application, described below.
......@@ -33,23 +33,23 @@ Network topology or "shape" describes how the nodes are connected in order to sh
The Launcher has definitions of three different network "shapes" based on inter-nodal connections, which can be selected by a command line option, or you can supply your own network topology by editing the Launcher generated configuration file.
####Ring network
#### Ring network
This is the simplest network, where each node identifies just the node next to it as it's only peer.
####Star network
#### Star network
A "star" is intended to support the use larger number nodes in the testnet. In this case the number of peers connected to a node and the distribution of those nodes varies based on the number of nodes in the network.
####Mesh network
#### Mesh network
In a "mesh" network, each node is connected to as many peer nodes as possible.
#The Launcher Application
# The Launcher Application
To address the complexity implied by distributing multiple eosd nodes across a LAN or a wider network, the launcher application was created.
Based on a handful of command line arguments the Launcher is able to compose per-node configuration files, distribute these files securely amongst the peer hosts, then start up the multiple instances of eosd.
Eosd instances started this way have their output logged in individual text files. Finally the launcher application is also able to shut down some or all of the test network.
##Running the Launcher application
## Running the Launcher application
The launcher program is used to configure and deploy producing and non-producing eosd nodes that talk to each other using configured routes. The configuration for each node is stored in separate directories, permitting multiple nodes to be active on the same host, assuming the machine has sufficient memory and disk space for multiple eosd instances. The launcher makes use of multiple configuration sources in order to deploy a testnet. A handful of command line arguments can be used to set up simple local networks.
......@@ -140,7 +140,7 @@ The ssh helper fields are paths to ssh and scp, an identity if necessary, and an
The rest of the testnet.json file is the collection of node descriptors. The fragment shown above was created with the command line `programs/launcher/launcher -p6 -s mesh -o testnet.json` and then edited to refer to a remote host named "remoteserv."
###Elements Of The JSON File
### Elements Of The JSON File
This table describes all of the key/value pairs used in the testnet.json file.
|Value | Description
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册