aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp32
-rw-r--r--src/cryptonote_core/blockchain.h1
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.cpp14
-rw-r--r--src/cryptonote_core/tx_pool.cpp2
-rw-r--r--src/cryptonote_core/tx_pool.h2
5 files changed, 26 insertions, 25 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index a0c557c79..d332f8997 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -498,6 +498,7 @@ block Blockchain::pop_block_from_blockchain()
}
}
}
+ update_next_cumulative_size_limit();
m_tx_pool.on_blockchain_dec(m_db->height()-1, get_tail_id());
return popped_block;
@@ -2016,18 +2017,12 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t& max_used_block
TIME_MEASURE_START(a);
bool res = check_tx_inputs(tx, tvc, &max_used_block_height);
TIME_MEASURE_FINISH(a);
- crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
if(m_show_time_stats)
LOG_PRINT_L0("HASH: " << "+" << " VIN/VOUT: " << tx.vin.size() << "/" << tx.vout.size() << " H: " << max_used_block_height << " chcktx: " << a + m_fake_scan_time);
if (!res)
return false;
- // ND: Speedup:
- // 1. keep a list of verified transactions, when the Blockchain tries to check a tx again,
- // verify against list and skip if already verified to be correct.
- m_check_tx_inputs_table.emplace(tx_prefix_hash, std::make_pair(res, max_used_block_height));
-
CHECK_AND_ASSERT_MES(max_used_block_height < m_db->height(), false, "internal error: max used block index=" << max_used_block_height << " is not less then blockchain size = " << m_db->height());
max_used_block_id = m_db->get_block_hash_from_height(max_used_block_height);
return true;
@@ -2077,16 +2072,6 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context
crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
- auto its = m_check_tx_inputs_table.find(tx_prefix_hash);
- if (its != m_check_tx_inputs_table.end())
- {
- if (!its->second.first)
- return false;
- if (pmax_used_block_height)
- *pmax_used_block_height = its->second.second;
- return true;
- }
-
// from hard fork 2, we require mixin at least 2 unless one output cannot mix with 2 others
// if one output cannot mix with 2 others, we accept at most 1 output that can mix
if (m_hardfork->get_current_version() >= 2)
@@ -2140,7 +2125,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context
std::vector < uint64_t > results;
results.resize(tx.vin.size(), 0);
- int threads = boost::thread::hardware_concurrency();
+ int threads = tools::get_max_concurrency();
boost::asio::io_service ioservice;
boost::thread_group threadpool;
@@ -2160,6 +2145,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context
if(ioservice_active) \
{ \
work.reset(); \
+ while (!ioservice.stopped()) ioservice.poll(); \
threadpool.join_all(); \
ioservice.stop(); \
ioservice_active = false; \
@@ -2728,7 +2714,11 @@ leave:
// populate various metadata about the block to be stored alongside it.
block_size = cumulative_block_size;
cumulative_difficulty = current_diffic;
- already_generated_coins = already_generated_coins + base_reward;
+ // In the "tail" state when the minimum subsidy (implemented in get_block_reward) is in effect, the number of
+ // coins will eventually exceed MONEY_SUPPLY and overflow a uint64. To prevent overflow, cap already_generated_coins
+ // at MONEY_SUPPLY. already_generated_coins is only used to compute the block subsidy and MONEY_SUPPLY yields a
+ // subsidy of 0 under the base formula and therefore the minimum subsidy >0 in the tail state.
+ already_generated_coins = base_reward < (MONEY_SUPPLY-already_generated_coins) ? already_generated_coins + base_reward : MONEY_SUPPLY;
if(m_db->height())
cumulative_difficulty += m_db->get_block_cumulative_difficulty(m_db->height() - 1);
@@ -2968,7 +2958,6 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync)
TIME_MEASURE_FINISH(t1);
m_blocks_longhash_table.clear();
m_scan_table.clear();
- m_check_tx_inputs_table.clear();
m_blocks_txs_check.clear();
m_check_txin_table.clear();
@@ -3013,7 +3002,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
return true;
bool blocks_exist = false;
- uint64_t threads = boost::thread::hardware_concurrency();
+ uint64_t threads = tools::get_max_concurrency();
if (blocks_entry.size() > 1 && threads > 1 && m_max_prepare_blocks_threads > 1)
{
@@ -3116,7 +3105,6 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
m_fake_pow_calc_time = 0;
m_scan_table.clear();
- m_check_tx_inputs_table.clear();
m_check_txin_table.clear();
TIME_MEASURE_FINISH(prepare);
@@ -3213,7 +3201,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
// [output] stores all transactions for each tx_out_index::hash found
std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size());
- threads = boost::thread::hardware_concurrency();
+ threads = tools::get_max_concurrency();
if (!m_db->can_thread_bulk_indices())
threads = 1;
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index a62487d1e..21086d578 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -790,7 +790,6 @@ namespace cryptonote
// metadata containers
std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, std::vector<output_data_t>>> m_scan_table;
- std::unordered_map<crypto::hash, std::pair<bool, uint64_t>> m_check_tx_inputs_table;
std::unordered_map<crypto::hash, crypto::hash> m_blocks_longhash_table;
std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, bool>> m_check_txin_table;
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp
index 94f3d51d2..3b9dcc8a4 100644
--- a/src/cryptonote_core/cryptonote_format_utils.cpp
+++ b/src/cryptonote_core/cryptonote_format_utils.cpp
@@ -145,7 +145,19 @@ namespace cryptonote
[&out_amounts](uint64_t a_dust) { out_amounts.push_back(a_dust); });
CHECK_AND_ASSERT_MES(1 <= max_outs, false, "max_out must be non-zero");
- CHECK_AND_ASSERT_MES(max_outs >= out_amounts.size(), false, "max_out exceeded");
+ if (height == 0)
+ {
+ // the genesis block was not decomposed, for unknown reasons
+ while (max_outs < out_amounts.size())
+ {
+ out_amounts[out_amounts.size() - 2] += out_amounts.back();
+ out_amounts.resize(out_amounts.size() - 1);
+ }
+ }
+ else
+ {
+ CHECK_AND_ASSERT_MES(max_outs >= out_amounts.size(), false, "max_out exceeded");
+ }
uint64_t summary_amounts = 0;
for (size_t no = 0; no < out_amounts.size(); no++)
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index a06826163..3d5ab86e1 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -512,7 +512,7 @@ namespace cryptonote
{
if(txd.max_used_block_height >= m_blockchain.get_current_blockchain_height())
return false;
- if(m_blockchain.get_block_id_by_height(txd.max_used_block_height) != txd.max_used_block_id)
+ if(true)
{
//if we already failed on this height and id, skip actual ring signature check
if(txd.last_failed_id == m_blockchain.get_block_id_by_height(txd.last_failed_height))
diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h
index 84e11eeff..c7aab7f08 100644
--- a/src/cryptonote_core/tx_pool.h
+++ b/src/cryptonote_core/tx_pool.h
@@ -310,6 +310,7 @@ namespace cryptonote
#define CURRENT_MEMPOOL_ARCHIVE_VER 11
+#define CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER 11
/**
* @brief serialize the transaction pool to/from disk
@@ -530,6 +531,7 @@ namespace boost
}
}
BOOST_CLASS_VERSION(cryptonote::tx_memory_pool, CURRENT_MEMPOOL_ARCHIVE_VER)
+BOOST_CLASS_VERSION(cryptonote::tx_memory_pool::tx_details, CURRENT_MEMPOOL_TX_DETAILS_ARCHIVE_VER)