Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19290db10d | |||
| 657b3df4bf | |||
| a35a0bef2d | |||
| 291cd11cd4 | |||
| 15b271a98a | |||
| 4ec1281918 | |||
| 318e1e4533 | |||
| ccdaa64392 | |||
| 150fe5de8f | |||
| 59cf021b08 | |||
| 8b52aac579 | |||
| 1dd3f89555 | |||
| 5969e8b6fe | |||
| 8cbd7decca | |||
| 25915c3510 | |||
| 2299d0b626 | |||
| c9fcb2ac2c | |||
| 40576f5416 | |||
| b5232f0eaf | |||
| 8134e5394a | |||
| 6176fa323c | |||
| 5d1ab0c0bb | |||
| ac1a035b5e | |||
| 191aafc8f6 | |||
| 405ac4178d | |||
| 41bb796d77 | |||
| 1e80205270 | |||
| 483b462717 | |||
| 1b04bdf71c | |||
| 9e2593cc16 | |||
| ec471ad8e5 | |||
| 3dbc0baeeb | |||
| ff4b20388b | |||
| f3c424ef90 | |||
| 2829420ecb | |||
| 43d462a8e0 | |||
| 87c7480656 | |||
| 971102e243 | |||
| e79f6781c0 | |||
| afeecdb533 | |||
| 847d82f5ba | |||
| d3b227a982 | |||
| a4582b5ba7 | |||
| 517f1cb987 | |||
| cb64c3fb38 | |||
| 446a04a607 | |||
| ffefb30a36 | |||
| e482676d42 | |||
| cce1b8d29a | |||
| def0d0df6d | |||
| 98464fef96 | |||
| da9addcaba | |||
| 87c34e86f4 | |||
| bb0490ceb9 | |||
| a47032b189 | |||
| 6761f93385 | |||
| 8a0ded9374 | |||
| 10df2bbf55 | |||
| 2a4c37c13f |
@@ -679,16 +679,16 @@ namespace IR
|
||||
}
|
||||
|
||||
//paranoia for future platforms
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::NoImm>) == 2);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::MemoryImm>) == 2);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::ControlStructureImm>) == 3);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::BranchImm>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::BranchTableImm>) == 18);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<I32>>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<I64>>) == 10);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<F32>>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<F64>>) == 10);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::GetOrSetVariableImm<false>>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::CallImm>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::CallIndirectImm>) == 6);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LoadOrStoreImm<0>>) == 10);
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::NoImm>) == 2, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::MemoryImm>) == 2, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::ControlStructureImm>) == 3, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::BranchImm>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::BranchTableImm>) == 18, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<I32>>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<I64>>) == 10, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<F32>>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LiteralImm<F64>>) == 10, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::GetOrSetVariableImm<false>>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::CallImm>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::CallIndirectImm>) == 6, "unexpected size");
|
||||
static_assert(sizeof(IR::OpcodeAndImm<IR::LoadOrStoreImm<0>>) == 10, "unexpected size");
|
||||
|
||||
@@ -204,9 +204,12 @@ public:
|
||||
// thread-safe, called when a new block is received
|
||||
void received_block();
|
||||
|
||||
const std::set<account_name>& producer_accounts() const;
|
||||
const std::set<account_name>& producer_accounts() const;
|
||||
|
||||
static void set_test_mode(bool m) { test_mode_ = m; }
|
||||
private:
|
||||
inline static bool test_mode_{false}; // to be moved into appbase (application_base)
|
||||
|
||||
std::shared_ptr<class producer_plugin_impl> my;
|
||||
};
|
||||
|
||||
|
||||
@@ -417,11 +417,85 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
|
||||
packed_transaction_ptr trx;
|
||||
next_func_t next;
|
||||
};
|
||||
|
||||
// The queue storing read-only transactions to be executed by read-only threads
|
||||
struct ro_trx_queue_t {
|
||||
std::mutex mtx;
|
||||
std::deque<ro_trx_t> queue;
|
||||
class ro_trx_queue_t {
|
||||
public:
|
||||
void push_back(ro_trx_t&& trx) {
|
||||
std::unique_lock<std::mutex> g( mtx );
|
||||
queue.push_back(std::move(trx));
|
||||
if (num_waiting)
|
||||
cond.notify_one();
|
||||
}
|
||||
|
||||
void push_front(ro_trx_t&& trx) {
|
||||
std::unique_lock<std::mutex> g( mtx );
|
||||
queue.push_front(std::move(trx));
|
||||
if (num_waiting)
|
||||
cond.notify_one();
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
std::lock_guard<std::mutex> g( mtx );
|
||||
return queue.empty();
|
||||
}
|
||||
|
||||
// may wait if the queue is empty, and not all other threads are already waiting.
|
||||
// returns true if a transaction was dequeued and should be executed, or false
|
||||
// if conditions are met to stop processing transactions.
|
||||
bool pop_front(ro_trx_t& trx) {
|
||||
std::unique_lock<std::mutex> g( mtx );
|
||||
|
||||
++num_waiting;
|
||||
cond.wait(g, [this]() {
|
||||
if (queue.empty()) {
|
||||
if (num_waiting == max_waiting && !exiting_read_window) {
|
||||
cond.notify_all();
|
||||
exiting_read_window = true;
|
||||
}
|
||||
return should_exit();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
--num_waiting;
|
||||
if (should_exit())
|
||||
return false;
|
||||
|
||||
trx = std::move(queue.front());
|
||||
queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
// We exit the read window when either:
|
||||
// - all threads would be idle
|
||||
// - or the net_plugin received a block.
|
||||
// - or we have reached the read_window_deadline
|
||||
void set_exit_criteria(uint32_t num_tasks, std::atomic<bool>* received_block, fc::time_point deadline) {
|
||||
std::lock_guard<std::mutex> g( mtx ); // not strictly necessary with current usage from single thread
|
||||
assert(num_tasks > 0 && num_waiting == 0 && received_block != nullptr);
|
||||
assert(received_block && *received_block == false);
|
||||
max_waiting = num_tasks;
|
||||
num_waiting = 0;
|
||||
received_block_ptr = received_block;
|
||||
read_window_deadline = deadline;
|
||||
exiting_read_window = false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool should_exit() {
|
||||
return exiting_read_window || fc::time_point::now() >= read_window_deadline || *received_block_ptr;
|
||||
}
|
||||
|
||||
mutable std::mutex mtx;
|
||||
std::condition_variable cond;
|
||||
deque<ro_trx_t> queue;
|
||||
uint32_t num_waiting{0};
|
||||
uint32_t max_waiting{0};
|
||||
bool exiting_read_window{false};
|
||||
std::atomic<bool>* received_block_ptr{nullptr};
|
||||
fc::time_point read_window_deadline;
|
||||
};
|
||||
|
||||
uint16_t _ro_thread_pool_size{ 0 };
|
||||
static constexpr uint16_t _ro_max_eos_vm_oc_threads_allowed{ 8 }; // Due to uncertainty to get total virtual memory size on a 5-level paging system, set a hard limit
|
||||
named_thread_pool<struct read> _ro_thread_pool;
|
||||
@@ -433,13 +507,13 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
|
||||
boost::asio::deadline_timer _ro_read_window_timer;
|
||||
fc::microseconds _ro_max_trx_time_us{ 0 }; // calculated during option initialization
|
||||
ro_trx_queue_t _ro_trx_queue;
|
||||
std::atomic<uint32_t> _ro_num_active_trx_exec_tasks{ 0 };
|
||||
std::atomic<uint32_t> _ro_num_active_trx_exec_tasks{ 0 };
|
||||
std::vector<std::future<bool>> _ro_trx_exec_tasks_fut;
|
||||
|
||||
void start_write_window();
|
||||
void switch_to_write_window();
|
||||
void switch_to_read_window();
|
||||
bool read_only_trx_execution_task();
|
||||
bool read_only_trx_execution_task(fc::time_point start);
|
||||
bool process_read_only_transaction(const packed_transaction_ptr& trx,
|
||||
const next_function<transaction_trace_ptr>& next,
|
||||
const fc::time_point& read_window_start_time);
|
||||
@@ -643,8 +717,7 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
|
||||
// Parallel read-only trx execution enabled.
|
||||
// Store the transaction in read-only-trx queue so that it is
|
||||
// executed in read window
|
||||
std::lock_guard<std::mutex> g( _ro_trx_queue.mtx );
|
||||
_ro_trx_queue.queue.push_back({trx, std::move(next)});
|
||||
_ro_trx_queue.push_back({trx, std::move(next)});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1076,8 +1149,9 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_
|
||||
my->_ro_thread_pool_size = options.at( "read-only-threads" ).as<uint16_t>();
|
||||
// only initialize other read-only options when read-only thread pool is enabled
|
||||
if ( my->_ro_thread_pool_size > 0 ) {
|
||||
EOS_ASSERT( my->_producers.empty(), plugin_config_exception, "--read-only-threads not allowed on producer node" );
|
||||
|
||||
if (!test_mode_)
|
||||
EOS_ASSERT( my->_producers.empty(), plugin_config_exception, "--read-only-threads not allowed on producer node" );
|
||||
|
||||
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
|
||||
if (chain.is_eos_vm_oc_enabled()) {
|
||||
// EOS VM OC requires 4.2TB Virtual for each executing thread. Make sure the memory
|
||||
@@ -2811,7 +2885,7 @@ void producer_plugin_impl::switch_to_read_window() {
|
||||
|
||||
// we are in write window, so no read-only trx threads are processing transactions.
|
||||
// _ro_trx_queue is not being accessed. No need to lock.
|
||||
if ( _ro_trx_queue.queue.empty() ) { // no read-only trxs to process. stay in write window
|
||||
if ( _ro_trx_queue.empty() ) { // no read-only trxs to process. stay in write window
|
||||
start_write_window(); // restart write window timer for next round
|
||||
return;
|
||||
}
|
||||
@@ -2822,9 +2896,11 @@ void producer_plugin_impl::switch_to_read_window() {
|
||||
|
||||
// start a read-only transaction execution task in each thread in the thread pool
|
||||
_ro_num_active_trx_exec_tasks = _ro_thread_pool_size;
|
||||
auto start_time = fc::time_point::now();
|
||||
_ro_trx_queue.set_exit_criteria(_ro_thread_pool_size, &_received_block, start_time + _ro_read_window_effective_time_us);
|
||||
for (auto i = 0; i < _ro_thread_pool_size; ++i ) {
|
||||
_ro_trx_exec_tasks_fut.emplace_back( post_async_task( _ro_thread_pool.get_executor(), [self = this] () {
|
||||
return self->read_only_trx_execution_task();
|
||||
_ro_trx_exec_tasks_fut.emplace_back( post_async_task( _ro_thread_pool.get_executor(), [this, start_time] () {
|
||||
return read_only_trx_execution_task(start_time);
|
||||
}) );
|
||||
}
|
||||
|
||||
@@ -2849,27 +2925,21 @@ void producer_plugin_impl::switch_to_read_window() {
|
||||
}
|
||||
|
||||
// Called from a read only trx thread. Run in parallel with app and other read only trx threads
|
||||
bool producer_plugin_impl::read_only_trx_execution_task() {
|
||||
auto start = fc::time_point::now();
|
||||
auto read_window_deadline = start + _ro_read_window_effective_time_us;
|
||||
bool producer_plugin_impl::read_only_trx_execution_task(fc::time_point start) {
|
||||
// We have 4 ways to break out the while loop:
|
||||
// 1. pass read window deadline
|
||||
// 2. Net_plugin receives a block
|
||||
// 3. No more transactions in the read-only trx queue
|
||||
// 4. A transaction execution is exhaused
|
||||
while ( fc::time_point::now() < read_window_deadline && !_received_block ) {
|
||||
std::unique_lock<std::mutex> lck( _ro_trx_queue.mtx );
|
||||
if ( _ro_trx_queue.queue.empty() ) {
|
||||
break;
|
||||
}
|
||||
auto trx = _ro_trx_queue.queue.front();
|
||||
_ro_trx_queue.queue.pop_front();
|
||||
lck.unlock();
|
||||
|
||||
ro_trx_t trx;
|
||||
while ( _ro_trx_queue.pop_front(trx) ) {
|
||||
// If the queue is empty, pop_front() waits on condition variable, and returns false
|
||||
// when and only when all tasks must exit (i.e queue is empty and all tasks are idle, or
|
||||
// we have reached the end of the read window, or net plugin received a block)
|
||||
|
||||
auto retry = process_read_only_transaction( trx.trx, trx.next, start );
|
||||
if ( retry ) {
|
||||
lck.lock();
|
||||
_ro_trx_queue.queue.push_front(trx);
|
||||
_ro_trx_queue.push_front(std::move(trx));
|
||||
// Do not schedule new execution
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ void test_trxs_common(std::vector<const char*>& specific_args) {
|
||||
|
||||
auto[prod_plug, chain_plug] = plugin_fut.get();
|
||||
auto chain_id = chain_plug->get_chain_id();
|
||||
prod_plug->set_test_mode(true);
|
||||
|
||||
std::atomic<size_t> next_calls = 0;
|
||||
std::atomic<size_t> num_posts = 0;
|
||||
@@ -150,4 +151,27 @@ BOOST_AUTO_TEST_CASE(no_read_only_threads) {
|
||||
test_trxs_common(specific_args);
|
||||
}
|
||||
|
||||
// test read-only trxs on 1 threads (with --read-only-threads)
|
||||
BOOST_AUTO_TEST_CASE(with_1_read_only_threads) {
|
||||
std::vector<const char*> specific_args = { "-p", "eosio", "-e",
|
||||
"--read-only-threads=1",
|
||||
"--max-transaction-time=10",
|
||||
"--read-only-write-window-time-us=100000",
|
||||
"--read-only-read-window-time-us=40000",
|
||||
"--disable-subjective-billing=true" };
|
||||
test_trxs_common(specific_args);
|
||||
}
|
||||
|
||||
// test read-only trxs on 16 separate threads (with --read-only-threads)
|
||||
BOOST_AUTO_TEST_CASE(with_16_read_only_threads) {
|
||||
std::vector<const char*> specific_args = { "-p", "eosio", "-e",
|
||||
"--read-only-threads=16",
|
||||
"--max-transaction-time=10",
|
||||
"--read-only-write-window-time-us=100000",
|
||||
"--read-only-read-window-time-us=40000",
|
||||
"--disable-subjective-billing=true" };
|
||||
test_trxs_common(specific_args);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
void pop_entry(bool call_send = true) {
|
||||
send_queue.erase(send_queue.begin());
|
||||
sending = false;
|
||||
if (call_send)
|
||||
if (call_send || !send_queue.empty())
|
||||
send();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,11 @@ from .Node import BlockType
|
||||
from .Node import Node
|
||||
from .WalletMgr import WalletMgr
|
||||
from .launch_transaction_generators import TransactionGeneratorsLauncher, TpsTrxGensConfig
|
||||
from .libc import unshare, CLONE_NEWNET
|
||||
from .interfaces import getInterfaceFlags, setInterfaceUp, IFF_LOOPBACK
|
||||
try:
|
||||
from .libc import unshare, CLONE_NEWNET
|
||||
from .interfaces import getInterfaceFlags, setInterfaceUp, IFF_LOOPBACK
|
||||
except:
|
||||
pass
|
||||
|
||||
# Protocol Feature Setup Policy
|
||||
class PFSetupPolicy:
|
||||
@@ -1727,4 +1730,7 @@ class Cluster(object):
|
||||
for line in f:
|
||||
firstTrxs.append(line.rstrip('\n'))
|
||||
Utils.Print(f"first transactions: {firstTrxs}")
|
||||
node.waitForTransactionsInBlock(firstTrxs)
|
||||
status = node.waitForTransactionsInBlock(firstTrxs)
|
||||
if status is None:
|
||||
Utils.Print('ERROR: Failed to spin up transaction generators: never received first transactions')
|
||||
return status
|
||||
|
||||
@@ -61,7 +61,7 @@ class Node(Transactions):
|
||||
self.fetchBlock = lambda blockNum: self.processUrllibRequest("trace_api", "get_block", {"block_num":blockNum}, silentErrors=False, exitOnError=True)
|
||||
self.fetchKeyCommand = lambda: "[transaction][transaction_header][ref_block_num]"
|
||||
self.fetchRefBlock = lambda trans: trans["transaction_header"]["ref_block_num"]
|
||||
self.cleosLimit = "--time-limit 99999"
|
||||
self.cleosLimit = "--time-limit 999"
|
||||
self.fetchHeadBlock = lambda node, headBlock: node.processUrllibRequest("chain", "get_block_info", {"block_num":headBlock}, silentErrors=False, exitOnError=True)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -118,10 +118,10 @@ class NodeosQueries:
|
||||
# could be a transaction response
|
||||
if cntxt.hasKey("processed"):
|
||||
cntxt.add("processed")
|
||||
cntxt.add("action_traces")
|
||||
cntxt.index(0)
|
||||
if not cntxt.isSectionNull("except"):
|
||||
return "no_block"
|
||||
cntxt.add("action_traces")
|
||||
cntxt.index(0)
|
||||
return cntxt.add("block_num")
|
||||
|
||||
# or what the trace api plugin returns
|
||||
@@ -242,7 +242,7 @@ class NodeosQueries:
|
||||
assert(isinstance(transId, str))
|
||||
exitOnErrorForDelayed=not delayedRetry and exitOnError
|
||||
timeout=3
|
||||
cmdDesc="get transaction_trace"
|
||||
cmdDesc=self.fetchTransactionCommand()
|
||||
cmd="%s %s" % (cmdDesc, transId)
|
||||
msg="(transaction id=%s)" % (transId);
|
||||
for i in range(0,(int(60/timeout) - 1)):
|
||||
@@ -295,8 +295,8 @@ class NodeosQueries:
|
||||
refBlockNum=None
|
||||
key=""
|
||||
try:
|
||||
key="[transaction][transaction_header][ref_block_num]"
|
||||
refBlockNum=trans["transaction_header"]["ref_block_num"]
|
||||
key = self.fetchKeyCommand()
|
||||
refBlockNum = self.fetchRefBlock(trans)
|
||||
refBlockNum=int(refBlockNum)+1
|
||||
except (TypeError, ValueError, KeyError) as _:
|
||||
Utils.Print("transaction%s not found. Transaction: %s" % (key, trans))
|
||||
@@ -347,8 +347,8 @@ class NodeosQueries:
|
||||
|
||||
def getTable(self, contract, scope, table, exitOnError=False):
|
||||
cmdDesc = "get table"
|
||||
cmd="%s %s %s %s" % (cmdDesc, contract, scope, table)
|
||||
msg="contract=%s, scope=%s, table=%s" % (contract, scope, table);
|
||||
cmd=f"{cmdDesc} {self.cleosLimit} {contract} {scope} {table}"
|
||||
msg=f"contract={contract}, scope={scope}, table={table}"
|
||||
return self.processCleosCmd(cmd, cmdDesc, exitOnError=exitOnError, exitMsg=msg)
|
||||
|
||||
def getTableAccountBalance(self, contract, scope):
|
||||
@@ -529,7 +529,7 @@ class NodeosQueries:
|
||||
return m.group(1)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
end=time.perf_counter()
|
||||
msg=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
Utils.Print("ERROR: Exception during code hash retrieval. cmd Duration: %.3f sec. %s" % (end-start, msg))
|
||||
return None
|
||||
|
||||
@@ -580,8 +580,9 @@ class NodeosQueries:
|
||||
except subprocess.CalledProcessError as ex:
|
||||
if not silentErrors:
|
||||
end=time.perf_counter()
|
||||
msg=ex.output.decode("utf-8")
|
||||
errorMsg="Exception during \"%s\". Exception message: %s. cmd Duration=%.3f sec. %s" % (cmdDesc, msg, end-start, exitMsg)
|
||||
out=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
errorMsg="Exception during \"%s\". Exception message: %s. stdout: %s. cmd Duration=%.3f sec. %s" % (cmdDesc, msg, out, end-start, exitMsg)
|
||||
if exitOnError:
|
||||
Utils.cmdError(errorMsg)
|
||||
Utils.errorExit(errorMsg)
|
||||
|
||||
@@ -107,7 +107,7 @@ class Transactions(NodeosQueries):
|
||||
self.trackCmdTransaction(trans, reportStatus=reportStatus)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
end=time.perf_counter()
|
||||
msg=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
Utils.Print("ERROR: Exception during funds transfer. cmd Duration: %.3f sec. %s" % (end-start, msg))
|
||||
if exitOnError:
|
||||
Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination))
|
||||
@@ -131,7 +131,7 @@ class Transactions(NodeosQueries):
|
||||
Utils.Print("cmd Duration: %.3f sec" % (end-start))
|
||||
except subprocess.CalledProcessError as ex:
|
||||
end=time.perf_counter()
|
||||
msg=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
Utils.Print("ERROR: Exception during spawn of funds transfer. cmd Duration: %.3f sec. %s" % (end-start, msg))
|
||||
if exitOnError:
|
||||
Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination))
|
||||
@@ -158,15 +158,15 @@ class Transactions(NodeosQueries):
|
||||
except subprocess.CalledProcessError as ex:
|
||||
if not shouldFail:
|
||||
end=time.perf_counter()
|
||||
msg=ex.output.decode("utf-8")
|
||||
Utils.Print("ERROR: Exception during set contract. cmd Duration: %.3f sec. %s" % (end-start, msg))
|
||||
out=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
Utils.Print("ERROR: Exception during set contract. stderr: %s. stdout: %s. cmd Duration: %.3f sec." % (msg, out, end-start))
|
||||
return None
|
||||
else:
|
||||
retMap={}
|
||||
retMap["returncode"]=ex.returncode
|
||||
retMap["cmd"]=ex.cmd
|
||||
retMap["output"]=ex.output
|
||||
retMap["stdout"]=ex.stdout
|
||||
retMap["stderr"]=ex.stderr
|
||||
return retMap
|
||||
|
||||
@@ -213,7 +213,7 @@ class Transactions(NodeosQueries):
|
||||
Utils.Print("cmd Duration: %.3f sec" % (end-start))
|
||||
return (NodeosQueries.getTransStatus(retTrans) == 'executed', retTrans)
|
||||
except subprocess.CalledProcessError as ex:
|
||||
msg=ex.output.decode("utf-8")
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
if not silentErrors:
|
||||
end=time.perf_counter()
|
||||
Utils.Print("ERROR: Exception during push transaction. cmd Duration=%.3f sec. %s" % (end - start, msg))
|
||||
@@ -245,7 +245,6 @@ class Transactions(NodeosQueries):
|
||||
except subprocess.CalledProcessError as ex:
|
||||
msg=ex.stderr.decode("utf-8")
|
||||
output=ex.output.decode("utf-8")
|
||||
msg=ex.output.decode("utf-8")
|
||||
if not silentErrors:
|
||||
end=time.perf_counter()
|
||||
Utils.Print("ERROR: Exception during push message. stderr: %s. stdout: %s. cmd Duration=%.3f sec." % (msg, output, end - start))
|
||||
|
||||
+1
-1
@@ -352,7 +352,7 @@ def abi_file_with_nodeos_test():
|
||||
os.makedirs(data_dir, exist_ok=True)
|
||||
walletMgr = WalletMgr(True)
|
||||
walletMgr.launch()
|
||||
node = Node('localhost', 8888, nodeId, cmd="./programs/nodeos/nodeos -e -p eosio --plugin eosio::trace_api_plugin --trace-no-abis --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::chain_plugin --plugin eosio::http_plugin --access-control-allow-origin=* --http-validate-host=false --resource-monitor-not-shutdown-on-threshold-exceeded " + "--data-dir " + data_dir + " --config-dir " + data_dir, walletMgr=walletMgr)
|
||||
node = Node('localhost', 8888, nodeId, cmd="./programs/nodeos/nodeos -e -p eosio --plugin eosio::trace_api_plugin --trace-no-abis --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::chain_plugin --plugin eosio::http_plugin --access-control-allow-origin=* --http-validate-host=false --max-transaction-time=-1 --resource-monitor-not-shutdown-on-threshold-exceeded " + "--data-dir " + data_dir + " --config-dir " + data_dir, walletMgr=walletMgr)
|
||||
node.verifyAlive() # Setting node state to not alive
|
||||
node.relaunch(newChain=True, cachePopen=True)
|
||||
node.waitForBlock(1)
|
||||
|
||||
@@ -126,13 +126,15 @@ try:
|
||||
waitForBlock(node0, blockNum, blockType=BlockType.lib)
|
||||
|
||||
Print("Configure and launch txn generators")
|
||||
|
||||
targetTpsPerGenerator = 10
|
||||
testTrxGenDurationSec=60*30
|
||||
cluster.launchTrxGenerators(contractOwnerAcctName=cluster.eosioAccount.name, acctNamesList=[account1Name, account2Name],
|
||||
acctPrivKeysList=[account1PrivKey,account2PrivKey], nodeId=snapshotNodeId, tpsPerGenerator=targetTpsPerGenerator,
|
||||
numGenerators=trxGeneratorCnt, durationSec=testTrxGenDurationSec, waitToComplete=False)
|
||||
|
||||
cluster.waitForTrxGeneratorsSpinup(nodeId=snapshotNodeId, numGenerators=trxGeneratorCnt)
|
||||
status = cluster.waitForTrxGeneratorsSpinup(nodeId=snapshotNodeId, numGenerators=trxGeneratorCnt)
|
||||
assert status is not None, "ERROR: Failed to spinup Transaction Generators"
|
||||
|
||||
blockNum=node0.getBlockNum(BlockType.head)
|
||||
timePerBlock=500
|
||||
@@ -156,12 +158,8 @@ try:
|
||||
minReqPctLeeway=0.60
|
||||
minRequiredTransactions=minReqPctLeeway*transactionsPerBlock
|
||||
assert steadyStateAvg>=minRequiredTransactions, "Expected to at least receive %s transactions per block, but only getting %s" % (minRequiredTransactions, steadyStateAvg)
|
||||
|
||||
Print("Create snapshot")
|
||||
blockNumSnap=nodeSnap.getBlockNum(BlockType.head)
|
||||
ret = nodeProg.scheduleSnapshotAt(blockNumSnap)
|
||||
assert ret is not None, "Snapshot creation failed"
|
||||
|
||||
Print("Create snapshot (node 0)")
|
||||
ret = nodeSnap.createSnapshot()
|
||||
assert ret is not None, "Snapshot creation failed"
|
||||
ret_head_block_num = ret["payload"]["head_block_num"]
|
||||
@@ -178,6 +176,29 @@ try:
|
||||
Utils.processLeapUtilCmd("snapshot to-json --input-file {}".format(snapshotFile), "snapshot to-json", silentErrors=False)
|
||||
snapshotFile = snapshotFile + ".json"
|
||||
|
||||
Print("Trim programmable blocklog to snapshot head block num and relaunch programmable node")
|
||||
nodeProg.kill(signal.SIGTERM)
|
||||
output=cluster.getBlockLog(progNodeId, blockLogAction=BlockLogAction.trim, first=0, last=ret_head_block_num, throwException=True)
|
||||
removeState(progNodeId)
|
||||
Utils.rmFromFile(Utils.getNodeConfigDir(progNodeId, "config.ini"), "p2p-peer-address")
|
||||
isRelaunchSuccess = nodeProg.relaunch(chainArg="--replay", addSwapFlags={}, timeout=relaunchTimeout, cachePopen=True)
|
||||
assert isRelaunchSuccess, "Failed to relaunch programmable node"
|
||||
|
||||
Print("Schedule snapshot (node 2)")
|
||||
ret = nodeProg.scheduleSnapshotAt(ret_head_block_num)
|
||||
assert ret is not None, "Snapshot scheduling failed"
|
||||
|
||||
Print("Wait for programmable node lib to advance")
|
||||
waitForBlock(nodeProg, ret_head_block_num+1, blockType=BlockType.lib)
|
||||
|
||||
Print("Kill programmable node")
|
||||
nodeProg.kill(signal.SIGTERM)
|
||||
|
||||
Print("Convert snapshot to JSON")
|
||||
progSnapshotFile = getLatestSnapshot(progNodeId)
|
||||
Utils.processLeapUtilCmd("snapshot to-json --input-file {}".format(progSnapshotFile), "snapshot to-json", silentErrors=False)
|
||||
progSnapshotFile = progSnapshotFile + ".json"
|
||||
|
||||
Print("Trim irreversible blocklog to snapshot head block num")
|
||||
nodeIrr.kill(signal.SIGTERM)
|
||||
output=cluster.getBlockLog(irrNodeId, blockLogAction=BlockLogAction.trim, first=0, last=ret_head_block_num, throwException=True)
|
||||
@@ -205,15 +226,6 @@ try:
|
||||
irrSnapshotFile = irrSnapshotFile + ".json"
|
||||
|
||||
assert Utils.compareFiles(snapshotFile, irrSnapshotFile), f"Snapshot files differ {snapshotFile} != {irrSnapshotFile}"
|
||||
|
||||
Print("Kill programmable node")
|
||||
nodeProg.kill(signal.SIGTERM)
|
||||
|
||||
Print("Convert snapshot to JSON")
|
||||
progSnapshotFile = getLatestSnapshot(progNodeId)
|
||||
Utils.processLeapUtilCmd("snapshot to-json --input-file {}".format(progSnapshotFile), "snapshot to-json", silentErrors=False)
|
||||
progSnapshotFile = progSnapshotFile + ".json"
|
||||
|
||||
assert Utils.compareFiles(progSnapshotFile, irrSnapshotFile), f"Snapshot files differ {progSnapshotFile} != {irrSnapshotFile}"
|
||||
|
||||
testSuccessful=True
|
||||
|
||||
@@ -118,7 +118,8 @@ try:
|
||||
tpsPerGenerator=targetTpsPerGenerator, numGenerators=trxGeneratorCnt, durationSec=testTrxGenDurationSec,
|
||||
waitToComplete=False)
|
||||
|
||||
cluster.waitForTrxGeneratorsSpinup(nodeId=node0.nodeId, numGenerators=trxGeneratorCnt)
|
||||
status = cluster.waitForTrxGeneratorsSpinup(nodeId=node0.nodeId, numGenerators=trxGeneratorCnt)
|
||||
assert status is not None, "ERROR: Failed to spinup Transaction Generators"
|
||||
|
||||
blockNum=head(node0)
|
||||
timePerBlock=500
|
||||
|
||||
@@ -56,7 +56,7 @@ class PluginHttpTest(unittest.TestCase):
|
||||
"http_plugin", "db_size_api_plugin", "prometheus_plugin"]
|
||||
nodeos_plugins = "--plugin eosio::" + " --plugin eosio::".join(plugin_names)
|
||||
nodeos_flags = (" --data-dir=%s --config-dir=%s --trace-dir=%s --trace-no-abis --access-control-allow-origin=%s "
|
||||
"--contracts-console --http-validate-host=%s --verbose-http-errors --abi-serializer-max-time-ms 30000 --http-max-response-time-ms 30000 "
|
||||
"--contracts-console --http-validate-host=%s --verbose-http-errors --max-transaction-time -1 --abi-serializer-max-time-ms 30000 --http-max-response-time-ms 30000 "
|
||||
"--p2p-peer-address localhost:9011 --resource-monitor-not-shutdown-on-threshold-exceeded ") % (self.data_dir, self.config_dir, self.data_dir, "\'*\'", "false")
|
||||
start_nodeos_cmd = ("%s -e -p eosio %s %s ") % (Utils.EosServerPath, nodeos_plugins, nodeos_flags)
|
||||
self.nodeos.launchCmd(start_nodeos_cmd, self.node_id)
|
||||
|
||||
Reference in New Issue
Block a user