Remove generate_hash_votes_at from config (#1170)

* Remove generate_hash_votes time from config

* Clear blocks_bundle

* Default 0 for generate_hash_votes_at v14

* republish_block should only republish block without voting

* Put new version

* Remove unused condition

* Remove unnessesary blocks_bundle.clear ()

* Remove unused transaction

* Remove transaction from network.republish_block

* Fixes

* Returning correct files permissions

* Correct permission for common.sh
This commit is contained in:
SergiySW 2018-10-05 00:33:21 +03:00 committed by Lee Bousfield
commit 956713dc43
8 changed files with 21 additions and 59 deletions

View file

@ -76,7 +76,7 @@ TEST (gap_cache, gap_bootstrap)
// The separate publish and vote system doesn't work very well here because it's instantly confirmed.
// We help it get the block and vote out here.
auto transaction (system.nodes[0]->store.tx_begin ());
system.nodes[0]->network.republish_block (transaction, latest_block);
system.nodes[0]->network.republish_block (latest_block);
}
while (system.nodes[1]->balance (rai::genesis_account) != rai::genesis_amount - 200)
{

View file

@ -153,7 +153,7 @@ TEST (network, send_discarded_publish)
rai::genesis genesis;
{
auto transaction (system.nodes[0]->store.tx_begin ());
system.nodes[0]->network.republish_block (transaction, block);
system.nodes[0]->network.republish_block (block);
ASSERT_EQ (genesis.hash (), system.nodes[0]->ledger.latest (transaction, rai::test_genesis_key.pub));
ASSERT_EQ (genesis.hash (), system.nodes[1]->latest (rai::test_genesis_key.pub));
}
@ -174,7 +174,7 @@ TEST (network, send_invalid_publish)
auto block (std::make_shared<rai::send_block> (1, 1, 20, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (1)));
{
auto transaction (system.nodes[0]->store.tx_begin ());
system.nodes[0]->network.republish_block (transaction, block);
system.nodes[0]->network.republish_block (block);
ASSERT_EQ (genesis.hash (), system.nodes[0]->ledger.latest (transaction, rai::test_genesis_key.pub));
ASSERT_EQ (genesis.hash (), system.nodes[1]->latest (rai::test_genesis_key.pub));
}

View file

@ -603,7 +603,7 @@ TEST (node, confirm_locked)
auto transaction (system.nodes[0]->store.tx_begin ());
system.wallet (0)->enter_password (transaction, "1");
auto block (std::make_shared<rai::send_block> (0, 0, 0, rai::keypair ().prv, 0, 0));
system.nodes[0]->network.republish_block (transaction, block);
system.nodes[0]->network.republish_block (block);
}
TEST (node_config, random_rep)

View file

@ -272,42 +272,8 @@ bool confirm_block (rai::transaction const & transaction_a, rai::node & node_a,
return result;
}
void rai::network::republish_block (rai::transaction const & transaction, std::shared_ptr<rai::block> block, bool enable_voting)
void rai::network::republish_block (std::shared_ptr<rai::block> block)
{
auto hash (block->hash ());
auto list (node.peers.list_fanout ());
// If we're a representative, broadcast a signed confirm, otherwise an unsigned publish
if (!enable_voting || !confirm_block (transaction, node, list, block))
{
rai::publish message (block);
std::shared_ptr<std::vector<uint8_t>> bytes (new std::vector<uint8_t>);
{
rai::vectorstream stream (*bytes);
message.serialize (stream);
}
auto hash (block->hash ());
for (auto i (list.begin ()), n (list.end ()); i != n; ++i)
{
republish (hash, bytes, *i);
}
if (node.config.logging.network_logging ())
{
BOOST_LOG (node.log) << boost::str (boost::format ("Block %1% was republished to peers") % hash.to_string ());
}
}
else
{
if (node.config.logging.network_logging ())
{
BOOST_LOG (node.log) << boost::str (boost::format ("Block %1% was confirmed to peers") % hash.to_string ());
}
}
}
void rai::network::republish_block_batch (std::deque<std::shared_ptr<rai::block>> blocks_a, unsigned delay_a)
{
auto block (blocks_a.front ());
blocks_a.pop_front ();
auto hash (block->hash ());
auto list (node.peers.list_fanout ());
rai::publish message (block);
@ -324,6 +290,13 @@ void rai::network::republish_block_batch (std::deque<std::shared_ptr<rai::block>
{
BOOST_LOG (node.log) << boost::str (boost::format ("Block %1% was republished to peers") % hash.to_string ());
}
}
void rai::network::republish_block_batch (std::deque<std::shared_ptr<rai::block>> blocks_a, unsigned delay_a)
{
auto block (blocks_a.front ());
blocks_a.pop_front ();
republish_block (block);
if (!blocks_a.empty ())
{
std::weak_ptr<rai::node> node_w (node.shared ());
@ -1053,9 +1026,6 @@ block_processor_batch_max_time (std::chrono::milliseconds (5000))
preconfigured_representatives.push_back (rai::account ("2399A083C600AA0572F5E36247D978FCFC840405F8D4B6D33161C0066A55F431"));
preconfigured_representatives.push_back (rai::account ("2298FAB7C61058E77EA554CB93EDEEDA0692CBFCC540AB213B2836B29029E23A"));
preconfigured_representatives.push_back (rai::account ("3FE80B4BC842E82C1C18ABFEEC47EA989E63953BC82AC411F304D13833D52A56"));
// 2018-09-01 UTC 00:00 in unix time
// Technically, time_t is never defined to be unix time, but compilers implement it as such
generate_hash_votes_at = std::chrono::system_clock::from_time_t (1535760000);
break;
default:
assert (false);
@ -1108,7 +1078,6 @@ void rai::node_config::serialize_json (boost::property_tree::ptree & tree_a) con
tree_a.put ("callback_port", std::to_string (callback_port));
tree_a.put ("callback_target", callback_target);
tree_a.put ("lmdb_max_dbs", lmdb_max_dbs);
tree_a.put ("generate_hash_votes_at", std::chrono::system_clock::to_time_t (generate_hash_votes_at));
tree_a.put ("block_processor_batch_max_time", block_processor_batch_max_time.count ());
}
@ -1212,11 +1181,12 @@ bool rai::node_config::upgrade_json (unsigned version, boost::property_tree::ptr
tree_a.put ("version", "13");
result = true;
case 13:
tree_a.put ("generate_hash_votes_at", std::chrono::system_clock::to_time_t (generate_hash_votes_at));
tree_a.put ("generate_hash_votes_at", "0");
tree_a.erase ("version");
tree_a.put ("version", "14");
result = true;
case 14:
tree_a.erase ("generate_hash_votes_at");
tree_a.put ("block_processor_batch_max_time", block_processor_batch_max_time.count ());
tree_a.erase ("version");
tree_a.put ("version", "15");
@ -1307,8 +1277,6 @@ bool rai::node_config::deserialize_json (bool & upgraded_a, boost::property_tree
callback_target = tree_a.get<std::string> ("callback_target");
auto lmdb_max_dbs_l = tree_a.get<std::string> ("lmdb_max_dbs");
result |= parse_port (callback_port_l, callback_port);
auto generate_hash_votes_at_l = tree_a.get<time_t> ("generate_hash_votes_at");
generate_hash_votes_at = std::chrono::system_clock::from_time_t (generate_hash_votes_at_l);
auto block_processor_batch_max_time_l = tree_a.get<std::string> ("block_processor_batch_max_time");
try
{
@ -3910,7 +3878,7 @@ bool rai::election::publish (std::shared_ptr<rai::block> block_a)
{
blocks.insert (std::make_pair (block_a->hash (), block_a));
confirm_if_quorum (transaction);
node.network.republish_block (transaction, block_a, false);
node.network.republish_block (block_a);
}
}
}
@ -3984,9 +3952,9 @@ void rai::active_transactions::announce_votes ()
// Broadcast winner
if (node.ledger.could_fit (transaction, *election_l->status.winner))
{
if (node.config.enable_voting && std::chrono::system_clock::now () >= node.config.generate_hash_votes_at)
rebroadcast_bundle.push_back (election_l->status.winner);
if (node.config.enable_voting)
{
rebroadcast_bundle.push_back (election_l->status.winner);
blocks_bundle.push_back (election_l->status.winner->hash ());
if (blocks_bundle.size () >= 12)
{
@ -3997,11 +3965,6 @@ void rai::active_transactions::announce_votes ()
blocks_bundle.clear ();
}
}
else
{
election_l->compute_rep_votes (transaction);
rebroadcast_bundle.push_back (election_l->status.winner);
}
}
else
{

View file

@ -412,7 +412,7 @@ public:
void receive_action (rai::udp_data *);
void rpc_action (boost::system::error_code const &, size_t);
void republish_vote (std::shared_ptr<rai::vote>);
void republish_block (rai::transaction const &, std::shared_ptr<rai::block>, bool = true);
void republish_block (std::shared_ptr<rai::block>);
static unsigned const broadcast_interval_ms = (rai::rai_network == rai::rai_networks::rai_test_network) ? 10 : 50;
void republish_block_batch (std::deque<std::shared_ptr<rai::block>>, unsigned = broadcast_interval_ms);
void republish (rai::block_hash const &, std::shared_ptr<std::vector<uint8_t>>, rai::endpoint);
@ -520,7 +520,6 @@ public:
rai::stat_config stat_config;
rai::uint256_union epoch_block_link;
rai::account epoch_block_signer;
std::chrono::system_clock::time_point generate_hash_votes_at;
std::chrono::milliseconds block_processor_batch_max_time;
static std::chrono::seconds constexpr keepalive_period = std::chrono::seconds (60);
static std::chrono::seconds constexpr keepalive_cutoff = keepalive_period * 5;

View file

@ -994,7 +994,7 @@ std::shared_ptr<rai::block> rai::wallet::send_action (rai::account const & sourc
if (block != nullptr)
{
cached_block = true;
wallets.node.network.republish_block (transaction, block);
wallets.node.network.republish_block (block);
}
}
else if (status != MDB_NOTFOUND)

View file

@ -679,7 +679,7 @@ void rai_qt::block_viewer::rebroadcast_action (rai::uint256_union const & hash_a
auto block (wallet.node.store.block_get (transaction, hash_a));
if (block != nullptr)
{
wallet.node.network.republish_block (transaction, std::move (block));
wallet.node.network.republish_block (std::move (block));
auto successor (wallet.node.store.block_successor (transaction, hash_a));
if (!successor.is_zero ())
{

View file

@ -186,7 +186,7 @@ TEST (node, fork_storm)
auto open_result (system.nodes[i]->process (*open));
ASSERT_EQ (rai::process_result::progress, open_result.code);
auto transaction (system.nodes[i]->store.tx_begin ());
system.nodes[i]->network.republish_block (transaction, open);
system.nodes[i]->network.republish_block (open);
}
}
auto again (true);