Search code examples
network-programmingblockchainsmartcontractsbitcoincryptocurrency

Where and how does blockchain gets stored?


I'm trying to visualize the concept of blockchain with real-world example. So let's say I want to purchase bitcoin. As the concept of blockchain is decentralization, the transaction will be hashed and stored in "every node" within the "network". Here is where I have question on.

  • From what I understand so far, "every node" is basically every computer within the blockchain network. So that means it must be stored somewhere in my computer locally right? So where exactly will it be stored and how does it ensure that my computer is part of the "network"? Is there some kind of software I need to download and execute to be part of the "network" or something?

  • As every time there's a new transaction happening in the network, my blockchain stored in my computer should update its data with new transaction. As more and more transaction happens, wouldn't the size of my blockchain data also increase? What if I only have limited storage?

  • What if I'm using a mediator like Coinbase? And let's assume majority of people purchasing cryptocurrency are using Coinbase. Doesn't this mean the blockchain is no longer decentralized due to the fact that one or couple of mediators own all the data?

  • What if there are only 2 nodes for a blockchain (me and my friend maybe)? Does this mean if I hack other person's computer and change its value, there's no ways to verify data authenticity? Isn't this similar to how smart contracts work (network with very few nodes)?


Solution

  • it must be stored somewhere in my computer locally right?

    Correct. In order to become a peer in the Bitcoin network, you need to run a Bitcoin client software. For example the original bitcoind. Its data, including the raw blockchain database, is stored in a folder on your drive - either the default location or configured.

    What if I only have limited storage?

    Then your client software won't be able to sync any longer and will stay out of sync with the rest of the network. Depending on the specific software, you might still be able to see your transactions before this event, might be able to sign and broadcast transactions, but won't know (from within the software) if they were accepted by the network or not. E.g. because you might be trying to spend more than you have at the moment, but the wallet is not reflecting your last transactions and current balance as it's not synced.

    What if I'm using a mediator like Coinbase?

    The amount of decentralization might be also perceived on a scale. In that case, the more people use custodial wallets such as Coinbase, the less decentralized is the network. But that might not be binary - "decentralized or not" - just "less decentralized than 100% users running their own node".

    What if there are only 2 nodes for a blockchain

    This is called the 51% attack. In this scenario of just 2 nodes in the network, you might be able to successfully perform the attack.

    Isn't this similar to how smart contracts work

    Bitcoin has a very limited possibility of scripting transactions - its scripting language is not Turing complete and is practically used "just" for multisig transactions. So I'm assuming you mean smart contracts on Ethereum and other platforms. These smart contracts produce a list of state changes (e.g. balance of an address or storage value of a smart contract) and this process and its result is validated by other peers in the network as well (again if it's produced in accordance with rules of the network). So smart contracts are not really related to the 51% attack.