mirror of
https://github.com/monero-project/monero.git
synced 2025-05-15 02:12:17 -04:00
v8: per byte fee, pad bulletproofs, fixed 11 ring size
This commit is contained in:
parent
869b3bf824
commit
5ffb2ff9b7
55 changed files with 1241 additions and 878 deletions
|
@ -67,7 +67,7 @@ namespace cryptonote {
|
|||
/* Cryptonote helper functions */
|
||||
/************************************************************************/
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
size_t get_min_block_size(uint8_t version)
|
||||
size_t get_min_block_weight(uint8_t version)
|
||||
{
|
||||
if (version < 2)
|
||||
return CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1;
|
||||
|
@ -86,7 +86,7 @@ namespace cryptonote {
|
|||
return CRYPTONOTE_MAX_TX_SIZE;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {
|
||||
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {
|
||||
static_assert(DIFFICULTY_TARGET_V2%60==0&&DIFFICULTY_TARGET_V1%60==0,"difficulty targets must be a multiple of 60");
|
||||
const int target = version < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET_V2;
|
||||
const int target_minutes = target / 60;
|
||||
|
@ -98,37 +98,37 @@ namespace cryptonote {
|
|||
base_reward = FINAL_SUBSIDY_PER_MINUTE*target_minutes;
|
||||
}
|
||||
|
||||
uint64_t full_reward_zone = get_min_block_size(version);
|
||||
uint64_t full_reward_zone = get_min_block_weight(version);
|
||||
|
||||
//make it soft
|
||||
if (median_size < full_reward_zone) {
|
||||
median_size = full_reward_zone;
|
||||
if (median_weight < full_reward_zone) {
|
||||
median_weight = full_reward_zone;
|
||||
}
|
||||
|
||||
if (current_block_size <= median_size) {
|
||||
if (current_block_weight <= median_weight) {
|
||||
reward = base_reward;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(current_block_size > 2 * median_size) {
|
||||
MERROR("Block cumulative size is too big: " << current_block_size << ", expected less than " << 2 * median_size);
|
||||
if(current_block_weight > 2 * median_weight) {
|
||||
MERROR("Block cumulative weight is too big: " << current_block_weight << ", expected less than " << 2 * median_weight);
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(median_size < std::numeric_limits<uint32_t>::max());
|
||||
assert(current_block_size < std::numeric_limits<uint32_t>::max());
|
||||
assert(median_weight < std::numeric_limits<uint32_t>::max());
|
||||
assert(current_block_weight < std::numeric_limits<uint32_t>::max());
|
||||
|
||||
uint64_t product_hi;
|
||||
// BUGFIX: 32-bit saturation bug (e.g. ARM7), the result was being
|
||||
// treated as 32-bit by default.
|
||||
uint64_t multiplicand = 2 * median_size - current_block_size;
|
||||
multiplicand *= current_block_size;
|
||||
uint64_t multiplicand = 2 * median_weight - current_block_weight;
|
||||
multiplicand *= current_block_weight;
|
||||
uint64_t product_lo = mul128(base_reward, multiplicand, &product_hi);
|
||||
|
||||
uint64_t reward_hi;
|
||||
uint64_t reward_lo;
|
||||
div128_32(product_hi, product_lo, static_cast<uint32_t>(median_size), &reward_hi, &reward_lo);
|
||||
div128_32(reward_hi, reward_lo, static_cast<uint32_t>(median_size), &reward_hi, &reward_lo);
|
||||
div128_32(product_hi, product_lo, static_cast<uint32_t>(median_weight), &reward_hi, &reward_lo);
|
||||
div128_32(reward_hi, reward_lo, static_cast<uint32_t>(median_weight), &reward_hi, &reward_lo);
|
||||
assert(0 == reward_hi);
|
||||
assert(reward_lo < base_reward);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue