Skip to content

Commit

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

- Wallet synchronization enhancements
- Daemon synchronization issue fix
- Daemon stability enhancements

Release notes 2.0.6

- Wallet synchronization enhancements
Expand Down
7 changes: 4 additions & 3 deletions src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const uint8_t BLOCK_MINOR_VERSION_0 = 0;
const uint8_t BLOCK_MINOR_VERSION_1 = 1;

const size_t BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT = 10000; //by default, blocks ids count in synchronizing
const size_t BLOCKS_SYNCHRONIZING_DEFAULT_COUNT = 200; //by default, blocks count in blocks downloading
const size_t BLOCKS_SYNCHRONIZING_DEFAULT_COUNT = 100; //by default, blocks count in blocks downloading
const size_t COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT = 1000;

const int P2P_DEFAULT_PORT = 8080;
Expand All @@ -107,7 +107,7 @@ const int RPC_DEFAULT_PORT = 8081;
const size_t P2P_LOCAL_WHITE_PEERLIST_LIMIT = 1000;
const size_t P2P_LOCAL_GRAY_PEERLIST_LIMIT = 5000;

const size_t P2P_CONNECTION_MAX_WRITE_BUFFER_SIZE = 16 * 1024 * 1024; // 16 MB
const size_t P2P_CONNECTION_MAX_WRITE_BUFFER_SIZE = 32 * 1024 * 1024; // 32 MB
const uint32_t P2P_DEFAULT_CONNECTIONS_COUNT = 8;
const size_t P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT = 70;
const uint32_t P2P_DEFAULT_HANDSHAKE_INTERVAL = 60; // seconds
Expand Down Expand Up @@ -186,7 +186,8 @@ const CheckpointData CHECKPOINTS[] = {
{1272000, "2fb2c50328c8345d2f0a16b3ec4ea680a8a93730358494265ada9edbb9bfa1a6"},
{1273000, "496a9238c654d79c48d269224aa75d61f51831bae6dc744f5e709bec11c7c9f2"},
{1278000, "de0225cd279ca27cc8d4f8da1b5b92ba0112e48b3777b8c50301846ccfc9146b"},
{1283000, "826043db95e9801f038f254d223ce0d0912da269dcce1461b5f0f05ddfae9e1c"}
{1283000, "826043db95e9801f038f254d223ce0d0912da269dcce1461b5f0f05ddfae9e1c"},
{1324000, "981e6f6871a7c295b56c5ce544adb5a7d52540ee23e15474b4357c7728952fef"}
};
} // CryptoNote

Expand Down
4 changes: 3 additions & 1 deletion src/CryptoNoteCore/DataBaseErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace error {
enum class DataBaseErrorCodes : int {
NOT_INITIALIZED = 1,
ALREADY_INITIALIZED,
INTERNAL_ERROR
INTERNAL_ERROR,
IO_ERROR
};

class DataBaseErrorCategory : public std::error_category {
Expand All @@ -46,6 +47,7 @@ class DataBaseErrorCategory : public std::error_category {
case static_cast<int>(DataBaseErrorCodes::NOT_INITIALIZED) : return "Object was not initialized";
case static_cast<int>(DataBaseErrorCodes::ALREADY_INITIALIZED) : return "Object has been already initialized";
case static_cast<int>(DataBaseErrorCodes::INTERNAL_ERROR) : return "Internal error";
case static_cast<int>(DataBaseErrorCodes::IO_ERROR) : return "IO error";
default: return "Unknown error";
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/CryptoNoteCore/RocksDBWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ void RocksDBWrapper::init(const DataBaseConfig& config) {
rocksdb::Status status = rocksdb::DB::Open(dbOptions, dataDir, &dbPtr);
if (status.ok()) {
logger(INFO) << "DB opened in " << dataDir;
} else if (!status.ok() || status.IsNotFound()) {
} else if (!status.ok() && status.IsInvalidArgument()) {
logger(INFO) << "DB not found in " << dataDir << ". Creating new DB...";
dbOptions.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(dbOptions, dataDir, &dbPtr);
if (!status.ok()) {
logger(ERROR) << "DB Error. DB can't be created in " << dataDir << ". Error: " << status.ToString();
throw std::system_error(make_error_code(CryptoNote::error::DataBaseErrorCodes::INTERNAL_ERROR));
}
} else if (status.IsIOError()) {
logger(ERROR) << "DB Error. DB can't be opened in " << dataDir << ". Error: " << status.ToString();
throw std::system_error(make_error_code(CryptoNote::error::DataBaseErrorCodes::IO_ERROR));
} else {
logger(ERROR) << "DB Error. DB can't be opened in " << dataDir << ". Error: " << status.ToString();
throw std::system_error(make_error_code(CryptoNote::error::DataBaseErrorCodes::INTERNAL_ERROR));
Expand Down
6 changes: 3 additions & 3 deletions src/PaymentGateService/PaymentGateService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ void PaymentGateService::runInProcess(Logging::LoggerRef& log) {
//TODO: make command line options
dbConfig.setConfigFolderDefaulted(true);
dbConfig.setDataDir(config.dataDir);
dbConfig.setMaxOpenFiles(10);
dbConfig.setReadCacheSize(100*1024*1024);
dbConfig.setWriteBufferSize(100*1024*1024);
dbConfig.setMaxOpenFiles(100);
dbConfig.setReadCacheSize(128*1024*1024);
dbConfig.setWriteBufferSize(128*1024*1024);
dbConfig.setTestnet(false);
dbConfig.setBackgroundThreadsCount(2);

Expand Down
12 changes: 10 additions & 2 deletions src/Transfers/BlockchainSynchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bool BlockchainSynchronizer::setFutureStateIf(State s, std::function<bool(void)>

void BlockchainSynchronizer::actualizeFutureState() {
std::unique_lock<std::mutex> lk(m_stateMutex);
if (m_currentState == State::stopped && m_futureState == State::deleteOldTxs) { // start(), immideately attach observer
if (m_currentState == State::stopped && (m_futureState == State::deleteOldTxs || m_futureState == State::blockchainSync)) { // start(), immideately attach observer
m_node.addObserver(this);
}

Expand Down Expand Up @@ -349,7 +349,15 @@ void BlockchainSynchronizer::start() {
throw std::runtime_error(message);
}

if (!setFutureStateIf(State::deleteOldTxs, [this] { return m_currentState == State::stopped && m_futureState == State::stopped; })) {
State nextState;
if (!wasStarted) {
nextState = State::deleteOldTxs;
wasStarted = true;
} else {
nextState = State::blockchainSync;
}

if (!setFutureStateIf(nextState, [this] { return m_currentState == State::stopped && m_futureState == State::stopped; })) {
auto message = "Failed to start: already started";
m_logger(ERROR, BRIGHT_RED) << message;
throw std::runtime_error(message);
Expand Down
2 changes: 2 additions & 0 deletions src/Transfers/BlockchainSynchronizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class BlockchainSynchronizer :
mutable std::mutex m_consumersMutex;
mutable std::mutex m_stateMutex;
std::condition_variable m_hasWork;

bool wasStarted = false;
};

}
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.6"
#define PROJECT_VERSION_BUILD_NO "1236"
#define PROJECT_VERSION "2.0.7"
#define PROJECT_VERSION_BUILD_NO "1242"
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO " (" BUILD_COMMIT_ID ")"
76 changes: 75 additions & 1 deletion tests/UnitTests/TestBcS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ class ConsumerStub : public IBlockchainConsumer {

virtual uint32_t onNewBlocks(const CompleteBlock* blocks, uint32_t startHeight, uint32_t count) override {
//assert(m_blockchain.size() == startHeight);
uint32_t blocksAdded = count;
for (size_t i = 0; i < count; ++i) {
m_blockchain.push_back(blocks->blockHash);
++blocks;
}
return count;
return blocksAdded;
}

const std::vector<Hash>& getBlockchain() const {
Expand Down Expand Up @@ -1405,3 +1406,76 @@ TEST_F(BcSTest, checkTxOrder) {

EXPECT_EQ(expectedTxHashes, receivedTxHashes);
}

TEST_F(BcSTest, outdatedTxsRemovedOnlyAtFirstStart) {
auto tx1ptr = createTransaction();

auto tx1 = ::createTx(*tx1ptr.get());

auto tx1hash = getObjectHash(tx1);

FunctorialPoolConsumerStub c1(m_currency.genesisBlockHash());

c1.addPoolTransaction(tx1hash);

std::vector<Hash> expectedDeletedPoolAnswer = { tx1hash };

std::vector<Hash> c1ResponseDeletedPool;
std::vector<Hash> c1ResponseNewPool;

c1.onPoolUpdatedFunctor = [&](const std::vector<std::unique_ptr<ITransactionReader>>& new_txs, const std::vector<Hash>& deleted)->std::error_code {
c1ResponseDeletedPool.assign(deleted.begin(), deleted.end());
for (const auto& tx : new_txs) {
Hash hash = tx->getTransactionHash();
c1ResponseNewPool.push_back(reinterpret_cast<const Hash&>(hash));
}

return std::error_code();
};


m_sync.addConsumer(&c1);

int requestsCount = 0;
m_node.getPoolSymmetricDifferenceFunctor = [&](const std::vector<Hash>& known, Hash last, bool& is_actual,
std::vector<std::unique_ptr<ITransactionReader>>& new_txs, std::vector<Hash>& deleted, const INode::Callback& callback) {
++requestsCount;
is_actual = true;
deleted.push_back(tx1hash);
callback(std::error_code());
return false;
};

IBlockchainSynchronizerFunctorialObserver o1;
EventWaiter e;
o1.syncFunc = [&e](std::error_code) {
e.notify();
};

m_sync.addObserver(&o1);
m_sync.start();
e.wait();
m_sync.stop();
m_sync.removeObserver(&o1);
o1.syncFunc = [](std::error_code) {};

EXPECT_EQ(2, requestsCount);
EXPECT_EQ(expectedDeletedPoolAnswer, c1ResponseDeletedPool);

generator.generateEmptyBlocks(20);
requestsCount = 0;

o1.syncFunc = [&e](std::error_code) {
e.notify();
};

m_sync.addObserver(&o1);
m_sync.start();
e.wait();
m_sync.stop();
m_sync.removeObserver(&o1);
o1.syncFunc = [](std::error_code) {};

EXPECT_EQ(1, requestsCount);
EXPECT_EQ(expectedDeletedPoolAnswer, c1ResponseDeletedPool);
}

0 comments on commit 14f60a4

Please sign in to comment.