mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
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.
This commit is contained in:
parent
6f526cdff8
commit
c3b3260ae5
19 changed files with 120 additions and 36 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue