Compare commits

...

7 Commits

@ -2,6 +2,7 @@
#ifdef _MSC_VER
#pragma warning(push, 0)
#pragma warning(disable : 4866)
#endif
#include "proto/gRPC/base_node.pb.h"

@ -62,7 +62,7 @@ void p2pool_usage()
"--no-igd An alias for --no-upnp\n"
"--upnp-stratum Port forward Stratum port (it's not forwarded by default)\n"
#endif
"--merge-mine IP:port and wallet address for another blockchain to merge mine with"
"--merge-mine IP:port and wallet address for another blockchain to merge mine with\n"
"--version Print p2pool's version and build details\n"
"--help Show this help message\n\n"
"Example command line:\n\n"

@ -149,47 +149,60 @@ void MergeMiningClientTari::run()
LOGINFO(6, "Getting new block template from Tari node");
grpc::Status status;
NewBlockTemplateRequest request;
GetNewBlockTemplateWithCoinbasesRequest request;
PowAlgo* algo = new PowAlgo();
algo->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
request.clear_algo();
request.set_allocated_algo(algo);
request.set_max_weight(1);
grpc::ClientContext ctx;
NewBlockTemplateResponse response;
status = m_TariNode->GetNewBlockTemplate(&ctx, request, &response);
NewBlockCoinbase* coinbase = request.add_coinbases();
coinbase->set_address(m_auxWallet);
grpc::ClientContext ctx2;
GetNewBlockResult response2;
status = m_TariNode->GetNewBlock(&ctx2, response.new_block_template(), &response2);
// TODO this should be equal to the total weight of shares in the PPLNS window for each wallet
coinbase->set_value(1);
bool aux_id_empty;
{
ReadLock lock2(m_chainParamsLock);
aux_id_empty = m_chainParams.aux_id.empty();
}
coinbase->set_stealth_payment(false);
coinbase->set_revealed_value_proof(true);
coinbase->clear_coinbase_extra();
if (aux_id_empty) {
const std::string& id = response2.tari_unique_id();
LOGINFO(1, m_hostStr << " uses chain_id " << log::LightCyan() << log::hex_buf(id.data(), id.size()));
grpc::ClientContext ctx;
GetNewBlockResult response;
if (id.size() == HASH_SIZE) {
WriteLock lock2(m_chainParamsLock);
std::copy(id.begin(), id.end(), m_chainParams.aux_id.h);
}
else {
LOGERR(1, "Tari unique_id has invalid size (" << id.size() << ')');
const grpc::Status status = m_TariNode->GetNewBlockTemplateWithCoinbases(&ctx, request, &response);
if (!status.ok()) {
LOGWARN(5, "GetNewBlockTemplateWithCoinbases failed: " << status.error_message());
if (!status.error_details().empty()) {
LOGWARN(5, "GetNewBlockTemplateWithCoinbases failed: " << status.error_details());
}
}
else {
bool aux_id_empty;
{
ReadLock lock2(m_chainParamsLock);
aux_id_empty = m_chainParams.aux_id.empty();
}
LOGINFO(6, "Tari block template: height = " << response.new_block_template().header().height()
<< ", diff = " << response.miner_data().target_difficulty()
<< ", reward = " << response.miner_data().reward()
<< ", fees = " << response.miner_data().total_fees()
);
if (aux_id_empty) {
const std::string& id = response.tari_unique_id();
LOGINFO(1, m_hostStr << " uses chain_id " << log::LightCyan() << log::hex_buf(id.data(), id.size()));
if (id.size() == HASH_SIZE) {
WriteLock lock2(m_chainParamsLock);
std::copy(id.begin(), id.end(), m_chainParams.aux_id.h);
}
else {
LOGERR(1, "Tari unique_id has invalid size (" << id.size() << ')');
}
}
LOGINFO(6, "Tari block template: height = " << response.block().header().height()
<< ", diff = " << response.miner_data().target_difficulty()
<< ", reward = " << response.miner_data().reward()
<< ", fees = " << response.miner_data().total_fees()
);
}
const int64_t timeout = std::max<int64_t>(500'000'000 - duration_cast<nanoseconds>(high_resolution_clock::now() - t1).count(), 1'000'000);

@ -760,6 +760,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) {

@ -54,6 +54,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) {}

@ -326,12 +326,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__;
}
uint8_t merkle_proof_size;
READ_BYTE(merkle_proof_size);

Loading…
Cancel
Save