Skip to content

Commit

Permalink
Fix sync issues
Browse files Browse the repository at this point in the history
caused by bugs introduced by emergency tx flood protection attempts
  • Loading branch information
aivve committed Apr 4, 2018
1 parent 8d193dd commit c2e236d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_CURRENT = CRYPTONOTE_BL
const size_t CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE = 600;
const size_t CRYPTONOTE_DISPLAY_DECIMAL_POINT = 12;
const uint64_t MINIMUM_FEE = UINT64_C(100000000000);
const uint64_t DEFAULT_DUST_THRESHOLD = UINT64_C(0);
const uint64_t DEFAULT_DUST_THRESHOLD = UINT64_C(100000000);
const uint64_t MAX_TX_MIXIN_SIZE = 20;

const uint64_t EXPECTED_NUMBER_OF_BLOCKS_PER_DAY = 24 * 60 * 60 / DIFFICULTY_TARGET;
Expand Down
10 changes: 4 additions & 6 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1579,12 +1579,6 @@ bool Blockchain::checkTransactionInputs(const Transaction& tx, const Crypto::Has
assert(inputIndex < tx.signatures.size());
if (txin.type() == typeid(KeyInput)) {

uint64_t txMixin = boost::get<KeyInput>(txin).outputIndexes.size();
if (txMixin > CryptoNote::parameters::MAX_TX_MIXIN_SIZE) {
logger(DEBUGGING, BRIGHT_WHITE) << "Transaction << " << transactionHash << " hast too large mixin count.";
return false;
}

const KeyInput& in_to_key = boost::get<KeyInput>(txin);
if (!(!in_to_key.outputIndexes.empty())) { logger(ERROR, BRIGHT_RED) << "empty in_to_key.outputIndexes in transaction with id " << getObjectHash(tx); return false; }

Expand Down Expand Up @@ -2559,4 +2553,8 @@ bool Blockchain::isBlockInMainChain(const Crypto::Hash& blockId) {
return m_blockIndex.hasBlock(blockId);
}

bool Blockchain::isInCheckpointZone(const uint32_t height) {
return m_checkpoints.is_in_checkpoint_zone(height);
}

}
1 change: 1 addition & 0 deletions src/CryptoNoteCore/Blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ namespace CryptoNote {
bool getBlockIdsByTimestamp(uint64_t timestampBegin, uint64_t timestampEnd, uint32_t blocksNumberLimit, std::vector<Crypto::Hash>& hashes, uint32_t& blocksNumberWithinTimestamps);
bool getTransactionIdsByPaymentId(const Crypto::Hash& paymentId, std::vector<Crypto::Hash>& transactionHashes);
bool isBlockInMainChain(const Crypto::Hash& blockId);
bool isInCheckpointZone(const uint32_t height);

template<class visitor_t> bool scanOutputKeysForIndexes(const KeyInput& tx_in_to_key, visitor_t& vis, uint32_t* pmax_related_block_height = NULL);

Expand Down
19 changes: 11 additions & 8 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,15 +1052,18 @@ bool core::handleIncomingTransaction(const Transaction& tx, const Crypto::Hash&
return false;
}

if (!check_tx_fee(tx, blobSize, tvc)) {
tvc.m_verifivation_failed = true;
return false;
}
// is in checkpoint zone
if (!m_blockchain.isInCheckpointZone(get_current_blockchain_height())) {
if (!check_tx_fee(tx, blobSize, tvc)) {
tvc.m_verifivation_failed = true;
return false;
}

if (!check_tx_mixin(tx)) {
logger(INFO) << "Transaction verification failed: mixin count for transaction " << txHash << " is too large, rejected";
tvc.m_verifivation_failed = true;
return false;
if (!check_tx_mixin(tx)) {
logger(INFO) << "Transaction verification failed: mixin count for transaction " << txHash << " is too large, rejected";
tvc.m_verifivation_failed = true;
return false;
}
}

if (!check_tx_semantic(tx, keptByBlock)) {
Expand Down

0 comments on commit c2e236d

Please sign in to comment.