What is blockchain?
The term blockchain can be easily defined as a structure that has the ability to store transactional records. This method of storage is often referred to as a 'digital ledger'. It can be further broken down into 'blocks' which refer to how the data is stored, and then into 'chains' which pertains to the blocks of data being linked together in a permanent 'chain', resulting in a 'blockchain'.
The benefits of using this structure are that at its core, it is a shared and immutable ledger that enables transactions to be recorded, and assets to be tracked. Furthermore, with this technology it is possible to track any item of value, and also trade it on a blockchain network, which in turn offers numerous benefits, such as reducing the costs and risk for all parties, to name just a few.
Firstly, as can be seen in the illustration below, a blockchain essentially consists of a chain of blocks all containing information. Each individual block contains several components. However, to simplify this and give an initial high-level overview, these can roughly be characterized into the block header and the transaction list (data).
The very first block in the chain is known as the Genesis block, and each new block is always linked to the preceding block.
Essentially, a blockchain is a database that is shared across multiple computers. Centralized databases can also be shared between multiple computers as well, however, one of the key advantages of blockchain is that the power of altering this shared database does not lay in the hands of a central authority, instead it is governed by a network of machines, or nodes. In this network, the nodes are competing to add new blocks to the chain, by rules defined in the consensus algorithm. This will be explained in more detail on the following page How blockchain works.
In general, the key attributes of blockchain technology are decentralization, accountability, and security, which also results in operational efficiency and significant cost savings.
As is more than evident today, the design, construction, and utilization of applications built on blockchain architecture are increasing exponentially.
To summarize at this point, the blockchain is a distributed ledger (which can be public or private), is decentralized, and each block can contain numerous different kinds of transactions. Blockchains utilize what is known as a distributed peer-to-peer network (often called a P2P network), which allows all users to connect to this network. Once entering this network, the user will have access to a full copy of the blockchain.
As the network may consist of many computers all connected globally, each connected computer is known as a node. This P2P network is made up of many nodes, and one of the key advantages of such a blockchain network, is that the data contained in the blocks cannot be altered without the consensus of the entire network.
A transaction consists of a set of records, and its associated meta data that are recorded in a block. They can be thought of as data structures which are recorded in the blockchain, and may contain a variety of information which is replicated and broadcast to all the nodes in the network instantaneously. The main properties consist of durability, uniformity, and fungibility to name a few. The transactions structure and validity are confirmed by ensuring that a valid signature exists. Specific rules are set to ensure the validity, and the transactions protocol requirements are checked by validators before they are added to the distributed ledger. In the case whereby an invalid transaction occurs, the block containing this transaction will be detected, and subsequently rejected by the network.
As will be covered further in this documentation, Lisk offers the possibility whereby every account can issue a transaction. Certain transactions are grouped together in a module which is responsible for each transaction performed within that particular module. These types of transactions and their properties are explained in further detail in the Transactions page.
Before delving more deeply into the intricacies of how blockchain works, it is helpful to understand the key overall concept here, which can be broken down into the following consecutive points:
A transaction is sent: Once a transaction is sent, every node (computer), connected to the blockchain network is informed about it.
The validation process: The transaction is then validated by each node connected to the network. The transaction validation is confirmed via a consensus protocol, which basically requires the nodes to relay this information to each other.
The verification process: The transaction is verified by the node. If the verification was successful, the transaction is added to the block.
The block creation: The verified transaction is now visible on the ledger as a permanent block of data. All transactions that were included within the block, such as the sender, the receiver, the relevant data (e.g. the token/coin amount), the timestamp, and other technical criteria (which will be covered further in this section), are now present in this block, which cannot be altered, modified, replaced, or removed. Hence, it is now immutable, and the transaction is completed.
Immutability is classed as one of the key advantages of blockchain and this is made possible by the deployment of cryptographic hashes. The key benefit here is that a hash cannot be reverse-engineered, so the very nature of cryptographic hashes means that it is virtually immune to being hacked, altered, or any other malfeasance. One of the most common and popular hash functions is known as the Secure Hash Algorithm, more commonly referred to as SHA-256.
The contents of each block, e.g. the transactions are created using a cryptographic hash function. This basically consists of an alphanumeric string that is generated by each block individually. Every block contains a hash value for its respective data, and also for the previous block. This enables and ensures the blocks are subsequently coupled (chained), together.
This functionality is the definition of immutability and ensures the data already saved in each block is tamper-free, and cannot be interfered with. As can be seen in the more detailed diagram below the hash functions are linked together. Finally, some of the benefits here consist of increased efficiency, coupled with complete data integrity. This leads in to the next topics of decentralization and consensus which are also important to understand how a whole blockchain functions.
Hashing can be thought of as a mathematical function when processed results in a fixed length character string output. This character string then represents a data record, regardless of its length, it will always produce the same fixed length character string. The methodology of this hashing process is invaluable, as it is the key to cryptographic security. In effect, it can transform any random data into a string of characters, which is used to identify a transaction on the blockchain. Furthermore, using a fixed length output offers excellent security as it is impossible to ascertain the amount or size of the hashed data, as the output of the hashed data will always be the same fixed string of characters of the exact same length.
The cryptographic hash function is both deterministic and computationally efficient, and finally it is collision-resistant. Hence, it is impossible for 2 different sets of data input to result in the same output. A hash function has to be collision-resistant which ensures that it is impossible for two different inputs to produce the same hashed output.
To ensure the integrity of the transaction(s), and to ensure the correct order of transactions is maintained in the blockchain, the hash of the previous block is always stored in each consecutive block, as can be seen in the illustration below. By doing this prevents any modifications being made to a transaction, as it would cause the hash in the preceding block to be invalidated, and in turn will also affect the following blocks in the chain.
All completed transactions are recorded in a chronological manner, subsequently all of these blocks in the blockchain are then distributed across all the nodes within the network, and therefore the blockchain is accessible by all nodes, as it does not exist in any one specific location.
A decentralized network basically consists of a number of nodes (computers), that are independently connected on a peer-to-peer basis (also known as P2P). Decentralization is not actually a new concept and consists of 3 architectural types: decentralized, distributed, and centralized as shown in the illustration below:
Naturally, there are pros and cons with respect to all 3 architectures, however, we will focus more on the decentralized architecture which pertains more to blockchain technologies. All new transactions that occur within the network simultaneously update every fully participating node in the network ecosystem regardless of their location.
Now the basics of blockchain have been explained, the following section will delve into further detail and explain how a blockchain works.