Skip to content

Commit

Permalink
disable merged mining
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptokatz committed Nov 14, 2018
1 parent 895b30b commit 5a8000d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2016-2018, The Karbo developers
// Copyright (c) 2018 The Circle Foundation

// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "Blockchain.h"

#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <boost/foreach.hpp>
#include "Common/Math.h"
#include "Common/int-util.h"
Expand All @@ -16,6 +20,7 @@
#include "Rpc/CoreRpcServerCommandsDefinitions.h"
#include "Serialization/BinarySerializationTools.h"
#include "CryptoNoteTools.h"
#include "TransactionExtra.h"

using namespace Logging;
using namespace Common;
Expand Down Expand Up @@ -1183,6 +1188,13 @@ bool Blockchain::handle_alternative_block(const Block& b, const Crypto::Hash& id
return false;
}

// Disable merged mining
TransactionExtraMergeMiningTag mmTag;
if (getMergeMiningTagFromExtra(bei.bl.baseTransaction.extra, mmTag) && bei.height >= CryptoNote::parameters::UPGRADE_HEIGHT_V6) {
logger(ERROR, BRIGHT_RED) << "Merge mining tag was found in extra of miner transaction";
return false;
}

// Always check PoW for alternative blocks
m_is_in_checkpoint_zone = false;
difficulty_type current_diff = get_next_difficulty_for_alternative_chain(alt_chain, bei);
Expand Down Expand Up @@ -1918,6 +1930,17 @@ bool Blockchain::pushBlock(const Block& blockData, const std::vector<Transaction
return false;
}

// Disable merged mining
uint32_t height = 0;
TransactionExtraMergeMiningTag mmTag;
if (m_blockIndex.getBlockHeight(blockHash, height)) {
if (getMergeMiningTagFromExtra(blockData.baseTransaction.extra, mmTag) && height >= CryptoNote::parameters::UPGRADE_HEIGHT_V6) {
logger(ERROR, BRIGHT_RED) << "Merge mining tag was found in extra of miner transaction";
return false;
}
}


if (blockData.previousBlockHash != getTailId()) {
logger(INFO, BRIGHT_WHITE) <<
"Block " << blockHash << " has wrong previousBlockHash: " << blockData.previousBlockHash << ", expected: " << getTailId();
Expand Down
2 changes: 2 additions & 0 deletions src/CryptoNoteCore/Checkpoints.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2018 The Circle Foundation
// Copyright (c) 2016-2018, The Karbo developers

// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
2 changes: 2 additions & 0 deletions src/CryptoNoteCore/TransactionExtra.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2018 The Circle Foundation

// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -89,6 +90,7 @@ bool appendMergeMiningTagToExtra(std::vector<uint8_t>& tx_extra, const Transacti
bool append_message_to_extra(std::vector<uint8_t>& tx_extra, const tx_extra_message& message);
std::vector<std::string> get_messages_from_extra(const std::vector<uint8_t>& extra, const Crypto::PublicKey &txkey, const Crypto::SecretKey *recepient_secret_key);
void appendTTLToExtra(std::vector<uint8_t>& tx_extra, uint64_t ttl);
bool getMergeMiningTagFromExtra(const std::vector<uint8_t>& tx_extra, TransactionExtraMergeMiningTag& mm_tag);

bool createTxExtraWithPaymentId(const std::string& paymentIdString, std::vector<uint8_t>& extra);
//returns false if payment id is not found or parse error
Expand Down

0 comments on commit 5a8000d

Please sign in to comment.