A blockchain is a distributed database that is shared among the nodes of a computer network. But what exactly is a node?
From a technical perspective, a node is a point of intersection within a data communication network. A blockchain node is a server or a computer that runs a blockchain network software. These computers run a code that enables them to connect and share information with each other. This information can take the form of transactions, data, documents, cryptocurrencies, etc.
Blockchain is a chain of blocks and each block consists of three major elements: a previous block hash, a log of transactions and a block hash. For a new block to be added to the blockchain, its transactions need to be evaluated and confirmed by a network of nodes or simply individual computers.
For the purpose of this article, we will take a look at the Bitcoin blockchain and its network of nodes, which comprises hundreds and thousands of computers around the world.
Why is blockchain so secure?
Interference with a blockchain is almost impossible due to its core characteristics
- Block hash
A block hash is a reference number that identifies a block in the blockchain. It’s like a fingerprint, completely unique. If someone was trying to tamper with the information inside a block, the hash would change and the entire chain would break.
However, the computing power is becoming stronger and faster producing hundreds or thousands of hashes per second. In theory, a computer could temper with a block and recalculate hashes of all other blocks to make them seem valid again. Here is where the Proof of Work concept comes in.
- Proof of Work (PoW)
The PoW mechanism slows down the creation of new blocks. With Bitcoin, the PoW calculation of each new block takes approximately 10 minutes. If somebody tampered with one block, they would need to alter all other blocks as well and each one of them would take around 10 minutes, considerably slowing down anyone trying to interfere with the validity of a block.
- Distribution among nodes
Blockchain is a peer-to-peer network which means that each participant or node has the entire blockchain stored on his computer. Once a new block is created, it gets sent to all blockchain nodes. Once all of them confirm that the block is valid, meaning that it hasn’t been tampered with, they all add the block to their local copy of blockchain. If they conclude that a block has been tampered with, they reject it. The agreement around the block validity forms a network consensus.
If someone wanted to interfere with a block, they would need to recalculate all block hashes, do the necessary proof of work for all blocks and take control over at least 50 percent of the peer-to-peer network to gain consensus.
This intricate system forms the foundation of blockchain security. Overwhelming, right?
How does a new node join the network?
A new node first connects to its first peer. Once the peer verifies the new node, it establishes a connection and shares information such as a list of other peers, a local copy of the blockchain, and any missing blocks.
Types of nodes
We differentiate between full nodes and lightweight nodes. They can perform four main functions.
- Routing: nodes discover and connect with other peers in the network. They also validate and propagate new blocks in the blockchain.
- Storage: nodes store a local copy of the entire blockchain and can validate blocks independently.
- Mining or validating: nodes verify transactions and add new blocks to the blockchain.
- Wallet Services: nodes verify transactions without having to download the entire blockchain.
Full nodes and miners
A full node is a computer storing a local copy of the blockchain (for reference, the current size of the Bitcoin blockchain is approximately 400 gigabytes). It also provides routing services. A full node autonomously verifies new blocks and adds them to the blockchain.
Full nodes can also function as miners, but while all miners are also full nodes, not all full nodes need to be miners.
A miner first needs to set up a full node and then add mining functionality on top of it. Mining nodes need to run the mining software and add transactions to the network. They do not necessarily need to provide storage for the local copy of the blockchain, because they can simply join a mining pool and use their blockchain storage services instead.
Full nodes really only need an appropriate amount of storage and memory to store the blockchain and verify new blocks. On the other hand, miners require enormous amounts of computing power and consume a lot of electricity. Miners also get compensated with newly mined bitcoin, while full nodes don’t.
Blockchains running on the basis of the proof of stake concept benefit from the so-called validator nodes which are similar to the PoW mining nodes to a certain degree.
Lightweight nodes are all devices that run any kind of software necessary to handle cryptocurrencies, eg. crypto wallets. They can provide network routing and wallet services. Light nodes don’t need to store the entire blockchain copy, but only parts of it, necessary to run their desired operations, like sending and receiving funds. They can run on low-power devices.
Lightweight nodes access the real-time blockchain status through their connection to the full nodes.
Some blockchains also use masternodes. These tend to be more powerful than regular full nodes. On top of other full node functionalities, masternodes assist with other operations on the blockchain, such as managing voting events, providing protocol execution, and enforcing the rules of the respective blockchain.
Running a masternode requires more technical knowledge and consumes a lot more resources (energy, uptime, maintenance, storage space, and memory). Participants also need to stake a lot of coins as collateral, but they get compensated by a share of the block rewards.
One of the best known blockchains with built-in masternodes is Dash (DASH).
The idea behind the node network
The blockchain structure incentivizes its participants to respect the rules of the game. No matter who is involved, if they want to make a profit they must ensure validity of new blocks creating consensus in the peer-to-peer network. Firstly, nodes can get compensated for confirming new blocks and secondly, by achieving consensus they contribute to the blockchain stability and higher price of crypto coins, which again represents profit for all blockchain participants.
Tempering with the blockchain is almost impossible and it makes much more sense for all participants to respect the rules and play it fair. It’s really the only sure way for nodes to make money in this technology masterpiece called the blockchain.
Join the GoCrypto community on Telegram!