diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-12 18:45:07 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:30:26 +0100 |
commit | c3b3260ae5b5acde445fa88a6f0909f582903754 (patch) | |
tree | 7b8b6977d84045568980b8d01169281c4a79c073 /tests | |
parent | rct: log why verification fails (diff) | |
download | monero-c3b3260ae5b5acde445fa88a6f0909f582903754.tar.xz |
New "Halfway RingCT" outputs for coinbase transactions
When RingCT is enabled, outputs from coinbase transactions
are created as a single output, and stored as RingCT output,
with a fake mask. Their amount is not hidden on the blockchain
itself, but they are then able to be used as fake inputs in
a RingCT ring. Since the output amounts are hidden, their
"dustiness" is not an obstacle anymore to mixing, and this
makes the coinbase transactions a lot smaller, as well as
helping the TXO set to grow more slowly.
Also add a new "Null" type of rct signature, which decreases
the size required when no signatures are to be stored, as
in a coinbase tx.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_tests/block_validation.cpp | 2 | ||||
-rw-r--r-- | tests/core_tests/chaingen.cpp | 1 | ||||
-rw-r--r-- | tests/core_tests/double_spend.inl | 1 | ||||
-rw-r--r-- | tests/core_tests/integer_overflow.cpp | 1 | ||||
-rw-r--r-- | tests/core_tests/rct.cpp | 28 | ||||
-rw-r--r-- | tests/core_tests/rct.h | 2 | ||||
-rw-r--r-- | tests/core_tests/transaction_tests.cpp | 1 | ||||
-rw-r--r-- | tests/core_tests/v2_tests.cpp | 1 | ||||
-rw-r--r-- | tests/functional_tests/transactions_generation_from_blockchain.cpp | 1 | ||||
-rw-r--r-- | tests/performance_tests/multi_tx_test_base.h | 1 |
10 files changed, 28 insertions, 11 deletions
diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp index 3989a71c9..df8972556 100644 --- a/tests/core_tests/block_validation.cpp +++ b/tests/core_tests/block_validation.cpp @@ -337,6 +337,7 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events se.amount = blk_0.miner_tx.vout[0].amount; se.push_output(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(blk_0.miner_tx); se.real_output_in_tx_index = 0; std::vector<tx_source_entry> sources; @@ -379,6 +380,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry> se.amount = blk_1.miner_tx.vout[0].amount; se.push_output(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(blk_1.miner_tx); se.real_output_in_tx_index = 0; std::vector<tx_source_entry> sources; diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index b7a1c3dec..4cb70e745 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -458,6 +458,7 @@ bool fill_tx_sources(std::vector<tx_source_entry>& sources, const std::vector<te continue; ts.real_output = realOutput; + ts.rct = false; sources.push_back(ts); diff --git a/tests/core_tests/double_spend.inl b/tests/core_tests/double_spend.inl index e9ec1c2cd..f97d48851 100644 --- a/tests/core_tests/double_spend.inl +++ b/tests/core_tests/double_spend.inl @@ -130,6 +130,7 @@ bool gen_double_spend_in_tx<txs_keeped_by_block>::generate(std::vector<test_even se.amount = tx_0.vout[0].amount; se.push_output(0, boost::get<cryptonote::txout_to_key>(tx_0.vout[0].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(tx_0); se.real_output_in_tx_index = 0; sources.push_back(se); diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp index aad377d6d..936f29675 100644 --- a/tests/core_tests/integer_overflow.cpp +++ b/tests/core_tests/integer_overflow.cpp @@ -63,6 +63,7 @@ namespace se.amount = tx.vout[out_idx].amount; se.push_output(0, boost::get<cryptonote::txout_to_key>(tx.vout[out_idx].target).key, se.amount); se.real_output = 0; + se.rct = false; se.real_out_tx_key = get_tx_pub_key_from_extra(tx); se.real_output_in_tx_index = out_idx; diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp index b358ce8b2..c29854888 100644 --- a/tests/core_tests/rct.cpp +++ b/tests/core_tests/rct.cpp @@ -57,8 +57,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev miner_accounts[n].generate(); CHECK_AND_ASSERT_MES(generator.construct_block_manually(blocks[n], *prev_block, miner_accounts[n], test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 4, 4, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 4), + 2, 2, prev_block->timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 2), false, "Failed to generate block"); events.push_back(blocks[n]); prev_block = blocks + n; @@ -74,8 +74,8 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, - 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 4), + 2, 2, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long + crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 2), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; @@ -104,6 +104,7 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev src.real_output = n; src.real_output_in_tx_index = index_in_tx; src.mask = rct::identity(); + src.rct = false; //fill outputs entry tx_destination_entry td; @@ -135,9 +136,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev } CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes[n], blk_last, miner_account, - test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version, + test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_tx_hashes | test_generator::bf_hf_version | test_generator::bf_max_outs, 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 0, 4), + crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, 4), false, "Failed to generate block"); events.push_back(blk_txes[n]); blk_last = blk_txes[n]; @@ -149,9 +150,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev { cryptonote::block blk; CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk, blk_last, miner_account, - test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version, + test_generator::bf_major_ver | test_generator::bf_minor_ver | test_generator::bf_timestamp | test_generator::bf_hf_version | test_generator::bf_max_outs, 4, 4, blk_last.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN * 2, // v2 has blocks twice as long - crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 4), + crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 6, 4), false, "Failed to generate block"); events.push_back(blk); blk_last = blk; @@ -161,7 +162,9 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev // create a tx from the requested ouputs std::vector<tx_source_entry> sources; - size_t rct_idx = 0, pre_rct_idx = 0; + size_t global_rct_idx = 6; // skip first coinbase (6 outputs) + size_t rct_idx = 0; + size_t pre_rct_idx = 0; for (size_t out_idx_idx = 0; out_idx[out_idx_idx] >= 0; ++out_idx_idx) { sources.resize(sources.size()+1); tx_source_entry& src = sources.back(); @@ -173,12 +176,16 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev src.real_out_tx_key = get_tx_pub_key_from_extra(rct_txes[rct_idx/4]); src.real_output_in_tx_index = rct_idx&3; src.mask = rct_tx_masks[rct_idx]; + src.rct = true; for (int m = 0; m <= mixin; ++m) { rct::ctkey ctkey; ctkey.dest = rct::pk2rct(boost::get<txout_to_key>(rct_txes[rct_idx/4].vout[rct_idx&3].target).key); ctkey.mask = rct_txes[rct_idx/4].rct_signatures.outPk[rct_idx&3].mask; - src.outputs.push_back(std::make_pair(rct_idx, ctkey)); + src.outputs.push_back(std::make_pair(global_rct_idx, ctkey)); ++rct_idx; + ++global_rct_idx; + if (global_rct_idx % 10 == 0) + global_rct_idx += 6; // skip the coinbase } } else @@ -188,6 +195,7 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[pre_rct_idx].miner_tx); src.real_output_in_tx_index = 4; src.mask = rct::identity(); + src.rct = false; for (int m = 0; m <= mixin; ++m) { src.push_output(m, boost::get<txout_to_key>(blocks[pre_rct_idx].miner_tx.vout[4].target).key, src.amount); ++pre_rct_idx; diff --git a/tests/core_tests/rct.h b/tests/core_tests/rct.h index bf0dc61f5..e01815d26 100644 --- a/tests/core_tests/rct.h +++ b/tests/core_tests/rct.h @@ -81,7 +81,7 @@ private: template<> struct get_test_options<gen_rct_tx_validation_base> { - const std::pair<uint8_t, uint64_t> hard_forks[2] = {std::make_pair(1, 0), std::make_pair(4, 1)}; + const std::pair<uint8_t, uint64_t> hard_forks[3] = {std::make_pair(1, 0), std::make_pair(2, 1), std::make_pair(4, 65)}; const cryptonote::test_options test_options = { hard_forks }; diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 8a1638c1d..cb585b975 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -97,6 +97,7 @@ bool test_transaction_generation_and_ring_signature() src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(tx_mine_2); src.real_output = 1; + src.rct = false; src.real_output_in_tx_index = 0; } //fill outputs entry diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp index d9328d13a..93ddd8a12 100644 --- a/tests/core_tests/v2_tests.cpp +++ b/tests/core_tests/v2_tests.cpp @@ -96,6 +96,7 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve } src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[0].miner_tx); src.real_output = 0; + src.rct = false; src.real_output_in_tx_index = out_idx[out_idx_idx]; } diff --git a/tests/functional_tests/transactions_generation_from_blockchain.cpp b/tests/functional_tests/transactions_generation_from_blockchain.cpp index 9dbcbbc10..63ff0343b 100644 --- a/tests/functional_tests/transactions_generation_from_blockchain.cpp +++ b/tests/functional_tests/transactions_generation_from_blockchain.cpp @@ -113,6 +113,7 @@ bool make_tx(blockchain_storage& bch) src.real_out_tx_key = td.m_tx.tx_pub_key; src.real_output = interted_it - src.outputs.begin(); src.real_output_in_tx_index = td.m_internal_output_index; + src.rct = false; ++i; } diff --git a/tests/performance_tests/multi_tx_test_base.h b/tests/performance_tests/multi_tx_test_base.h index 0883d674c..d8898b60d 100644 --- a/tests/performance_tests/multi_tx_test_base.h +++ b/tests/performance_tests/multi_tx_test_base.h @@ -72,6 +72,7 @@ public: source_entry.real_output_in_tx_index = 0; source_entry.outputs.swap(output_entries); source_entry.real_output = real_source_idx; + source_entry.rct = false; m_sources.push_back(source_entry); |