diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c index c71f350b400a721459dec1ddbcea4d9f279b27b7..c97b807bde632027a2e7c2a046c836164179edbc 100644 --- a/modules/chain/dap_chain_ledger.c +++ b/modules/chain/dap_chain_ledger.c @@ -3686,6 +3686,11 @@ static int s_tx_add_unsafe(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, d return s_tx_add(a_ledger,a_tx,a_tx_hash,a_from_threshold,false); } +void dap_chain_ledger_set_tps_start_time(dap_ledger_t *a_ledger) +{ + clock_gettime(CLOCK_REALTIME, &PVT(a_ledger)->tps_start_time); +} + /** * @brief Add new transaction to the cache list * @param a_ledger @@ -3707,10 +3712,11 @@ static inline int s_tx_add(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, d dap_list_t *l_list_bound_items = NULL; dap_list_t *l_list_tx_out = NULL; dap_chain_ledger_tx_item_t *l_item_tmp = NULL; - unsigned l_hash_value = 0; if (!l_ledger_priv->tps_timer) { - clock_gettime(CLOCK_REALTIME, &l_ledger_priv->tps_start_time); +#ifndef DAP_TPS_TEST + dap_chain_ledger_set_tps_start_time(a_ledger); +#endif l_ledger_priv->tps_current_time.tv_sec = l_ledger_priv->tps_start_time.tv_sec; l_ledger_priv->tps_current_time.tv_nsec = l_ledger_priv->tps_start_time.tv_nsec; l_ledger_priv->tps_count = 0; diff --git a/modules/chain/include/dap_chain_ledger.h b/modules/chain/include/dap_chain_ledger.h index 486450c5748ca22d8310bc9bd18dc563f62c850e..6dac0ff88af4eb4c1196fdaf4000608105c070ce 100644 --- a/modules/chain/include/dap_chain_ledger.h +++ b/modules/chain/include/dap_chain_ledger.h @@ -195,6 +195,7 @@ unsigned dap_chain_ledger_count(dap_ledger_t *a_ledger); uint64_t dap_chain_ledger_count_from_to(dap_ledger_t * a_ledger, dap_time_t a_ts_from, dap_time_t a_ts_to); size_t dap_chain_ledger_count_tps(dap_ledger_t *a_ledger, struct timespec *a_ts_from, struct timespec *a_ts_to); +void dap_chain_ledger_set_tps_start_time(dap_ledger_t *a_ledger); /** * Check whether used 'out' items diff --git a/modules/consensus/esbocs/dap_chain_cs_esbocs.c b/modules/consensus/esbocs/dap_chain_cs_esbocs.c index bce0e7dbba68e9268b16939b8452d5c7da066aef..d299af05eeed93b58821b2dfe8e0c5437378e6c3 100644 --- a/modules/consensus/esbocs/dap_chain_cs_esbocs.c +++ b/modules/consensus/esbocs/dap_chain_cs_esbocs.c @@ -619,7 +619,7 @@ static void s_session_state_change(dap_chain_esbocs_session_t *a_session, enum s log_it(L_ERROR, "ESBOCS: No finish candidate found!"); break; } - dap_list_sort(l_store->candidate_signs, s_signs_sort_callback); + l_store->candidate_signs = dap_list_sort(l_store->candidate_signs, s_signs_sort_callback); size_t l_candidate_size_exclude_signs = l_store->candidate_size; for (dap_list_t *it = l_store->candidate_signs; it; it = it->next) { dap_sign_t *l_candidate_sign = (dap_sign_t *)it->data; @@ -711,7 +711,7 @@ static void s_session_proc_state(dap_chain_esbocs_session_t *a_session) break; } debug_if(l_cs_debug, L_MSG, "ESBOCS: net:%s, chain:%s, round:%"DAP_UINT64_FORMAT_U", attempt:%hu." - " Attempt finish by reason: cant't collect minimum number of validator's signs", + " Attempt finished by reason: cant't collect minimum number of validator's signs", a_session->chain->net_name, a_session->chain->name, a_session->cur_round.id, a_session->cur_round.attempt_num); s_session_attempt_new(a_session); @@ -720,7 +720,7 @@ static void s_session_proc_state(dap_chain_esbocs_session_t *a_session) case DAP_CHAIN_ESBOCS_SESSION_STATE_WAIT_FINISH: if (l_time - a_session->ts_attempt_start >= PVT(a_session->esbocs)->round_attempt_timeout) { debug_if(l_cs_debug, L_MSG, "ESBOCS: net:%s, chain:%s, round:%"DAP_UINT64_FORMAT_U", attempt:%hu." - " Attempt finisedh by reason: cant't collect minimum number of validator's precommits with same final hash", + " Attempt finished by reason: cant't collect minimum number of validator's precommits with same final hash", a_session->chain->net_name, a_session->chain->name, a_session->cur_round.id, a_session->cur_round.attempt_num); s_session_attempt_new(a_session); diff --git a/modules/net/dap_chain_node.c b/modules/net/dap_chain_node.c index fd546ba24c1962e6560fc04d004aad08ebe7575f..d7cd6b9be46face7dd15e6cef9b3643e673c2bae 100644 --- a/modules/net/dap_chain_node.c +++ b/modules/net/dap_chain_node.c @@ -217,7 +217,11 @@ bool dap_chain_node_mempool_process(dap_chain_t *a_chain, dap_chain_datum_t *a_d l_verify_datum != DAP_CHAIN_CS_VERIFY_CODE_TX_NO_EMISSION && l_verify_datum != DAP_CHAIN_CS_VERIFY_CODE_TX_NO_TOKEN) return true; - if (!l_verify_datum) + if (!l_verify_datum +#ifdef DAP_TPS_TEST + || l_verify_datum == DAP_CHAIN_CS_VERIFY_CODE_TX_NO_PREVIOUS +#endif + ) a_chain->callback_add_datums(a_chain, &a_datum, 1); return false; } diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index a412d74d503cf90299b36a3c0efc8bfb9ae5f7be..80e1bda575225dc034cb7e6a82e0d40dee33ff6d 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -2939,6 +2939,9 @@ int com_mempool_proc_all(int argc, char ** argv, char ** a_str_reply) { l_chain->name); } +#ifdef DAP_TPS_TEST + dap_chain_ledger_set_tps_start_time(l_net->pub.ledger); +#endif dap_chain_node_mempool_process_all(l_chain, true); dap_cli_server_cmd_set_reply_text(a_str_reply, "The entire mempool has been processed in %s.%s.", l_net->pub.name, l_chain->name); diff --git a/modules/type/blocks/dap_chain_cs_blocks.c b/modules/type/blocks/dap_chain_cs_blocks.c index 05f962ea7d62b2e003bb0ba18a335a4705af3729..6a494ee99ed19f49d3e40f4af50f6f1e9fa7e309 100644 --- a/modules/type/blocks/dap_chain_cs_blocks.c +++ b/modules/type/blocks/dap_chain_cs_blocks.c @@ -69,7 +69,6 @@ typedef struct dap_chain_cs_blocks_pvt uint64_t difficulty; time_t time_between_blocks_minimum; // Minimal time between blocks - size_t block_size_maximum; // Maximum block size bool is_celled; dap_timerfd_t *fill_timer; @@ -237,7 +236,6 @@ int dap_chain_cs_blocks_new(dap_chain_t * a_chain, dap_config_t * a_chain_config l_cs_blocks_pvt->chunks = dap_chain_block_chunks_create(l_cs_blocks); - l_cs_blocks_pvt->block_size_maximum = 1 * 1024 * 1024; // 1 Mb l_cs_blocks_pvt->fill_timeout = dap_config_get_item_uint64_default(a_chain_config, "blocks", "fill_timeout", 60) * 1000; // 1 min l_cs_blocks_pvt->blocks_count = 0; @@ -374,7 +372,7 @@ static int s_cli_blocks(int a_argc, char ** a_argv, char **a_str_reply) const char *l_chain_type = dap_chain_net_get_type(l_chain); - if (!strstr(l_chain_type, "block_")){ + if (!strstr(l_chain_type, "block_") && strcmp(l_chain_type, "esbocs")){ dap_cli_server_cmd_set_reply_text(a_str_reply, "Type of chain %s is not block. This chain with type %s is not supported by this command", l_chain->name, l_chain_type); @@ -1190,8 +1188,8 @@ static size_t s_callback_add_datums(dap_chain_t *a_chain, dap_chain_datum_t **a_ log_it(L_WARNING, "Empty datum"); /* How might it be? */ continue; } - if (l_blocks->block_new_size + l_datum_size > l_blocks_pvt->block_size_maximum) { - log_it(L_DEBUG, "Maximum size exeeded, %zu > %zu", l_blocks->block_new_size + l_datum_size, l_blocks_pvt->block_size_maximum); + if (l_blocks->block_new_size + l_datum_size > DAP_CHAIN_CS_BLOCKS_MAX_BLOCK_SIZE) { + log_it(L_DEBUG, "Maximum size exeeded, %zu > %d", l_blocks->block_new_size + l_datum_size, DAP_CHAIN_CS_BLOCKS_MAX_BLOCK_SIZE); break; } if (!l_blocks->block_new) { diff --git a/modules/type/blocks/include/dap_chain_cs_blocks.h b/modules/type/blocks/include/dap_chain_cs_blocks.h index e244a7925ec63eacd75b283cc12277c9af2de546..f9cce9b5633691520e2ddf9f49d854a9c99ca4d7 100644 --- a/modules/type/blocks/include/dap_chain_cs_blocks.h +++ b/modules/type/blocks/include/dap_chain_cs_blocks.h @@ -26,6 +26,11 @@ #include "dap_chain_block.h" #include "dap_chain_block_cache.h" +#ifdef DAP_TPS_TEST +#define DAP_CHAIN_CS_BLOCKS_MAX_BLOCK_SIZE (100 * 1024 * 1024) +#else +#define DAP_CHAIN_CS_BLOCKS_MAX_BLOCK_SIZE (1 * 1024 * 1024) // 1 Mb +#endif typedef struct dap_chain_cs_blocks dap_chain_cs_blocks_t;