How to hard fork a altcoin?

2

I have created a altcoin using the reference of LTC and already 170k blocks were formed. Now i want to change the conformation time as well as i want the difficulty to start from base difficulty.Basically i want to Hard fork the coin, & for that i recompiled the the code with new parameters and started the daemon.

And now i dont think the approach i took is leading me to proper direction as:

1)I am not at all able to bring the difficulty down to base difficulty. (according my new code,difficulty shoud get adjusted after each block) &

2) some of the new node could not even get the copy of ledger even after they are connected to pre existing healthy nodes.

debug.log says:

2018-06-12 09:14:49   nActualTimespan = 0  before bounds  
2018-06-12 09:14:49 GetNextWorkRequired RETARGET  
2018-06-12 09:14:49 nTargetTimespan = 15    nActualTimespan = 3 
2018-06-12 09:14:49 Before: 1e0ffff0  00000ffff0000000000000000000000000000000000000000000000000000000  
2018-06-12 09:14:49 After:  1e033330  0000033330000000000000000000000000000000000000000000000000000000  
2018-06-12 09:14:49 ERROR: AcceptBlock() : incorrect proof of work  
2018-06-12 09:14:49 ERROR: ProcessBlock() : AcceptBlock FAILED    

Can someone tell me is there other way by which i can Hardfork a altcoin. Or can someone suggest me what my next step could be

cryptoKTM

Posted 2018-06-12T09:10:24.660

Reputation: 489

Question was closed 2018-06-13T00:03:09.573

If you recalculate the difficulty after each block, have you been able to solve a block at the previous difficulty? I would be surprised because the hash rate on LTC is so high.JBaczuk 2018-06-12T13:46:57.283

Actually it was not forked from LTC, the source code i used was that of LTC but blockchain was started from genesis block so starting difficulty was 0.00024414cryptoKTM 2018-06-12T14:06:26.160

I'm confused, why do you call it a hard fork?JBaczuk 2018-06-12T14:14:55.363

I am sorry that was my mistake to call this altcoin as fork of LTC. But what i want to implement after block no 170k in my altcoin is HardforkcryptoKTM 2018-06-12T14:24:05.743

Got, it thanks for the clarification. It appears the validity checks are still failing, can you check AcceptBlock() for where it is failing. Could be this, for example: bool fHasMoreOrSameWork = (chainActive.Tip() ? pindex->nChainWork >= chainActive.Tip()->nChainWork : true);JBaczuk 2018-06-12T14:40:01.867

Did you include any hard fork conditions (e.g. follow these new rules after block 170,000)? It seems to me that you have introduced new rules and are trying to validate old blocks under these new rules. However what you should be doing is instead validating old blocks under the old rules, and then after some condition is met (e.g. block height is >= 170,000) you start using the new rules to validate blocks.Andrew Chow 2018-06-12T18:48:16.793

No answers