Compare commits

...

3 Commits

Author SHA1 Message Date
SChernykh 6dd72dfcd5 Fixed a rare crash on shutdown
2 weeks ago
SChernykh b3f562caab Added sanity checks for height and difficulty
2 weeks ago
SChernykh a847baf331 Revert "Fixed include paths"
2 weeks ago

@ -21,7 +21,7 @@
#include "uv_util.h"
extern "C" {
#include <crypto-ops.h>
#include "crypto-ops.h"
}
// l = 2^252 + 27742317777372353535851937790883648493.

@ -21,7 +21,7 @@
#include "stratum_server.h"
#include "block_template.h"
#include "pow_hash.h"
#include <randomx.h>
#include "randomx.h"
#include "params.h"
#include "p2pool_api.h"
#include "side_chain.h"

@ -771,6 +771,11 @@ void P2PServer::Peer::normalize()
void P2PServer::broadcast(const PoolBlock& block, const PoolBlock* parent)
{
// Don't broadcast blocks when shutting down
if (m_finished.load()) {
return;
}
MinerData miner_data = m_pool->miner_data();
if (block.m_txinGenHeight + 2 < miner_data.height) {

@ -20,7 +20,7 @@
#include "zmq_reader.h"
#include "mempool.h"
#include "json_rpc_request.h"
#include <rapidjson/document.h>
#include "rapidjson/document.h"
#include "json_parsers.h"
#include "pow_hash.h"
#include "block_template.h"

@ -53,6 +53,12 @@ static constexpr uint64_t MAX_BLOCK_SIZE = 128 * 1024 - 5;
// 0.6 XMR
static constexpr uint64_t BASE_BLOCK_REWARD = 600000000000ULL;
// 1000 years at 1 TH/s. It should be enough for any normal use.
static constexpr difficulty_type MAX_CUMULATIVE_DIFFICULTY{ 13019633956666736640ULL, 1710ULL };
// 1000 years at 1 block/second. It should be enough for any normal use.
static constexpr uint64_t MAX_SIDECHAIN_HEIGHT = 31556952000ULL;
struct DifficultyData
{
FORCEINLINE DifficultyData(uint64_t t, const difficulty_type& d) : m_timestamp(t), m_cumulativeDifficulty(d) {}

@ -306,12 +306,20 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
READ_VARINT(m_sidechainHeight);
if (m_sidechainHeight > MAX_SIDECHAIN_HEIGHT) {
return __LINE__;
}
READ_VARINT(m_difficulty.lo);
READ_VARINT(m_difficulty.hi);
READ_VARINT(m_cumulativeDifficulty.lo);
READ_VARINT(m_cumulativeDifficulty.hi);
if (m_cumulativeDifficulty > MAX_CUMULATIVE_DIFFICULTY) {
return __LINE__;
}
READ_BUF(m_sidechainExtraBuf, sizeof(m_sidechainExtraBuf));
#undef READ_BYTE

@ -33,7 +33,7 @@
#include "params.h"
#include "json_parsers.h"
#include "crypto.h"
#include <hardforks/hardforks.h>
#include "hardforks/hardforks.h"
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <fstream>

@ -26,7 +26,7 @@
#define ROBIN_HOOD_CALLOC(count, size) p2pool::calloc_hook((count), (size))
#define ROBIN_HOOD_FREE(ptr) p2pool::free_hook(ptr)
#include <robin_hood.h>
#include "robin_hood.h"
#ifdef _MSC_VER
#pragma warning(pop)

@ -24,7 +24,7 @@
#include "crypto.h"
extern "C" {
#include <crypto-ops.h>
#include "crypto-ops.h"
}
namespace {

Loading…
Cancel
Save