mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 14:06:07 -04: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
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue