Skip to content

Commit deda499

Browse files
author
Antonio Juarez
committed
Bytecoin v.1.0.7 release
1 parent 49572fc commit deda499

30 files changed

+779
-165
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set(CMAKE_SKIP_INSTALL_RULES ON)
99
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
1010
set(CMAKE_SUPPRESS_REGENERATION ON)
1111
enable_testing()
12+
# copy CTestCustom.cmake to build dir to disable long running tests in 'make test'
13+
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
1214

1315
project(Bytecoin)
1416

CTestCustom.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(CTEST_CUSTOM_TESTS_IGNORE
2+
CoreTests
3+
IntegrationTestLibrary
4+
TestGenerator
5+
CryptoTests
6+
IntegrationTests
7+
NodeRpcProxyTests
8+
PerformanceTests
9+
TransfersTests
10+
)
11+

ReleaseNotes.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Release notes 1.0.7
2+
3+
- Fusion transactions support
4+
- Various simplewallet improvements
5+
16
Release notes 1.0.6
27

38
- High-level API update

src/CryptoNoteConfig.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const uint64_t CRYPTONOTE_MEMPOOL_TX_LIVETIME = 60 * 60 * 24;
6262
const uint64_t CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME = 60 * 60 * 24 * 7; //seconds, one week
6363
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
6464

65+
const size_t FUSION_TX_MAX_SIZE = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE * 30 / 100;
66+
const size_t FUSION_TX_MIN_INPUT_COUNT = 6;
67+
const size_t FUSION_TX_MIN_IN_OUT_COUNT_RATIO = 3;
68+
6569
const uint64_t UPGRADE_HEIGHT = 546602;
6670
const unsigned UPGRADE_VOTING_THRESHOLD = 90; // percent
6771
const size_t UPGRADE_VOTING_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY; // blocks
@@ -156,7 +160,8 @@ const CheckpointData CHECKPOINTS[] = {
156160
{785500, "de1a487d70964d25ed6f7de196866f357a293e867ee81313e7fd0352d0126bdd"},
157161
{789000, "acef490bbccce3b7b7ae8554a414f55413fbf4ca1472c6359b126a4439bd9f01"},
158162
{796000, "04e387a00d35db21d4d93d04040b31f22573972a7e61d72cc07d0ab69bcb9c44"},
159-
{800000, "d7fa4eea02e5ce60b949136569c0ea7ac71ea46e0065311054072ac415560b86"}
163+
{800000, "d7fa4eea02e5ce60b949136569c0ea7ac71ea46e0065311054072ac415560b86"},
164+
{804000, "bcc8b3782499aae508c40d5587d1cc5d68281435ea9bfc6804a262047f7b934d"}
160165
};
161166
} // CryptoNote
162167

src/CryptoNoteCore/CryptoNoteBasic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
namespace CryptoNote {
2424
const Crypto::Hash NULL_HASH = boost::value_initialized<Crypto::Hash>();
2525
const Crypto::PublicKey NULL_PUBLIC_KEY = boost::value_initialized<Crypto::PublicKey>();
26+
const Crypto::SecretKey NULL_SECRET_KEY = boost::value_initialized<Crypto::SecretKey>();
2627

2728
KeyPair generateKeyPair();
2829

src/CryptoNoteCore/Currency.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,52 @@ bool Currency::constructMinerTx(uint32_t height, size_t medianSize, uint64_t alr
209209
return true;
210210
}
211211

212+
bool Currency::isFusionTransaction(const Transaction& transaction, uint64_t inputAmount, size_t size) const {
213+
assert(getInputAmount(transaction) == inputAmount);
214+
assert(getObjectBinarySize(transaction) == size);
215+
216+
if (size > fusionTxMaxSize()) {
217+
return false;
218+
}
219+
220+
if (transaction.inputs.size() < fusionTxMinInputCount()) {
221+
return false;
222+
}
223+
224+
if (transaction.inputs.size() < transaction.outputs.size() * fusionTxMinInOutCountRatio()) {
225+
return false;
226+
}
227+
228+
std::vector<uint64_t> expectedOutputsAmounts;
229+
expectedOutputsAmounts.reserve(transaction.outputs.size());
230+
decomposeAmount(inputAmount, defaultDustThreshold(), expectedOutputsAmounts);
231+
assert(!expectedOutputsAmounts.empty());
232+
233+
if (expectedOutputsAmounts.size() != transaction.outputs.size()) {
234+
return false;
235+
}
236+
237+
std::sort(expectedOutputsAmounts.begin(), expectedOutputsAmounts.end());
238+
239+
if (expectedOutputsAmounts.front() <= defaultDustThreshold()) {
240+
return false;
241+
}
242+
243+
auto it1 = expectedOutputsAmounts.begin();
244+
auto it2 = transaction.outputs.begin();
245+
for (; it1 != expectedOutputsAmounts.end(); ++it1, ++it2) {
246+
if (*it1 != it2->amount) {
247+
return false;
248+
}
249+
}
250+
251+
return true;
252+
}
253+
254+
bool Currency::isFusionTransaction(const Transaction& transaction) const {
255+
return isFusionTransaction(transaction, getInputAmount(transaction), getObjectBinarySize(transaction));
256+
}
257+
212258
std::string Currency::accountAddressAsString(const AccountBase& account) const {
213259
return getAccountAddressAsStr(m_publicAddressBase58Prefix, account.getAccountKeys().address);
214260
}
@@ -240,6 +286,16 @@ std::string Currency::formatAmount(uint64_t amount) const {
240286
return s;
241287
}
242288

289+
std::string Currency::formatAmount(int64_t amount) const {
290+
std::string s = formatAmount(static_cast<uint64_t>(std::abs(amount)));
291+
292+
if (amount < 0) {
293+
s.insert(0, "-");
294+
}
295+
296+
return s;
297+
}
298+
243299
bool Currency::parseAmount(const std::string& str, uint64_t& amount) const {
244300
std::string strAmount = str;
245301
boost::algorithm::trim(strAmount);
@@ -422,6 +478,10 @@ CurrencyBuilder::CurrencyBuilder(Logging::ILogger& log) : m_currency(log) {
422478
mempoolTxFromAltBlockLiveTime(parameters::CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME);
423479
numberOfPeriodsToForgetTxDeletedFromPool(parameters::CRYPTONOTE_NUMBER_OF_PERIODS_TO_FORGET_TX_DELETED_FROM_POOL);
424480

481+
fusionTxMaxSize(parameters::FUSION_TX_MAX_SIZE);
482+
fusionTxMinInputCount(parameters::FUSION_TX_MIN_INPUT_COUNT);
483+
fusionTxMinInOutCountRatio(parameters::FUSION_TX_MIN_IN_OUT_COUNT_RATIO);
484+
425485
upgradeHeight(parameters::UPGRADE_HEIGHT);
426486
upgradeVotingThreshold(parameters::UPGRADE_VOTING_THRESHOLD);
427487
upgradeVotingWindow(parameters::UPGRADE_VOTING_WINDOW);

src/CryptoNoteCore/Currency.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class Currency {
7272
uint64_t mempoolTxFromAltBlockLiveTime() const { return m_mempoolTxFromAltBlockLiveTime; }
7373
uint64_t numberOfPeriodsToForgetTxDeletedFromPool() const { return m_numberOfPeriodsToForgetTxDeletedFromPool; }
7474

75+
size_t fusionTxMaxSize() const { return m_fusionTxMaxSize; }
76+
size_t fusionTxMinInputCount() const { return m_fusionTxMinInputCount; }
77+
size_t fusionTxMinInOutCountRatio() const { return m_fusionTxMinInOutCountRatio; }
78+
7579
uint64_t upgradeHeight() const { return m_upgradeHeight; }
7680
unsigned int upgradeVotingThreshold() const { return m_upgradeVotingThreshold; }
7781
size_t upgradeVotingWindow() const { return m_upgradeVotingWindow; }
@@ -99,11 +103,15 @@ class Currency {
99103
uint64_t fee, const AccountPublicAddress& minerAddress, Transaction& tx,
100104
const BinaryArray& extraNonce = BinaryArray(), size_t maxOuts = 1, bool penalizeFee = false) const;
101105

106+
bool isFusionTransaction(const Transaction& transaction) const;
107+
bool isFusionTransaction(const Transaction& transaction, uint64_t inputAmount, size_t size) const;
108+
102109
std::string accountAddressAsString(const AccountBase& account) const;
103110
std::string accountAddressAsString(const AccountPublicAddress& accountPublicAddress) const;
104111
bool parseAccountAddressString(const std::string& str, AccountPublicAddress& addr) const;
105112

106113
std::string formatAmount(uint64_t amount) const;
114+
std::string formatAmount(int64_t amount) const;
107115
bool parseAmount(const std::string& str, uint64_t& amount) const;
108116

109117
difficulty_type nextDifficulty(std::vector<uint64_t> timestamps, std::vector<difficulty_type> cumulativeDifficulties) const;
@@ -159,6 +167,10 @@ class Currency {
159167
uint64_t m_mempoolTxFromAltBlockLiveTime;
160168
uint64_t m_numberOfPeriodsToForgetTxDeletedFromPool;
161169

170+
size_t m_fusionTxMaxSize;
171+
size_t m_fusionTxMinInputCount;
172+
size_t m_fusionTxMinInOutCountRatio;
173+
162174
uint64_t m_upgradeHeight;
163175
unsigned int m_upgradeVotingThreshold;
164176
size_t m_upgradeVotingWindow;
@@ -228,6 +240,10 @@ class CurrencyBuilder : boost::noncopyable {
228240
CurrencyBuilder& mempoolTxFromAltBlockLiveTime(uint64_t val) { m_currency.m_mempoolTxFromAltBlockLiveTime = val; return *this; }
229241
CurrencyBuilder& numberOfPeriodsToForgetTxDeletedFromPool(uint64_t val) { m_currency.m_numberOfPeriodsToForgetTxDeletedFromPool = val; return *this; }
230242

243+
CurrencyBuilder& fusionTxMaxSize(size_t val) { m_currency.m_fusionTxMaxSize = val; return *this; }
244+
CurrencyBuilder& fusionTxMinInputCount(size_t val) { m_currency.m_fusionTxMinInputCount = val; return *this; }
245+
CurrencyBuilder& fusionTxMinInOutCountRatio(size_t val) { m_currency.m_fusionTxMinInOutCountRatio = val; return *this; }
246+
231247
CurrencyBuilder& upgradeHeight(uint64_t val) { m_currency.m_upgradeHeight = val; return *this; }
232248
CurrencyBuilder& upgradeVotingThreshold(unsigned int val);
233249
CurrencyBuilder& upgradeVotingWindow(size_t val) { m_currency.m_upgradeVotingWindow = val; return *this; }

src/CryptoNoteCore/TransactionPool.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ namespace CryptoNote {
110110
m_fee_index(boost::get<1>(m_transactions)),
111111
logger(log, "txpool") {
112112
}
113-
114113
//---------------------------------------------------------------------------------
115114
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) {
116115
if (!check_inputs_types_supported(tx)) {
@@ -134,7 +133,8 @@ namespace CryptoNote {
134133
}
135134

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

214214
tvc.m_added_to_pool = true;
215-
216-
if (inputsValid && fee > 0)
217-
tvc.m_should_be_relayed = true;
218-
215+
tvc.m_should_be_relayed = inputsValid && (fee > 0 || isFusionTransaction);
219216
tvc.m_verifivation_failed = true;
220217

221218
if (!addTransactionInputs(id, tx, keptByBlock))
@@ -360,10 +357,24 @@ namespace CryptoNote {
360357

361358
BlockTemplate blockTemplate;
362359

360+
for (auto it = m_fee_index.rbegin(); it != m_fee_index.rend() && it->fee == 0; ++it) {
361+
const auto& txd = *it;
362+
363+
if (m_currency.fusionTxMaxSize() < total_size + txd.blobSize) {
364+
continue;
365+
}
366+
367+
TransactionCheckInfo checkInfo(txd);
368+
if (is_transaction_ready_to_go(txd.tx, checkInfo) && blockTemplate.addTransaction(txd.id, txd.tx)) {
369+
total_size += txd.blobSize;
370+
}
371+
}
372+
363373
for (auto i = m_fee_index.begin(); i != m_fee_index.end(); ++i) {
364374
const auto& txd = *i;
365375

366-
if (max_total_size < total_size + txd.blobSize) {
376+
size_t blockSizeLimit = (txd.fee == 0) ? median_size : max_total_size;
377+
if (blockSizeLimit < total_size + txd.blobSize) {
367378
continue;
368379
}
369380

@@ -374,7 +385,7 @@ namespace CryptoNote {
374385
m_fee_index.modify(i, [&checkInfo](TransactionCheckInfo& item) {
375386
item = checkInfo;
376387
});
377-
388+
378389
if (ready && blockTemplate.addTransaction(txd.id, txd.tx)) {
379390
total_size += txd.blobSize;
380391
fee += txd.fee;

src/PaymentGate/WalletService.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ std::error_code WalletService::getTransactionByTransferId(size_t transferId, siz
428428
return std::make_error_code(std::errc::argument_out_of_domain);
429429
}
430430

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

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

456456
found = false;
457+
457458
try {
458-
auto tx = wallet->getTransaction(txId);
459459
if (txId + 1 >= transfersIndices.size()) {
460460
logger(Logging::WARNING) << "Unable to get transaction " << txId << ": argument out of domain.";
461461
return std::make_error_code(std::errc::argument_out_of_domain);
462462
}
463463

464+
auto tx = wallet->getTransaction(txId);
465+
464466
fillTransactionRpcInfo(txId, tx, rpcInfo);
465467

466468
found = true;

src/Platform/Windows/System/ErrorMessage.cpp

100644100755
File mode changed.

0 commit comments

Comments
 (0)