Hello, i had a question, it's about work process of a miner,
I was wondering what does a miner do during minig process, 1. It first finds a random number smaller than network target, broadcast it's wining to other nodes then adds transactions from pool or 2. It first adds transactions to the block until finds a valid hash smaller than network target and broadcast ot other nodes ?
Which information is neede as input of hash function (specially Nonce) ?
What other miners do in the next 10 minute until finding new hash puzzel?
Just to complement previous answers
You are basically asking how proof of work(pow) work.
I made a brief summary about it here:
https://bitcointalksearch.org/topic/summary-of-proof-of-work-3317586BlockchainThe idea proposed by Satoshi is to register transactions on a block. When the proof of work solution for that block is found, it is hashed. Each block includes the previous block’s hash, forming a chain of blocks (blockchain), and each additional block reinforcing the ones before it.
Because of that process, if any transaction in a past block is changed the output hash will be different.
When you make a Bitcoin transaction and you see that you have 5 confirmations, that means that 5 blocks were mined after that transaction. A transaction with 6 confirmations is considered irreversible.
Proof of WorkIn the Blockchain, all transactions are publicly announced to all nodes, as there is no central authority who validate transactions.
Proof of Work is an algorithm that rewards participants who solve a cryptographic puzzle in order to validate transactions and create new blocks (this process in known as mining).
This puzzle consists in scanning for a value (called Nonce) that when hashed together with thr block data, the hash begins with a number of zeros.
In this
website you can see how this process works. You can try to find a Nonce that when hashed generates a hash that start with 0000 on your own. You will see that it is hard, unless you are very lucky. And you are going to be lucky twice in row, if you do go to a casino or something like that lol.
The difficult in finding that nonce increases exponentially as more zeros are required by the block. Difficult is adjusted every 2016 blocks, based on the average hashrate of those past 2016 blocks, so that 2016 blocks are mined every two weeks. (So a block is mined every 10 minutes)
Miners only get their reward if they are mining the longest chain, as it has the greatest processing power invested. If the honest nodes control the majority processing power, the honest chain will always be the longest and will outpace attacker’s chain.
To modify a past transaction the attacker would have to redo the PoW of the block and all subsequent blocks, and outpace the honest chain. For this to happen, the attacker’s would need more processing power than the honest chain, also known as 51% attack.
The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power.
Source: bitcoin whitepaper. Images from:
https://nakamotoinstitute.org/bitcoin/