Bitcoin Forum
November 16, 2024, 06:24:35 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they believe that the creator of this topic displays some red flags which make them high-risk. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
Author Topic: Nxt source code flaw reports  (Read 113374 times)
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1010

Newbie


View Profile
January 06, 2014, 02:36:18 PM
 #521

We need guys like him in our team. Hey, big stakeholders, do u hear me?
Definitely. ricot found most interesting flaws in last days, not a small local mistakes, but broken logic in execution flow.

Btw, did you miss my observation in shadows of big ricot investigation? Smiley Any comment, please...

I need more time to check it, do u know how to fix it if it's a bug?
ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 06, 2014, 02:46:19 PM
 #522

We need guys like him in our team. Hey, big stakeholders, do u hear me?
Definitely. ricot found most interesting flaws in last days, not a small local mistakes, but broken logic in execution flow.

Btw, did you miss my observation in shadows of big ricot investigation? Smiley Any comment, please...

I need more time to check it, do u know how to fix it if it's a bug?

The crude fix would be to just add a synchronize(blocks) around the whole processBlock thingy Wink
The proper fix: Writing a proper software that doesn't mix the servlet with the block processing Smiley


[edit]
Btw: There seems to be another bug or attack whose result is that a node responds to getCumulativeDifficulty with {"error":"java.lang.NullPointerException"}
My client hasn't experienced that behaviour yet, but if anyone's has, it's another nice chance to debug. Smiley
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 02:50:38 PM
 #523

We need guys like him in our team. Hey, big stakeholders, do u hear me?
Definitely. ricot found most interesting flaws in last days, not a small local mistakes, but broken logic in execution flow.

Btw, did you miss my observation in shadows of big ricot investigation? Smiley Any comment, please...

I need more time to check it, do u know how to fix it if it's a bug?
There's no simple way.
First of all, syncronization code is already rewritten, so any of my suggestions can be invalid.
Simplest way is totally sync "processBlock" request and loading thread on blocks, so either pushBlock() rejects new block as already loaded, or loading thread choose another commonBlockId.
But it is looks like dirty hack. I personally don't like total syncronizations.
I think, Jean-Luc as author of refactorings must check my assumptions on newer code.
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 02:54:33 PM
 #524

Btw: There seems to be another bug or attack whose result is that a node responds to getCumulativeDifficulty with {"error":"java.lang.NullPointerException"}
My client hasn't experienced that behaviour yet, but if anyone's has, it's another nice chance to debug. Smiley
No need to debug. Look at analyse() method:

Code:
                height = Block.getLastBlock().height + 1;
                lastBlock = getId();
                blocks.put(lastBlock, this);
                baseTarget = Block.getBaseTarget();
                cumulativeDifficulty = blocks.get(previousBlock).cumulativeDifficulty.add(two64.divide(BigInteger.valueOf(baseTarget)));

This code set lastBlock with block that have null cumulativeDifficulty, then calc it.
"getCumulativeDifficulty" executes asynchronously and can catch last block in state with cumulativeDifficulty = null, so
Code:
response.put("cumulativeDifficulty", Block.getLastBlock().cumulativeDifficulty.toString());
throws NPE.

Good catch!
theKnownUnknown
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
January 06, 2014, 03:05:34 PM
 #525

Is it one of the flaws that blocks do not contain the hashcode of their previous block?
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 03:08:18 PM
 #526

Is it one of the flaws that blocks do not contain the hashcode of their previous block?
Where have you seen such flaw?
ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 06, 2014, 03:09:16 PM
 #527

Nice one, but that's not it.
The nodes I mean reply with the Nullpointer every time.
You can try wget -q -S -O - --post-data='{"protocol":1,"requestType":"getCumulativeDifficulty"}' 'http://node81.nxtbase.com:7874/nxt'
this one has been in that state for a few hours now.
theKnownUnknown
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
January 06, 2014, 03:12:18 PM
 #528

Block class does not contain hashcode of previous block, only block id and pushBlock() does not check anything into this direction. Isn't it possible to modify old blocks afterwards (By the original author of the block)?
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 03:14:16 PM
 #529

Nice one, but that's not it.
The nodes I mean reply with the Nullpointer every time.
You can try wget -q -S -O - --post-data='{"protocol":1,"requestType":"getCumulativeDifficulty"}' 'http://node81.nxtbase.com:7874/nxt'
this one has been in that state for a few hours now.
Code:
http://node81.nxtbase.com:7874/nxt?requestType=getState

{"lastBlock":"2680262203532249785","numberOfAliases":0,"numberOfBlocks":0,"numberOfPeers":182,"lastBlockchainFeeder":null,"totalMemory":709558272,"freeMemory":637372280,"maxMemory":912261120,"numberOfTransactions":0,"numberOfUsers":0,"version":"0.5.0","numberOfOrders":0,"time":3726746,"availableProcessors":1,"numberOfAssets":0,"numberOfAccounts":0}

It's dead, man. Dead and smells bad.
ferment
Full Member
***
Offline Offline

Activity: 168
Merit: 100


IDEX - LIVE Real-time DEX


View Profile
January 06, 2014, 03:19:03 PM
 #530

Nice one, but that's not it.
The nodes I mean reply with the Nullpointer every time.
You can try wget -q -S -O - --post-data='{"protocol":1,"requestType":"getCumulativeDifficulty"}' 'http://node81.nxtbase.com:7874/nxt'
this one has been in that state for a few hours now.
Code:
http://node81.nxtbase.com:7874/nxt?requestType=getState

{"lastBlock":"2680262203532249785","numberOfAliases":0,"numberOfBlocks":0,"numberOfPeers":182,"lastBlockchainFeeder":null,"totalMemory":709558272,"freeMemory":637372280,"maxMemory":912261120,"numberOfTransactions":0,"numberOfUsers":0,"version":"0.5.0","numberOfOrders":0,"time":3726746,"availableProcessors":1,"numberOfAssets":0,"numberOfAccounts":0}

It's dead, man. Dead and smells bad.

Yes, there is some combination of circumstances (aka bug) that prevent a portion of my nodes from never getting the blockchain. I'm not the best with tcpdump but I could probably dig around.

ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 03:19:21 PM
 #531

Block class does not contain hashcode of previous block, only block id and pushBlock() does not check anything into this direction. Isn't it possible to modify old blocks afterwards (By the original author of the block)?
It contains prev block hash in 0.5.0. At least I see it in decompiled code.
Don't know, is it fixed flaw, or injected.
theKnownUnknown
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
January 06, 2014, 03:22:15 PM
 #532

Mh demotivating to find flaws in old code that are fixed already in the new one.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1010

Newbie


View Profile
January 06, 2014, 03:22:30 PM
 #533

Is it one of the flaws that blocks do not contain the hashcode of their previous block?

Only 64 bits of 256 bit r used to reference previous block.
gsan1
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 06, 2014, 03:22:50 PM
 #534

I took a look at the peer handling. There is a thread running, which gets any peer from my list and asks him for his peers, to which I perhaps could connect. So it makes a post request to any peer "getPeers". Let's take a look at the code:

Code:
case "getPeers":
{
    JSONArray peers = new JSONArray();
    for (Peer otherPeer : Nxt.peers.values()) {

        if (otherPeer.blacklistingTime == 0 && otherPeer.announcedAddress.length() > 0) {

            peers.add(otherPeer.announcedAddress);

        }

    }
    response.put("peers", peers);

}
break;
 

The other peer is answering with his peers list, where blacklistingTime = 0 and announcedAddress > 0. Seems okay. But wait - does that mean that he is also answering with peers he is not or not more connected with (maybe because they are down)? Would'nt it be better to answer only the peers he is currently connected with?
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1010

Newbie


View Profile
January 06, 2014, 03:23:26 PM
 #535

Mh demotivating to find flaws in old code that are fixed already in the new one.

New version has TF enabled.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1010

Newbie


View Profile
January 06, 2014, 03:24:27 PM
 #536

Would'nt it be better to answer only the peers he is currently connected with?

Yes. New version already has this fixed.
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 03:30:45 PM
 #537

Nice one, but that's not it.
The nodes I mean reply with the Nullpointer every time.
You can try wget -q -S -O - --post-data='{"protocol":1,"requestType":"getCumulativeDifficulty"}' 'http://node81.nxtbase.com:7874/nxt'
this one has been in that state for a few hours now.
Code:
http://node81.nxtbase.com:7874/nxt?requestType=getState

{"lastBlock":"2680262203532249785","numberOfAliases":0,"numberOfBlocks":0,"numberOfPeers":182,"lastBlockchainFeeder":null,"totalMemory":709558272,"freeMemory":637372280,"maxMemory":912261120,"numberOfTransactions":0,"numberOfUsers":0,"version":"0.5.0","numberOfOrders":0,"time":3726746,"availableProcessors":1,"numberOfAssets":0,"numberOfAccounts":0}

It's dead, man. Dead and smells bad.

Yes, there is some combination of circumstances (aka bug) that prevent a portion of my nodes from never getting the blockchain. I'm not the best with tcpdump but I could probably dig around.

This is very unusial situation.
Take a look at "getState" query:
Code:
response.put("numberOfBlocks", blocks.size());

There's no call like remove() on blocks collection. Even popBlock() doesn't flush block from it. So it can be empty only because of bad startup. Very bad startup, because even if blocks.nxt doesn't exists or damaged, genesis block is synthesized and putted to collection.

Or there may be some new code which we do not have.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1010

Newbie


View Profile
January 06, 2014, 03:33:37 PM
 #538

This is very unusial situation.
Take a look at "getState" query:
Code:
response.put("numberOfBlocks", blocks.size());

There's no call like remove() on blocks collection. Even popBlock() doesn't flush block from it. So it can be empty only because of bad startup. Very bad startup, because even if blocks.nxt doesn't exists or damaged, genesis block is synthesized and putted to collection.

That's correct. Something really bad happened during initialization.
ferment
Full Member
***
Offline Offline

Activity: 168
Merit: 100


IDEX - LIVE Real-time DEX


View Profile
January 06, 2014, 03:47:15 PM
 #539

This is very unusial situation.
Take a look at "getState" query:
Code:
response.put("numberOfBlocks", blocks.size());

There's no call like remove() on blocks collection. Even popBlock() doesn't flush block from it. So it can be empty only because of bad startup. Very bad startup, because even if blocks.nxt doesn't exists or damaged, genesis block is synthesized and putted to collection.

That's correct. Something really bad happened during initialization.

Yes, these nodes were started from deleted *.nxt.

ferment
Full Member
***
Offline Offline

Activity: 168
Merit: 100


IDEX - LIVE Real-time DEX


View Profile
January 06, 2014, 03:52:46 PM
 #540

This is very unusial situation.
Take a look at "getState" query:
Code:
response.put("numberOfBlocks", blocks.size());

There's no call like remove() on blocks collection. Even popBlock() doesn't flush block from it. So it can be empty only because of bad startup. Very bad startup, because even if blocks.nxt doesn't exists or damaged, genesis block is synthesized and putted to collection.

That's correct. Something really bad happened during initialization.

So, I got it to catchup by deleting *.nxt again, changing 'communicationLoggingMask' to 7. It's worth mentioning that communicationLoggingMask didn't log until I deleted *.nxt and restarted.

Everything looked good so I stopped java with supervisorctl, edited web.xml to turn off log, and started NRS again. Then it got stuck again back at the genesis block.

A SIGTERM shouldn't corrupt anything?

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!