Bitcoin – Transactions Processing

Transaction Flooding

After joining the network, the initial step is to get the most recent copy of the blockchain from the peer nodes. After receiving the updated blockchain, initiate the transaction. Let us say A -> B: BTC 10 and broadcast the transaction to the peer nodes. As a consequence, every node in the peer nodes receives the transaction. Each transaction includes input and output scripts used to validate the transaction by the peer nodes and miners.

Broadcast the transaction - Bitcoin Network
Broadcasting of transaction to the P2P Bitcoin Network

Transaction Validation by Peer Nodes

One of the most important tasks of the peer nodes is to validate the transaction, and it can be performed by executing input and output scripts. However, before executing the script, the script validation will ensure that it is not crafted to harm the peer nodes. So the script matches with a pre-given set of whitelist operators to avoid the execution of unusual scripts. After the successful execution of the script, the peer node will decide the further action based on the return status of execution. The peer nodes validate the transactions based on the various aspects:

  • Whether Alice has sufficient bitcoins to transfer and can be verified by accessing the old records stored in the bitcoin blockchain.
  • Double spending checks:
    • Transferring to the same recipient twice: If the peer nodes have already seen the same bitcoin transaction twice, then include or forward the first transaction to other peer nodes.
    • Transferring to the different recipients one after another: If the peer nodes have already seen the same bitcoin transaction for two recipients, don’t include or forward second transaction information to the peer nodes.
Validation of transaction -Bitcoin network.
Validation of transaction – By Bitcoin network peer nodes

Transaction relay by peer nodes

If the intended recipient is the actual recipient based on the transaction records, the recipient will accept the transaction and add it to his/her wallet. However, if the intended recipient is not the actual recipient and a valid transaction, it will be flooded to the peer nodes.

Flooding of transaction - notepub
Flood the transaction

After validation, they again flood the transaction in the network. This way, every transaction is actually getting propagated in the entire bitcoin network.  And everyone in the entire bitcoin network will see all the transactions if they are online during that time. However, it may happen that a particular node has already seen the transaction. In that case, that node will drop that transaction to avoids the entire bitcoin network getting clogged with duplicate transactions.

Drop the same transaction received again
Drop the same transaction if it received again from other peer nodes.

The interesting concept behind bitcoin mining is that the miners will also receive all the transactions that are propagated in the bitcoin network. They will be able to construct a block with the help of received transactions. However, whenever nodes are flooding the transactions, there are certain interesting scenarios. Different nodes may have a different pool of transactions, as illustrated in the below diagram.

Different nodes may have different transaction pools.
Different nodes may have different transaction pools.

This can always happen in the network. If this happens then, a particular miner accepts the first set of transactions that have been heard and uses those transactions to construct a new block. Whenever a miner is constructing a new block, it is always like different miners in the network can start working with a different set of transactions. They try to push the set of transactions in the existing blockchain.

In general, what miners do, they wait for around 10 minutes to take all the transactions they observe and then construct a block of maximum block size. It may be possible that one of the miners will finish work quickly and add the new block to the existing blockchain while the others were busy constructing a new block. In that scenario, they discard their ongoing work and start constructing the new blocks to include those transactions that are not there in the latest block of the updated blockchain.

Accept the first set of transactions that are seen by the miners
Accept the first set of transactions that are seen by the miners

Summary

This note shows how the flooding works and which transaction needs to flood with the peer nodes and which one to be discarded, and parameters to be checked during transaction validation. 

References

  • NPTEL lecture series on Blockchains Architecture, Design and Use Cases by Prof. Sandip Chakraborty, IIT Kharagpur.

 227 total views,  1 views today

Scroll to Top
Scroll to Top