Author

Topic: P2P Network discovery question. (Read 138 times)

legendary
Activity: 3472
Merit: 10611
March 04, 2021, 11:53:41 PM
#7
Generally the bitcoin protocol works by doing this with seed nodes and then those nodes advertise other nodes (either randomly selected or selected by speed) on to the new peer to reduce their load.
(DNS) Seeds are not nodes, they are more like servers and they are only used when your node does not have any local list of peers to connect to so it has to get it from somewhere. This situation happens only when the node is a fresh install and comes online for the first time. After the very first connection your node builds a local database of all peers that it knows about.
In other words in lifetime of any node they connect to DNS seeds only once unless a certain rare circumstance occurs such as local peer database is deleted or all peers in it fail to connect.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
March 04, 2021, 11:34:44 PM
#6
2. So once the IDB is done, then sync is pretty much instantly is done. Depending on the network latency, I could see the new block right away or probably next day then...
Depending on the peers. Unless you have intentionally connected to some very bad peers, you will still see the headers pretty quickly as the block is propagated.
3. So in this case, say Block B has a transaction saying PA sent 10 bitcoin to PB. Then this will be invalid transaction..so PA will receive back that 10 bitcoin...then this PA user will eventually find out the bitcoin hasn't been sent..or PB found out he/she hasn't received it..then PA will need to send 10 bitcoins again eventually?
That depends. In this case, a transaction would only be invalid if a different transaction which spends any of the same inputs (UTXOs) are included in the longest chain. If there are no competing transactions, the transactions in block B which are otherwise not included in any of the blocks that are in the longest chain (Block A or C) would just be returned back into the mempool, awaiting for another miner to mine a block that includes the transaction.
newbie
Activity: 29
Merit: 3
March 04, 2021, 11:25:45 PM
#5
2. So once the IDB is done, then sync is pretty much instantly is done. Depending on the network latency, I could see the new block right away or probably next day then...

3. So in this case, say Block B has a transaction saying PA sent 10 bitcoin to PB. Then this will be invalid transaction..so PA will receive back that 10 bitcoin...then this PA user will eventually find out the bitcoin hasn't been sent..or PB found out he/she hasn't received it..then PA will need to send 10 bitcoins again eventually?
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
March 04, 2021, 11:00:03 PM
#4
1. When bitcoin-qt started, full sync will be performed. Say I started my bitcoin-qt, then once the full sync is done, my blockchain is up-to-date, which means, my latest block height is highest number. Correct?
Bitcoin Core will determine if it's the latest block by comparing the block header with your peers.
2. Each node has their own copy of the blockchain. Whenever sync is done, the blockchain in each node will be updated acoordingly. So when the sync is actually performing? Only at the startup? Whenever new block is submitted from a miner? Periodically?
Initial Block Download (IDB) is the process to download the blockchain from the genesis block initially. After it gets to the chain tip, it will verify and process blocks when it gets relayed from any of its peers that it is currently connected to.
3.I am not sure I fully understand here...so how the block height will be synced across nodes correctly? I mean...say..in A node, there r 5 blocks...and new block submitted to this node, and added in that chain, say the block height of this new block is 6...say in B node, there are 5 blocks as well...say new block submitted to this node, and added...then this block height is also 6... So..basically same block height number, but different  blocks... wouldn't that be necessary to resolve this somehow?
Nodes will always follow the chain with the highest cumulative POW(POW). If two blocks happens to be found at the same time, a fork is formed. In a perfect scenario, half of the network's nodes will see Block A and half of the network's node will see Block B. Miners will build their blocks on top of the block that they see first. Whichever miner that finds the block on either chain will lengthen the chain and thus increase it's cumulative POW. After which, the new block, Block C which is built ontop of Block A will be relayed through the network. Those nodes which sees Block A will include Block C in their Blockchain and those nodes which sees Block B will discard Block B and include both Block A and Block C in their blockchain.

As such, Block B is out of the equation and the network continues to build on Block C.
newbie
Activity: 29
Merit: 3
March 04, 2021, 09:14:45 PM
#3
1. When bitcoin-qt started, full sync will be performed. Say I started my bitcoin-qt, then once the full sync is done, my blockchain is up-to-date, which means, my latest block height is highest number. Correct?

2. Each node has their own copy of the blockchain. Whenever sync is done, the blockchain in each node will be updated acoordingly. So when the sync is actually performing? Only at the startup? Whenever new block is submitted from a miner? Periodically?

3.I am not sure I fully understand here...so how the block height will be synced across nodes correctly? I mean...say..in A node, there r 5 blocks...and new block submitted to this node, and added in that chain, say the block height of this new block is 6...say in B node, there are 5 blocks as well...say new block submitted to this node, and added...then this block height is also 6... So..basically same block height number, but different  blocks... wouldn't that be necessary to resolve this somehow?

Thanks

 
copper member
Activity: 2856
Merit: 3071
https://bit.ly/387FXHi lightning theory
March 04, 2021, 05:21:58 PM
#2
Yes so host1 knows host2 so host1 sends a message to host2. Host2 then sends a message back and stores host1 on their peer list. They send a message to each other every so often with ne wpeers they'd like to advertise the other connect to.

Generally the bitcoin protocol works by doing this with seed nodes and then those nodes advertise other nodes (either randomly selected or selected by speed) on to the new peer to reduce their load.
newbie
Activity: 29
Merit: 3
March 04, 2021, 05:15:49 PM
#1
Hello,

I've read couple of articles and books about P2P Network discovery...

Here is my question about addr and getaddr protocol.

Let's say there are two nodes. ( 1.2.3.4 and 5.6.7.8 )...Say 1.2.3.4 knows the 5.6.7.8 peer ip address.

1. Since 1.2.3.4 knows 5.6.7.8 as a peer, so 1.2.3.4 registers 5.6.7.8 as a peer.
2. 1.2.3.4 sends "addr" to 5.6.7.8 ..then 5.6.7.8 registers the 1.2.3.4 as peer. At this point, so 5.6.7.8 has only one peer, which is 1.2.3.4
3. 1.2.3.4 sends "getaddr" to 5.6.7.8 then 1.2.3.4 receives the peers of 5.6.7.8. At this point, 5.6.7.8 only sends 1.2.3.4, which has been registered in #2.
4. When 1.2.3.4 received the list of peer, which is 1.2.3.4..then it is the same node of current host, so it doesn't register as a peer, then skipped.
5. So at this point, 1.2.3.4 has one peer of 5.6.7.8 and 5.6.7.8 has one peer of 1.2.3.4

Is my understanding pretty much correct?

Thanks,


Jump to: