1

I have some gaps in my understanding to the life cycle of the transaction that I want someone to help me fill them specially with the validation.

What I understand about the life cycle with my questions:

1) Transaction is signed off by the user through the wallet app and broadcasted to the blockchain network.

The question at this step is: does the wallet app perform any kind of transaction validation that requires to check the whole history of the blockchain at this level ?


2) The broadcasted transaction is now sent to many nodes on the network, and these nodes forward/ "propagate" the transactions to other nodes till all the nodes have this transaction in their "pool of unconfirmed transactions" ?

Tell me if I'm getting any part wrong or not in it's right order


3) Each miner will pick some transactions and start the mining (doing the proof of work till finding a correct hash)

At this level when the miner picks the transactions, does he perform a validation of each transaction that requires full scan of the history of the blockchain ?


4) When the miner solves the block, he will broadcast that block along with the hashed value he produced to the blockchain network in the same way the transaction was broadcasted to some nodes and propagated to the rest. Then the nodes will hash the block header to verify whether or not it produces the same hash so they can accept that block.

The question here is: do the nodes perform another validation at all the transactions sent with the block header to verify they are real transactions not fake ones created by the miner who solved the block ?

Does the validations on these transactions require a check against all the history of the blockchain ?

I know how merkle trees hash multiple transactions and that any modification to a transaction's hash will change the merkle root's value, but my question here is how is that helpful ? wouldn't the miner who already faked up any of the transactions have the right merkle root for all the transactions in the block since he is the one who added them in the first place ? My point is how does merkle root help ? what value does it add ? what kind of attack does it prevent ?


The last question is the consensus, from its definition it is that all nodes agree that they are at the same level with the new block. I know the PoW, but how all the nodes check and communicate together to acknowledge that all of them got the same block ?

2

The question at this step is: does the wallet app perform any kind of transaction validation that requires to check the whole history of the blockchain at this level ?

It depends on the wallet.

In general, a wallet will likely do some validation as a sanity check to ensure that the transaction they create is valid and will be accepted by nodes on the network. They will usually check that the signatures are valid and that the transaction is valid assuming that the previous transactions it spends from are also valid.

Whether those previous transactions are valid are a different story. There are different validation and security models that are employed. But generally, a wallet will only store and recognize a transaction as its when it believes it to be valid. It will then rely on the assumption that it is valid (whether it validated it or has some other means to believe it is valid) so that it does not need to re-validate the transaction later.

2) The broadcasted transaction is now sent to many nodes on the network, and these nodes forward/ "propagate" the transactions to other nodes till all the nodes have this transaction in their "pool of unconfirmed transactions" ?

That is correct. But at this stage, nodes validate the transaction using the full transaction history before they relay the transaction further onto other peers. Note that they don't re-validate previous transactions nor do they linearly search through the blockchain. Rather they have databases and indexes which make transaction validation extremely fast.

Additionally, not all nodes need to have the transaction or to have seen the transaction. There is also no way to know whether all nodes have seen and validated a particular transaction.

The question here is: do the nodes perform another validation at all the transactions sent with the block header to verify they are real transactions not fake ones created by the miner who solved the block ?

Naively (and previously), yes. A simple implementation would simply re-validate every single transaction received in a block.

A faster implementation (and what Bitcoin Core does now), is to cache whether a particular transaction has been validated before and whether it was valid. So when it goes through a block, instead of re-validating all the transactions that the node has seen before, it just calls up the validation result previously. This can be easily done by restricting the mempool (pool of unconfirmed transactions) to transactions that would be valid if they are included in he next block. So if a transaction that is received in a block is found in the mempool, then it is known to be valid and does not need to be re-validated.

I know how merkle trees hash multiple transactions and that any modification to a transaction's hash will change the merkle root's value, but my question here is how is that helpful ? wouldn't the miner who already faked up any of the transactions have the right merkle root for all the transactions in the block since he is the one who added them in the first place ? My point is how does merkle root help ? what value does it add ? what kind of attack does it prevent ?

The merkle root has nothing to do with transaction validity.

The merkle serves two purposes: to ensure that all transactions are included in the block hash, and to prove that a particular transaction was in a block without needing the block itself.

Since the merkle root is part of the block header, and since it is the hash of all transactions in a block, it serves to commit all of those transactions to the block header and to the Proof of Work. It just ensures that the block hash covers the transactions as well.

The merkle tree used to produce the merkle root also means that anyone with a full block can produce a simple proof that a transaction was included in a particular block. This is useful for SPV wallets. It does not prove that a transaction is valid and has no effect on whether a transaction is valid. A miner could include an invalid transaction and it would be part of the merkle tree. This doesn't make that transaction valid, nor does it make the block valid.

The last question is the consensus, from its definition it is that all nodes agree that they are at the same level with the new block. I know the PoW, but how all the nodes check and communicate together to acknowledge that all of them got the same block ?

They don't; there is no need to. Consensus is reached because nodes are connected to each other and broadcast blocks to each other. Because every node is programmed to follow the blockchain with the most work and to do its best to ensure that its peers learn about what it thinks is the best blockchain, the network naturally achieves consensus without any sort of agreement and acknowledgment. By relying on nodes switching to use the valid blockchain with the most work, nodes will converge onto the same blockchain as eventually, one blockchain will have the most work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.