Is the asymptotic performance of bitcoin O(n) relative to the block chain length?

1

If I want the latest information (ie. account balance) of account A do I have to traverse the entire block chain to get that info or is the relevant information store in the latest block or some other companion data structure?

If I have to traverse the entire block chain, is there going to be scalable problem as block chain grows?

Jal

Posted 2017-08-02T20:20:16.170

Reputation: 113

2

Possible duplicate of How is a wallet's balance computed?

alcio 2017-08-03T09:18:29.473

I'm voting to leave open. While the proposed duplicate is closely related it doesn't comprehensively address scalability or complexity of calculating the balances.Murch 2017-08-05T20:59:10.740

Answers

0

You have to traverse entire blockchain. At the lowest bitcoin level there is no accounts, there is concept of "unspent output". Bitсoin clients (excluding light versions) should support index of all transactions with unspent output, in order to validate transactions quickly. That means bitcoin clients doesn't actually scan entire blockchain, they just know balance of all accounts.

You are right, it can cause scalability problem, if bitcoin become more valuable, and count of transactions with unspent output will grow very quickly.

Zergatul

Posted 2017-08-02T20:20:16.170

Reputation: 948

the index part sounds nice but could also be a bottle neck right? there is about 1 billion credit cards in use right now, assuming there is 1 billion bitcoin user and each meta data cost 1kb that is 1 terabyte of index. Is there propose solution to solve these scalability problem?Jal 2017-08-02T21:53:29.960

Bitcoin wasn't designed to replace existing credit cards. It was designed as decentralized, and any user with PC should be able to run full bitcoin node. But even now it requires very good PC with quick hard drive and good internet connection. So, at the current time and current technology level bitcoin network cannot handle 1 billion active users. I don't like when people compare bitcoin to Visa/Mastercard and other very high load payment systems.Zergatul 2017-08-02T22:00:25.493

ah I see, sorry for the comparison, its just that I see alot of argument on how bitcoin can replace fiat and facilitate machine to machine transaction, so I wanted to understand the fundamental infrastructure a bit more.Jal 2017-08-02T22:04:32.583

Bitcoin Core does not have an index of transactions anymore since 0.8. Instead, there is a database with just the unspent outputs (not an index into the chain, just a copy of all outputs). During validation, the blocks and transactions aren't accessed anymore - only the database is consulted and updated.Pieter Wuille 2017-08-03T05:42:37.793

@PieterWuille That's is what I meant, maybe it wasn't clear. In terms of relative databases, we would say, there is 2 tables, one is blockchain, second is unspent outputs. Index on top of second allows to validate transations in O(log m), where m is number of unspent outputsZergatul 2017-08-03T08:10:30.563