0

I know that the transactions stay in the block and hashed alongside few other things and that hash is stored in the next block. And I understand that if you try to tamper with one of the transactions, the hash will change and it will affect all the blocks that come after it.

However, how does a block know that its transactions have tampered with in the first place?

Assume that block #1000 has 10 transactions. Now, the hash has been calculated and stored in block #1001

so, if I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated? does this mean that the hash of each block is recalculated regularly?

  • 1
    what makes you think you can "add" a transaction to a block? the miner chooses what goes in the block. a miner can mine with your transaction included or excluded, but if he includes it, he can get the fees. somebody might find another block at the same height, that doesn't include your transaction but has high enough difficulty. but the security assumption is that it's hash will be different. – Janus Troelsen Sep 23 '19 at 23:11
1

Hashes don't actually 'change'. When you add a transaction to a block you are creating another block.

It's like an author published a book and then next year printed a new edition with an extra comma in the page 36 and the fans said he released a 'new' book. It doesn't make sense for books but for blockchain every bit counts.

|improve this answer|||||
0

If I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated?

Once a block has been mined and accepted as part of the longest valid chain (ie, several confirmations deep), it will not ever change (which means the block's contents, and thus hash, will not change).

In order to change it, you would have to also change every block that comes after it, all the way up until the current chain tip. This would take a huge amount of computational power to pull off, you would basically need to 51% attack the network, to re-write the blockchain history. This sort of attack is extremely expensive, and ignores the incentives for mining honestly, you can read more about it here.

Otherwise, if you just changed block #1000, and then attempted to broadcast the changed block to your peers, they will all reject that block, since it is not part of the longest valid chain (assuming they have already heard about the original block #1000, and all of the blocks that came after it).

does this mean that the hash of each block is recalculated regularly?

A block's hash will be calculated in order to determine its validity, but we would never expect the hash to change for a block that has a sufficient number of confirmations on the network.

|improve this answer|||||
0

how does a block know that its transactions have tampered with in the first place?

It is not the block that knows this; it is the nodes which verify that. To quote the bitcoin whitepaper:

When a node finds a proof-of-work, it broadcasts the block to all nodes. Nodes accept the block only if all transactions in it are valid and not already spent.

and

[...] network nodes can verify transactions for themselves

So, the nodes verify the transactions upon receiving a new block. This adds to the blocks confirmation counter (you can see it in here, for example), hence making it more trustworthy.

To answer your question directly, yes, the blocks get recalculated regularly.

This is not much of a problem for a node however, since it needs only one hash (the nonce is already known) to verify a block, which is vastly easier than calculating a proof-of-work. Same goes for verifying transactions. Exactly how many transactions are verified is something which I don't know myself, might be a topic for another question.

When a node "notices" that a block is invalid, it discards it and can even

[prompt] user's software to download the full block and alerted transactions to confirm the inconsistency.

You might also find this thread quite informative: Bitcoin transactions validation process

|improve this answer|||||
0

I think you are referring to consensus..if you try to go back and add something to a prior block and transmit it to the network the other nodes will reject it..

|improve this answer|||||
  • This doesn't answer the question – Raghav Sood Jan 6 at 4:36
  • Sure it does, if its rejected you know – Johnny Good Jan 6 at 4:55

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.