Skip to content

Conversation

@NyanCatTW1
Copy link
Contributor

@NyanCatTW1 NyanCatTW1 commented Jul 1, 2025

Facts of the hard fork:

  • Start date: 2025-04-01
  • Deadline: 2026-04-01
  • Threshold: 95% miner agreement over the time window of 672 blocks (same as deadpool hardfork)
  • Activation: When >= 95% of blocks in epoch X support the hardfork, hard diff removal becomes active while determining the difficulty for epoch X+2. There is an epoch where hard diff is still possible (epoch X+1), because it's BIP9's LOCKED_IN retarget period

Concept of the new difficulty adjustment algorithm:

  • If block time is too short, increase diff by 1 until we reach an even diff (in do {} while (); manner)
  • If block time it too long, decrease diff by 1 until we reach an even diff (in do {} while (); manner)
  • If block time is just right and we're at an even diff: Don't change diff
  • If block time is just right but we're at an odd diff: Decrease diff by 1. (Why decrease and not increase: My rationale is that the difficulty is currently too high anyways)

What's considered too short/long are identical to the original algorithm (<27 mins is too short, >31 mins is too long)

Introduce more aggressive difficulty adjustment when block time deviates far away (>2x) from 30 minutes:

  • If block time is way too short (<15 mins), increase diff by 4 or 3, instead of only by 2 or 1
  • If block time is way too long (>60 mins), decrease diff by 4 or 3, instead of only by 2 or 1

Whether it's even or odd depends on whether the original difficulty were even or odd

@NyanCatTW1 NyanCatTW1 marked this pull request as draft July 1, 2025 08:46
…en the block time outside of 15 ~ 60 minutes range
@NyanCatTW1 NyanCatTW1 marked this pull request as ready for review July 1, 2025 09:31
@NyanCatTW1 NyanCatTW1 marked this pull request as draft July 1, 2025 13:07
@NyanCatTW1 NyanCatTW1 marked this pull request as ready for review July 4, 2025 13:46
Copy link
Contributor

@ReverseControl ReverseControl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CalculateDifficultyDelta(): Most of those if statements got to go. We will use bit-operators and ternary operators. Almost every if statement in there is unnecessary.

Copy link
Contributor

@ReverseControl ReverseControl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for now as this has been tested. The optimizations will come in later.

@ReverseControl ReverseControl merged commit 215360b into ProjectFactor:main Jul 10, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants