Once a miner has found a block, how easy it is for him to add or remove a tx included in that very block? Would he have to solve the modified block from the scratch or is there a point he can resume the solving process?
3 Answers
Once a miner has found a block, how easy it is for him to add or remove a tx included in that very block?
It is impossible. The solved block depends on every byte of transaction data, nothing can be changed. It is important that it be this way. What if I could broadcast a solved block but leave out the transaction where I sent coins to someone else, essentially reverting my spend? That would make for an insecure system.
Would he have to solve the modified block from the scratch or is there a point he can resume the solving process?
It is basically like starting over. This is mainly because of the merkle root in the block header. Think of it like a function that depends on every single byte of the transactions, and if any of the transactions change then the function output changes completely.
See this for more info on merkle trees in bitcoin: What is the Merkle root?
EDIT: I wanted to add this mining analogy that I find useful.
Each hash that the miner computes has a chance to solve a block. Mining is basically like taking a video of yourself flipping 256 coins, trying to get a long string of heads. How long the string of heads needs to be is determined by how many other coin flippers you are competing with. If you get a long enough string of heads, you show the proof (video) and get the reward. Otherwise, you just try again. You essentially start over each time you do a new hash (so billions of times), and changing your block data doesn't make you any more or less unlikely to flip the coins successfully.
Notice how it takes a lot of work to flip the heads successfully (it would take you many tries, where each try is really easy), but very little work to verify that a video of coin flips is legitimate.
-
"It is basically like starting over." Actually, it is indistinguishable from starting over. ;)– Murch ♦Commented Mar 24, 2015 at 10:20
From the original Bitcoin paper:
... we implement the proof-of-work by incrementing a nonce in the block until a value is found that gives the block's hash the required zero bits. Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing all the blocks after it.
SHA256 is a Cryptographic hash function.
Among other traits, it is
- infeasible to change the input of a CHF without changing the hash output
- there is no discernible pattern between the hashes of two differing messages
As the block hash is the product of applying SHA256 to the block data, and the transaction data is represented in the input through the Merkle Root, it is impossible to change even one bit of a block or transaction without starting over from scratch, and there is no headstart by working from a closely related input.