Bitcoin Forum
November 02, 2024, 05:22:56 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Relationship between transaction confirmations and miners  (Read 1192 times)
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 20, 2013, 08:59:35 PM
 #1

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...)
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 12:10:07 AM
 #2

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.
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 21, 2013, 06:55:52 AM
 #3

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.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 07:47:26 AM
 #4

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.
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 21, 2013, 03:25:20 PM
 #5

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?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 03:41:34 PM
 #6

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.
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 21, 2013, 04:02:20 PM
 #7

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?

DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 04:17:37 PM
 #8

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.
stslimited
Hero Member
*****
Offline Offline

Activity: 546
Merit: 500


View Profile
April 21, 2013, 04:34:23 PM
 #9

anyone "mining" is confirming transactions


mining is a misnomer
WuLabsWuTecH
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
April 21, 2013, 04:35:00 PM
 #10

I'm bookmarking this!  This was a really useful explanation of the way mining works!  Better even than the bitcoin wiki!
mdszy
Newbie
*
Offline Offline

Activity: 12
Merit: 0


View Profile
April 21, 2013, 04:40:39 PM
 #11

Yes very interesting and I am bookmarking it as well.
3Dfilament
Member
**
Offline Offline

Activity: 92
Merit: 10



View Profile
April 21, 2013, 05:25:59 PM
 #12

So in some layman's terms, the transactions of coin that occur are verified and driven by mining/transaction verification activity and for that a reward is offered, so in this respect both the creation of the coin currency and it's verification in transactions are the coin more so than "what is a coin". Rather than being an expense of doing business in bitcoin, the transaction verification, the mining, is the profitable part of interacting with bitcoin/litecoin, etc ..., thus being a miner, is "being a bitcoin".
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 21, 2013, 06:57:06 PM
 #13

Why the size of a transaction is not a predefined size? Isn't a transaction's content is a pair of wallets and the sum transferred?
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 21, 2013, 07:08:00 PM
 #14

Another question. The SHA256 hash can run on any size of data since it divids the data into 512 byte blocks.
What exactly is the input to the SHA256 hashing algorithm? Is it something constant in size? Does the hash rate have any correlation to the  algorithm  e.g., the rare will be twice lower if SHA512 was used?
kokjo
Legendary
*
Offline Offline

Activity: 1050
Merit: 1000

You are WRONG!


View Profile
April 21, 2013, 07:11:11 PM
 #15

Another question. The SHA256 hash can run on any size of data since it divids the data into 512 byte blocks.
What exactly is the input to the SHA256 hashing algorithm? Is it something constant in size? Does the hash rate have any correlation to the  algorithm  e.g., the rare will be twice lower if SHA512 was used?
we are not your brain. go search the fucking web.
http://en.wikipedia.org/wiki/SHA-2
https://en.bitcoin.it/wiki/Main_Page
http://bitcoin.org/bitcoin.pdf

"The whole problem with the world is that fools and fanatics are always so certain of themselves and wiser people so full of doubts." -Bertrand Russell
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 11:32:32 PM
 #16

Why the size of a transaction is not a predefined size?

Transactions can have multiple inputs and multiple outputs. The size of the transaction is largely dependent upon the number of each.

Isn't a transaction's content is a pair of wallets and the sum transferred?

No. That isn't how Bitcoin transactions work at all. It would probably be a really good idea for you to take a look at the bitcoin white paper written by Satoshi Nakamoto. Many of your questions are explained there.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 21, 2013, 11:48:21 PM
 #17

What exactly is the input to the SHA256 hashing algorithm?

I'm pretty sure I already explained that the input is the header of the block.

Is it something constant in size?

I don't remember if there is any variability to the size of a block header, but if there is it isn't more than a few bytes.

Does the hash rate have any correlation to the  algorithm  e.g., the rare will be twice lower if SHA512 was used?

The current protocol specifies that SHA-256 is to be used. If SHA-512 were used, no peers would accept the blocks as valid. It is impossible to predict what the current difficulty would be, since we don't know how much hashing power the network would be providing today under those altered circumstances. Regardless, the protocol would adjust the difficulty to ensure an average of ten minutes per block no matter how fast (or slow) the hashes are generated.
Nissi
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
April 22, 2013, 12:18:36 AM
 #18

Does anyone have a good (Concise) explanation of the BTC and/or LTC hashing algorithms and how confirmations work... I would like to explain this to a sceptic but cant find succinct resources...
szangvil (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 22, 2013, 06:08:25 AM
 #19


kokjo, thank you for the fucking links Wink I did read those, but I am a slow learner i.e., a NEWBIE!
DannyHamilton
Legendary
*
Offline Offline

Activity: 3472
Merit: 4801



View Profile
April 22, 2013, 06:52:30 AM
 #20

Does anyone have a good (Concise) explanation of the BTC and/or LTC hashing algorithms and how confirmations work... I would like to explain this to a sceptic but cant find succinct resources...

I'd suggest you not waste your time on a skeptic.  If they aren't curious or interested, then they aren't going to accept anything you say about it.

On the other hand if they are curious or interested, then I'd send them here to bitcointalk.org where any questions or concerns they may have can be addressed.

As far as I know there isn't a "concise" explanation of the SHA-256 hashing process. It is a rather complex algorithm.  About the best I've seen is the wikipedia page:

http://en.wikipedia.org/wiki/Sha-256

As for how confirmations work, your best bet is to make sure that you understand the process well enough to explain it yourself.  That way when the skeptic responds with questions, you'll be ready to answer, and you'll be able to adjust your presentation to their particular level of understanding.  Is there something in this thread that isn't clear?  This post from earlier in this discussion thread is about as concise as I can get it:

- snip -

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.

The block that contains a transaction is the first confirmation for that transaction.  After that every new block added to the blockchain is another confirmation.
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!