An in-depth review of blockchain — cryptography and metaverse (part three- concurrency-part three)

metamondial
5 min readSep 18, 2022

--

Concurrency topics are so many and long that no matter how much I tried to explain their abstracts and summaries, they still do not end at the end of this article, but please note that these topics are very, very important in understanding blockchain and Web 3 and in computer science as a whole.

Critical section

With concurrent programming, concurrent accesses to shared resources can result in unpredictable behavior or errors. Therefore, the parts of the program where the shared resource is accessed must be maintained in a way that prevents concurrent access. This protected area is called the critical section or critical area. This area cannot be accessed by more than one process at the same time. Resource such as a data structure, peripheral device or network connection, this shared resource will not function properly if multiple accesses are made at the same time. Typically, a critical section accesses a shared successor.

Different codes and processes may contain the same variables or other resources to be read or written, but their results depend on the order in which the operations are performed. For example, if variable x is to be read by process A and process B is to write to variable x at the same time, then process A can accept either the old value or the new value of x.

// Process 
.
.
b = x + 5; // instruction executes at time = Tx
// Process A
.
.
b = x + 5; // instruction executes at time = Tx
A

In such cases, the presence of a critical section is required. In the example above, if A needs to read the updated value of x, running process A and process B at the same time may not produce the desired result. To prevent this, the variable x is protected by a critical section. First, B accesses the desired area. When B has finished writing the value, A accesses the critical section and the variable x can be read. Careful control of which variable changes inside and outside the critical section prevents concurrent access to the shared variable. Typically, the critical region is used when a multithreaded program needs to update several related variables and at the same time no single thread can cause stressful changes in them. In a similar situation, we can use the critical section in situations where a shared resource, say a printer, can only be accessed by one process at a time.

I still have more things to explain to get to things related to blockchain and similar networks, so be patient.

Correctness Requirements for the Critical Section problem

1. Mutual Exclusion Freedom

  • There must never be two or more processes in the critical section at the same time.

2. Freedom from Deadlock

  • If one or more processes want to enter the critical section, then one of the processes must enter the critical section.

3. Freedom from Starvation

  • If a process wants to enter the critical section, this process must enter the critical section

So far we have seen that there are certain standards and rules in concurrency that computer scientists know and have developed, these topics start with the infrastructure of the operating system and extend to the most common applications, there are two types of errors in computer science, programming and technical errors and design errors.

One of the biggest disadvantages of blockchain networks like Ethereum and Bitcoin is the low transaction speed and gas for transactions, maybe some people don’t see gas as a weakness, but for now let’s analyze this issue later and take a technical look at it for now.

Pay attention to the design of Ethereum and Bitcoin blockchain network, if we consider the activities of the miners as a critical point and each transaction as a process, we realize that all processes must be performed (Freedom from Starvation (Starvation-Freedom) ), but actually many Transactions on the Ethereum or Bitcoin network are recorded and not processed… This is one of the weaknesses in the infrastructural and technical design of the first and second generation blockchain networks,sure, the first founders of digital currencies were very innovative and progressive, but that doesn’t mean that we shouldn’t identify and fix the flaws in their work, if we look at the original design of the Bitcoin network, we see a deep flaw, In data structure science, we have a type of data structure called a stack or queue As a programmer, you’re probably familiar with these concepts. If you are familiar with the data structure, you will see that the creators of Bitcoin definitely knew these concepts, but faced fundamental and philosophical problems due to many innovations and the creation of a new thing called digital currency.

Long before the emergence of Bitcoin, computer scientists and economists had invented the concept of cryptocurrency and published many articles, but these concepts were completely implausible in our world and for ordinary people, you may remember the first time you were introduced to the term crypto and you must have thought, why should I pay for a number or digital data? Or why is bitcoin valuable?

You definitely had a problem explaining these issues to common people and you tried a lot to explain Bitcoin to others, all these philosophical questions and… were among the problems faced by the founders and creators of Bitcoin and Ethereum of course, Ethereum’s creators suffered from far fewer problems, so they were able to easily introduce the concept of the smart contract to the world.

Although long before the creation of Ethereum, many scientists had tried to create a smart contract, and even many people tried to put a smart contract in Bitcoin, but they failed, but now most people in the world are familiar with the concepts of crypto and… so now is the time to fix the problems of the past and create a new network that is synced to the Metaverse, the first major disadvantage of Bitcoin and Ethereum is their slow speed, and this slow speed is due to their network design and major programming bugs.

The second problem is the energy consumption of the Bitcoin and Ethereum network when it really doesn’t need to consume that much energy and technically it doesn’t really add anything to the network, for example, if the number of miners increases or the difficulty of the network increases, this does not help the speed of data recording or data transmission, all these are the problems of these blockchain networks and the basis and logic of their design is problematic, although I have to say that there was no other way but this way and they should have gone this way, to better understand how to design an optimal and fast network, we need to explore more concepts of concurrency.

Continued in the next article

--

--