aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 22:07:58 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 22:07:58 +0000
commit81cb0fcdccf08afd6f37d21ccfefb31131fd3950 (patch)
tree8e706285c9ab229c428a1ef231898026aab23743 /src/cryptonote_core/blockchain.cpp
parentblockchain: add missing m_tx_pool.on_blockchain_dec (diff)
downloadmonero-81cb0fcdccf08afd6f37d21ccfefb31131fd3950.tar.xz
blockchain: fix bitflipping test with quantized block rewards
Block reward may now be less than the full amount allowed. This was breaking the bitflipping test. We now keep track of whether a block which was accepted by the core has a lower than allowed block reward, and allow this in the test.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 6bdbdf4cd..a178d1203 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -941,13 +941,14 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height)
}
//------------------------------------------------------------------
// This function validates the miner transaction reward
-bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins)
+bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, bool &partial_block_reward)
{
LOG_PRINT_L3("Blockchain::" << __func__);
//validate reward
uint64_t money_in_use = 0;
BOOST_FOREACH(auto& o, b.miner_tx.vout)
money_in_use += o.amount;
+ partial_block_reward = false;
std::vector<size_t> last_blocks_sizes;
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
@@ -977,6 +978,8 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
// emission. This modifies the emission curve very slightly.
CHECK_AND_ASSERT_MES(money_in_use - fee <= base_reward, false, "base reward calculation bug");
base_reward = money_in_use - fee;
+ if(base_reward + fee != money_in_use)
+ partial_block_reward = true;
}
return true;
}