Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce block reward for hf18 #372

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/cryptonote_basic/cryptonote_basic_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ namespace cryptonote {
{
return CRYPTONOTE_MAX_TX_SIZE;
}

uint64_t get_adjusted_block_reward(uint64_t reward_in, uint8_t hf_version)
{
uint64_t reward = reward_in;
if (hf_version >= 10) {
// halving reward since version 10
reward /= 2;
if (hf_version >= 18)
// quartering reward since version 18
reward /= 4;
}
return reward;
}
//-----------------------------------------------------------------------------------------------
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");
Expand Down Expand Up @@ -113,11 +126,7 @@ namespace cryptonote {
}

if (current_block_weight <= median_weight) {
reward = base_reward;
if (version >= 10) {
// halving reward since version 10
reward /= 2;
}
reward = get_adjusted_block_reward(base_reward, version);
return true;
}

Expand All @@ -142,12 +151,7 @@ namespace cryptonote {
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);

reward = reward_lo;
if (version >= 10) {
// halving reward since version 10
reward /= 2;
}
reward = get_adjusted_block_reward(reward_lo, version);
return true;
}
//------------------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ static const struct {
// hf 16 increase stake period to 32 days, 2019-08-12@15:00:00+00
{ 16, 412780, 0, 1565622000 },
// hf 17 RandomX PoW, 2021-08-18T@12:00:00+00
{ 17, 936150, 0, 1629288000 }
{ 17, 936150, 0, 1629288000 },
// hf 18 reduce block reward, 2021-09-21@12:00:00+00
{ 18, 960490, 0, 1632225600 }
};
// static const uint64_t mainnet_hard_fork_version_1_till = 1009826;
static const uint64_t mainnet_hard_fork_version_1_till = 1;
Expand Down Expand Up @@ -176,7 +178,9 @@ static const struct {
// hf 16 increase stake period to 32 days, 2019-08-05T@09:00:00+00
{ 16, 381520, 0, 1564995600 },
// hf 17 RandomX PoW, 2021-07-29T@08:30:00+00
{ 17, 421865, 0, 1627547400 }
{ 17, 421865, 0, 1627547400 },
// hf 18 quartered block reward, 2021-09-17@12:00:00+00
{ 18, 457790, 0, 1631880000 }
};

// static const uint64_t testnet_hard_fork_version_1_till = 624633;
Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define DEF_GRAFT_VERSION_TAG "@VERSIONTAG@"
#define DEF_GRAFT_VERSION "1.10.0"
#define DEF_GRAFT_VERSION "1.10.1"
#define DEF_GRAFT_RELEASE_NAME "Vela Pulsar"
#define DEF_GRAFT_VERSION_FULL DEF_GRAFT_VERSION "-" DEF_GRAFT_VERSION_TAG

Expand Down