aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_core.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2020-09-06 15:49:36 +0200
committerRiccardo Spagni <ric@spagni.net>2020-09-06 15:49:37 +0200
commitaefa7740c38754b31a4f5748569ac1af59034667 (patch)
treeffb822e7c7e0929d70b706f26f29f94caec7aecd /src/cryptonote_core/cryptonote_core.cpp
parent2a7086caa8a63f16ee360d11fae3036fa61598eb (diff)
parentd20ff4f648ea3b716825ea34db05b98ad24239b4 (diff)
downloadmonzero-core-aefa7740c38754b31a4f5748569ac1af59034667.tar.gz
monzero-core-aefa7740c38754b31a4f5748569ac1af59034667.tar.xz
monzero-core-aefa7740c38754b31a4f5748569ac1af59034667.zip
Merge pull request #6111
d20ff4f64 functional_tests: add a large (many randomx epochs) p2p reorg test (moneromooo-monero) 6a0b3b1f8 functional_tests: add randomx tests (moneromooo-monero) 9d42649d5 core: fix mining from a block that's not the current top (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/cryptonote_core.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 894071924..fef411a0c 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -226,8 +226,8 @@ namespace cryptonote
core::core(i_cryptonote_protocol* pprotocol):
m_mempool(m_blockchain_storage),
m_blockchain_storage(m_mempool),
- m_miner(this, [this](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash) {
- return cryptonote::get_block_longhash(&m_blockchain_storage, b, hash, height, threads);
+ m_miner(this, [this](const cryptonote::block &b, uint64_t height, const crypto::hash *seed_hash, unsigned int threads, crypto::hash &hash) {
+ return cryptonote::get_block_longhash(&m_blockchain_storage, b, hash, height, seed_hash, threads);
}),
m_starter_message_showed(false),
m_target_blockchain_height(0),
@@ -1184,11 +1184,42 @@ namespace cryptonote
size_t core::get_block_sync_size(uint64_t height) const
{
static const uint64_t quick_height = m_nettype == TESTNET ? 801219 : m_nettype == MAINNET ? 1220516 : 0;
+ size_t res = 0;
if (block_sync_size > 0)
- return block_sync_size;
- if (height >= quick_height)
- return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
- return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4;
+ res = block_sync_size;
+ else if (height >= quick_height)
+ res = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
+ else
+ res = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4;
+
+ static size_t max_block_size = 0;
+ if (max_block_size == 0)
+ {
+ const char *env = getenv("SEEDHASH_EPOCH_BLOCKS");
+ if (env)
+ {
+ int n = atoi(env);
+ if (n <= 0)
+ n = BLOCKS_SYNCHRONIZING_MAX_COUNT;
+ size_t p = 1;
+ while (p < (size_t)n)
+ p <<= 1;
+ max_block_size = p;
+ }
+ else
+ max_block_size = BLOCKS_SYNCHRONIZING_MAX_COUNT;
+ }
+ if (res > max_block_size)
+ {
+ static bool warned = false;
+ if (!warned)
+ {
+ MWARNING("Clamping block sync size to " << max_block_size);
+ warned = true;
+ }
+ res = max_block_size;
+ }
+ return res;
}
//-----------------------------------------------------------------------------------------------
bool core::are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const
@@ -1360,14 +1391,14 @@ namespace cryptonote
m_mempool.set_relayed(epee::to_span(tx_hashes), tx_relay);
}
//-----------------------------------------------------------------------------------------------
- bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce)
+ bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash)
{
- return m_blockchain_storage.create_block_template(b, adr, diffic, height, expected_reward, ex_nonce);
+ return m_blockchain_storage.create_block_template(b, adr, diffic, height, expected_reward, ex_nonce, seed_height, seed_hash);
}
//-----------------------------------------------------------------------------------------------
- bool core::get_block_template(block& b, const crypto::hash *prev_block, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce)
+ bool core::get_block_template(block& b, const crypto::hash *prev_block, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash)
{
- return m_blockchain_storage.create_block_template(b, prev_block, adr, diffic, height, expected_reward, ex_nonce);
+ return m_blockchain_storage.create_block_template(b, prev_block, adr, diffic, height, expected_reward, ex_nonce, seed_height, seed_hash);
}
//-----------------------------------------------------------------------------------------------
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const