Features
Difficulty Adjustment

Introduction

The difficulty adjustment algorithm is a crucial component of any blockchain protocol that utilizes a Proof-Of-Work (PoW) consensus mechanism. Its primary function is to maintain the block generation time close to a predefined target as the network's hashing power fluctuates. This mechanism plays a vital role in ensuring that the creation rate of new coins remains relatively stable over time, thereby contributing to the network's security.

The cost of launching an attack on the network is directly proportional to the network's hashing power. Consequently, a network that harnesses substantial hashing power from numerous sources is inherently more secure.

Having an efficient difficulty adjustment algorithm is paramount for the security and stability of the network.

Difficulty Adjustment Algorithm

XELIS employs a streamlined version of the Kalman Filter (opens in a new tab) to accurately estimate the network's hash rate based on the incoming block frequency. This refined estimate is crucial for adjusting the difficulty target for each new block.

The advantage of using the Kalman filter lies in its ability to rapidly converge on the actual network hash rate while effectively filtering out misleading fluctuations caused by temporary hash rate spikes.

The algorithm adjusts the difficulty for every block, drawing on the heaviest block's tip as the basis for the parent difficulty. This selection hinges on the cumulative difficulty accrued in its DAG branch, informing the parent difficulty parameter for the algorithm.

To estimate the time taken to solve the block, the algorithm uses the timestamp from the tip of the youngest block available. The choice of the youngest block's tip is determined by the highest timestamp among all block tips, serving as the basis for the parent timestamp parameter in the algorithm.
This value is then subtracted from the current block's timestamp to estimate the solve time.