From 181474b721f3214444738c2835690945d4bdf2a1 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Tue, 24 Oct 2023 15:48:57 -0400 Subject: [PATCH 1/4] read_only_trx unit tests improvements * Increase max-transaction-time for setting bios contract * Refactor tests to use common command line arguments --- tests/test_read_only_trx.cpp | 48 +++++++++++++----------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/tests/test_read_only_trx.cpp b/tests/test_read_only_trx.cpp index 27a6c6be1e..635f58314c 100644 --- a/tests/test_read_only_trx.cpp +++ b/tests/test_read_only_trx.cpp @@ -106,7 +106,16 @@ void test_trxs_common(std::vector& specific_args, bool test_disable std::thread app_thread( [&]() { try { fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug); - std::vector argv = {"test", "--data-dir", temp_dir_str.c_str(), "--config-dir", temp_dir_str.c_str()}; + std::vector argv = { + "test", // dummy executible name + "-p", "eosio", "-e", // actual arguments follow + "--data-dir", temp_dir_str.c_str(), + "--config-dir", temp_dir_str.c_str(), + "--max-transaction-time=100", + "--abi-serializer-max-time-ms=999", + "--read-only-write-window-time-us=10000", + "--read-only-read-window-time-us=400000" + }; argv.insert(argv.end(), specific_args.begin(), specific_args.end()); app->initialize(argv.size(), (char**)&argv[0]); app->find_plugin()->chain(); @@ -180,62 +189,39 @@ void test_trxs_common(std::vector& specific_args, bool test_disable // test read-only trxs on 1 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_1_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=1", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + std::vector specific_args = { "--read-only-threads=1" }; test_trxs_common(specific_args); } // test read-only trxs on 3 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_3_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=3", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + std::vector specific_args = { "--read-only-threads=3" }; test_trxs_common(specific_args); } // test read-only trxs on 3 threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_3_read_only_threads_no_tierup) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=3", + std::vector specific_args = { "--read-only-threads=3", #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED "--eos-vm-oc-enable=none", #endif - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=100000", - "--read-only-read-window-time-us=40000" }; + }; test_trxs_common(specific_args, true); } // test read-only trxs on 8 separate threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_8_read_only_threads) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=8", - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", - "--read-only-read-window-time-us=400000" }; + std::vector specific_args = { "--read-only-threads=8" }; test_trxs_common(specific_args); } // test read-only trxs on 8 separate threads (with --read-only-threads) BOOST_AUTO_TEST_CASE(with_8_read_only_threads_no_tierup) { - std::vector specific_args = { "-p", "eosio", "-e", - "--read-only-threads=8", + std::vector specific_args = { "--read-only-threads=8", #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED "--eos-vm-oc-enable=none", #endif - "--max-transaction-time=10", - "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", - "--read-only-read-window-time-us=400000" }; + }; test_trxs_common(specific_args, true); } From f80545a2568e1db4124de6d67e7ccc5cd6cc49b7 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Wed, 25 Oct 2023 12:20:33 -0400 Subject: [PATCH 2/4] make write-window-time as big as max-transaction-time --- tests/test_read_only_trx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_read_only_trx.cpp b/tests/test_read_only_trx.cpp index a3429f848a..56b684da86 100644 --- a/tests/test_read_only_trx.cpp +++ b/tests/test_read_only_trx.cpp @@ -113,7 +113,7 @@ void test_trxs_common(std::vector& specific_args, bool test_disable "--config-dir", temp_dir_str.c_str(), "--max-transaction-time=100", "--abi-serializer-max-time-ms=999", - "--read-only-write-window-time-us=10000", + "--read-only-write-window-time-us=100000", "--read-only-read-window-time-us=400000" }; argv.insert(argv.end(), specific_args.begin(), specific_args.end()); From fa7d5ea28f0bcb471deb3429c39a3073754434ea Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Thu, 26 Oct 2023 09:05:49 -0400 Subject: [PATCH 3/4] Undo the temporary switch to `mapped` mode when loading a snapshot in `mapped_private` mode. --- libraries/chain/controller.cpp | 2 -- libraries/chain/include/eosio/chain/controller.hpp | 1 - plugins/chain_plugin/chain_plugin.cpp | 7 ------- 3 files changed, 10 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index ca586a3af6..51e1d4a198 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -609,8 +609,6 @@ struct controller_impl { ilog( "Snapshot loaded, lib: ${lib}", ("lib", head->block_num) ); init(std::move(check_shutdown)); - if (conf.revert_to_private_mode) - db.revert_to_private_mode(); auto snapshot_load_time = (fc::time_point::now() - snapshot_load_start_time).to_seconds(); ilog( "Finished initialization from snapshot (snapshot load time was ${t}s)", ("t", snapshot_load_time) ); } catch (boost::interprocess::bad_alloc& e) { diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index f03d61a1f1..e25a201050 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -79,7 +79,6 @@ namespace eosio { namespace chain { bool disable_replay_opts = false; bool contracts_console = false; bool allow_ram_billing_in_notify = false; - bool revert_to_private_mode = false; uint32_t maximum_variable_signature_length = chain::config::default_max_variable_signature_length; bool disable_all_subjective_mitigations = false; //< for developer & testing purposes, can be configured using `disable-all-subjective-mitigations` when `EOSIO_DEVELOPER` build option is provided uint32_t terminate_at_block = 0; diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 69dd037851..4ccbc264c0 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -927,13 +927,6 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) { chain_config->db_map_mode = options.at("database-map-mode").as(); - // when loading a snapshot, all the state will be modified, so temporarily use the `mapped` mode instead - // of `mapped_private` to lower memory requirements. - if (snapshot_path && chain_config->db_map_mode == pinnable_mapped_file::mapped_private) { - chain_config->db_map_mode = pinnable_mapped_file::mapped; - chain_config->revert_to_private_mode = true; // revert to `mapped_private` mode after loading snapshot. - } - #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED if( options.count("eos-vm-oc-cache-size-mb") ) chain_config->eosvmoc_config.cache_size = options.at( "eos-vm-oc-cache-size-mb" ).as() * 1024u * 1024u; From 1e695684d2c51a4c68c84406ddbcc78938addfa7 Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Thu, 26 Oct 2023 13:34:13 -0400 Subject: [PATCH 4/4] Update chainbase to tip (removal of unused member functions) --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 13c9c35e39..7615ddab28 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 13c9c35e393f1739c053ff7a03edb4d9df30990d +Subproject commit 7615ddab287e06fd31f800e66fe39b3a19320ec8