Merge remote-tracking branch 'upstream/main'

This commit is contained in:
t1amak
2025-11-16 21:47:35 +00:00
7 changed files with 42 additions and 14 deletions

View File

@@ -122,7 +122,7 @@ constexpr uint8_t MINER_REWARD_UNLOCK_TIME = 60;
constexpr uint8_t NONCE_SIZE = 4;
constexpr uint8_t EXTRA_NONCE_SIZE = 4;
constexpr uint8_t EXTRA_NONCE_MAX_SIZE = EXTRA_NONCE_SIZE + 10;
constexpr uint8_t TX_VERSION = 60;
constexpr uint8_t TX_VERSION = 4;
constexpr uint8_t TXIN_GEN = 0xFF;
constexpr uint8_t TXOUT_TO_TAGGED_KEY = 3;
constexpr uint8_t TXOUT_TO_CARROT_V1 = 4;

View File

@@ -2486,6 +2486,11 @@ bool P2PServer::P2PClient::on_handshake_challenge(const uint8_t* buf)
uint64_t peer_id;
memcpy(&peer_id, buf + CHALLENGE_SIZE, sizeof(uint64_t));
LOGINFO(0, "DEBUG: Received handshake from " << static_cast<const char*>(m_addrString)
<< " peer_id=" << peer_id
<< " my_id=" << server->get_peerId(false)
<< " my_tor_id=" << server->get_peerId(true));
if ((peer_id == server->get_peerId(false)) || (peer_id == server->get_peerId(true))) {
LOGWARN(5, "tried to connect to self at " << static_cast<const char*>(m_addrString));
return false;
@@ -3189,11 +3194,35 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_
}
uint64_t unlock_height;
if (!readVarint(buf + data.header_size + 1, buf + header_and_miner_tx_size, unlock_height)) {
const uint8_t* p = buf + data.header_size + 1;
p = readVarint(p, buf + header_and_miner_tx_size, unlock_height); // Capture return value!
if (!p) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: unlock_height not found");
return false;
}
// Parse actual height from txin_gen (Salvium uses literal 60 for unlock_time)
uint64_t num_inputs;
p = readVarint(p, buf + header_and_miner_tx_size, num_inputs); // Capture return value!
if (!p || (num_inputs != 1)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: num_inputs invalid");
return false;
}
// Check input type (should be 0xff for txin_gen)
if ((p >= buf + header_and_miner_tx_size) || (*p != 0xff)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: txin_gen not found");
return false;
}
++p;
uint64_t height;
p = readVarint(p, buf + header_and_miner_tx_size, height); // Capture return value!
if (!p) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: height not found in txin_gen");
return false;
}
p2pool* pool = server->m_pool;
// Ignore blocks which already unlocked
@@ -3213,7 +3242,6 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_
return true;
}
const uint64_t height = unlock_height - MINER_REWARD_UNLOCK_TIME;
LOGINFO(6, "on_monero_block_broadcast: height = " << height);
difficulty_type diff;

View File

@@ -160,7 +160,7 @@ std::vector<uint8_t> PoolBlock::serialize_mainchain_data(size_t* header_size, si
// Miner tx
data.push_back(TX_VERSION);
writeVarint(m_txinGenHeight + MINER_REWARD_UNLOCK_TIME, data);
writeVarint(MINER_REWARD_UNLOCK_TIME, data);
data.push_back(1);
data.push_back(TXIN_GEN);
writeVarint(m_txinGenHeight, data);

View File

@@ -88,7 +88,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
READ_VARINT(m_txinGenHeight);
if (m_majorVersion != sidechain.network_major_version(m_txinGenHeight)) return __LINE__;
if (unlock_height != m_txinGenHeight + MINER_REWARD_UNLOCK_TIME) return __LINE__;
if (unlock_height != MINER_REWARD_UNLOCK_TIME) return __LINE__;
std::vector<uint8_t> outputs_blob;
const int outputs_offset = static_cast<int>(data - data_begin);

View File

@@ -55,9 +55,9 @@ static constexpr uint64_t MONERO_BLOCK_TIME = 120;
namespace p2pool {
static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 };
static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 57,130,201,26,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 };
static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 171,248,206,148,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 };
static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 83,65,76,86,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 };
static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 83,65,76,77,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 };
static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 83,65,76,78,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 };
NetworkType SideChain::s_networkType = NetworkType::Invalid;

View File

@@ -336,7 +336,7 @@ static std::vector<uint8_t> construct_monero_block_blob(rapidjson::Value* value,
blob.push_back(1);
blob.push_back(TXIN_GEN);
writeVarint(unlock_height - MINER_REWARD_UNLOCK_TIME, blob);
writeVarint(MINER_REWARD_UNLOCK_TIME, blob);
auto arr = outputs->value.GetArray();