Merge pull request #5970

ab96181 blockchain: use effective median block weight for penalty from v12 (moneromooo-monero)
This commit is contained in:
luigi1111 2019-10-22 10:09:56 -05:00
commit 8bb3c6a8e6
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
2 changed files with 13 additions and 3 deletions

View File

@ -165,6 +165,7 @@
#define HF_VERSION_SAME_MIXIN 12 #define HF_VERSION_SAME_MIXIN 12
#define HF_VERSION_REJECT_SIGS_IN_COINBASE 12 #define HF_VERSION_REJECT_SIGS_IN_COINBASE 12
#define HF_VERSION_ENFORCE_MIN_AGE 12 #define HF_VERSION_ENFORCE_MIN_AGE 12
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY 12
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8

View File

@ -1176,9 +1176,18 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
} }
} }
uint64_t median_weight;
if (version >= HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY)
{
median_weight = m_current_block_cumul_weight_median;
}
else
{
std::vector<uint64_t> last_blocks_weights; std::vector<uint64_t> last_blocks_weights;
get_last_n_blocks_weights(last_blocks_weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW); get_last_n_blocks_weights(last_blocks_weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
if (!get_block_reward(epee::misc_utils::median(last_blocks_weights), cumulative_block_weight, already_generated_coins, base_reward, version)) median_weight = epee::misc_utils::median(last_blocks_weights);
}
if (!get_block_reward(median_weight, cumulative_block_weight, already_generated_coins, base_reward, version))
{ {
MERROR_VER("block weight " << cumulative_block_weight << " is bigger than allowed for this blockchain"); MERROR_VER("block weight " << cumulative_block_weight << " is bigger than allowed for this blockchain");
return false; return false;