Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty #91

Closed
Mojo-LB opened this issue Mar 7, 2018 · 125 comments
Closed

Difficulty #91

Mojo-LB opened this issue Mar 7, 2018 · 125 comments

Comments

@Mojo-LB
Copy link

Mojo-LB commented Mar 7, 2018

Dear @mbg033 ,

Since you are very active today, care to comment on:
#78

For a completely different approach, please check:
zawy12/difficulty-algorithms#3

Thank you :)

@mbg033
Copy link
Contributor

mbg033 commented Mar 9, 2018

@Mojo-LB we did some tests with algorithm used in Masari, but currently this task was put on hold until it's confirmed as high prio task

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 9, 2018

@mbg033 An argument can be made that this currently is a high priority task, looking at several issues with current network, and the implications of leaving things as they are.

However, I understand this is not your decision, and I hope the management realizes that responding to market demands is good way to approach issues.

@bobbieltd
Copy link

I object difficulty algo changes.

  1. We still need to wait to see the effectiveness of new algo.
  2. Graft network is quite stable and soon big enough to avoid network fluctuation.
  3. We need to wait for opinions from other projects’ well known dev.

Nothing to be hurried.

@bobbieltd
Copy link

@Mojo-LB For info, if you use that difficulty algo, you must change Readme to put copyright notice to Massari project at Readme to avoid copyright issue. It’s really annoying when people go around to try to put their copyright at Readme of other projects.

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 10, 2018

@bobbieltd Please don't make any comments before checking the linked pull request.

@bobbieltd
Copy link

@Mojo-LB Sorry, I think you are promoting zawy12’s new difficulty algo. That requires to add copyright notice to Readme and difficulty.cpp for Masari Project. One person (I guess from Masari Project) have raised copyright issue with DeroProject and I feel really angried about that demand.
For Pull Request, I have nothing to comment. Sorry again, I misunderstanded you.

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 10, 2018

@bobbieltd

  1. Check = check, not advertising, just what I thought is good.
  2. I seen you going around spamming any post related to algos, especially zawy12. Triggered much?
  3. Again, did you check the linked pull request before posting, again?

@bobbieltd
Copy link

@Mojo-LB

  1. Check = Check. Let be it.
  2. I feel it’s wrong so if I see it is promoted any where. I’ll give a warning. Warning = warning, not spamming, it’s what I thought. It’s same as your way of thinking. If they didn’t raise their copyright demand, I wouldn’t need to be angried with them. I posted only two new issues at two repos where there is post about this new algo. The other two, it’s my replies like this post.
  3. Before posting this, I saw your posts relating to new difficulty algo and I didn’t check your pull requests. At this point, I agree that I’m wrong. I’m not hard coders and I don’t understand much blockchain. However, I still can give out my opinion.

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 10, 2018 via email

@bobbieltd
Copy link

I think I’m very wrong in my over-reactions. I need to double check all infos.
For you PR, of course, I saw it and it’s unrelated.

@bobbieltd
Copy link

@Mojo-LB I think I was confused between two people which are unrelated 😂. Oufff.

@zawy12
Copy link

zawy12 commented Mar 21, 2018

There are now 5 Monero clones using my LWMA algorithm. These charts show how much the coins have improved at stopping "hash attacks" and post-attack delays. Miners with 25x the baseline hash rate can jump on without causing hardly any harm. On the LWMA page you can see links to their code.

@zawy12
Copy link

zawy12 commented Mar 26, 2018

The suggestion @Mojo-LB has made in his pull request to simply reduce the window from 720 to 60 is a good one. If Monero/Cryptonote/Forknote coins had used this, they would have never been desperate to find a new algorithm, and so no one would have heard of my algorithms. But the LWMA algorithm is a lot better.

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 26, 2018

@zawy12 Thank you for your endorsement. I realize that my pull request would be better if done as a planned fork rather than change instantly, however I made it just to show how easy it is to make things better.

Graft Team announced they are working on it along with the monero7 asic-resistance move, but haven't announced/merged anything yet to indicate if they're simply adjusting the window or using your LWMA algo. https://www.graft.network/2018/03/22/brief-update-status-asic-resistance-difficulty-algorithm/

My personal preference is your LWMA algorithm. It has been proven repeatedly to be the best out there, and I've seen its effect on the stability of Masari network, and several others.

@zawy12
Copy link

zawy12 commented Mar 26, 2018

I've been talking to ultranote, and it seems they have 2 hour delays on occasion with N=35. So maybe it is important to go to LWMA

@Mojo-LB
Copy link
Author

Mojo-LB commented Mar 26, 2018

It is.

Although adjusting difficulty window makes it much less profitable for anyone to perform a "high hashrate attack", it doesn't allow the network to efficiently recover following such incident. That is a big part where your algo really shines.

Devs already have access to this information for some time, and are aware of the conditions that have been affecting mining since day 1 (difficulty and hash pumps) and day 30 (botnet).

I think the real issue here is not HOW, but IF and WHEN.

@zawy12
Copy link

zawy12 commented Mar 26, 2018

@bobbieltd No one has to use the Masari version of the algorithm pseudocode. My copyright notice is not important as long as it remains open source as the M.I.T license requires. But I like people to know where the algorithm comes from so that they can check for updated versions. Same thing in regards to including a reference to Masari. There are important reasons for people to know where the code originally comes from that is not related to boosting the dev's reputation or whatever. They may want to be able to do searches that can reveal if someone else (not necessarily Masari) made an improvement or found a security hole.

@zawy12
Copy link

zawy12 commented Apr 12, 2018

I hear graft lost 340 blocks in the past hour. Similar things were happening to the 25 coins that have switched to my LWMA difficulty algorithm in the last 2 or 3 months. Coins that have switched or are in process of switching:

karbo
stellite
masari
alloy
iridium
bitsum?
qwerty?
brazuk?
ultranote
BTC Gold
BTC Candy
IPBC
turtle
haven
myztic
wownero
niobio
bbscoin
redwind?
balkan?
bulwark?
NYCoin
intense
vertical?
forknote is going to get it so this stops happening to it's offspring.

@Mojo-LB
Copy link
Author

Mojo-LB commented Apr 12, 2018

@zawy12, Graft haven't haven't moved to LWMA yet. Fork is planned on block 67850 as of now (might be sooner). Changes are implemented in #100

Edit: Just adjusted to block number 65110 expected Saturday April 14th. #106

@zawy12
Copy link

zawy12 commented Apr 15, 2018

This shows graft has been a very typical cryptonote coin, suffering from the slow difficulty at the beginning, then seeming to be OK for a while, and then slowly advancing to the point of "blowing up" from the oscillations. They are switching just in time, although I can see the past week (last plot) was not good.

image

@zawy12
Copy link

zawy12 commented Apr 20, 2018

This is the chart of what happened immediately after I posted the warning above. Graft "blew up" like the others I've been following. This is from being too slow to respond in the presence of big miners having the option to come and go. Maybe ASICs no longer having Monero are the overwhelming cause of this.
I've tried to warn Monero about this aspect of their incredibly slow algorithm, but they have no interest. I guess they'll be alright as long as they are one of the top two coins for their POW. But there are other reasons to have it faster, and no benefit to having it so slow.

image

At the worst of it (second-to-last magenta peaks) the on-off mining like this got 500 blocks in 8.3 minutes. This was followed by a 6 hour block, 20 hours to get 10 confirmations. They then switched to LWMA and everything looks fine. I included per-LWMA data from above because I needed to change the scales.

image

@plavirudar
Copy link

plavirudar commented Apr 20, 2018

@zawy12 There are significant benefits to having a slower DAA if your coin is not at risk of 51% attacks. For one, the XMR difficulty is remarkably stable, which means that miners get highly consistent payouts, as well as providing them no incentive to switch between multiple coins following profits. Compare that with LWMA, which has up to 50% difficulty fluctuations due to the Poisson distribution of blocks, and their rationale should become clearer. The same also applies for BTC vs BCH, where BTC has a 2-week DAA, and suffers no ill effects due to its majority hashrate position, as opposed to BCH, which had to switch its DAA.

If no miner can achieve 51% attack hashrates, they can't perform timewarp attacks or "block-stealing" attacks effectively, and therefore the benefit of having a stable difficulty outweighs the benefit of preventing these attacks.

@zawy12
Copy link

zawy12 commented Apr 20, 2018

Timestamp manipulation: let a miner with 2% of the network hashrate send a timestamp 7000 seconds into the future once every 2 hours to see the effect. I've told miners to stay on graft because they'll get 7 days worth of blocks in 3 hours if and when the timestamp manipulator drops by this coin like he has on 4 others the past 2 months. Terminology: time warp attack as it was originally a problem in BTC and described is not possible on coins with rolling averages.

Stable difficulty = unstable network. There is no problem from difficulty jumping all around if it that's the result of it accurately tracking network hashrate. It also achieves more consistent solvetimes. See the blow up above which is the result of trying to achieve a stable difficulty. The goal is not stable difficulty, but to match difficulty to the current hashrate. A 24 hour avg like monero is matching difficulty to the hash rate as it was 12 hours in the past (24 hr average). Miners do not want constant difficulty. They want a fair difficulty. Constant difficulty = unfair mining conditions. A difficulty that matches hashrate = a consistently fair difficulty. Talk to miners on the 10 coins using LWMA. They do not about it rising 3x in 30 minutes in response to a 10x hash attack , or about it dropping 80% in 30 minutes after the attackers leave. They love it. They are the small miners who spread the word about a coin and hold the coins, rather than a big miner looking to sell right away. They do not have a problem with it changing all the time +/- 15% as it tries to find the correct value.

@zawy12
Copy link

zawy12 commented Apr 20, 2018

I forgot that they have a limit (10xT) inside the difficulty algorithm also. That means it takes a 15% (or maybe 30% miner with the LWMA) to consistently lower it until the 7200 second limit is reached. I could run the test to know how low they can get it but I think someone is going to start doing it before I get a chance to run the test. ( He has to have > 1/10 Network hashpwer to consistently make it go lower until the 7200 limit is reached whereas with the 1/7 he needs more than 13% to do it)

@jagerman
Copy link
Contributor

I've told miners to stay on graft because they'll get 7 days worth of blocks in 3 hours if and when the timestamp manipulator drops by this coin like he has on 4 others the past 2 months.

I could run the test to know how low they can get it but I think someone is going to start doing it before I get a chance to run the test.

Indeed you appear to be several hours too late already: this has been happening to graft since last night, with the +2h forged timestamps hitting approximately every 3 hours. The most recent is four blocks in 66220-66228; another couple at 66197 and 66204; another five forged timestamps between 66145-66154; 1 at 66109; another at 65940; two more at 65910-65911.

@imperdin
Copy link

I still firmly believe the the correct approach to solve the "Hash attacks" and the threat of 51% attacks is to slightly tweak the PoW to limit the means of acquiring massive amount of hash power

@plavirudar
Copy link

plavirudar commented Apr 20, 2018

@zawy12 You're right about timewarp attacks being nomenclaturally unsound since they can also be used to refer to an older, different attack. Let's stick to using the term "forged timestamps" instead when talking about the issue currently occurring to low hashrate CN coins.

You're also right in that miners want a fair difficulty, and when difficulty is divorced from true hashrate, there is a problem.

The issue with using fast DAAs is that any sampling of a Poisson process with small N will result in fluctuations, and the only way to correct for this is to increase N. In fact, one can model this deviation. For a given coin taking N blocks into account, Poisson statistics will mean that the actual standard deviation time of these N blocks will be $sqrt(N)$, or roughly 24% from the normal after 17 blocks, or 10% from the normal after 100 blocks in the absence of true hashrate fluctuations. Approximately 31% of blocktimes will fall outside of this range, and approximately 5% of blocktimes will be outside double this range (hence my initial 50% fluctuations claim).

By setting N too small in the absence of external hash attacks, you end up creating deviations from the true hashrate, instead of protecting the network from deviations.

@Mojo-LB
Copy link
Author

Mojo-LB commented Apr 20, 2018

@jagerman Those are either a wrongly configured node hosts, or a probe. We have no way to identify that at this point.

@zawy12
Copy link

zawy12 commented Apr 20, 2018

@jagerman In short, the single bad timestamps are not much of a problem due to the 10xT that is in the code. If it was not there, it would be a big problem like I said 2 posts above. The attack has not yet hit. Long story The single +2 hour timestamps are limited to dropping the difficulty in Graft to about (60-10)/60 = 0.83 of the previous difficulty because there is a 10xT limit in the code rather than the FTL=7200 limit. A 20% miner can drop it to about 50% of the correct difficulty in about 50 blocks, but then the 7200 limit starts blocking him, so he has to go away for up to 2 hours before he can repeat the manipulation. But once he erodes difficulty by "only" 25%, 3x more hash power will switch to the coin, and he'll no longer be able to get the blocks he was hoping for, and he won't be able to manipulate it any further because he'll be below the 10% network hash power required to take advantage of the 10xT limits. A > 50% miner can make the difficulty reduce by (N-7200/T)/N max which is D=0 in this case of N=60 and T=120. He can get about 30 blocks at I think 25% of the original difficulty. He also will have to stop periodically to let chain time go back to being close to normal once his blocks start getting near the 7200. You have to go through the simple but confusing recursive math involved here to confirm my numbers and equation. My experiments indicated these approximate results for all DAs.

@imperdin Hash attacks by ASICs and NiceHase are not a problem for LWMA when it's implemented with the tighter 500 second limit. >51% hash rate is only a danger to other aspects of a coin.

@plavirudar I've written many times about the 1/SQRT(N) effect, although in a Poisson process like this, the variation is a little bit more. I am the source of SMAs with N=17 that Karbo and Sumo loved for curing their cryptonote hash attack problems and spread to many coins. It was only about 9 months ago I finally looked at the results when trying to help with BCH's new DA and realized it was a bad idea. It wasn't near as good as Digishield which is like N = 4x17 = 68. The >24% variation from N=17 was very harmful to sumo and karbo although they did not seem to realize it. It was the source of constant on-off mining. 3x changes in hashrate 20 times a day was almost typical. But they never locked up either. They just knew they were not being sent off to the Cryptonote slow difficulty graveyard like many others....who either died out or copied them.

Karbowanc shows the improvement when switching from SMA N=17 to LWMA N=60. BTW the bad spot in the graph below is what I think will happen to Graft pretty soon. Karbowanec had the 7200 and was sorting timestamps which is effectively the same as Graft's current liability.

image

LWMA N=60 has a speed of response like SMA N=45. So, you are suggesting I might be still pushing for an N that is too low. I have data to argue against this. HUSH uses Zcash's digishield (N like 68). There are many coins with LWMA N=60ish and they all are performing very well and look like the end of the karbo plot above. Most are smaller than hush so you'd expect hush to be more stable. But here's what Hush's results look like, from choosing an SMA equivlaent N=68, more than 50% slower than LWMA N=60. You can see it's not nearly as well. Like karbo, these are very recent blocks.

image

For comparison, here's Masari's (Masari is 1/7 the price of HUSH with fewer total coins)

image

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"they accidentally reverted to a previous algorithm"

no with full intent. You spoke to them even once?

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

" They switched POW during this time, but you can't even tell when"

I can. IPBCs problems ended the second the PoW was switched. Same for Haven. There has been ZERO problems with those coins who left the monero PoW.

@Serena-DeroProject
Copy link

Serena-DeroProject commented Apr 22, 2018

@jagerman

The references to Dero have been removed. With respect, I didn't come here to publicly discuss difficulty algorithms. I came to ask that references to Dero please be removed, and they have been.

Dero makes no claim to the LWMA algorithm.

@zawy12
Copy link

zawy12 commented Apr 22, 2018

@sebseb7 I chat with IPBC's F.Hearns. I didn't keep my word to review his paper this past week. He said they thought an unsigned integer times a signed one was causing a problem, so they switched back from a tweaked LWMA to the previous LWMA. He didn't go into any details. What problems were they having? I don't see a problem in the difficulties or solvetimes. I sent him a DM to try to find out the details.

@zawy12
Copy link

zawy12 commented Apr 22, 2018

@Mojo-LB Graft did the FTL and MTP adjustments like I was wanting, so you can close this issue.

@Mojo-LB
Copy link
Author

Mojo-LB commented Apr 22, 2018

Thank you @zawy12 for all the help you provided and all the time you spent.

Thank you to all the contributors who helped :)

@Mojo-LB Mojo-LB closed this as completed Apr 22, 2018
@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"What problems were they having?"

the new implementation caused the deamon to not find any blocks because of a possible overun so that part of the fork was cancelled.

The plan was to fork to a new PoW and a new LWMA implementation. Only the PoW fork happened and it was successful. No more hashrate fluctuations at all.

@zawy12
Copy link

zawy12 commented Apr 22, 2018

OK, I see the difficulty drop at the end was from implementation of the POW. But the hashrate fluctuations were not causing any problem. The blue peaks did not happen very often, and they are not tall. That means they did not have any delays. The perfect average solvetime shows things were functioning fine.

I'll work on finding out what happened. Havendev is looking into it because your PM got him worried. (they copied his code)

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"But the hashrate fluctuations were not causing any problem."

Not at IPBC thats true. IPBC will work with ANY diff algo...

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

" Havendev is looking into it because your PM got him worried. "

The problem at IPBC should worry him. He said "I also spoke to the algo creator Zawy who double reassured there was no issue."

You double reassured when "I'll work on finding out what happened."

WIP in production how I like that.

@zawy12
Copy link

zawy12 commented Apr 22, 2018

Why do you view hash rate fluctuations as a problem if the solvetimes are OK and the big miners were unable to get cheap blocks?

@zawy12
Copy link

zawy12 commented Apr 22, 2018

IPBC problem: Since other coins are not having a problem with it, and it worked fine in their testing, and since no pool switched to the new difficulty at the fork, and no block was found, I think it's speculative to believe the fork was done correctly and to assume there was something wrong with the algorithm.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"Why do you view hash rate fluctuations as a problem if the solvetimes are OK and the big miners were unable to get cheap blocks?"

never said hashrate fluctuations are a problem.

big miners don't need cheap blocks, they are more effective so then can work with way lower margins.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"since no pool switched to the new difficulty at the fork, and no block was found"

  • daemon and pool software was updated at the pools.
  • No block was found because of daemon bug.
  • LWMA update removed -> all fine

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

" I think it's speculative to believe the fork was done correctly and to assume there was something wrong with the algorithm."

Why is it speculative? You can get the code from github and replay the chain.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

" and to assume there was something wrong with the algorithm"

I assume you have never seen that before:

2018-Apr-16 11:16:51.701863 ERROR difficulty overhead.
2018-Apr-16 11:16:51.701927 ERROR Failed to create block template

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

graft right now also fails to accept valid shares:

2018-04-22 13:56:25.414    [RPC0]  ERROR   cn      src/cryptonote_core/cryptonote_core.cpp:1045    mined block failed verification

@zawy12
Copy link

zawy12 commented Apr 22, 2018

You implied hash rate fluctuations are bad with

Only the PoW fork happened and it was successful. No more hashrate fluctuations at all.

So, then.....why are you saying POW change was needed by IPBC? What are you saying is improved by changing POW if a coin already has LWMA?

daemon and pool software was updated at the pools.

Why do you say that when all the miners were saying no pool would update to the newer LWMA? It just sounded like the fork was not done correctly.

Why is it speculative? You can get the code from github and replay the chain.

That doesn't determine if the fork method or newer LWMA was the problem. Obviously the newer LWMA was fine because testnet was fine. Obviously the fork was bad because ... well it never forked to run the algorithm like testnet did.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"You implied hash rate fluctuations are bad with"
"So, then.....why are you saying POW change was needed by IPBC"

I said the PoW change made the hashrate stable. Not stated my opinion wether this is good or bad.

"Why do you say that when all the miners were saying no pool would update to the newer LWMA?"

maybe you should ask the pools not the miners. They miners can't know the daemon version the pool is running.

" Obviously the newer LWMA was fine because testnet was fine."

when you use a testnet with higher difficutly the testnet fails also.

" Obviously the fork was bad because ... well it never forked to run the algorithm like testnet did."

obviously you are assuming all of this. I have seen logfiles from the two biggest pools, have you?

@zawy12
Copy link

zawy12 commented Apr 22, 2018

I said the PoW change made the hashrate stable. Not stated my opinion wether this is good or bad.

Again, why did you come here saying a POW change was needed if unstable hashrate is neither good or bad?

when you use a testnet with higher difficutly the testnet fails also.

How are you going to force testnet to a higher difficulty when it's using the correct algorithm?

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"Again, why did you come here saying a POW change was needed if unstable hashrate is neither good or bad?"

those people who want to stabilize graft nethash should consider a PoW change. I don't care wether hashrate is stable or not.

"How are you going to force testnet to a higher difficulty when it's using the correct algorithm?"

you can manupilate the speed of the clock for example... do I really need to explain this?

@zawy12
Copy link

zawy12 commented Apr 22, 2018

Your presumption is that LWMA gave an unjustifiably (wrong) high difficulty due to a code error, and you're going to accelerate the testnet clock in order to give a correct high difficulty? What does that achieve? You claim to have data to prove what you're saying. What were the timestamps sent to the LWMA algorithm to make it throw an unusually high difficulty? What was the value of that high difficulty? What difficulty did the pools think was the correct one, and based on what timestamps? We need some sort of data to back up your speculations.

@plavirudar
Copy link

plavirudar commented Apr 22, 2018

big miners don't need cheap blocks

Big miners need cheap blocks as much as (or more so than) the average miner, since they're doing it for profit instead of doing it for a hobby.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"Your presumption is that LWMA gave an unjustifiably (wrong) high difficulty due to a code error"

no I said the IPBC daemon failed at fork time, then LWMA was removed. Thats all I said. Also I don't need to prove it because everyone interested can look for themself. The code is available, the blockchain also.

" We need some sort of data to back up your speculations."

You said you love Puzzles. Let's have some fun... you don't even have an idea of the size of the puzzle as of now.

@zawy12
Copy link

zawy12 commented Apr 22, 2018

no I said the IPBC daemon failed at fork time

It seems you've reversed course away from promoting a POW change as a cure-all, and now it seems you're reluctant to directly point the finger at the newer LWMA code as the cause of IPBC's unique fork problem.

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

I don't know what went wrong at IPBC and why problems gone now, you can research for yourself. But fact is, graft may never reach fork height, because it is broken:

image

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

😆

solvetime is infinite now...

image

@sebseb7
Copy link

sebseb7 commented Apr 22, 2018

"It seems you've reversed course away from promoting a POW change as a cure-all"

I still promote it as a "cure" to the current situation. If you consider the current situation acceptable, then no cure is needed.

@zawy12
Copy link

zawy12 commented Apr 24, 2018

I post this to wrong issue.

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

No branches or pull requests

10 participants