Bitcoin Forum
May 04, 2024, 01:28:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Technical design of Bitcoin  (Read 299 times)
NHalden (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
May 04, 2018, 09:42:26 AM
Merited by ABCbits (1)
 #1

Hello everyone,

I eventually read Satoshi's white paper on bitcoin but I am still asking myself some question about the technical design of the Bitcoin blockchain.
I know the answers must be somewhere in this forum but I could not find them.

Here they are :

- How is possible to find/verify a transaction thanks to the Merkle Root hash ?
- Where are the old blocks and transactions stored ?
- How do the minors decide whether a transaction is legit before adding it to the block ?

Thanks a lot for your answers. 
1714786130
Hero Member
*
Offline Offline

Posts: 1714786130

View Profile Personal Message (Offline)

Ignore
1714786130
Reply with quote  #2

1714786130
Report to moderator
1714786130
Hero Member
*
Offline Offline

Posts: 1714786130

View Profile Personal Message (Offline)

Ignore
1714786130
Reply with quote  #2

1714786130
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714786130
Hero Member
*
Offline Offline

Posts: 1714786130

View Profile Personal Message (Offline)

Ignore
1714786130
Reply with quote  #2

1714786130
Report to moderator
Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
May 04, 2018, 10:45:16 AM
Merited by achow101 (2), ABCbits (1), pebwindkraft (1)
 #2

Quote
How is possible to find/verify a transaction thanks to the Merkle Root hash ?
By constructing a Merkle path to the root node of the Merkle tree.
(The hyperlink has a very good explanation of how it works; in fact the whole book is a good introduction to the nitty-gritty of bitcoin)

Quote
Where are the old blocks and transactions stored ?
Blocks are stored as a LevelDB database  on the harddrives of computers that run the bitcoin client (i.e nodes) in $DATADIR/blocks On computers running Windows 7 and later the full directory path is: C:\Users\YourUserName\Appdata\Roaming\Bitcoin\Blocks
"Transactions" aren't stored individually, but are validated in blocks and stored as blocks.
Unspent Transaction Outputs (UTXOs) which represent the "Bitcoins" that are valid and can be spent.
They are stored as a database in the $DATADIR/chainstate folder.

Quote
How do the miners decide whether a transaction is legit before adding it to the block ?
Miners do not have special power to "decide" which transaction is legitimate or not, instead node software determines that on its own following a set of established protocols
The protocols state that bitcoin is able to act as money eg it must not be able to spend more than it has (i.e Outputs CANNOT be greater than inputs -- except in Coinbase transactions), it must not have been spent elsewhere (i.e it must be included in the UTXO set and the output being referenced shouldn't be present in the blockchain), it must be "mature" (i.e the nLockTime must have elapsed), etc.

If miners create a block that contains at least one  invalid transaction -- coinbase or otherwise -- other nodes in the network will reject the block as invalid and the miner would have wasted his electricity used to create the block.
LUKEEEEE
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
May 05, 2018, 07:06:11 AM
 #3

how mining exactly works?

1. Miner collects txs and makes a block (not final). Each tx is from chainstate. Yes?
2. He checks all scripts are valid. (Signatures or so called simple scripts)
3. Adds block headers such as merkle root etc.., coinbase
4. Starts calculating different hashes with different nonces until he reaches target difficulty.
5. Once hash is found, he submits block to network.
6. Peers do step 2. again. If block is valid, peers add it to blockchain
7. Repeat

Is this correct? Am i missing something?

How does switching tx in block affects miners performance? Is tx with greater fee iniciative to add it in block? Doesnt calculating merkle root take some time?
Xynerise
Sr. Member
****
Offline Offline

Activity: 322
Merit: 363

39twH4PSYgDSzU7sLnRoDfthR6gWYrrPoD


View Profile
May 05, 2018, 09:34:55 AM
Merited by ABCbits (3), achow101 (2)
 #4

how mining exactly works?

1. Miner collects txs and makes a block (not final). Each tx is from chainstate. Yes?
Every transaction is from his node's mempool. Transactions reference UTXOs stored in the chainstate folder of his node.
Quote
2. He checks all scripts are valid. (Signatures or so called simple scripts)
Miner checks the validity of transactions as he adds them to his candidate block.
Quote
How does switching tx in block affects miners performance?
By "switching" I assume you mean shuffling the order of transactions. (CMIIW)

By shuffling the order of transactions in a block, a miner can find the target hash quicker by trying to generate collisions on the last 4 bytes of the Merkle root, which is how covert ASICBoost works
Quote
Is tx with greater fee iniciative to add it in block?
Yes, usually miners sort transactions by the fee paid, so the higher your transaction fee the more likely your transaction will be mined.
Quote
Doesnt calculating merkle root take some time?

No, not really.
The hard part in finding a valid block is finding a block header hash lower than the target hash.
NHalden (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 1


View Profile
May 22, 2018, 08:48:57 AM
 #5

Hello @Xynerise,

I'm really sorry for my late reply.
Thank you very much for your answers. It is enlightening Smiley
pebwindkraft
Sr. Member
****
Offline Offline

Activity: 257
Merit: 343


View Profile
May 24, 2018, 05:57:14 AM
Merited by achow101 (2), ABCbits (1)
 #6

...
Quote
How do the miners decide whether a transaction is legit before adding it to the block ?
Miners do not have special power to "decide" which transaction is legitimate or not, instead node software determines that on its own following a set of established protocols
...
Next to the protocol specification there is also the detailed rules on the wiki:

https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages
Pages: [1]
  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!