Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: twally on September 04, 2020, 05:30:54 AM



Title: Help for someone new
Post by: twally on September 04, 2020, 05:30:54 AM
Hi all

This is pretty basic, so I apologise about that but it is something I have failed to find an answer to so far (probably just looking in the wrong places.)

Anyway, my question is this, at what exact stage does a new block get formed in the Bitcoin blockchain and how? In my research it seemed to say that a new block is formed once a miner solves the required "puzzle". From what I read, the puzzle is the first solution to a specific SHA-256 hash of the current blocks contents plus a nonce that generates a specific number of leading zeros. I understood once that is solved, a new block is created, the successful miner is rewarded and new transactions will then be written to the new block. That all seems fine (as long as my understanding is correct.)

What I do not understand in the above process, the hashing of the current block surely only works if the data inside the block is complete and unchanging. If the data is changing the data hash would keep changing. But surely if a new transaction is made, new data is being added to the block and that data is causing the hash to change.

Can anyone please set me straight on what I have wrong or am missing.

Thanks  


Title: Re: Help for someone new
Post by: pooya87 on September 04, 2020, 05:41:52 AM
you are slightly off.

miner first constructs a new block which includes creating the first transaction (aka coinbase tx), including as many transactions as they can find and fits in the block (along other checks such as sigopcount) and building its header (version, previous block hash, merkle root hash which is constructed from all those transactions, target, time and nonce).

then miner starts changing nonce (inside header) and computing the hash of this header and each time comparing it as an integer with the target (not just leading zeros but as in bigint1 <= bigint2) meanwhile its node keeps an eye out for others solving the same block and if they did it will inform the miner to give up and work on the next one.
if they go through all 32 bits of nonce and didn't find the appropriate hash then they change the transactions inside their block to change all hashes they are about to compute and start from nonce 0 again. and repeat this until they find the desired hash. this change could be swapping some transactions (like with txs paying higher fee) or simply changing the coinbase tx hash by changing a variable inside its script usually referred to as extraNonce.


Title: Re: Help for someone new
Post by: HCP on September 04, 2020, 10:03:56 PM
What I do not understand in the above process, the hashing of the current block surely only works if the data inside the block is complete and unchanging. If the data is changing the data hash would keep changing. But surely if a new transaction is made, new data is being added to the block and that data is causing the hash to change.
Miners won't necessarily "care" about any new transaction being made... Especially when there are more transactions in their mempool than can actually "fit" in a block. Generally, they'll only try and include it if the money to made from including it, is worth more than the "cost" of including it.

This is why you often need to pay $$$ in fees if you want "next block"... it makes your transaction more "attractive" to the miners and gives them an incentive to include it... whereas, if you pay the minimum 1 sat/vbyte... you end up in the big pile at the bottom of the mempool with the other 10,000+ transactions waiting for days :P


Title: Re: Help for someone new
Post by: twally on September 06, 2020, 07:19:56 AM
Thank you both very much for replying. The whole mining process and block construction looks somewhat more complicated than my simple understanding but you have both given me areas to investigate further for my understanding. Thank you again, it is much appreciated.


Title: Re: Help for someone new
Post by: bob123 on September 11, 2020, 06:07:30 PM
want to accept bitcoin what are top sites to join

http://manashost.com


Ye sure..

Code:
Domain Name: MANASHOST.COM
Registry Domain ID: 2550514742_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.syrahost.com
Registrar URL: http://www.crazydomains.com
Updated Date: 2020-08-30T18:27:12Z
Creation Date: 2020-08-03T00:00:00Z


I would recommend to not trust newbies advertising a completely new website.
Visit / use it at your own risk. You have been warned.

When using bitcoin services, stick to reputable and trusted ones.