Author

Topic: On the Section 5 (Network) in the Original Bitcoin Whitepaper (Read 1539 times)

staff
Activity: 4284
Merit: 8808
By the way, why is there an upper size limit for a block?
To prevent the system from being easily DOS attacked by miners, or from losing its decentralization to a scaling slippery slope, and to create the scarcity needed for a market to exist for fees to pay for network security.
full member
Activity: 152
Merit: 100
Miners get to choose which transactions they include in the blocks that they add to the blockchain.  If they want to include transactions that have no fee, they certainly can.  There is nothing in the protocol that prevents that. However, the protocol does limit the size of each block, and it limits the frequency that blocks are created. Therefore, it would be impossible for the blockchain to grow to a terrabyte until there are at least 1,000,000 blocks.  Since blocks occur on average every 10 minutes, it would take about 20 years to reach 1 terrabyte in size unless the protocol is changed.
You're absolutely correct. So actually that means the exclusion of the non-spam transactions. I just went one step further to include all transactions to a block without a limit.

By the way, why is there an upper size limit for a block?
legendary
Activity: 3472
Merit: 4801
Great things to know!

Can a node select which other node to connect with?

You can confirgure it if you want with an "addnode" parameter:
https://github.com/bitcoin/bitcoin/blob/cf9c4887f176634c9f39305ad70657d9fff3962d/src/rpcnet.cpp#L162

Or otherwise, how do nodes find peers?

Once you connect to a peer, you can get a list of peers that it knows about from it with the getaddr message:
https://github.com/bitcoin/bitcoin/blob/2adce1f71600881f69ba44a4d847ade5d7066f7e/src/main.cpp#L3533

If you support your answers with the related pieces from the code, I'd be more than grateful.

No problem.  Links are to the github source code.

By the way, I don't believe that it is the relay rules that which prevents spam.

You are welcome to believe whatever you like.

It should be the tx fee which does this job. If the tx fee was zero, then a spammer would find enough nodes without getting blacklisted by all of them to make the block chain size grow in terabytes.

I don't think bitcoin works the way you think it works.

Miners get to choose which transactions they include in the blocks that they add to the blockchain.  If they want to include transactions that have no fee, they certainly can.  There is nothing in the protocol that prevents that. However, the protocol does limit the size of each block, and it limits the frequency that blocks are created. Therefore, it would be impossible for the blockchain to grow to a terrabyte until there are at least 1,000,000 blocks.  Since blocks occur on average every 10 minutes, it would take about 20 years to reach 1 terrabyte in size unless the protocol is changed.
full member
Activity: 152
Merit: 100
Great things to know!

Can a node select which other node to connect with? Or otherwise, how do nodes find peers? If you support your answers with the related pieces from the code, I'd be more than grateful.

By the way, I don't believe that it is the relay rules that which prevents spam. It should be the tx fee which does this job. If the tx fee was zero, then a spammer would find enough nodes without getting blacklisted by all of them to make the block chain size grow in terabytes.
copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
Yeah, I've read the dev documentation. But I need more than that. Well, for instance, you said nodes have a banscore. Where is that banscore stored?

In memory.

If you enter getpeerinfo in the console or if you use bitcoind getpeerinfo from a linux terminal on a machine that allready has bitcoind running you get something like this:

Code:
[
{
"addr" : "-IP-:8333",
"addrlocal" : "-IP-:8333",
"services" : "00000001",
"lastsend" : 1417103014,
"lastrecv" : 1417103015,
"bytessent" : 426967,
"bytesrecv" : 28102212,
"conntime" : 1417095403,
"pingtime" : 0.00000000,
"version" : 70002,
"subver" : "/Satoshi:0.9.2.1/",
"inbound" : false,
"startingheight" : 331833,
"banscore" : 0,
"syncnode" : true
},-more nodes here-
]

I currently have none with a banscore >0.

But this information is gone as soon as you terminate the client/daemon.

In the block chain? I don't think so. And, is that banscore written to the IP address of the node?

Yes, its per IP and each node has its own list for the banscore. You can modify your tolerance for it in the bitcoind.conf file if you want and a custom written client might also write it to disk when shutting down.

And if such a thing exists, can there also be a banscore for the spammers? Then, an IP based spam prevention would be possible, instead of the fee structure.

Well, AFAIK the reason behind the banscore is to prevent a DoS attack not transactionspam. A DoS or even DDoS attack would simply fail because of the banscore system. An attack with cheap data of invalid transactions would only result in an increasing banscore and finally in a disconnect. The invalid transactions would not be relayed to the network, thus unable to bother all nodes at the same time. Over time any attacker(s) would run out of IP addresses and can only ever bother a few nodes at a time.
The fees exists to make mining profitable in the long run. In the distant future when the blockreward is so small it is no longer of relevance or even shrunk to zero, the fees will be the payment for the miners to keep going, to keep mining profitable.
The relay rules are what currently prevents transactionspam, or rather what makes it harder to spam with 1 satoshi TX. If you look at the rules in the "isDust" function I linked earlier you will notice that a dust transaction is actually valid and might be even valueable in the future. Currently dust transactions are not relayed by bitcoin core, but kept in memory as valid transactions. This makes it harder for spammers as they cant just broadcast their transactions to any random node and hope that the network will know about the transaction within seconds. They still happen though, since not all the nodes run the same version and possibly some spammers have access to reasonable hashingpower. Usually its done as a sort of advertising and would include a tag on blockchain.info
legendary
Activity: 3472
Merit: 4801
Yeah, I've read the dev documentation. But I need more than that. Well, for instance, you said nodes have a banscore. Where is that banscore stored?
Each node keeps track of banscores for the nodes it is connected to.

If Node A sends invalid transactions to Node B, but does not send any invalid transactions to Node C, then Node B will store locally an increasing banscore for Node A, while Node C will still consider Node A to have a banscore of 0.

banscore is just a way for a node to keep track of which nodes it has received bad information from.

In the block chain?

No.

I don't think so. And, is that banscore written to the IP address of the node?

Written to the IP address?  I'm not sure what you mean.

And if such a thing exists, can there also be a banscore for the spammers? Then, an IP based spam prevention would be possible, instead of the fee structure.

Sure, it would be possible for your node to ban peers that sent "spam" to it.
full member
Activity: 152
Merit: 100
Yeah, I've read the dev documentation. But I need more than that. Well, for instance, you said nodes have a banscore. Where is that banscore stored? In the block chain? I don't think so. And, is that banscore written to the IP address of the node? And if such a thing exists, can there also be a banscore for the spammers? Then, an IP based spam prevention would be possible, instead of the fee structure.
copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
shorena,

Thank you very much. You're my saver. I am trying to learn how the network works in detail bit by bit. Unfortunately, it's really hard to delve into the code directly. So I need a guide like the answer you gave. Thanks again.

You are welcome. You can also read more in the dev doc [1] I guess its more helpfull than the code itself.

[1] https://bitcoin.org/en/developer-documentation
full member
Activity: 152
Merit: 100
shorena,

Thank you very much. You're my saver. I am trying to learn how the network works in detail bit by bit. Unfortunately, it's really hard to delve into the code directly. So I need a guide like the answer you gave. Thanks again.
copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
Hi,

Satoshi et al. has written so little on how the network operates. Can someone offer me a good read, other than the source code?

I am especially curious about how nodes broadcast. For instance, if someone having zero balance tries to send some bitcoins to an address, the standard bitcoin client wouldn't allow it. But it should be easy to change the code so as to allow broadcasting such an invalid transaction. Then, when peers get the transaction request, do they check if it's valid or not before they send the request to other peers?
Or do I understand the process completely wrong?
-snip-

Yes each transaction is checked when received against a certain set of rules. If the transaction is invalid it is dropped from memory and the node sending it gets a little banscore. If the banscore reaches a certain amount no more connections and or transaction from that node are accepted. There is also a set of rules to check if the transaction should be relayed. E.g. a TX sending 1 Satoshi is valid, but bitcoin core would not relay it.

If each node checks if a transaction is valid or not, then it means each node is responsible for the security of the block chain, not only miners. Is that correct?

In a way yes.

Another thing is, when downloading the block chain, does a node checks if all the transactions in each block are valid?

Yes, each block is checked and only accepted if correct.

If you can show me the portions of the source code which deals with those issues, please show me where to look.

Thanks

You can use the search function here [1] e.g. the is it dust check can be found in the transaction.h [2]

[1] https://github.com/bitcoin/bitcoin
[2] https://github.com/bitcoin/bitcoin/blob/df504e924a57fac331babef31420e257d332aa64/src/core/transaction.h#L137
full member
Activity: 152
Merit: 100
Hi,

Satoshi et al. has written so little on how the network operates. Can someone offer me a good read, other than the source code?

I am especially curious about how nodes broadcast. For instance, if someone having zero balance tries to send some bitcoins to an address, the standard bitcoin client wouldn't allow it. But it should be easy to change the code so as to allow broadcasting such an invalid transaction. Then, when peers get the transaction request, do they check if it's valid or not before they send the request to other peers? Or do I understand the process completely wrong?

If each node checks if a transaction is valid or not, then it means each node is responsible for the security of the block chain, not only miners. Is that correct?

Another thing is, when downloading the block chain, does a node checks if all the transactions in each block are valid?

If you can show me the portions of the source code which deals with those issues, please show me where to look.

Thanks
Jump to: