Skip to content

Commit

Permalink
Bytecoin v.2.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Juarez committed Aug 11, 2017
1 parent 14f60a4 commit fba8937
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 15 deletions.
5 changes: 5 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Release notes 2.1.0

- Transaction pool issue fixes
- Daemon synchronization improvements

Release notes 2.0.7

- Wallet synchronization enhancements
Expand Down
3 changes: 2 additions & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ const CheckpointData CHECKPOINTS[] = {
{1273000, "496a9238c654d79c48d269224aa75d61f51831bae6dc744f5e709bec11c7c9f2"},
{1278000, "de0225cd279ca27cc8d4f8da1b5b92ba0112e48b3777b8c50301846ccfc9146b"},
{1283000, "826043db95e9801f038f254d223ce0d0912da269dcce1461b5f0f05ddfae9e1c"},
{1324000, "981e6f6871a7c295b56c5ce544adb5a7d52540ee23e15474b4357c7728952fef"}
{1324000, "981e6f6871a7c295b56c5ce544adb5a7d52540ee23e15474b4357c7728952fef"},
{1329000, "b88ed8dfe95a19bd6377f77c01d87df9cf7bd14cd6de7ec616beca95deb1fc85"}
};
} // CryptoNote

Expand Down
24 changes: 21 additions & 3 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ std::error_code Core::addBlock(const CachedBlock& cachedBlock, RawBlock&& rawBlo

cache->pushBlock(cachedBlock, transactions, validatorState, cumulativeBlockSize, emissionChange, currentDifficulty, std::move(rawBlock));

actualizePoolTransactions();
updateBlockMedianSize();
actualizePoolTransactionsLite(validatorState);

ret = error::AddBlockErrorCode::ADDED_TO_MAIN;
logger(Logging::DEBUGGING) << "Block " << cachedBlock.getBlockHash() << " added to main chain. Index: " << (previousBlockIndex + 1);
Expand All @@ -662,6 +663,8 @@ std::error_code Core::addBlock(const CachedBlock& cachedBlock, RawBlock&& rawBlo
assert(endpointIndex != 0);
std::swap(chainsLeaves[0], chainsLeaves[endpointIndex]);
updateMainChainSet();

updateBlockMedianSize();
actualizePoolTransactions();
copyTransactionsToPool(chainsLeaves[endpointIndex]);

Expand All @@ -688,9 +691,8 @@ std::error_code Core::addBlock(const CachedBlock& cachedBlock, RawBlock&& rawBlo
currentDifficulty, std::move(rawBlock));

updateMainChainSet();
updateBlockMedianSize();
}

updateBlockMedianSize();
} else {
logger(Logging::DEBUGGING) << "Adding alternative block: " << cachedBlock.getBlockHash();

Expand Down Expand Up @@ -744,6 +746,22 @@ void Core::actualizePoolTransactions() {
}
}

void Core::actualizePoolTransactionsLite(const TransactionValidatorState& validatorState) {
auto& pool = *transactionPool;
auto hashes = pool.getTransactionHashes();

for (auto& hash : hashes) {
auto tx = pool.getTransaction(hash);

auto txState = extractSpentOutputs(tx);

if (hasIntersections(validatorState, txState) || tx.getTransactionBinaryArray().size() > getMaximumTransactionAllowedSize(blockMedianSize, currency)) {
pool.removeTransaction(hash);
notifyObservers(makeDelTransactionMessage({ hash }, Messages::DeleteTransaction::Reason::NotActual));
}
}
}

void Core::switchMainChainStorage(uint32_t splitBlockIndex, IBlockchainCache& newChain) {
assert(mainChainStorage->getBlockCount() > splitBlockIndex);

Expand Down
2 changes: 2 additions & 0 deletions src/CryptoNoteCore/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ class Core : public ICore, public ICoreInformation {
void notifyOnSuccess(error::AddBlockErrorCode opResult, uint32_t previousBlockIndex, const CachedBlock& cachedBlock,
const IBlockchainCache& cache);
void copyTransactionsToPool(IBlockchainCache* alt);

void actualizePoolTransactions();
void actualizePoolTransactionsLite(const TransactionValidatorState& validatorState); //Checks pool txs only for double spend.

void transactionPoolCleaningProcedure();
void updateBlockMedianSize();
Expand Down
4 changes: 3 additions & 1 deletion src/CryptoNoteCore/TransactionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ bool TransactionPool::pushTransaction(CachedTransaction&& transaction, Transacti
return false;
}

if (!mergeStates(poolState, transactionState)) {
if (hasIntersections(poolState, transactionState)) {
logger(Logging::DEBUGGING) << "pushTransaction: failed to merge states, some keys already used";
return false;
}

mergeStates(poolState, transactionState);

logger(Logging::DEBUGGING) << "pushed transaction " << pendingTx.getTransactionHash() << " to pool";
return transactionHashIndex.emplace(std::move(pendingTx)).second;
}
Expand Down
17 changes: 10 additions & 7 deletions src/CryptoNoteCore/TransactionValidatiorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

namespace CryptoNote {

bool mergeStates(TransactionValidatorState& source, TransactionValidatorState& destination) {
/* source.spentKeyImages.insert(destination.spentKeyImages.begin(), destination.spentKeyImages.end()); */
/* source.spentMultisignatureGlobalIndexes.insert(destination.spentMultisignatureGlobalIndexes.begin(), destination.spentMultisignatureGlobalIndexes.end()); */
return std::all_of(destination.spentKeyImages.begin(), destination.spentKeyImages.end(),
[&](const Crypto::KeyImage& ki) { return source.spentKeyImages.insert(ki).second; }) &&
std::all_of(destination.spentMultisignatureGlobalIndexes.begin(), destination.spentMultisignatureGlobalIndexes.end(),
void mergeStates(TransactionValidatorState& destionation, const TransactionValidatorState& source) {
destionation.spentKeyImages.insert(source.spentKeyImages.begin(), source.spentKeyImages.end());
destionation.spentMultisignatureGlobalIndexes.insert(source.spentMultisignatureGlobalIndexes.begin(), source.spentMultisignatureGlobalIndexes.end());
}

bool hasIntersections(const TransactionValidatorState& destination, const TransactionValidatorState& source) {
return std::any_of(source.spentKeyImages.begin(), source.spentKeyImages.end(),
[&](const Crypto::KeyImage& ki) { return destination.spentKeyImages.count(ki) != 0; }) ||
std::any_of(source.spentMultisignatureGlobalIndexes.begin(), source.spentMultisignatureGlobalIndexes.end(),
[&](const std::pair<uint64_t, uint32_t>& pr) {
return source.spentMultisignatureGlobalIndexes.insert(pr).second;
return destination.spentMultisignatureGlobalIndexes.count(pr) != 0;
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/CryptoNoteCore/TransactionValidatiorState.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct TransactionValidatorState {
std::set<std::pair<uint64_t, uint32_t>> spentMultisignatureGlobalIndexes;
};

bool mergeStates(TransactionValidatorState& destionation, TransactionValidatorState& source);
void mergeStates(TransactionValidatorState& destionation, const TransactionValidatorState& source);
bool hasIntersections(const TransactionValidatorState& destionation, const TransactionValidatorState& source);
void excludeFromState(TransactionValidatorState& state, const CachedTransaction& transaction);

}
4 changes: 2 additions & 2 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "2.0.7"
#define PROJECT_VERSION_BUILD_NO "1242"
#define PROJECT_VERSION "2.1.0"
#define PROJECT_VERSION_BUILD_NO "1243"
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO " (" BUILD_COMMIT_ID ")"

0 comments on commit fba8937

Please sign in to comment.