P2Pool and Solo Mining only

This commit is contained in:
_XxFedexX_ 2023-02-17 21:09:15 +00:00
commit 633ca6073c
7 changed files with 68 additions and 31 deletions

View file

@ -473,8 +473,10 @@ namespace cryptonote
if (major_version >= HF_VERSION_BLOCK_HEADER_MINER_SIG)
{
FIELD(signature)
if (major_version < HF_VERSION_P2POOL) {
FIELD(vote)
}
}
END_SERIALIZE()
};

View file

@ -199,8 +199,10 @@ namespace boost
if (b.major_version >= HF_VERSION_BLOCK_HEADER_MINER_SIG)
{
a & b.signature;
if (b.major_version < HF_VERSION_P2POOL) {
a & b.vote;
}
}
//------------------
a & b.miner_tx;
a & b.tx_hashes;

View file

@ -627,8 +627,11 @@ namespace cryptonote
crypto::generate_signature(sig_data, eph_pub_key, eph_secret_key, signature);
// amend signature to block header before PoW hashing
b.signature = signature;
if (b.major_version < HF_VERSION_P2POOL) {
b.vote = m_int_vote;
}
}
crypto::hash h;
m_gbh(b, height, NULL, tools::get_max_concurrency(), h);

View file

@ -198,6 +198,10 @@
#define HF_VERSION_VIEW_TAGS 20
#define HF_VERSION_2021_SCALING 20
#define HF_VERSION_BLOCK_HEADER_MINER_SIG 18
#define HF_VERSION_P2POOL 20
#define MIN_MINER_OUTPUTS 5
#define MIN_MINER_AMOUNT_FACTOR 500
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
#define CRYPTONOTE_SCALING_2021_FEE_ROUNDING_PLACES 2

View file

@ -1414,6 +1414,11 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
// Miner Block Header Signing
if (hf_version >= HF_VERSION_BLOCK_HEADER_MINER_SIG)
{
// block has been P2Pool mined, no signature required
if (hf_version >= HF_VERSION_P2POOL && b.miner_tx.vout.size() >= MIN_MINER_OUTPUTS)
{
LOG_PRINT_L1("Transaction meets MIN_MINER_OUTPUTS")
} else {
// sanity checks
if (b.miner_tx.vout.size() != 1)
{
@ -1425,7 +1430,7 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
MWARNING("Wrong txout type");
return false;
}
if (b.vote > 2)
if (hf_version < HF_VERSION_P2POOL && b.vote > 2)
{
MWARNING("Vote integer must be either 0, 1, or 2");
return false;
@ -1441,9 +1446,12 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
return false;
} else {
LOG_PRINT_L1("Miner signature is good");
if (hf_version < HF_VERSION_P2POOL) {
LOG_PRINT_L1("Vote: " << b.vote);
}
}
}
}
LOG_PRINT_L3("Blockchain::" << __func__);
CHECK_AND_ASSERT_MES(b.miner_tx.vin.size() == 1, false, "coinbase transaction in the block has no inputs");
@ -1546,6 +1554,20 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
partial_block_reward = true;
base_reward = money_in_use - fee;
}
// check that each output has minimal amount of WOW
if (version >= HF_VERSION_P2POOL) {
uint64_t min_miner_amount = base_reward / MIN_MINER_AMOUNT_FACTOR;
for (auto &o: b.miner_tx.vout)
{
if (o.amount+1 < min_miner_amount)
{
MERROR_VER("Each output must have at least " << print_money(min_miner_amount) << " block reward");
return false;
}
}
}
return true;
}
//------------------------------------------------------------------

View file

@ -2204,8 +2204,10 @@ namespace cryptonote
if (b.major_version >= HF_VERSION_BLOCK_HEADER_MINER_SIG)
{
b.signature = {};
if (b.major_version < HF_VERSION_P2POOL) {
b.vote = 0;
}
}
crypto::hash seed_hash = crypto::null_hash;
if (b.major_version >= RX_BLOCK_VERSION && !epee::string_tools::hex_to_pod(template_res.seed_hash, seed_hash))
{

View file

@ -898,8 +898,10 @@ namespace rpc
if (b.major_version >= HF_VERSION_BLOCK_HEADER_MINER_SIG)
{
header.signature = b.signature;
if (b.major_version < HF_VERSION_P2POOL) {
header.vote = b.vote;
}
}
header.prev_id = b.prev_id;
header.depth = m_core.get_current_blockchain_height() - header.height - 1;