Pages:
Author

Topic: Relationship between transaction confirmations and miners - page 2. (Read 1190 times)

legendary
Activity: 3472
Merit: 4794
The hash rate means how many times this process can be be repeated in a second?

Yes. The hash rate is an indication of how many times per second this process can be repeated.

So why is it so hard to calculate a new block? Is it due to the number of times this has to be repeated? Why does it take so much computing power?

The protocol is designed to set a target value for the hash that will take on average about ten minutes for the entire network to find.

Think about it this way:

I set a target difficulty of 5.

You roll a 6-sided dice until you get a number less than or equal to the target.

Now I set a target difficulty of 3.

You do the same (roll a 6-sided dice until you get a number less than or equal to the target).

Now I set a target difficulty of 1.

You do the same (roll a 6-sided dice until you get a number less than or equal to the target).

You can picture in your mind why the target difficulty of 3 is likely to take longer to get than the target difficulty of 5?  And why the target difficulty of 1 will take even longer?

In the case of a SHA-256 hash, the difficulty (and values being generated) are not somewhere between 1 and 6, they are somewhere between 0 and 1.16 x 1077

How many unconfirmed transactions can be selected?

There is currently a limit on the maximum blocksize of 1 megabyte.  The number of transactions that will fit in that size depends on the size of the transactions selected.  As such, there is an incentive for the miner to choose the transactions that offer the highest fee/size ratio.

Does it affect the hash rate? I mean, if the computer selects 1 transaction or 100, does it have any meaning?

No, the number of transactions has a minimal affect on the time required to create, solve, and transmit a block.  The financial incentive to include transactions so you can claim the transaction fee, generally outweighs any miniscule incentive there may be to exclude transactions.
newbie
Activity: 35
Merit: 0
So why is it so hard to calculate a new block? Why does it take so much computing power? Is it due to the number of times this has to be repeated? The hash rate means how many times this process can be be repeated in a second?
How many unconfirmed transactions can be selected? Does it affect the hash rate? I mean, if the computer selects 1 transaction or 100, does it have any meaning?

legendary
Activity: 3472
Merit: 4794
Thank you for the detailed explanation!

Now, what exactly happens during mining? The computer generates random data, calculate its hash and if the hash is valid, the generated data is considered a valid block?

The computer selects a set of unconfirmed transactions.

A block header for that set of transactions is created

A double SHA-256 hash of the block header is calculated.

If the hash value is less than the target difficulty required by the protocol, the header and set of transactions are considered a valid block.

If the hash value is not less than the target difficulty, a number in the header called a "nonce" is incremented.

A double SHA-256 hash of the block header is calculated.

If the hash value is less than the target difficulty required by the protocol, the header and set of transactions are considered a valid block.

The nonce increment, double hash, and compare steps are repeated as fast as possible until either:

  • A hash value less than the target difficulty is found
  • A valid block is received from a peer

In either case the valid block (received or created) is added to the local copy of the blockchain and broadcast to all connected peers.

The process then begins all over again with a new set of unconfirmed transactions.
newbie
Activity: 35
Merit: 0
Thank you for the detailed explanation!

Now, what exactly happens during mining? The computer generates random data, calculate its hash and if the hash is valid, the generated data is considered a valid block?
legendary
Activity: 3472
Merit: 4794
So how exactly a block is added to the chain? Why some blocks have very few transactions while others have a many? What does it mean that "a new block is discovered"?
I still did not understand the relationship between a miner and transaction confirmation.

When you send a transaction you broadcast it to any peers you are connected to.  Those peers validate the transaction and then re-broadcast it to any peers they are connected to.  Those peers validate the transaction and re-broadcast it, and so on.  Every peer that hears about the transaction keeps track of it in a memory pool so they can transmit it to any new peers that haven't heard about it yet.

Eventually some of the peers that hear about the transaction are miners.  Miners choose unconfirmed transactions from the list they have in memory of all currently unconfirmed transactions.  The protocol allows miners can use any criteria they want for deciding which transactions to choose.  They can choose just a few if they want, they can choose enough to completely fill a block (there is currently a 1 megabyte limit to the maximum size of a block). The miner also creates a special transaction called a "coinbase" transaction.  The coinbase transaction pays the block reward to an address (or addresses) of the miner's choosing.  This block reward is allowed by the protocol to be equal to the sum of the block subsidy (currently 25 BTC) and all transaction fees from all transactions that the miner has selected
for the block.

Once the miner has determined which of the unconfirmed transactions they want to include in the block they are creating, they generate a special hash of the transactions (called a "merkle root"), adn include it in a block header that they create.  If any transaction changes (or the order of the transactions changes), then the merkle root will be an entirely different value.  As such, the merkle root can later be used by any/every peer to verify that the merkle root in the block header truly represents the exact list of transactions in the block.  There are various other attributes that are stored in the block header that the miner is creating (such as a date/time stamp, the hash of the most recently solved block on the network, the block size, etc).

Once the miner has finished creating a block header they calculate a pair of SHA-256 hashes of the header and compare the result to the current difficulty target determined by the protocol.  If the value of the hash is low enough then the block is "solved".  If it is not low enough, then the miner increments a special field in the block header called a nonce (the only purpose of which is to provide a fast easy way for the miner to alter the contents of the header so that a new hash value will result).  The miner then calculates the pair of SHA-256 hashes of the block header and compares the resulting value to the difficulty target again.  The miner repeats this process until they either find a hash with a low enough value, or receive a newly solved block relayed to them from a peer.

If they receive a newly solved block from a peer, they check all the values of the block to ensure it is valid. Then they add it to their own copy of the blockchain, remove from their memory all the previously unconfirmed transactions that are in the block they just received, discard the block they've been working on, and begin working on a new block per the steps outlined above.

If they find a hash of a low enough value before they receive a newly solved block from a peer, then they are lucky enough to be the miner that has just solved a new block.  They broadcast the block header and list of transactions to all the peers that they are connected to.  Each peer checks all the values of the block to ensure it is valid. Then they add it to their own copy of the blockchain, remove from their memory all the previously unconfirmed transactions that are in the block that they just received, and re-broadcast the block header and transactions to each peer they are connected to.  This process repeats until all peers on the network have heard about the new block and added it to their own copy of the blockchain.

The first confirmation on a transaction simply means that a miner has chosen the transaction for a block they were working on and successfully "solved" the block by finding a nonce that results in a hash of low enough value and broadcasting it.

Any change to the contents of a block will result in different hash value for the block.  This means that nobody can convince any peer on the network to change the contents of a block without first going through the effort of finding a hash of low enough value to be considered "solved".  This is a process that takes the entire hashing power of the entire bitcoin network approximately 10 minutes on average to find.  Meanwhile the rest of the network is busy working on the next block.  Since the hash value of a block is always included in the following block, someone attempting to modify a transaction in an older block must recreate (and re-solve) every single block that has occurred since, and they have to do it faster than the rest of the network is solving blocks or they'll never catch up.

Therefore, each new block that is added to the blockchain makes it exponentially more difficult for an attack to go back and modify a transaction that was added to an older block.  For this reason every new block added to the blockchain is considered to be an additional "confirmation" on top of every transaction already in the blockchain.

TLDR;
Miners select transactions and create a set of them which is then called a "block".
Miners do some work that requires significant processing power to come up with a value that proves they did the work.
Miners then broadcast the selected transactions and the proof that they did the work.
If a transaction is in the set selected by the miner that successfully finds the value, then the transaction is considered "confirmed".
This proof of work makes it difficult for an attacker to modify the transaction history.
newbie
Activity: 35
Merit: 0
So how exactly a block is added to the chain? Why some blocks have very few transactions while others have a many? What does it mean that "a new block is discovered"?
I still did not understand the relationship between a miner and transaction confirmation.
legendary
Activity: 3472
Merit: 4794
I did some reading but I still can't grasp the relationship between transaction confirmations and miners... What is a confirmation exactly?

The first confirmation is an indication that the transaction has been added to the blockchain.  Every confirmation after that is an indication that another block has been added to the blockchain.

I got it that each transaction is written to the blockchain to the current block and I know that miners generate new blocks. But after it is written, can it be removed if it's not valid?

It can't be added to the blockchain in the first place if it's not valid.

Where exactly in the blockchain does it say if each transaction is confirmed?

It doesn't say if it's confirmed.  "Confirmed" is just a way of saying that it is in the blockchain.

When a new block is 'found' by the miners, who checks if its valid or not?

Every single full peer on the network

who/what decides to add it to the block chain?

Every peer decides for itself if it will add the block to its own blockchain and relay it.

Do miners generate empty blocks which transactions are later appended to?

No. A block is a collection of transactions.  It's not possible to change a block once it has been "solved" and broadcast.
newbie
Activity: 35
Merit: 0
I did some reading but I still can't grasp the relationship between transaction confirmations and miners... What is a confirmation exactly?
I got it that each transaction is written to the blockchain to the current block and I know that miners generate new blocks. But after it is written, can it be removed if it's not valid? Where exactly in the blockchain does it say if each transaction is confirmed?
When a new block is 'found' by the miners, who checks if its valid or not? who/what decides to add it to the block chain? Do miners generate empty blocks which transactions are later appended to?

Would be happy to get a good explanation (since what I read in the wiki, only raised more questions...)
Pages:
Jump to: