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

PH: Add a longer running read-only trx for tests #1685

Merged
merged 5 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 0 additions & 1 deletion programs/nodeos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
1 change: 1 addition & 0 deletions tests/PerformanceHarness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions tests/PerformanceHarness/readOnlySlowTrxData.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
]
}
1 change: 1 addition & 0 deletions tests/TestHarness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
150 changes: 150 additions & 0 deletions tests/TestHarness/logging-template.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
8 changes: 8 additions & 0 deletions tests/read_only_trx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions unittests/test-contracts/payloadless/payloadless.abi
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
"name": "doit",
"base": "",
"fields": []
},
{
"name": "doitslow",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "doit",
"type": "doit",
"ricardian_contract": ""
},
{
"name": "doitslow",
"type": "doitslow",
"ricardian_contract": ""
}
],
"tables": [],
Expand Down
45 changes: 45 additions & 0 deletions unittests/test-contracts/payloadless/payloadless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more clear.

}
return prime;
linh2931 marked this conversation as resolved.
Show resolved Hide resolved
}

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.
linh2931 marked this conversation as resolved.
Show resolved Hide resolved
//eosio::print_f(" %u", p);
}
}
}

3 changes: 3 additions & 0 deletions unittests/test-contracts/payloadless/payloadless.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ class [[eosio::contract]] payloadless : public eosio::contract {

[[eosio::action]]
void doit();

[[eosio::action]]
void doitslow();
};
Binary file modified unittests/test-contracts/payloadless/payloadless.wasm
Binary file not shown.