Skip to content
Permalink
Browse files

blockchain: use effective median block weight for penalty from v12

It was using the raw block weight median, which was not what was
intended in ArticMine's design
  • Loading branch information...
moneromooo-monero committed Oct 9, 2019
1 parent bf52579 commit 2830e463e16d0c3b62782b6718518009055ddf8d
Showing with 13 additions and 3 deletions.
  1. +1 −0 src/cryptonote_config.h
  2. +12 −3 src/cryptonote_core/blockchain.cpp
@@ -165,6 +165,7 @@
#define HF_VERSION_SAME_MIXIN 12
#define HF_VERSION_REJECT_SIGS_IN_COINBASE 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

@@ -1176,9 +1176,18 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
}
}

std::vector<uint64_t> last_blocks_weights;
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))
uint64_t penalty_weight;
if (version >= HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY)
{
penalty_weight = m_current_block_cumul_weight_median;
}
else
{
std::vector<uint64_t> last_blocks_weights;
get_last_n_blocks_weights(last_blocks_weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
penalty_weight = epee::misc_utils::median(last_blocks_weights);
}
if (!get_block_reward(penalty_weight, cumulative_block_weight, already_generated_coins, base_reward, version))
{
MERROR_VER("block weight " << cumulative_block_weight << " is bigger than allowed for this blockchain");
return false;

0 comments on commit 2830e46

Please sign in to comment.
You can’t perform that action at this time.