新闻与媒体
No items found.

Introduction

The Abelian blockchain has undergone a change in its difficulty adjustment scheme starting block 284000, and its effects on the block difficulty and average block time can be seen in the graphs below.

This writeup will briefly explain how the new adjustment mechanism (Difficulty Smoothing Adjustment) works, and follow it up with an example of calculating a slot’s new target and bits parameters.

Difficulty Smoothing Adjustment (DSA)

Work, Hash Rate, & Target

When mining a block, a miner would first compute the hash value of its header, and then check if it’s less than the block’s target.

Since the hash algorithm used is SHA-256, there are 2²⁵⁶ possible hash rate values, and the miner succeeds in mining a block for target possible values. This means the probability of successfully mining a block would be

and therefore the expected number of attempts until a miner succeeds would be

We define work (for a single block) to be this number of expected attempts, and we define the hash rate as the amount of work done per second.

Note: Instead of target, we only see the bits value in the Explorer’s API. For example, https://api.abelian.info/v1/block/284800 displays

The bits value represents the target value in compact form, which we can convert back to its full form like so:

DSA Summary

Note: A slot consists of 200 consecutive blocks. For example, 284800–284999 is a single slot.

The new Difficulty Smoothing Algorithm was launched at block 284000, replacing the original adjustment mechanism. It now recalculates the target for each slot, by first calculating a weighted average hash rate over the past 20 slots, then using the weighted hash rate to come up with a new targetso that the average time taken for a block to be mined would be 256 seconds, assuming the next slot’s hash rate matches the predicted weighted hash rate.

First, given a target and slot time (number of seconds between the mining time of the first and last block in the slot), we can calculate a slot’s hash rate like so:

Or equivalently,

Once we calculate the hash rate of the past 20 slots (hash rateᵢ₋₂₀, hash rateᵢ₋₁₉, . . . , hash rateᵢ₋₁), we then proceed with calculating the weighted average hash rate:

We then compare the ratio between avg hash rate and the most recent slot’s hash rate (hash rateᵢ₋₁). If the ratio is below 1/4 or above 4, we clamp it between these values.

Note: Assuming the hash rate of the next slot doesn’t change from the most recent slot, and if the newly-calculated difficulty would increase the average block time to over 4 · 256 = 1024 seconds, or decrease it to below 256/4 = 64 seconds, this would clamp the average block time between these values.

Finally, we ‘predict’ the next slot’s hash rate would be target hash rate, and we would calculate the new targetvalue accordingly. Given the relationship between hash rate and target:

We wish for the upcoming slot timeto be 199 · 256 seconds, therefore our new target would be:

And finally, we would convert our target into compact form as bits, and use bits’s value in all future calculations and comparisons.

Illustrative Example

We demonstrate DSA by calculating the target for the slot 284800–284999.

First, we retrieve the parameters of the previous 20 slots from the Explorer’s API, and use them to calculate each slot’s hash rate. For example, we see that slot 280800–280999 has the following parameters:

We convert bits into target:

And we calculate slot time:

Once we have targetand slot time, we calculate hash rate:

We repeat these steps for each of the past 20 slots:

Table 1: Hash rates of the past 20 slots

Once we have the past 20 slots’ hash rates, we calculate the weighted avg hash rate:

Table 2: Calculating the avg hash rate

We then compute theratio:

Since ratio = 4.16 > 4, we clamp target hash rate to 4 · hash rateᵢ₋₁) = 2662210207228.

Finally, we can use target hash rate to compute the new target:

Now that we have the target, we can find the bits value by repeatedly dividing the mantissa by 256 and incrementing the exponent by 1 starting from 3, until mantissa < 0x00800000.

Table 3: Mantissa & Bits

We find the bits value to be 1a69bad4, and we will use the bits’s corresponding targetvalue in future calculations:

Note — we can also find the difficulty value as shown in the Explorer’s API like so:

where M is the maximum possible difficulty (whose bits is 1d017c38).

For example, for slot 284800–284999,

Further reading

For more about the advantages of DSA, learn more about how the algorithm quickly adapts to hashrate fluctuations and stabilizes the average block time.
Advantages of Abelian’s Difficulty Smoothing Algorithm (DSA)

最新动态与媒体

探索阿贝尔链与区块链的一切

品牌动态

阿贝尔链: 迈向隐私和后量子技术未来的变革性一步

今天,阿贝尔链(Abelian)宣布了一个里程碑式的时刻,我们正式推出焕然一新的品牌和对未来充满活力的愿景。在这个技术快速发展且对隐私和安全的关注日益加剧的时代,阿贝尔链(Abelian) 正在为区块链技术树立一个新标准 — — 不仅适用于当下的安全需求,更为量子时代做好了充分的准备。

阅读更多
阿贝尔链: 迈向隐私和后量子技术未来的变革性一步
Read More
品牌动态

Abelian 2024 回顾:创新、增长与具影响力的一年

随着 2024 年接近尾声,Abelian 回顾了这一年为推进后量子时代的区块链安全与隐私所做的变革性努力。秉承我们的使命,Abelian 始终站在创新的最前沿,通过利用抗量子密码学和多层隐私保护技术,致力于为 Web3 的未来提供保障。

阅读更多
Abelian 2024 回顾:创新、增长与具影响力的一年
Read More

阿贝尔链打造后量子时代的未来

阿贝尔链是旨在抵御量子威胁的第一层区块链。美国国家标准与技术研究所 (NIST) 已批准多种基于格子密码算法,用于抗量子加密和数字签名。凭借抗量子密码学、多层隐私保护以及高度去中心化,阿贝尔链为您的区块链提供当前及未来的安全与隐私保障。

加入我们的团队

携手迎战量子威胁

阿贝尔链赋能下一代区块链,保护交易、资产与数据免受量子攻击。

立即体验阿贝尔链
No items found.