diff --git a/programs/nodeos/CMakeLists.txt b/programs/nodeos/CMakeLists.txt index 493c9e3a43..49b43670b4 100644 --- a/programs/nodeos/CMakeLists.txt +++ b/programs/nodeos/CMakeLists.txt @@ -5,7 +5,6 @@ if( UNIX AND NOT APPLE ) endif() configure_file(config.hpp.in config.hpp ESCAPE_QUOTES) -configure_file(logging.json ${CMAKE_BINARY_DIR}/tests/TestHarness/logging-template.json) target_include_directories(${NODE_EXECUTABLE_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ed884355da..b73809254d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -274,7 +274,7 @@ set_property(TEST gelf_test PROPERTY LABELS nonparallelizable_tests) add_test(NAME performance_test_bp COMMAND tests/PerformanceHarnessScenarioRunner.py findMax testBpOpMode --max-tps-to-test 50 --test-iteration-min-step 10 --test-iteration-duration-sec 10 --final-iterations-duration-sec 10 --calc-chain-threads lmax overrideBasicTestConfig -v --tps-limit-per-generator 25 --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_api COMMAND tests/PerformanceHarnessScenarioRunner.py findMax testApiOpMode --max-tps-to-test 50 --test-iteration-min-step 10 --test-iteration-duration-sec 10 --final-iterations-duration-sec 10 --calc-chain-threads lmax overrideBasicTestConfig -v --tps-limit-per-generator 25 --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -add_test(NAME performance_test_read_only_trxs COMMAND tests/PerformanceHarnessScenarioRunner.py findMax testApiOpMode --max-tps-to-test 50 --test-iteration-min-step 10 --test-iteration-duration-sec 10 --final-iterations-duration-sec 10 overrideBasicTestConfig -v --tps-limit-per-generator 25 --api-nodes-read-only-threads 2 --read-only-write-window-time-us 1000 --read-only-read-window-time-us 165000 --account-name "payloadless" --abi-file payloadless.abi --wasm-file payloadless.wasm --contract-dir unittests/test-contracts/payloadless --user-trx-data-file tests/PerformanceHarness/readOnlyTrxData.json --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +add_test(NAME performance_test_read_only_trxs COMMAND tests/PerformanceHarnessScenarioRunner.py findMax testApiOpMode --max-tps-to-test 50 --test-iteration-min-step 10 --test-iteration-duration-sec 10 --final-iterations-duration-sec 10 overrideBasicTestConfig -v --tps-limit-per-generator 25 --api-nodes-read-only-threads 2 --read-only-write-window-time-us 1000 --read-only-read-window-time-us 165000 --account-name "payloadless" --abi-file payloadless.abi --wasm-file payloadless.wasm --contract-dir unittests/test-contracts/payloadless --user-trx-data-file tests/PerformanceHarness/readOnlySlowTrxData.json --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_cpu_trx_spec COMMAND tests/PerformanceHarnessScenarioRunner.py findMax testBpOpMode --max-tps-to-test 50 --test-iteration-min-step 10 --test-iteration-duration-sec 10 --final-iterations-duration-sec 10 overrideBasicTestConfig -v --tps-limit-per-generator 25 --chain-state-db-size-mb 200 --account-name "c" --abi-file eosmechanics.abi --wasm-file eosmechanics.wasm --contract-dir unittests/contracts/eosio.mechanics --user-trx-data-file tests/PerformanceHarness/cpuTrxData.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_basic_p2p COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --producer-nodes 1 --validation-nodes 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_basic_http COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --endpoint-mode http --producer-nodes 1 --validation-nodes 1 --api-nodes 1 --target-tps 10 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -282,7 +282,7 @@ add_test(NAME performance_test_basic_transfer_trx_spec COMMAND tests/Performance add_test(NAME performance_test_basic_new_acct_trx_spec COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --producer-nodes 1 --validation-nodes 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 --user-trx-data-file tests/PerformanceHarness/userTrxDataNewAccount.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_basic_cpu_trx_spec COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --producer-nodes 1 --validation-nodes 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 --account-name "c" --abi-file eosmechanics.abi --wasm-file eosmechanics.wasm --contract-dir unittests/contracts/eosio.mechanics --user-trx-data-file tests/PerformanceHarness/cpuTrxData.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME performance_test_basic_ram_trx_spec COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --producer-nodes 1 --validation-nodes 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 --account-name "r" --abi-file eosmechanics.abi --wasm-file eosmechanics.wasm --contract-dir unittests/contracts/eosio.mechanics --user-trx-data-file tests/PerformanceHarness/ramTrxData.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -add_test(NAME performance_test_basic_read_only_trxs COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --endpoint-mode http --producer-nodes 1 --validation-nodes 1 --api-nodes 1 --api-nodes-read-only-threads 2 --read-only-write-window-time-us 1000 --read-only-read-window-time-us 165000 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 --account-name "payloadless" --abi-file payloadless.abi --wasm-file payloadless.wasm --contract-dir unittests/test-contracts/payloadless --user-trx-data-file tests/PerformanceHarness/readOnlyTrxData.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +add_test(NAME performance_test_basic_read_only_trxs COMMAND tests/PerformanceHarnessScenarioRunner.py singleTest -v --endpoint-mode http --producer-nodes 1 --validation-nodes 1 --api-nodes 1 --api-nodes-read-only-threads 2 --read-only-write-window-time-us 1000 --read-only-read-window-time-us 165000 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --chain-state-db-size-mb 200 --account-name "payloadless" --abi-file payloadless.abi --wasm-file payloadless.wasm --contract-dir unittests/test-contracts/payloadless --user-trx-data-file tests/PerformanceHarness/readOnlySlowTrxData.json ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_property(TEST performance_test_bp PROPERTY LABELS long_running_tests) set_property(TEST performance_test_api PROPERTY LABELS long_running_tests) set_property(TEST performance_test_read_only_trxs PROPERTY LABELS long_running_tests) diff --git a/tests/PerformanceHarness/CMakeLists.txt b/tests/PerformanceHarness/CMakeLists.txt index f5a7711e3f..cba9f6282e 100644 --- a/tests/PerformanceHarness/CMakeLists.txt +++ b/tests/PerformanceHarness/CMakeLists.txt @@ -5,6 +5,7 @@ configure_file(genesis.json . COPYONLY) configure_file(cpuTrxData.json . COPYONLY) configure_file(ramTrxData.json . COPYONLY) configure_file(readOnlyTrxData.json . COPYONLY) +configure_file(readOnlySlowTrxData.json . COPYONLY) configure_file(userTrxDataTransfer.json . COPYONLY) configure_file(userTrxDataNewAccount.json . COPYONLY) diff --git a/tests/PerformanceHarness/readOnlySlowTrxData.json b/tests/PerformanceHarness/readOnlySlowTrxData.json new file mode 100644 index 0000000000..ec6a61fd96 --- /dev/null +++ b/tests/PerformanceHarness/readOnlySlowTrxData.json @@ -0,0 +1,14 @@ +{ + "initAccounts": ["payloadless"], + "abiFile": "unittests/test-contracts/payloadless/payloadless.abi", + "apiEndpoint": "/v1/chain/send_read_only_transaction", + "actions": [ + { + "actionName": "doitslow", + "actionData": { + }, + "actionAuthAcct": "payloadless", + "authorization": {} + } + ] +} diff --git a/tests/TestHarness/CMakeLists.txt b/tests/TestHarness/CMakeLists.txt index 1e00fbf567..82da444a6e 100644 --- a/tests/TestHarness/CMakeLists.txt +++ b/tests/TestHarness/CMakeLists.txt @@ -14,3 +14,4 @@ configure_file(logging.py . COPYONLY) configure_file(depresolver.py . COPYONLY) configure_file(launcher.py . COPYONLY) configure_file(accounts.py . COPYONLY) +configure_file(logging-template.json . COPYONLY) diff --git a/tests/TestHarness/logging-template.json b/tests/TestHarness/logging-template.json new file mode 100644 index 0000000000..fff1143346 --- /dev/null +++ b/tests/TestHarness/logging-template.json @@ -0,0 +1,150 @@ +{ + "includes": [], + "appenders": [{ + "name": "stderr", + "type": "console", + "args": { + "format": " : ] ", + "stream": "std_error", + "level_colors": [{ + "level": "debug", + "color": "green" + },{ + "level": "warn", + "color": "brown" + },{ + "level": "error", + "color": "red" + } + ], + "flush": true + }, + "enabled": true + },{ + "name": "stdout", + "type": "console", + "args": { + "stream": "std_out", + "level_colors": [{ + "level": "debug", + "color": "green" + },{ + "level": "warn", + "color": "brown" + },{ + "level": "error", + "color": "red" + } + ], + "flush": true + }, + "enabled": true + } + ], + "loggers": [{ + "name": "default", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "net_plugin_impl", + "level": "info", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "http_plugin", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "producer_plugin", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transaction_success_tracing", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transaction_failure_tracing", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "trace_api", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transaction_trace_success", + "level": "info", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transaction_trace_failure", + "level": "info", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transient_trx_success_tracing", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transient_trx_failure_tracing", + "level": "debug", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "state_history", + "level": "info", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + },{ + "name": "transaction", + "level": "info", + "enabled": true, + "additivity": false, + "appenders": [ + "stderr" + ] + } + ] +} diff --git a/tests/read_only_trx_test.py b/tests/read_only_trx_test.py index 91f92a8a0b..7b6a555bc5 100755 --- a/tests/read_only_trx_test.py +++ b/tests/read_only_trx_test.py @@ -204,6 +204,9 @@ def sendTransaction(account, action, data, auth=[], opts=None): def sendReadOnlyPayloadless(): return sendTransaction('payloadless', action='doit', data={}, auth=[], opts='--read') +def sendReadOnlySlowPayloadless(): + return sendTransaction('payloadless', action='doitslow', data={}, auth=[], opts='--read') + # Send read-only trxs from mutltiple threads to bump load def sendReadOnlyTrxOnThread(startId, numTrxs): Print("start sendReadOnlyTrxOnThread") @@ -219,6 +222,11 @@ def sendReadOnlyTrxOnThread(startId, numTrxs): results = sendReadOnlyPayloadless() assert(results[0]) assert(results[1]['processed']['action_traces'][0]['console'] == "Im a payloadless action") + + results = sendReadOnlySlowPayloadless() + assert(results[0]) + assert(results[1]['processed']['action_traces'][0]['console'] == "Im a payloadless slow action") + assert(int(results[1]['processed']['elapsed']) > 100) except Exception as e: Print("Exception in sendReadOnlyTrxOnThread: ", e) errorInThread = True diff --git a/unittests/test-contracts/payloadless/payloadless.abi b/unittests/test-contracts/payloadless/payloadless.abi index ad6c695ea6..aafa35c171 100644 --- a/unittests/test-contracts/payloadless/payloadless.abi +++ b/unittests/test-contracts/payloadless/payloadless.abi @@ -7,6 +7,11 @@ "name": "doit", "base": "", "fields": [] + }, + { + "name": "doitslow", + "base": "", + "fields": [] } ], "actions": [ @@ -14,6 +19,11 @@ "name": "doit", "type": "doit", "ricardian_contract": "" + }, + { + "name": "doitslow", + "type": "doitslow", + "ricardian_contract": "" } ], "tables": [], diff --git a/unittests/test-contracts/payloadless/payloadless.cpp b/unittests/test-contracts/payloadless/payloadless.cpp index 16637efa2b..46566c3215 100644 --- a/unittests/test-contracts/payloadless/payloadless.cpp +++ b/unittests/test-contracts/payloadless/payloadless.cpp @@ -5,3 +5,48 @@ using namespace eosio; void payloadless::doit() { print("Im a payloadless action"); } + +constexpr size_t cpu_prime_max = 15375u; + +bool is_prime(int p) { + if (p == 2) { + return true; + } else if (p <= 1 || p % 2 == 0) { + return false; + } + + bool prime = true; + const int to = sqrt(p); + for (int i = 3; i <= to; i += 2) { + if (p % i == 0) { + prime = false; + break; + } + } + return prime; +} + +bool is_mersenne_prime(int p) { + if (p == 2) return true; + + const long long unsigned m_p = (1LLU << p) - 1; + long long unsigned s = 4; + int i; + for (i = 3; i <= p; i++) { + s = (s * s - 2) % m_p; + } + return bool(s == 0); +} + + +void payloadless::doitslow() { + print("Im a payloadless slow action"); + + for (size_t p = 2; p <= cpu_prime_max; p += 1) { + if (is_prime(p) && is_mersenne_prime(p)) { + // We need to keep an eye on this to make sure it doesn't get optimized out. So far so good. + //eosio::print_f(" %u", p); + } + } +} + diff --git a/unittests/test-contracts/payloadless/payloadless.hpp b/unittests/test-contracts/payloadless/payloadless.hpp index 945a0d7417..0fea87a29b 100644 --- a/unittests/test-contracts/payloadless/payloadless.hpp +++ b/unittests/test-contracts/payloadless/payloadless.hpp @@ -8,4 +8,7 @@ class [[eosio::contract]] payloadless : public eosio::contract { [[eosio::action]] void doit(); + + [[eosio::action]] + void doitslow(); }; diff --git a/unittests/test-contracts/payloadless/payloadless.wasm b/unittests/test-contracts/payloadless/payloadless.wasm index 7b0ae32153..dc91259462 100755 Binary files a/unittests/test-contracts/payloadless/payloadless.wasm and b/unittests/test-contracts/payloadless/payloadless.wasm differ