Skip to content

Commit

Permalink
Bytecoin v.1.0.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Juarez committed Aug 11, 2015
1 parent 49572fc commit deda499
Show file tree
Hide file tree
Showing 30 changed files with 779 additions and 165 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set(CMAKE_SKIP_INSTALL_RULES ON)
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
set(CMAKE_SUPPRESS_REGENERATION ON)
enable_testing()
# copy CTestCustom.cmake to build dir to disable long running tests in 'make test'
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})

project(Bytecoin)

Expand Down
11 changes: 11 additions & 0 deletions CTestCustom.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(CTEST_CUSTOM_TESTS_IGNORE
CoreTests
IntegrationTestLibrary
TestGenerator
CryptoTests
IntegrationTests
NodeRpcProxyTests
PerformanceTests
TransfersTests
)

5 changes: 5 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Release notes 1.0.7

- Fusion transactions support
- Various simplewallet improvements

Release notes 1.0.6

- High-level API update
Expand Down
7 changes: 6 additions & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const uint64_t CRYPTONOTE_MEMPOOL_TX_LIVETIME = 60 * 60 * 24;
const uint64_t CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME = 60 * 60 * 24 * 7; //seconds, one week
const uint64_t CRYPTONOTE_NUMBER_OF_PERIODS_TO_FORGET_TX_DELETED_FROM_POOL = 7; // CRYPTONOTE_NUMBER_OF_PERIODS_TO_FORGET_TX_DELETED_FROM_POOL * CRYPTONOTE_MEMPOOL_TX_LIVETIME = time to forget tx

const size_t FUSION_TX_MAX_SIZE = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 30 / 100;
const size_t FUSION_TX_MIN_INPUT_COUNT = 6;
const size_t FUSION_TX_MIN_IN_OUT_COUNT_RATIO = 3;

const uint64_t UPGRADE_HEIGHT = 546602;
const unsigned UPGRADE_VOTING_THRESHOLD = 90; // percent
const size_t UPGRADE_VOTING_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY; // blocks
Expand Down Expand Up @@ -156,7 +160,8 @@ const CheckpointData CHECKPOINTS[] = {
{785500, "de1a487d70964d25ed6f7de196866f357a293e867ee81313e7fd0352d0126bdd"},
{789000, "acef490bbccce3b7b7ae8554a414f55413fbf4ca1472c6359b126a4439bd9f01"},
{796000, "04e387a00d35db21d4d93d04040b31f22573972a7e61d72cc07d0ab69bcb9c44"},
{800000, "d7fa4eea02e5ce60b949136569c0ea7ac71ea46e0065311054072ac415560b86"}
{800000, "d7fa4eea02e5ce60b949136569c0ea7ac71ea46e0065311054072ac415560b86"},
{804000, "bcc8b3782499aae508c40d5587d1cc5d68281435ea9bfc6804a262047f7b934d"}
};
} // CryptoNote

Expand Down
1 change: 1 addition & 0 deletions src/CryptoNoteCore/CryptoNoteBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace CryptoNote {
const Crypto::Hash NULL_HASH = boost::value_initialized<Crypto::Hash>();
const Crypto::PublicKey NULL_PUBLIC_KEY = boost::value_initialized<Crypto::PublicKey>();
const Crypto::SecretKey NULL_SECRET_KEY = boost::value_initialized<Crypto::SecretKey>();

KeyPair generateKeyPair();

Expand Down
60 changes: 60 additions & 0 deletions src/CryptoNoteCore/Currency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,52 @@ bool Currency::constructMinerTx(uint32_t height, size_t medianSize, uint64_t alr
return true;
}

bool Currency::isFusionTransaction(const Transaction& transaction, uint64_t inputAmount, size_t size) const {
assert(getInputAmount(transaction) == inputAmount);
assert(getObjectBinarySize(transaction) == size);

if (size > fusionTxMaxSize()) {
return false;
}

if (transaction.inputs.size() < fusionTxMinInputCount()) {
return false;
}

if (transaction.inputs.size() < transaction.outputs.size() * fusionTxMinInOutCountRatio()) {
return false;
}

std::vector<uint64_t> expectedOutputsAmounts;
expectedOutputsAmounts.reserve(transaction.outputs.size());
decomposeAmount(inputAmount, defaultDustThreshold(), expectedOutputsAmounts);
assert(!expectedOutputsAmounts.empty());

if (expectedOutputsAmounts.size() != transaction.outputs.size()) {
return false;
}

std::sort(expectedOutputsAmounts.begin(), expectedOutputsAmounts.end());

if (expectedOutputsAmounts.front() <= defaultDustThreshold()) {
return false;
}

auto it1 = expectedOutputsAmounts.begin();
auto it2 = transaction.outputs.begin();
for (; it1 != expectedOutputsAmounts.end(); ++it1, ++it2) {
if (*it1 != it2->amount) {
return false;
}
}

return true;
}

bool Currency::isFusionTransaction(const Transaction& transaction) const {
return isFusionTransaction(transaction, getInputAmount(transaction), getObjectBinarySize(transaction));
}

std::string Currency::accountAddressAsString(const AccountBase& account) const {
return getAccountAddressAsStr(m_publicAddressBase58Prefix, account.getAccountKeys().address);
}
Expand Down Expand Up @@ -240,6 +286,16 @@ std::string Currency::formatAmount(uint64_t amount) const {
return s;
}

std::string Currency::formatAmount(int64_t amount) const {
std::string s = formatAmount(static_cast<uint64_t>(std::abs(amount)));

if (amount < 0) {
s.insert(0, "-");
}

return s;
}

bool Currency::parseAmount(const std::string& str, uint64_t& amount) const {
std::string strAmount = str;
boost::algorithm::trim(strAmount);
Expand Down Expand Up @@ -422,6 +478,10 @@ CurrencyBuilder::CurrencyBuilder(Logging::ILogger& log) : m_currency(log) {
mempoolTxFromAltBlockLiveTime(parameters::CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME);
numberOfPeriodsToForgetTxDeletedFromPool(parameters::CRYPTONOTE_NUMBER_OF_PERIODS_TO_FORGET_TX_DELETED_FROM_POOL);

fusionTxMaxSize(parameters::FUSION_TX_MAX_SIZE);
fusionTxMinInputCount(parameters::FUSION_TX_MIN_INPUT_COUNT);
fusionTxMinInOutCountRatio(parameters::FUSION_TX_MIN_IN_OUT_COUNT_RATIO);

upgradeHeight(parameters::UPGRADE_HEIGHT);
upgradeVotingThreshold(parameters::UPGRADE_VOTING_THRESHOLD);
upgradeVotingWindow(parameters::UPGRADE_VOTING_WINDOW);
Expand Down
16 changes: 16 additions & 0 deletions src/CryptoNoteCore/Currency.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class Currency {
uint64_t mempoolTxFromAltBlockLiveTime() const { return m_mempoolTxFromAltBlockLiveTime; }
uint64_t numberOfPeriodsToForgetTxDeletedFromPool() const { return m_numberOfPeriodsToForgetTxDeletedFromPool; }

size_t fusionTxMaxSize() const { return m_fusionTxMaxSize; }
size_t fusionTxMinInputCount() const { return m_fusionTxMinInputCount; }
size_t fusionTxMinInOutCountRatio() const { return m_fusionTxMinInOutCountRatio; }

uint64_t upgradeHeight() const { return m_upgradeHeight; }
unsigned int upgradeVotingThreshold() const { return m_upgradeVotingThreshold; }
size_t upgradeVotingWindow() const { return m_upgradeVotingWindow; }
Expand Down Expand Up @@ -99,11 +103,15 @@ class Currency {
uint64_t fee, const AccountPublicAddress& minerAddress, Transaction& tx,
const BinaryArray& extraNonce = BinaryArray(), size_t maxOuts = 1, bool penalizeFee = false) const;

bool isFusionTransaction(const Transaction& transaction) const;
bool isFusionTransaction(const Transaction& transaction, uint64_t inputAmount, size_t size) const;

std::string accountAddressAsString(const AccountBase& account) const;
std::string accountAddressAsString(const AccountPublicAddress& accountPublicAddress) const;
bool parseAccountAddressString(const std::string& str, AccountPublicAddress& addr) const;

std::string formatAmount(uint64_t amount) const;
std::string formatAmount(int64_t amount) const;
bool parseAmount(const std::string& str, uint64_t& amount) const;

difficulty_type nextDifficulty(std::vector<uint64_t> timestamps, std::vector<difficulty_type> cumulativeDifficulties) const;
Expand Down Expand Up @@ -159,6 +167,10 @@ class Currency {
uint64_t m_mempoolTxFromAltBlockLiveTime;
uint64_t m_numberOfPeriodsToForgetTxDeletedFromPool;

size_t m_fusionTxMaxSize;
size_t m_fusionTxMinInputCount;
size_t m_fusionTxMinInOutCountRatio;

uint64_t m_upgradeHeight;
unsigned int m_upgradeVotingThreshold;
size_t m_upgradeVotingWindow;
Expand Down Expand Up @@ -228,6 +240,10 @@ class CurrencyBuilder : boost::noncopyable {
CurrencyBuilder& mempoolTxFromAltBlockLiveTime(uint64_t val) { m_currency.m_mempoolTxFromAltBlockLiveTime = val; return *this; }
CurrencyBuilder& numberOfPeriodsToForgetTxDeletedFromPool(uint64_t val) { m_currency.m_numberOfPeriodsToForgetTxDeletedFromPool = val; return *this; }

CurrencyBuilder& fusionTxMaxSize(size_t val) { m_currency.m_fusionTxMaxSize = val; return *this; }
CurrencyBuilder& fusionTxMinInputCount(size_t val) { m_currency.m_fusionTxMinInputCount = val; return *this; }
CurrencyBuilder& fusionTxMinInOutCountRatio(size_t val) { m_currency.m_fusionTxMinInOutCountRatio = val; return *this; }

CurrencyBuilder& upgradeHeight(uint64_t val) { m_currency.m_upgradeHeight = val; return *this; }
CurrencyBuilder& upgradeVotingThreshold(unsigned int val);
CurrencyBuilder& upgradeVotingWindow(size_t val) { m_currency.m_upgradeVotingWindow = val; return *this; }
Expand Down
27 changes: 19 additions & 8 deletions src/CryptoNoteCore/TransactionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ namespace CryptoNote {
m_fee_index(boost::get<1>(m_transactions)),
logger(log, "txpool") {
}

//---------------------------------------------------------------------------------
bool tx_memory_pool::add_tx(const Transaction &tx, /*const Crypto::Hash& tx_prefix_hash,*/ const Crypto::Hash &id, size_t blobSize, tx_verification_context& tvc, bool keptByBlock) {
if (!check_inputs_types_supported(tx)) {
Expand All @@ -134,7 +133,8 @@ namespace CryptoNote {
}

const uint64_t fee = inputs_amount - outputs_amount;
if (!keptByBlock && fee < m_currency.minimumFee()) {
bool isFusionTransaction = fee == 0 && m_currency.isFusionTransaction(tx, inputs_amount, blobSize);
if (!keptByBlock && !isFusionTransaction && fee < m_currency.minimumFee()) {
logger(INFO) << "transaction fee is not enough: " << m_currency.formatAmount(fee) <<
", minimum fee: " << m_currency.formatAmount(m_currency.minimumFee());
tvc.m_verifivation_failed = true;
Expand Down Expand Up @@ -212,10 +212,7 @@ namespace CryptoNote {
}

tvc.m_added_to_pool = true;

if (inputsValid && fee > 0)
tvc.m_should_be_relayed = true;

tvc.m_should_be_relayed = inputsValid && (fee > 0 || isFusionTransaction);
tvc.m_verifivation_failed = true;

if (!addTransactionInputs(id, tx, keptByBlock))
Expand Down Expand Up @@ -360,10 +357,24 @@ namespace CryptoNote {

BlockTemplate blockTemplate;

for (auto it = m_fee_index.rbegin(); it != m_fee_index.rend() && it->fee == 0; ++it) {
const auto& txd = *it;

if (m_currency.fusionTxMaxSize() < total_size + txd.blobSize) {
continue;
}

TransactionCheckInfo checkInfo(txd);
if (is_transaction_ready_to_go(txd.tx, checkInfo) && blockTemplate.addTransaction(txd.id, txd.tx)) {
total_size += txd.blobSize;
}
}

for (auto i = m_fee_index.begin(); i != m_fee_index.end(); ++i) {
const auto& txd = *i;

if (max_total_size < total_size + txd.blobSize) {
size_t blockSizeLimit = (txd.fee == 0) ? median_size : max_total_size;
if (blockSizeLimit < total_size + txd.blobSize) {
continue;
}

Expand All @@ -374,7 +385,7 @@ namespace CryptoNote {
m_fee_index.modify(i, [&checkInfo](TransactionCheckInfo& item) {
item = checkInfo;
});

if (ready && blockTemplate.addTransaction(txd.id, txd.tx)) {
total_size += txd.blobSize;
fee += txd.fee;
Expand Down
6 changes: 4 additions & 2 deletions src/PaymentGate/WalletService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ std::error_code WalletService::getTransactionByTransferId(size_t transferId, siz
return std::make_error_code(std::errc::argument_out_of_domain);
}

auto nextTxId = std::lower_bound(transfersIndices.begin(), transfersIndices.end(), transferId);
auto nextTxId = std::upper_bound(transfersIndices.begin(), transfersIndices.end(), transferId);
transactionId = (nextTxId - transfersIndices.begin()) - 1;

return std::error_code();
Expand All @@ -454,13 +454,15 @@ std::error_code WalletService::getTransaction(size_t txId, bool& found, Transact
logger(Logging::DEBUGGING) << "getTransaction request came";

found = false;

try {
auto tx = wallet->getTransaction(txId);
if (txId + 1 >= transfersIndices.size()) {
logger(Logging::WARNING) << "Unable to get transaction " << txId << ": argument out of domain.";
return std::make_error_code(std::errc::argument_out_of_domain);
}

auto tx = wallet->getTransaction(txId);

fillTransactionRpcInfo(txId, tx, rpcInfo);

found = true;
Expand Down
Empty file modified src/Platform/Windows/System/ErrorMessage.cpp
100644 → 100755
Empty file.
Loading

0 comments on commit deda499

Please sign in to comment.