Bitcoin Forum
May 08, 2024, 07:20:52 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How does bitcoin store the utxo set?  (Read 209 times)
Anonymous Kid (OP)
Member
**
Offline Offline

Activity: 183
Merit: 25


View Profile
November 03, 2018, 03:17:53 PM
 #1

IS the utxo set stored independently from the block set?

so for each block that comes in you store;
block (Key: BlockHash)
then extract each tx and store;
tx (Key: TxHash)

or is it all stored inside blocks? how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715152852
Hero Member
*
Offline Offline

Posts: 1715152852

View Profile Personal Message (Offline)

Ignore
1715152852
Reply with quote  #2

1715152852
Report to moderator
1715152852
Hero Member
*
Offline Offline

Posts: 1715152852

View Profile Personal Message (Offline)

Ignore
1715152852
Reply with quote  #2

1715152852
Report to moderator
1715152852
Hero Member
*
Offline Offline

Posts: 1715152852

View Profile Personal Message (Offline)

Ignore
1715152852
Reply with quote  #2

1715152852
Report to moderator
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7486


Crypto Swap Exchange


View Profile
November 03, 2018, 03:26:22 PM
Merited by arulbero (1)
 #2

IS the utxo set stored independently from the block set?

Yes. It's called chainstate, few call it UTXO set.

so for each block that comes in you store;
block (Key: BlockHash)
then extract each tx and store;
tx (Key: TxHash)

AFAIK it's true, chainstate uses key/value pair method which contain TX hash and block hash.

how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?

By access chainstate, not access blocks

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Anonymous Kid (OP)
Member
**
Offline Offline

Activity: 183
Merit: 25


View Profile
November 03, 2018, 03:30:42 PM
 #3

IS the utxo set stored independently from the block set?

Yes. It's called chainstate, few call it UTXO set.

how does bitcoin search the db for a given utxo to verify a transaction is legitimate if it just stores the blocks?

By access chainstate, not access blocks

Okay thanks. This seems like something that could be easily optimised no? Instead of having a tonne of duplicated data that is both in the utxo db and blocks db. You could have each block, and each tx that tries to spend utxo's (instead of referencing a previous tx hash), references a block number and position in the block of the tx he is trying to spend. then the client finds the tx and position of the utxo inside the tx and checks the lockscript/unlockscript.
bones261
Legendary
*
Offline Offline

Activity: 1806
Merit: 1827



View Profile
November 03, 2018, 03:56:04 PM
 #4


Okay thanks. This seems like something that could be easily optimised no? Instead of having a tonne of duplicated data that is both in the utxo db and blocks db. You could have each block, and each tx that tries to spend utxo's (instead of referencing a previous tx hash), references a block number and position in the block of the tx he is trying to spend. then the client finds the tx and position of the utxo inside the tx and checks the lockscript/unlockscript.

The chainstate database is the optimization. You can now run a pruned node that only stores a few hundred blocks and with chainstate you still have a fully validating node.
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!