opened
XrayHunter
username_0
**LWMA** or Linearly Weighted Moving Average is difficulty algorithm made from [Zawy](https://github.com/zawy12/difficulty-algorithms/issues/3) and Thaer (Lead developer for Masari). This is a decent algorithm with a respectable response time when facing a hashrate drop. Lets take a look at real use of [LWMA](https://github.com/zawy12/difficulty-algorithms/issues/24) (Latest version V3).
So take a look at an example

- Let’s assume we got 3 fast blocks, we create a jump that increases difficulty by 10%. Then next block is harder to find. This means if an attacker is present, he will still find blocks fast but natural luck will decrease. This is how the network can easily differentiate between luck and an attacker.
- So next step we have 4 fast blocks found. Then the chain increases difficulty by 20%.
- The process continues like this until the latest 7 blocks were all fast solved. At the end, the chain will increase difficulty with a factor of 2 on the network. This is the reason why we can sometimes see such huge spikes on the network.

You may argue that with a lot of luck the last 7 blocks maybe found fast, but as we explained before this doesn’t happen as difficulty gets progressively larger than the previous block until this tip block. In this way even if there is some “natural luck/spikes”, the network is really stable.

Moreover to protect the network from at most the factor 2 spike, if the tip block found is not a fast one, all the jump rules are broken helping the network recover very quickly.

Few months ago LWMA difficulty algorithm saved [BSHA3](https://github.com/bsha3-community)
The original bsha3 chain was using the 2016 difficulty block adjustment and chain stucked. They fork off at block 20418 with the new LWMA 3 difficulty algorithm. They reset current difficulty and implemented LWMA V3.

I think implemanting LWMA to cruz is nice and secure solution of the current situation. There is another option to simple decrease difficulty block retarget #56. This option is vulnerable since very large spike in hashrate can slow-down or stuck chain.
LWMA difficulty algorithm
issue