Post
Topic
Board Development & Technical Discussion
Merits 8 from 2 users
Re: How do Bitcoin nodes verify the integrity of "Data"?
by
Xynerise
on 18/05/2018, 07:32:08 UTC
⭐ Merited by suchmoon (5) ,ETFbitcoin (3)
As far as I understand, mining works like this.

They get the "data" from the pool, in in order to verify them and put them in a "block",
I'll assume by pool You mean mempool which is where unconfirmed transactions are stored in nodes. There's no global mempool; all nodes have theirs.
And by "data" I assume you mean unconfirmed transactions.
Quote
they try to find the nonce with which if hashed with the data and the previous hash data produces

the hash result that starts with 0000000000xxxxxx...xxx.
There are other things concatenated with the previous block header hash before it is hashed to find the target: the version, the Merkle root of all the transactions in the block, the timestamp, target and nonce.
This is the template for the candidate block's block header hash. They hash this while iterating the nonce, then the timestamp until they find a hash that is lower than the target hash.
Quote
What I don't understand is, what is this "pool" where they send the data to all the nodes?
As explained above, it is the mempool and is peculiar to each node.
Quote
Also, how do the nodes

verify the integrity?
They verify it against the set of protocol rules. For example a transaction is not allowed to have more output than input (ie spend more than it has). If any transaction doesn't follow the rule then it's invalid and is discarded by the node and not related further in the network. If a node keeps relaying invalid transactions to another node then the recipient node will ban that node for some time.
Quote
What if the pool is compromised and sends the wrong data in the first place?
I don't see how the mempool can be compromised but like I said above, if you send invalid transaction or block to the node it will discard it and won't relay it so it doesn't propagate in the network.
Quote
How is finding the right nonce alone guarantee the integrity of data and transactions ?
Finding the right nonce is the job for the miners as they are the only ones allowed to append blocks to extend the blockchain, so the process must not be trivial.
For a miner to be able to extend the blockchain with his block then he must have expended some costs (usually in the form of electricity) and so is incentivized to follow the rules.
However, if he doesn't follow the rules and includes invalid transactions (transactions that don't follow the protocol rules) in his block, then his block will be rejected by other nodes in the network and his work will be a waste.

Finding a nonce which hashes to less than a particular target is hard work because you have to try a whole lot of values but verifying that this nonce is valid is just one hash which doesn't take time or consume CPU resources at all.