0

I found many Blockchain implementations on the web, but are they true Blockchain that can scale? Here we can see that the blockchain is started as an array

var blockchain = [getGenesisBlock()];

Here we can see the same implementation:

constructor() {
        this.chain = [this.createGenesis()];
    }

This article also recommends it:

constructor(genesisNode) {
     this.chain = [this.createGenesisBlock()];

However, are any of these implementations ready to scale?

Technically, according to maerics,

the maximum length of an array according to the ECMA-262 5th Edition specification is bound by an unsigned 32-bit integer due to the ToUint32 abstract operation, so the longest possible array could have 232-1 = 4,294,967,295 = 4.29 billion elements.

The size is not a problem. Ethereum has used'only' 7 millions blocks, Bitcoin 'only' 500k, therefore there is enough space for the future. The real problem that I'm thinking is, how long would it take to read the last element of the array and would this be scalable? In blockchain, the 'Block' structure always needs to read the hash of the last block, therefore I assume that as it scales it takes longer and longer to do it.

What would Bitcoin and/or Ethereum do if their Blockchain array of Blocks doesn't have any more space to store blocks? Would the Blockchain just end there?

Sophie259
  • 93
  • 8
  • 2
    It sounds like your concern is that looking up `arr[3]` takes less time than something like `arr[123456]`? Pretty sure lookup time is pretty constant, no matter the property name being looked up. It's not an `O(N)` operation – CertainPerformance Jan 08 '19 at 02:46
  • 1
    The implementations you're looking at are all toy implementations. They're not at all similar to the code used in production blockchains. One notable difference is that the implementations you're looking at don't write any data to disk. – user94559 Jan 08 '19 at 03:02
  • 1
    Thanks everyone. I didn't know they were 'toy' implementations and I took them for 'professional implementations'. I also took all courses on Udemy regarding to Blockchain and all of them have the same issue! – Sophie259 Jan 08 '19 at 19:44

1 Answers1

1
  • The scalability problem comes from the cost of validating transactions and reaching consensus between the nodes. So it's not the cost of accessing a certain block that's problematic here.
  • Blockchains are not arrays. Conceptually think of it more like a Linked List
  • There is no limit to the number of blocks (there is one for the number of coins though). The space to store those blocks is also not limited.

To answer the question

Yes, all the implementations given in the question are incorrect/insufficient for a blockchain to work. For some implementations you can refer to the Bitcoin's repository or Ethereum's

molamk
  • 4,076
  • 1
  • 13
  • 22