Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove node v18 and earlier upgrade support #2770

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
468 changes: 1 addition & 467 deletions nano/core_test/block_store.cpp

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions nano/core_test/ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,6 @@ TEST (ipc, synchronous)
ipc.stop ();
}

TEST (ipc, config_upgrade_v0_v1)
{
auto path1 (nano::unique_path ());
auto path2 (nano::unique_path ());
nano::ipc::ipc_config config1;
nano::ipc::ipc_config config2;
nano::jsonconfig tree;
config1.serialize_json (tree);
nano::jsonconfig local = tree.get_required_child ("local");
local.erase ("version");
local.erase ("allow_unsafe");
bool upgraded (false);
ASSERT_FALSE (config2.deserialize_json (upgraded, tree));
nano::jsonconfig local2 = tree.get_required_child ("local");
ASSERT_TRUE (upgraded);
ASSERT_LE (1, local2.get<int> ("version"));
ASSERT_FALSE (local2.get<bool> ("allow_unsafe"));
}

TEST (ipc, permissions_default_user)
{
// Test empty/nonexistant access config. The default user still exists with default permissions.
Expand Down
58 changes: 0 additions & 58 deletions nano/core_test/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,64 +58,6 @@ TEST (logging, serialization)
ASSERT_EQ (logging1.min_time_between_log_output, logging2.min_time_between_log_output);
}

TEST (logging, upgrade_v1_v2)
{
auto path1 (nano::unique_path ());
auto path2 (nano::unique_path ());
nano::logging logging1;
logging1.init (path1);
nano::logging logging2;
logging2.init (path2);
nano::jsonconfig tree;
logging1.serialize_json (tree);
tree.erase ("version");
tree.erase ("vote");
bool upgraded (false);
ASSERT_FALSE (logging2.deserialize_json (upgraded, tree));
ASSERT_LE (2, tree.get<int> ("version"));
ASSERT_FALSE (tree.get<bool> ("vote"));
}

TEST (logging, upgrade_v6_v7)
{
auto path1 (nano::unique_path ());
auto path2 (nano::unique_path ());
nano::logging logging1;
logging1.init (path1);
nano::logging logging2;
logging2.init (path2);
nano::jsonconfig tree;
logging1.serialize_json (tree);
tree.erase ("version");
tree.erase ("min_time_between_output");
tree.erase ("network_timeout_logging_value");
bool upgraded (false);
ASSERT_FALSE (logging2.deserialize_json (upgraded, tree));
ASSERT_TRUE (upgraded);
ASSERT_LE (7, tree.get<int> ("version"));
ASSERT_EQ (5, tree.get<uintmax_t> ("min_time_between_output"));
ASSERT_EQ (false, tree.get<bool> ("network_timeout_logging_value"));
}

TEST (logging, upgrade_v7_v8)
{
auto path1 (nano::unique_path ());
auto path2 (nano::unique_path ());
nano::logging logging1;
logging1.init (path1);
nano::logging logging2;
logging2.init (path2);
nano::jsonconfig tree;
logging1.serialize_json (tree);
tree.erase ("version");
tree.erase ("single_line_record");
bool upgraded (false);
ASSERT_FALSE (logging2.deserialize_json (upgraded, tree));
ASSERT_TRUE (upgraded);
ASSERT_LE (8, tree.get<int> ("version"));
ASSERT_EQ (false, tree.get<bool> ("single_line_record"));
}

TEST (logger, changing_time_interval)
{
auto path1 (nano::unique_path ());
Expand Down
191 changes: 0 additions & 191 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,197 +618,6 @@ TEST (node_config, serialization)
ASSERT_EQ (config2.deprecated_lmdb_max_dbs, config1.deprecated_lmdb_max_dbs);
}

TEST (node_config, v1_v2_upgrade)
{
auto path (nano::unique_path ());
nano::logging logging1;
logging1.init (path);
nano::jsonconfig tree;
tree.put ("peering_port", std::to_string (0));
tree.put ("packet_delay_microseconds", std::to_string (0));
tree.put ("bootstrap_fraction_numerator", std::to_string (0));
tree.put ("creation_rebroadcast", std::to_string (0));
tree.put ("rebroadcast_delay", std::to_string (0));
tree.put ("receive_minimum", nano::amount (0).to_string_dec ());
nano::jsonconfig logging_l;
logging1.serialize_json (logging_l);
tree.put_child ("logging", logging_l);
nano::jsonconfig preconfigured_peers_l;
tree.put_child ("preconfigured_peers", preconfigured_peers_l);
nano::jsonconfig preconfigured_representatives_l;
tree.put_child ("preconfigured_representatives", preconfigured_representatives_l);
bool upgraded (false);
nano::node_config config1;
config1.logging.init (path);
ASSERT_FALSE (tree.get_optional_child ("work_peers"));
config1.deserialize_json (upgraded, tree);
ASSERT_TRUE (upgraded);
ASSERT_TRUE (!!tree.get_optional_child ("work_peers"));
}

TEST (node_config, v2_v3_upgrade)
{
nano::jsonconfig tree;
add_required_children_node_config_tree (tree);
tree.put ("peering_port", std::to_string (0));
tree.put ("packet_delay_microseconds", std::to_string (0));
tree.put ("bootstrap_fraction_numerator", std::to_string (0));
tree.put ("creation_rebroadcast", std::to_string (0));
tree.put ("rebroadcast_delay", std::to_string (0));
tree.put ("receive_minimum", nano::amount (0).to_string_dec ());
tree.put ("version", "2");

nano::jsonconfig preconfigured_representatives_l;
preconfigured_representatives_l.push ("TR6ZJ4pdp6HC76xMRpVDny5x2s8AEbrhFue3NKVxYYdmKuTEib");
tree.replace_child ("preconfigured_representatives", preconfigured_representatives_l);

bool upgraded (false);
nano::node_config config1;
auto path (nano::unique_path ());
config1.logging.init (path);
ASSERT_FALSE (tree.get_optional<std::string> ("inactive_supply"));
ASSERT_FALSE (tree.get_optional<std::string> ("password_fanout"));
ASSERT_FALSE (tree.get_optional<std::string> ("io_threads"));
ASSERT_FALSE (tree.get_optional<std::string> ("work_threads"));
config1.deserialize_json (upgraded, tree);
//ASSERT_EQ (nano::uint128_union (0).to_string_dec (), tree.get<std::string> ("inactive_supply"));
ASSERT_EQ ("1024", tree.get<std::string> ("password_fanout"));
ASSERT_NE (0, std::stoul (tree.get<std::string> ("password_fanout")));
ASSERT_TRUE (upgraded);
auto version (tree.get<std::string> ("version"));
ASSERT_GT (std::stoull (version), 2);
}

TEST (node_config, v15_v16_upgrade)
{
auto test_upgrade = [](auto old_preconfigured_peers_url, auto new_preconfigured_peers_url) {
auto path (nano::unique_path ());
nano::jsonconfig tree;
add_required_children_node_config_tree (tree);
tree.put ("version", "15");

const char * dummy_peer = "127.5.2.1";
nano::jsonconfig preconfigured_peers_json;
preconfigured_peers_json.push (old_preconfigured_peers_url);
preconfigured_peers_json.push (dummy_peer);
tree.replace_child ("preconfigured_peers", preconfigured_peers_json);

auto upgraded (false);
nano::node_config config;
config.logging.init (path);
// These config options should not be present at version 15
ASSERT_FALSE (tree.get_optional_child ("allow_local_peers"));
ASSERT_FALSE (tree.get_optional_child ("signature_checker_threads"));
ASSERT_FALSE (tree.get_optional_child ("vote_minimum"));
config.deserialize_json (upgraded, tree);
// The config options should be added after the upgrade
ASSERT_TRUE (!!tree.get_optional_child ("allow_local_peers"));
ASSERT_TRUE (!!tree.get_optional_child ("signature_checker_threads"));
ASSERT_TRUE (!!tree.get_optional_child ("vote_minimum"));

ASSERT_TRUE (upgraded);
auto version (tree.get<std::string> ("version"));

auto read_preconfigured_peers_json (tree.get_required_child ("preconfigured_peers"));
std::vector<std::string> preconfigured_peers;
read_preconfigured_peers_json.array_entries<std::string> ([&preconfigured_peers](const auto & entry) {
preconfigured_peers.push_back (entry);
});

// Check that the new peer is updated while the other peer is untouched
ASSERT_EQ (preconfigured_peers.size (), 2);
ASSERT_EQ (preconfigured_peers.front (), new_preconfigured_peers_url);
ASSERT_EQ (preconfigured_peers.back (), dummy_peer);

// Check version is updated
ASSERT_GT (std::stoull (version), 15);
};

// Check that upgrades work with both
test_upgrade ("rai.raiblocks.net", "peering.nano.org");
test_upgrade ("rai-beta.raiblocks.net", "peering-beta.nano.org");
}

TEST (node_config, v16_values)
{
nano::jsonconfig tree;
add_required_children_node_config_tree (tree);

auto path (nano::unique_path ());
auto upgraded (false);
nano::node_config config;
config.logging.init (path);

// Check config is correct
tree.put ("allow_local_peers", false);
tree.put ("signature_checker_threads", 1);
tree.put ("vote_minimum", nano::Gxrb_ratio.convert_to<std::string> ());
config.deserialize_json (upgraded, tree);
ASSERT_FALSE (upgraded);
ASSERT_FALSE (config.allow_local_peers);
ASSERT_EQ (config.signature_checker_threads, 1);
ASSERT_EQ (config.vote_minimum.number (), nano::Gxrb_ratio);

// Check config is correct with other values
tree.put ("allow_local_peers", true);
tree.put ("signature_checker_threads", 4);
tree.put ("vote_minimum", (std::numeric_limits<nano::uint128_t>::max () - 100).convert_to<std::string> ());
upgraded = false;
config.deserialize_json (upgraded, tree);
ASSERT_FALSE (upgraded);
ASSERT_TRUE (config.allow_local_peers);
ASSERT_EQ (config.signature_checker_threads, 4);
ASSERT_EQ (config.vote_minimum.number (), std::numeric_limits<nano::uint128_t>::max () - 100);
}

TEST (node_config, v16_v17_upgrade)
{
auto path (nano::unique_path ());
nano::jsonconfig tree;
add_required_children_node_config_tree (tree);
tree.put ("version", "16");

auto upgraded (false);
nano::node_config config;
config.logging.init (path);
// These config options should not be present
ASSERT_FALSE (tree.get_optional_child ("tcp_io_timeout"));
ASSERT_FALSE (tree.get_optional_child ("pow_sleep_interval"));
ASSERT_FALSE (tree.get_optional_child ("external_address"));
ASSERT_FALSE (tree.get_optional_child ("external_port"));
ASSERT_FALSE (tree.get_optional_child ("tcp_incoming_connections_max"));
ASSERT_FALSE (tree.get_optional_child ("vote_generator_delay"));
ASSERT_FALSE (tree.get_optional_child ("vote_generator_threshold"));
ASSERT_FALSE (tree.get_optional_child ("diagnostics"));
ASSERT_FALSE (tree.get_optional_child ("use_memory_pools"));
ASSERT_FALSE (tree.get_optional_child ("confirmation_history_size"));
ASSERT_FALSE (tree.get_optional_child ("active_elections_size"));
ASSERT_FALSE (tree.get_optional_child ("bandwidth_limit"));
ASSERT_FALSE (tree.get_optional_child ("conf_height_processor_batch_min_time"));

config.deserialize_json (upgraded, tree);
// The config options should be added after the upgrade
ASSERT_TRUE (!!tree.get_optional_child ("tcp_io_timeout"));
ASSERT_TRUE (!!tree.get_optional_child ("pow_sleep_interval"));
ASSERT_TRUE (!!tree.get_optional_child ("external_address"));
ASSERT_TRUE (!!tree.get_optional_child ("external_port"));
ASSERT_TRUE (!!tree.get_optional_child ("tcp_incoming_connections_max"));
ASSERT_TRUE (!!tree.get_optional_child ("vote_generator_delay"));
ASSERT_TRUE (!!tree.get_optional_child ("vote_generator_threshold"));
ASSERT_TRUE (!!tree.get_optional_child ("diagnostics"));
ASSERT_TRUE (!!tree.get_optional_child ("use_memory_pools"));
ASSERT_TRUE (!!tree.get_optional_child ("confirmation_history_size"));
ASSERT_TRUE (!!tree.get_optional_child ("active_elections_size"));
ASSERT_TRUE (!!tree.get_optional_child ("bandwidth_limit"));
ASSERT_TRUE (!!tree.get_optional_child ("conf_height_processor_batch_min_time"));

ASSERT_TRUE (upgraded);
auto version (tree.get<std::string> ("version"));

// Check version is updated
ASSERT_GT (std::stoull (version), 16);
}

TEST (node_config, v17_values)
{
nano::jsonconfig tree;
Expand Down
72 changes: 0 additions & 72 deletions nano/core_test/versioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,6 @@

#include <gtest/gtest.h>

TEST (versioning, account_info_v1)
{
auto file (nano::unique_path ());
nano::account account (1);
nano::open_block open (1, 2, 3, nullptr);
open.sideband_set ({});
nano::account_info_v1 v1 (open.hash (), open.hash (), 3, 4);
{
nano::logger_mt logger;
nano::mdb_store store (logger, file);
ASSERT_FALSE (store.init_error ());
auto transaction (store.tx_begin_write ());
store.block_put (transaction, open.hash (), open);
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), nano::mdb_val (sizeof (v1), &v1), 0));
ASSERT_EQ (0, status);
store.version_put (transaction, 1);
}

nano::logger_mt logger;
nano::mdb_store store (logger, file);
ASSERT_FALSE (store.init_error ());
auto transaction (store.tx_begin_read ());
nano::account_info v_latest;
ASSERT_FALSE (store.account_get (transaction, account, v_latest));
ASSERT_EQ (open.hash (), v_latest.open_block);
ASSERT_EQ (v1.balance, v_latest.balance);
ASSERT_EQ (v1.head, v_latest.head);
ASSERT_EQ (v1.modified, v_latest.modified);
ASSERT_EQ (v1.rep_block, open.hash ());
ASSERT_EQ (1, v_latest.block_count);
nano::confirmation_height_info confirmation_height_info;
ASSERT_FALSE (store.confirmation_height_get (transaction, account, confirmation_height_info));
ASSERT_EQ (0, confirmation_height_info.height);
ASSERT_EQ (nano::epoch::epoch_0, v_latest.epoch ());
}

TEST (versioning, account_info_v5)
{
auto file (nano::unique_path ());
nano::account account (1);
nano::open_block open (1, 2, 3, nullptr);
open.sideband_set ({});
nano::account_info_v5 v5 (open.hash (), open.hash (), open.hash (), 3, 4);
{
nano::logger_mt logger;
nano::mdb_store store (logger, file);
ASSERT_FALSE (store.init_error ());
auto transaction (store.tx_begin_write ());
store.block_put (transaction, open.hash (), open);
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), nano::mdb_val (sizeof (v5), &v5), 0));
ASSERT_EQ (0, status);
store.version_put (transaction, 5);
}

nano::logger_mt logger;
nano::mdb_store store (logger, file);
ASSERT_FALSE (store.init_error ());
auto transaction (store.tx_begin_read ());
nano::account_info v_latest;
ASSERT_FALSE (store.account_get (transaction, account, v_latest));
ASSERT_EQ (v5.open_block, v_latest.open_block);
ASSERT_EQ (v5.balance, v_latest.balance);
ASSERT_EQ (v5.head, v_latest.head);
ASSERT_EQ (v5.modified, v_latest.modified);
ASSERT_EQ (v5.rep_block, open.hash ());
ASSERT_EQ (1, v_latest.block_count);
nano::confirmation_height_info confirmation_height_info;
ASSERT_FALSE (store.confirmation_height_get (transaction, account, confirmation_height_info));
ASSERT_EQ (0, confirmation_height_info.height);
ASSERT_EQ (nano::epoch::epoch_0, v_latest.epoch ());
}

TEST (versioning, account_info_v13)
{
auto file (nano::unique_path ());
Expand Down
Loading