Bitcoin Forum
May 07, 2024, 07:01:24 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Doubt on double spending  (Read 255 times)
pawanjain (OP)
Hero Member
*****
Offline Offline

Activity: 2674
Merit: 713


Nothing lasts forever


View Profile
February 26, 2020, 04:38:55 PM
Merited by NeuroticFish (1), TECSHARE (1), ABCbits (1)
 #1

I started learning more technical aspects of bitcoin lately and so I started reading it's whitepaper. I have a doubt in the 'reclaiming the disk space' section from the bitcoin whitepaper.

Quote
Once the latest transaction in a coin is buried under enough blocks, the spent transactions before
it can be discarded to save disk space. To facilitate this without breaking the block's hash,
transactions are hashed in a Merkle Tree [7][2][5], with only the root included in the block's hash.
Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do
not need to be stored.

As per the above, it is enough to store the block header and discard all the transactions inside the block by just keeping the root hash.

Now assume I am trying to double spend a transaction which was previously mined and buried under many lateral blocks.
How will the miner validate that the transaction is not being double spent since the miner will only be validating the block header and not all the transactions inside it?

Could someone clear my understanding ?

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits.
..........UNLEASH..........
THE ULTIMATE
GAMING EXPERIENCE
DUELBITS
FANTASY
SPORTS
████▄▄█████▄▄
░▄████
███████████▄
▐███
███████████████▄
███
████████████████
███
████████████████▌
███
██████████████████
████████████████▀▀▀
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
.
▬▬
VS
▬▬
████▄▄▄█████▄▄▄
░▄████████████████▄
▐██████████████████▄
████████████████████
████████████████████▌
█████████████████████
███████████████████
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
/// PLAY FOR  FREE  ///
WIN FOR REAL
..PLAY NOW..
1715065284
Hero Member
*
Offline Offline

Posts: 1715065284

View Profile Personal Message (Offline)

Ignore
1715065284
Reply with quote  #2

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

Posts: 1715065284

View Profile Personal Message (Offline)

Ignore
1715065284
Reply with quote  #2

1715065284
Report to moderator
1715065284
Hero Member
*
Offline Offline

Posts: 1715065284

View Profile Personal Message (Offline)

Ignore
1715065284
Reply with quote  #2

1715065284
Report to moderator
1715065284
Hero Member
*
Offline Offline

Posts: 1715065284

View Profile Personal Message (Offline)

Ignore
1715065284
Reply with quote  #2

1715065284
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6595


Just writing some code


View Profile WWW
February 26, 2020, 06:08:46 PM
Merited by suchmoon (7), Foxpup (4), bones261 (4), EFS (3), bitmover (3), hugeblack (2), Halab (2), fillippone (2), NeuroticFish (1), ABCbits (1)
 #2

This method of pruning was never implemented. Bitcoin Core uses a different method for pruning that is more efficient.

With this method of pruning, parts of the merkle tree is still stored, not just the root hash. It's more than just the block header. As transactions get spent, their txids get pruned from the merkle tree and the intermediate merkle branch hashes are stored. So if you were to perform a double spend, looking up the input would fail either because the txid is no longer stored as it has been hashed with others into a merkle branch, or it is still there but the particular output you are spending has been marked as spent. Either way, it is still safe.

But this is not as efficient and harder to reason about than how Bitcoin Core does pruning today. Bitcoin Core today builds a separate database of just the UTXOs. As a block is processed, all of the transactions are verified and the UTXO set is updated. When a block is done processing, it actually doesn't need to keep the block around because the UTXO set is what determines the chain state. So in Bitcoin Core, after a block is deep enough, its transaction data is discarded in entirety. The block header is still kept in another database, but the block data itself is deleted. This is safe because all of the important information, the UTXOs, are stored separately in the UTXO database. So if a double spend were to occur with a transaction that has been pruned, the output being spent would not exist in the UTXO database and thus that double spend is invalid.

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!