Decrease sensitivity of retargeting algorithm#3194
Open
Decrease sensitivity of retargeting algorithm#3194
Conversation
ljedrz
reviewed
Mar 25, 2026
Comment on lines
-405
to
406
| N::ANCHOR_TIME, | ||
| N::ANCHOR_TIMES[0].1, | ||
| N::ANCHOR_HEIGHT, |
Collaborator
There was a problem hiding this comment.
shouldn't the N::ANCHOR_HEIGHT be hardcoded instead? the N::ANCHOR_TIME is used in coinbase_reward_v2
Collaborator
Author
There was a problem hiding this comment.
The intention was to keep the rewards/emissions the same and only update the retargeting algorithm.
I agree this is confusing.
N::ANCHOR_HEIGHT shouldn't need changing because it's only relevant in coinbase_reward_v1 which is after the new anchor_time kicks in.
ljedrz
reviewed
Mar 25, 2026
| next_timestamp, | ||
| N::GENESIS_TIMESTAMP, | ||
| N::STARTING_SUPPLY, | ||
| N::ANCHOR_TIME, |
ljedrz
requested changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The retargeting algorithm for
coinbase_targetis sensitive to block time changes. A 30% increase in block time caused the coinbase target to drop abruptly and cascade downward. This PR decreases the sensitivity of the algorithm by increasing the anchor time from 25 to 35 seconds atConsensusVersion::V14, which will:coinbase_targetto trend upward over time when block times are consistently below the anchor, as the larger anchor widens the gap between actual and expected block timeThe coinbase reward algorithm does not change and still uses the original anchor time, which is now defined as
REWARD_ANCHOR_TIME.Implementation
This PR replaces
N::ANCHOR_TIMEwithN::ANCHOR_TIMES, a versioned array following the same pattern asMAX_PROGRAM_SIZEandMAX_WRITES. The V15 entry sets the anchor time to 35 seconds (from 25 seconds), activating onConsensusVersion::V15.to_next_targetsnow accepts aConsensusVersionas its first parameter and looks up the active anchor time to use for retargeting.ANCHOR_HEIGHTis preserved as a hardcoded V1 literal since it is used exclusively bycoinbase_reward_v1, which occurs well beforeConsensusVersion::V15.Test Plan
Tests have been added to verify that the coinbase target retargeting direction and magnitude differ between V1 (25s) and V14 (35s) anchor times, that the halving point shifts proportionally, and that doubling takes more blocks under the larger anchor time.
Backwards compatibility
Existing behavior is unchanged before V15. The new anchor time is gated behind ConsensusVersion::V15.