Update confirmation heights with new async timing (#1899)

* Fix timing issue in tests

* Increase deadline time

* Remove RPC tests from core_tests

* Make sure quorum is valid in confirmation_height.multiple test.
This commit is contained in:
Wesley Shillingford 2019-04-11 22:44:07 +01:00 committed by GitHub
commit 644c84f2cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 5149 deletions

View file

@ -16,7 +16,6 @@ add_executable (core_test
message_parser.cpp
processor_service.cpp
peer_container.cpp
rpc.cpp
signing.cpp
timer.cpp
uint256_union.cpp

View file

@ -1456,7 +1456,8 @@ TEST (confirmation_height, single)
TEST (confirmation_height, multiple)
{
auto amount (std::numeric_limits<nano::uint128_t>::max ());
nano::system system (24000, 2);
bool delay_frontier_confirmation_height_updating = true;
nano::system system (24000, 2, delay_frontier_confirmation_height_updating);
nano::keypair key1;
nano::keypair key2;
nano::keypair key3;
@ -1467,8 +1468,8 @@ TEST (confirmation_height, multiple)
system.wallet (1)->insert_adhoc (key3.prv);
// Send to all accounts
nano::send_block send1 (latest1, key1.pub, 300, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
nano::send_block send2 (send1.hash (), key2.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
nano::send_block send1 (latest1, key1.pub, 60000 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (latest1));
nano::send_block send2 (send1.hash (), key2.pub, 60000 * nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send1.hash ()));
nano::send_block send3 (send2.hash (), key3.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (send2.hash ()));
// Open all accounts
@ -1637,7 +1638,8 @@ TEST (confirmation_height, gap_bootstrap)
TEST (confirmation_height, gap_live)
{
nano::system system (24000, 2);
bool delay_frontier_confirmation_height_updating = true;
nano::system system (24000, 2, delay_frontier_confirmation_height_updating);
nano::keypair destination;
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
nano::block_hash latest1 (system.nodes[0]->latest (nano::test_genesis_key.pub));
@ -1687,7 +1689,7 @@ TEST (confirmation_height, gap_live)
while (true)
{
auto transaction = node->store.tx_begin_read ();
if (node->ledger.block_confirmed (transaction, open1->hash ()))
if (node->ledger.block_confirmed (transaction, receive2->hash ()))
{
break;
}
@ -1696,19 +1698,15 @@ TEST (confirmation_height, gap_live)
}
// This should confirm the open block and the source of the receive blocks
{
auto transaction (node->store.tx_begin ());
auto unchecked_count (node->store.unchecked_count (transaction));
ASSERT_EQ (unchecked_count, 0);
auto transaction (node->store.tx_begin ());
auto unchecked_count (node->store.unchecked_count (transaction));
ASSERT_EQ (unchecked_count, 0);
nano::account_info account_info;
ASSERT_FALSE (node->store.account_get (transaction, nano::test_genesis_key.pub, account_info));
ASSERT_EQ (4, account_info.block_count);
ASSERT_EQ (2, account_info.confirmation_height);
ASSERT_FALSE (node->store.account_get (transaction, destination.pub, account_info));
ASSERT_EQ (1, account_info.confirmation_height);
ASSERT_EQ (3, account_info.block_count);
}
nano::account_info account_info;
ASSERT_FALSE (node->store.account_get (transaction, nano::test_genesis_key.pub, account_info));
ASSERT_EQ (4, account_info.confirmation_height);
ASSERT_FALSE (node->store.account_get (transaction, destination.pub, account_info));
ASSERT_EQ (3, account_info.confirmation_height);
}
}

File diff suppressed because it is too large Load diff

View file

@ -1010,7 +1010,7 @@ node (init_a, io_ctx_a, application_path_a, alarm_a, nano::node_config (peering_
{
}
nano::node::node (nano::node_init & init_a, boost::asio::io_context & io_ctx_a, boost::filesystem::path const & application_path_a, nano::alarm & alarm_a, nano::node_config const & config_a, nano::work_pool & work_a, nano::node_flags flags_a) :
nano::node::node (nano::node_init & init_a, boost::asio::io_context & io_ctx_a, boost::filesystem::path const & application_path_a, nano::alarm & alarm_a, nano::node_config const & config_a, nano::work_pool & work_a, nano::node_flags flags_a, bool delay_frontier_confirmation_height_updating) :
io_ctx (io_ctx_a),
config (config_a),
flags (flags_a),
@ -1041,7 +1041,7 @@ block_processor_thread ([this]() {
online_reps (*this, config.online_weight_minimum.number ()),
stats (config.stat_config),
vote_uniquer (block_uniquer),
active (*this),
active (*this, delay_frontier_confirmation_height_updating),
startup_time (std::chrono::steady_clock::now ())
{
if (config.websocket_config.enabled)
@ -3335,10 +3335,11 @@ size_t nano::active_transactions::size ()
return roots.size ();
}
nano::active_transactions::active_transactions (nano::node & node_a) :
nano::active_transactions::active_transactions (nano::node & node_a, bool delay_frontier_confirmation_height_updating) :
node (node_a),
difficulty_cb (20, node.network_params.network.publish_threshold),
active_difficulty (node.network_params.network.publish_threshold),
next_frontier_check (std::chrono::steady_clock::now () + (delay_frontier_confirmation_height_updating ? std::chrono::seconds (60) : std::chrono::seconds (0))),
started (false),
stopped (false),
thread ([this]() {

View file

@ -99,7 +99,7 @@ public:
class active_transactions final
{
public:
explicit active_transactions (nano::node &);
explicit active_transactions (nano::node &, bool delay_frontier_confirmation_height_updating = false);
~active_transactions ();
// Start an election for a block
// Call action with confirmed block, may be different than what we started with
@ -420,7 +420,7 @@ class node final : public std::enable_shared_from_this<nano::node>
{
public:
node (nano::node_init &, boost::asio::io_context &, uint16_t, boost::filesystem::path const &, nano::alarm &, nano::logging const &, nano::work_pool &);
node (nano::node_init &, boost::asio::io_context &, boost::filesystem::path const &, nano::alarm &, nano::node_config const &, nano::work_pool &, nano::node_flags = nano::node_flags ());
node (nano::node_init &, boost::asio::io_context &, boost::filesystem::path const &, nano::alarm &, nano::node_config const &, nano::work_pool &, nano::node_flags = nano::node_flags (), bool delay_frontier_confirmation_height_updating = false);
~node ();
template <typename T>
void background (T action_a)

View file

@ -20,7 +20,7 @@ std::string nano::error_system_messages::message (int ev) const
return "Invalid error code";
}
nano::system::system (uint16_t port_a, uint16_t count_a) :
nano::system::system (uint16_t port_a, uint16_t count_a, boost::optional<bool> delay_frontier_confirmation_height_updating_a) :
alarm (io_ctx),
work (1)
{
@ -35,7 +35,8 @@ work (1)
{
nano::node_init init;
nano::node_config config (port_a + i, logging);
auto node (std::make_shared<nano::node> (init, io_ctx, nano::unique_path (), alarm, config, work));
bool delay_frontier_confirmation_height_updating = delay_frontier_confirmation_height_updating_a ? *delay_frontier_confirmation_height_updating_a : false;
auto node (std::make_shared<nano::node> (init, io_ctx, nano::unique_path (), alarm, config, work, nano::node_flags (), delay_frontier_confirmation_height_updating));
assert (!init.error ());
node->start ();
nano::uint256_union wallet;

View file

@ -15,7 +15,7 @@ enum class error_system
class system final
{
public:
system (uint16_t, uint16_t);
system (uint16_t, uint16_t, boost::optional<bool> delay_frontier_confirmation_height_updating_a = boost::none);
~system ();
void generate_activity (nano::node &, std::vector<nano::account> &);
void generate_mass_activity (uint32_t, nano::node &);