elective-stereophonic
elective-stereophonic
Block distribution in NXT network (Kind of a java question, too)
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.1 Upgrade before block 2870000 is mandatory!

Author Topic: Block distribution in NXT network (Kind of a java question, too)  (Read 2227 times)

marcus03

  • Sr. Member
  • ****
  • Karma: +24/-1
  • Offline Offline
  • Posts: 389
    • View Profile

From https://bitbucket.org/JeanLucPicard/nxt/src/525a1924962f4107c679b61aea7a3b9a4b60a4ab/src/java/nxt/BlockchainProcessorImpl.java?at=master:

Code: [Select]
if (block.getTimestamp() >= Convert.getEpochTime() - 15) {
            JSONObject request = block.getJSONObject();
            request.put("requestType", "processBlock");
            Peers.sendToSomePeers(request);

Does this mean that new blocks are only send to peers when they are max. 15 seconds old?

If so, when I receive lots of different blocks from just one of my peer, but not from the others, this might be a DOS attack or the system time on the other node might be wrong. Correct?
Logged
My Android NXT wallet project!
Raspberry Pi NXT node/Two VPS NRS nodes
NXT tips and donations: NXT-X5EB-VSL5-Z7DU-3GWTJ

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Karma: +816/-81
  • Offline Offline
  • Posts: 1610
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #1 on: March 29, 2014, 05:47:20 pm »

Yes, blocks generated more than 15 s ago are not forwarded to peers, the assumption is that they already have them. Or if not, they are going to get them with a pull request.

If blocks are generated on average once per minute, you can't receive lots of different blocks from just one peer - at most one of those blocks is likely to be less than 15 s old.
Logged
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
NXT-X4LF-9A4G-WN9Z-2R322

marcus03

  • Sr. Member
  • ****
  • Karma: +24/-1
  • Offline Offline
  • Posts: 389
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #2 on: March 30, 2014, 09:37:21 am »

If blocks are generated on average once per minute, you can't receive lots of different blocks from just one peer - at most one of those blocks is likely to be less than 15 s old.

So is there another explanation than a DOS attack when I see one node sending lots of blocks not received from other nodes (like more than say 5 blocks per minute)? Peer node being on a forked chain?

Furher, I'm looking at the standard deviation time for the times a specific block/transaction reaches my node from other peers. For transaction I usually get std. deviations below 10 seconds, so all nodes send the transaction at roughly the same time to my node.
For blocks however, I've seen std. deviations of 30, 60 and more seconds. Some nodes seem to send out blocks quite late. The only reason for this to happen I see is that the node time is wrong on a large number of nodes, so that the (block.getTimestamp() >= Convert.getEpochTime() - 15) check can pass.

Is there a mechanism that makes sure that node times are in sync?
Logged
My Android NXT wallet project!
Raspberry Pi NXT node/Two VPS NRS nodes
NXT tips and donations: NXT-X5EB-VSL5-Z7DU-3GWTJ

slothbag

  • Sr. Member
  • ****
  • Karma: +74/-4
  • Offline Offline
  • Posts: 454
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #3 on: March 30, 2014, 10:39:56 am »

A couple of weeks ago I was running a node on testnet using a custom genesis block (i.e different blockchain) and it was connecting to other testnet peers and sending lots of data to and from other nodes.. it never got blacklisted or anything like that.

Perhaps that is what you are seeing? someone running a parallel blockchain on the default main-net ports?
Logged

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Karma: +816/-81
  • Offline Offline
  • Posts: 1610
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #4 on: March 30, 2014, 10:59:09 am »

I am not sure. Do you know what those blocks look like, are they from the current blockchain or from a fork, are they all generated by the same account? Difficult to guess what it may be.

No mechanism for time sync, that would be like trying to re-implement NTP in java.
Logged
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
NXT-X4LF-9A4G-WN9Z-2R322

marcus03

  • Sr. Member
  • ****
  • Karma: +24/-1
  • Offline Offline
  • Posts: 389
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #5 on: March 30, 2014, 11:28:21 am »

I am not sure. Do you know what those blocks look like, are they from the current blockchain or from a fork, are they all generated by the same account? Difficult to guess what it may be.

I saw this yesterday. Right now it's gone. I'll look into it further when I see it again.

Quote
No mechanism for time sync, that would be like trying to re-implement NTP in java.

It would be hard to prevent this for a malicous node, but for normal nodes, they could send their local UTC timestamp upon connecting to other peers and other peers could deny the connection if the timediff to their local timestamp is larger than some value. This would disconnect nodes with wrong times from the network.
Logged
My Android NXT wallet project!
Raspberry Pi NXT node/Two VPS NRS nodes
NXT tips and donations: NXT-X5EB-VSL5-Z7DU-3GWTJ

CIYAM

  • Hero Member
  • *****
  • Karma: +75/-3
  • Offline Offline
  • Posts: 575
  • Ian Knowles - CIYAM Lead Developer
    • View Profile
    • CIYAM
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #6 on: March 30, 2014, 03:18:44 pm »

It would be hard to prevent this for a malicous node, but for normal nodes, they could send their local UTC timestamp upon connecting to other peers and other peers could deny the connection if the timediff to their local timestamp is larger than some value. This would disconnect nodes with wrong times from the network.

I would have thought it already did that (my PoS design does).
Logged
With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU

marcus03

  • Sr. Member
  • ****
  • Karma: +24/-1
  • Offline Offline
  • Posts: 389
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #7 on: March 31, 2014, 07:38:57 pm »

I am not sure. Do you know what those blocks look like, are they from the current blockchain or from a fork, are they all generated by the same account? Difficult to guess what it may be.

I saw this yesterday. Right now it's gone. I'll look into it further when I see it again.

Now I see it again. Node 78.99.62.166 sent ("processBlock") 1.974 blocks to my node nrs01.nxtsolaris.info in the last 60 minutes (around 4.080 in the last 2 hours).

http://nrs01.nxtsolaris.info:7876/nxt?requestType=getPeer&peer=78.99.62.166

returns:

{"shareAddress":true,"platform":"PC","application":"NRS","weight":0,"state":0,"announcedAddress":null,"downloadedVolume":11658739,"blacklisted":false,"version":"0.5.10","uploadedVolume":90793}

Should this version be able to connect to peers at all?
« Last Edit: March 31, 2014, 07:43:43 pm by marcus03 »
Logged
My Android NXT wallet project!
Raspberry Pi NXT node/Two VPS NRS nodes
NXT tips and donations: NXT-X5EB-VSL5-Z7DU-3GWTJ

slothbag

  • Sr. Member
  • ****
  • Karma: +74/-4
  • Offline Offline
  • Posts: 454
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #8 on: April 01, 2014, 01:28:32 am »

Is there a permanent blacklist feature? maybe in the conf file so we can block that IP completely?

Or perhaps have a customizable node version filter, so I can block all nodes < 0.8xx
Logged

marcus03

  • Sr. Member
  • ****
  • Karma: +24/-1
  • Offline Offline
  • Posts: 389
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #9 on: April 03, 2014, 07:11:06 pm »

Here's another one. 2.168 sparse blocks from 78.63.246.7 in the last two hours.

http://nrs02.nxtsolaris.info:7876/nxt?requestType=getPeer&peer=78.63.246.7

{"shareAddress":true,"platform":"PC","application":"NRS","weight":0,"state":0,"announcedAddress":null,"downloadedVolume":1548413,"blacklisted":false,"version":"0.5.11","uploadedVolume":13195}
Logged
My Android NXT wallet project!
Raspberry Pi NXT node/Two VPS NRS nodes
NXT tips and donations: NXT-X5EB-VSL5-Z7DU-3GWTJ

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Karma: +816/-81
  • Offline Offline
  • Posts: 1610
    • View Profile
Re: Block distribution in NXT network (Kind of a java question, too)
« Reply #10 on: April 03, 2014, 11:36:24 pm »

There is nxt.knownBlacklistedPeers property to blacklist specific IP addresses. I don't want to blacklist by version, because malicious nodes can fake version strings. There is already code to blacklist peers that return too many blocks in response to a getNextBlocks request, but not for sending processBlock, and I am not sure why a 0.5.10 node would be sending those processBlock requests...

Versions older than 0.7.7 and 0.8.8 can no longer forge because of the daylight savings time bug. And the 0.9 branch breaks compatibility with 0.7, so everyone still on 0.7.7 should upgrade to 0.8.13 soon.
Logged
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
NXT-X4LF-9A4G-WN9Z-2R322
 

elective-stereophonic
elective-stereophonic
assembly
assembly