Auroracoin Community Forum

The Auroracoin Project
It is currently Fri Aug 29, 2014 3:54 am

All times are UTC




Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Mon Feb 24, 2014 12:05 am 
Offline

Joined: Mon Feb 17, 2014 8:00 pm
Posts: 67
joiblumen wrote:
nite69 wrote:
Hi!

joiblumen wrote:
Hi nite96, I din't see this thread until now!

I also created a android wallet fork and converted it to aurora!
I would say it is nearing completion but there are some major issues with the network parameters that I cant seem to work out.

We should definitely join forces.

Here is are my repos: https://github.com/JoiBlumen/auroracoin-wallet-new , https://github.com/JoiBlumen/auroracoinj-new


We seem to have very similar problems :-\
And you are very ture, we should join our forces.
You seem to be forked from Dogecoin, I forked litecoin..
Here are the network parameters I have so far found out:
https://github.com/Nite69/bitcoinj-scry ... arams.java
(btw, maybe I should switch from branch 'messy' to master :-)


Yeah, I decided to fork the dogecoin solution as their main source code is/was actually a little closer to auroracoin than litecoin. As well as there seems to be more active development for the dogecoin android wallet than litecoin, they have multiple upstream updates and the wallet seems to work smooth.

I started with the (non wallet breaking) easy things e.g. replace text, class names and images with auroracoin. Booted the new fancy auroracoin looking wallet on my phone and everything worked. Except, of course, it connected to the dogecoin network, only now showing me how many AUR doges I had.

Now I could start working on the (wallet breaking) network parameters and spent a while figuring out the right ones for aurora; I read through the relevant bitcoinj code and tried to understand each and every function before setting auroracoin genesis block values.
I seem to have missed something as when I thought I had everything set for my genesis block "creation" it generated a wrong block! I spent a few hours trying multiple other values and workarounds, like manually inserting the merkle root, with no result.
Each time I made some change I stepped through the genesis creation phase in android debugging mode and it is obvious that the parameters are not right as the genesis block assertion kills the process every time.

I would recommend we switch to my repo, the code is very similar to bitcoinj and we can update upstream from the active doge development as well as bitcoinj. What do you say?


Finally got that genesis block right.. I think I should have all the network parameters now ok. Feel free to check the params.
However, it does not yet download the blockchain.
Maybe tomorrow..

_________________
AuroraCoin: AXVoGgYtSVkPv96JLL7CiwcyVvPxXHXRK9
Bitcoin: 17gNvfoD2FDqTfESUxNEmTukGbGVAiJhXp
Litecoin: LhbDew4s9wbV8xeNkrdFcLK5u78APSGLrR
Rent a VPS and keep auroraexplorer.atorox.net running: https://www.digitalocean.com/?refcode=c815fc73c453


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 12:16 am 
Offline

Joined: Mon Feb 17, 2014 8:00 pm
Posts: 67
joiblumen wrote:
I would recommend we switch to my repo, the code is very similar to bitcoinj and we can update upstream from the active doge development as well as bitcoinj. What do you say?


We must think about it. Let's keep them separate for a while and make the decision a bit later.

_________________
AuroraCoin: AXVoGgYtSVkPv96JLL7CiwcyVvPxXHXRK9
Bitcoin: 17gNvfoD2FDqTfESUxNEmTukGbGVAiJhXp
Litecoin: LhbDew4s9wbV8xeNkrdFcLK5u78APSGLrR
Rent a VPS and keep auroraexplorer.atorox.net running: https://www.digitalocean.com/?refcode=c815fc73c453


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 5:55 am 
Offline

Joined: Sat Feb 15, 2014 1:26 am
Posts: 43
Got the first 15 blocks from the blockchain to download on my phone, The 16th is getting a verification error. I think it is something related to the difficulty calculations.


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 10:52 am 
Offline

Joined: Tue Feb 18, 2014 10:26 am
Posts: 42
Thanks for letting us know about your progress!
You guys are doing a great service to Auroraoin


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 2:41 pm 
Offline

Joined: Sat Feb 15, 2014 1:26 am
Posts: 43
Ok, here are the exact errors from auroracoinj :

Code:
.
.
02:28:41 13 DownloadListener.startDownload: Downloading block chain of size 3121. This may take a while.
02:28:41 13 AbstractBlockChain.checkDifficultyTransitions: Difficulty hit proof of work limit: 17fffe800000000000000000000000000000000000000000000000000000
02:28:41 13 Peer.processHeaders: Block header verification failed
com.google.auroracoin.core.VerificationException: Could not verify block c05b64361afbf0abb2f2b6e99451c6fe5cfcddcf12fa6012f51e0203091aba10
v1 block:
   previous block: 4ed1684a7f76295245f1dec758514287ef5da1da62e3c73f4e002a5cfed1b66b
   merkle root: b4a6060086eddac2ffa640369a47baf38828dac5b14a11ffd3f7be1d5b57cbbb
   time: [1390928714] Tue Jan 28 17:05:14 GMT 2014
   difficulty target (nBits): 504365055
   nonce: 458760
.
.
Network provided difficulty bits do not match what was calculated: fffff000000000000000000000000000000000000000000000000000000 vs aaaaa000000000000000000000000000000000000000000000000000000


Does anyone see what could be going wrong here? Nite69? I have replaced the difficulty calculation with the one from main.cpp, that changed the calculated diff to aaaaa from another wrong calculated value. So the error seems to come from there..

If there is not a easy solution to this I think it is best to wait for the KGW implementation as that would replace the whole calculation algo making the fixes irrelevant.


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 3:14 pm 
Offline
Site Admin

Joined: Mon Feb 10, 2014 4:09 pm
Posts: 127
Auroracoinj would still have to validate blocks until the KGW implementation. So the calculations would have be accurate until block X when KGW is implemented.


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 3:27 pm 
Offline

Joined: Sat Feb 15, 2014 1:26 am
Posts: 43
Yeah that makes sense, I somehow had the delusion that we could start from the hardfork. Of course we can't, so this needs to get fixed. I hope Nite69 has some answers, I don't have enough time right now to look much deeper into this.


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 4:24 pm 
Offline

Joined: Mon Feb 17, 2014 8:00 pm
Posts: 67
joiblumen wrote:
Ok, here are the exact errors from auroracoinj :

Code:
.
.
02:28:41 13 DownloadListener.startDownload: Downloading block chain of size 3121. This may take a while.
02:28:41 13 AbstractBlockChain.checkDifficultyTransitions: Difficulty hit proof of work limit: 17fffe800000000000000000000000000000000000000000000000000000
02:28:41 13 Peer.processHeaders: Block header verification failed
com.google.auroracoin.core.VerificationException: Could not verify block c05b64361afbf0abb2f2b6e99451c6fe5cfcddcf12fa6012f51e0203091aba10
v1 block:
   previous block: 4ed1684a7f76295245f1dec758514287ef5da1da62e3c73f4e002a5cfed1b66b
   merkle root: b4a6060086eddac2ffa640369a47baf38828dac5b14a11ffd3f7be1d5b57cbbb
   time: [1390928714] Tue Jan 28 17:05:14 GMT 2014
   difficulty target (nBits): 504365055
   nonce: 458760
.
.
Network provided difficulty bits do not match what was calculated: fffff000000000000000000000000000000000000000000000000000000 vs aaaaa000000000000000000000000000000000000000000000000000000


Does anyone see what could be going wrong here? Nite69? I have replaced the difficulty calculation with the one from main.cpp, that changed the calculated diff to aaaaa from another wrong calculated value. So the error seems to come from there..

If there is not a easy solution to this I think it is best to wait for the KGW implementation as that would replace the whole calculation algo making the fixes irrelevant.


AbstractBlockChain.java:

Code:
    /**
     * Throws an exception if the blocks difficulty is not correct.
     */
    private void checkDifficultyTransitions(StoredBlock storedPrev, Block nextBlock) throws BlockStoreException, VerificationException {
        checkState(lock.isHeldByCurrentThread());
        Block prev = storedPrev.getHeader();
       
        // Is this supposed to be a difficulty transition point?
        if ((storedPrev.getHeight() + 1) % params.getInterval() != 0) {

            // TODO: Refactor this hack after 0.5 is released and we stop supporting deserialization compatibility.
            // This should be a method of the NetworkParameters, which should in turn be using singletons and a subclass
            // for each network type. Then each network can define its own difficulty transition rules.
            if (params.getId().equals(TestNet3Params.ID_TESTNET) && nextBlock.getTime().after(testnetDiffDate)) {
                checkTestnetDifficulty(storedPrev, prev, nextBlock);
                return;
            }

            // No ... so check the difficulty didn't actually change.
            if (nextBlock.getDifficultyTarget() != prev.getDifficultyTarget())
                throw new VerificationException("Unexpected change in difficulty at height " + storedPrev.getHeight() +
                        ": " + Long.toHexString(nextBlock.getDifficultyTarget()) + " vs " +
                        Long.toHexString(prev.getDifficultyTarget()));
            return;
        }

        // We need to find a block far back in the chain. It's OK that this is expensive because it only occurs every
        // two weeks after the initial block chain download.
        long now = System.currentTimeMillis();
        StoredBlock cursor = blockStore.get(prev.getHash());

        int goBack = params.getRetargetBlockCount(cursor);

        for (int i = 0; i < goBack; i++) {
            if (cursor == null) {
                // This should never happen. If it does, it means we are following an incorrect or busted chain.
                throw new VerificationException(
                        "Difficulty transition point but we did not find a way back to the genesis block.");
            }
            cursor = blockStore.get(cursor.getHeader().getPrevBlockHash());
        }

        long elapsed = System.currentTimeMillis() - now;
        if (elapsed > 50)
            log.info("Difficulty transition traversal took {}msec", elapsed);

        // Check if our cursor is null.  If it is, we've used checkpoints to restore.
        if(cursor == null) return;

        Block blockIntervalAgo = cursor.getHeader();
        log.info("Using block " + cursor.getHeight() + " to calculate next difficulty");
        log.info(cursor.toString());
        int timespan = (int) (prev.getTimeSeconds() - blockIntervalAgo.getTimeSeconds());
        final int targetTimespan = params.getTargetTimespan();
        BigInteger newDifficulty = Utils.decodeCompactBits(prev.getDifficultyTarget());
        if (AuroraCoinParams.ID_AURORACOIN.equals(params.getId())) {
           // Auroracoin block difficulty
           if ((cursor.getHeight()+1) < 135)
              newDifficulty = params.getProofOfWorkLimit();
           else if ((cursor.getHeight()+1) == 121)
              newDifficulty = params.genesisBlock.getDifficultyTargetAsInteger();
           else {
              
              int nActualTimespan = timespan;
              log.info(" nActualTimespan = " + nActualTimespan + " before bounds\n");       
   
                  int nActualTimespanMax = ((targetTimespan*75)/50);
                  int nActualTimespanMin = ((targetTimespan*50)/75);
                 
             if (nActualTimespan < nActualTimespanMin)
                 nActualTimespan = nActualTimespanMin;
             if (nActualTimespan > nActualTimespanMax)
                 nActualTimespan = nActualTimespanMax;
             
             log.info("Old diff target: " + newDifficulty.toString(16));
             newDifficulty = newDifficulty.multiply(BigInteger.valueOf(nActualTimespan));
             log.info("Times " + nActualTimespan);
              log.info("    is  " + newDifficulty.toString(16));
             newDifficulty = newDifficulty.divide(BigInteger.valueOf(targetTimespan));
              log.info("Div by " + targetTimespan);
              log.info("    is  " + newDifficulty.toString(16));
           }
        } else {
            // Limit the adjustment step.
           if (timespan < targetTimespan / 4)
               timespan = targetTimespan / 4;
           if (timespan > targetTimespan * 4)
               timespan = targetTimespan * 4;
   
           log.info("Old diff target: " + newDifficulty.toString(16));
           newDifficulty = newDifficulty.multiply(BigInteger.valueOf(timespan));
           log.info("Times " + timespan);
           log.info("    is  " + newDifficulty.toString(16));
           newDifficulty = newDifficulty.divide(BigInteger.valueOf(targetTimespan));
           log.info("Div by " + targetTimespan);
           log.info("    is  " + newDifficulty.toString(16));
        }
        if (newDifficulty.compareTo(params.getProofOfWorkLimit()) > 0) {
            log.info("Difficulty hit proof of work limit: {}", params.getProofOfWorkLimit().toString(16));
            newDifficulty = params.getProofOfWorkLimit();
            log.info("Setting to: {}", newDifficulty.toString(16));
        } else {
            log.info("Difficulty did not hit proof of work limit: {}", params.getProofOfWorkLimit().toString(16));
        }

        int accuracyBytes = (int) (nextBlock.getDifficultyTarget() >>> 24) - 3;
       
        // The calculated difficulty is to a higher precision than received, so reduce here.
        BigInteger mask = BigInteger.valueOf(0xFFFFFFL).shiftLeft(accuracyBytes * 8);
        newDifficulty = newDifficulty.and(mask);

        BigInteger receivedDifficulty = nextBlock.getDifficultyTargetAsInteger();
        if (newDifficulty.compareTo(receivedDifficulty) != 0)
            throw new VerificationException("Network provided difficulty bits do not match what was calculated: " +
                    receivedDifficulty.toString(16) + " vs " + newDifficulty.toString(16));
        else {
           log.info("Network provided difficulty bits match what was calculated: " +
                    receivedDifficulty.toString(16) + " vs " + newDifficulty.toString(16));       
       }
    }


Just in a hurry, this loads up to 135 headers, just dont have just now time to solve the problem, hope it helps.
You need to have the network params:
Code:
        proofOfWorkLimit = Utils.decodeCompactBits(0x1e0fffffL);
        addressHeader = 23;
        acceptableAddressCodes = new int[] { addressHeader };
        port = 12340;
        packetMagic = 0xfda4dc6cL;
        dumpedPrivateKeyHeader = 128 + addressHeader;

        targetTimespan = (int)(8 * 10 * 60);
   int targetSpacing = (int)(10 * 60);
        interval = targetTimespan/targetSpacing;

        genesisBlock.setDifficultyTarget(0x1e0fffffL);


See also auroracoin-qt source, main.cpp, GetNextWorkRequired

Edit: change cursor.getHeight() to storedPrev.getHeight(), ie:
Code:
           // Auroracoin block difficulty
           if ((storedPrev.getHeight()+1) < 135)
              newDifficulty = params.getProofOfWorkLimit();
           else if ((storedPrev.getHeight()+1) == 121)
              newDifficulty = params.genesisBlock.getDifficultyTargetAsInteger();
           else {


Over 2k blocks loaded,stops on some block, investigating..

YES! The whole current blockchain loaded. Some stability issues to be solved, but this is looking good!

_________________
AuroraCoin: AXVoGgYtSVkPv96JLL7CiwcyVvPxXHXRK9
Bitcoin: 17gNvfoD2FDqTfESUxNEmTukGbGVAiJhXp
Litecoin: LhbDew4s9wbV8xeNkrdFcLK5u78APSGLrR
Rent a VPS and keep auroraexplorer.atorox.net running: https://www.digitalocean.com/?refcode=c815fc73c453


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 6:25 pm 
Offline

Joined: Sat Feb 15, 2014 1:26 am
Posts: 43
ahh missed that <135 calculation, where did you get that (cursor.getHeight()+1) == 121) ?? Can't seem to find that in the code.
Anyways, I am stuck on 135 as well. Not sure what is causing it
Check out my commit https://github.com/JoiBlumen/auroracoin ... 05023115f5

EDIT: yeah that storedPrev fixed it :D .


Top
 Profile  
 
PostPosted: Mon Feb 24, 2014 7:13 pm 
Offline

Joined: Mon Feb 17, 2014 8:00 pm
Posts: 67
joiblumen wrote:
ahh missed that <135 calculation, where did you get that (cursor.getHeight()+1) == 121) ?? Can't seem to find that in the code.
Anyways, I am stuck on 135 as well. Not sure what is causing it
Check out my commit https://github.com/JoiBlumen/auroracoin ... 05023115f5

EDIT: yeah that storedPrev fixed it :D .


Well, that 121 *was* there before .. but it returns exactly the same than nProofOfWorkLimit, so that line is worthless.. and since 121<135, it is also never run :-D I should pay more attention..

And now there is KGW :-)
Does not seem to be difficult to make it with java.. but how to test it?

_________________
AuroraCoin: AXVoGgYtSVkPv96JLL7CiwcyVvPxXHXRK9
Bitcoin: 17gNvfoD2FDqTfESUxNEmTukGbGVAiJhXp
Litecoin: LhbDew4s9wbV8xeNkrdFcLK5u78APSGLrR
Rent a VPS and keep auroraexplorer.atorox.net running: https://www.digitalocean.com/?refcode=c815fc73c453


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group