JayDDee / cpuminer-opt

Optimized multi algo CPU miner
Other
765 stars 543 forks source link

Add new Cosanta (cosa) algo #330

Closed YetAnotherRussian closed 2 years ago

YetAnotherRussian commented 2 years ago

Looks like an easy addition:

https://github.com/cosanta/cpuminer-multi/commits/linux

Pools for testing: https://miningpoolstats.stream/cosanta Test address may be used from that source code I think

That miner is slow as compared to srbminer-multi, but I'm unsure if it's an optimization side or just "show higher hashrate to justify own fee"

JayDDee commented 2 years ago

X17 + GOST + LYRA2 = X19. Yes it's an easy addition and would inherit all the optimizations from X17 and Lyra2. GOST is hopelessly slow. But it's boring to code, mostly just coy/paste.

I don't see much potential for the algo. Most new X algos never catch on or, if they do, get taken over by ASICs. That it was named after the coin and not the more generic X19 suggests it will oly ever support one coin for however long the coin survives.

Not likely, but never say never. I may get bored and do it.

Edit:

I noticed something weird in the cosanta code. The Lyra2 function takes 80 bytes input but the previous function produced a 64 byte hash. This requires zero padding of the GOST hash before Lyra2 hashes it. This is very unusual, no other algo uses odd sized intermediate hash, it's always 64 bytes for X algos. 80 bytes is only used for the iniitial block header data hashed by the first function in the chain.

I don't know if this was intentional but the code to workaround it looks rushed. Instead of one 64 byte hash buffer there are four 128 byte buffers. First it doesn't need to use multiple buffers, second the buffer only needs to be 80 bytes, and third there is no need to initialize everything 128 bytes * 4. Way too complicated than necessary to accomodate the 80 byte twist if it was part of the design. If so the wallet would need the same workaround to make it work.

Have you tried it? Does it actually work? Even if not intentional it may now be part of the spec. It wouldn't be the first time this kind of thing has happened.

YetAnotherRussian commented 2 years ago

Have you tried it? Does it actually work?

If u mean the wallet, then yes, it works (at least in all basic cases).

JayDDee commented 2 years ago

I meant does the miner work, meaning are the shares accepted? If they are then the wallet and miner have the same hashing code and the same flaw.

Using a input data size that doesn't match the size of the previous function's output is either bad design or a bug. It's made worse by the sloppy workaround to make the bad code work.

In my opinion the algo is broken and Cosanta is using a broken algo. I won't support that.

YetAnotherRussian commented 2 years ago

Yes, both of the existing miners do work

gades commented 2 years ago

@JayDDee you're right and it will be grateful if you can add COSA (x19) algo to your product without our workaround.

JayDDee commented 2 years ago

@gades What do you mean "our workaround". Who are you?

The workaround is needed because it's now part of the definition of Cosanta algorithm, even if it's not intentional. It's not a true "X19" because of this workaround. If one or more coins choose a correct X19, or if Cosa changes it's algo to a corrected version, I will consider adding it. But I won't add the existing cosanta algo.

I'm not recommending Cosa change the algo due to the disruption it causes. It works as it is and it may be better to just leave it alone.

gades commented 2 years ago

@JayDDee I did this algo in Cosanta wallet and noticed that was wrong when we started the network and start changes for separate miner. We will not change the hashing function because in the future we're going to use PoS and we will use a different function for PoS. At the moment we only have PoW, then we will make a hybrid PoW + PoS, and then only PoS.

p.s. It's not X19 and there is haval hash X17 + HAVAL + GOST + LYRA2 it can be called X20, but in order for other coins to use it, we still need to do a lot

JayDDee commented 2 years ago

Thanks for the explanation. As I've mentioned a few time in various places I don't want to add algos that are likely to go obsolete. In your case it's part of the plan.

The best I can offer is some assistance in porting the optimizations. You'll have to import a lot of code for AVX2 & AVX512 but you can use X17 as a guide for the first 17 functions then add GOST & Lyra2 with the workround. You can start with the one way code as it most resembles your code, then do 4 & 8 way.

I won't do the work for you but I can help if you get stuck.

gades commented 2 years ago

Thanks, you can close this request. Our plan is disable PoW in future when coins will be distributed between community and you are right - no sense to do part of work for algo which will be abandoned in the future.

JayDDee commented 2 years ago

Good luck with your project.