Chapter 9
Cheating doesn't pay off

Initial version: 2024-03-05
Last update: 2024-03-06

In distributed, decentralized system it is really very difficult to ensure data correctness and consistency even if you really try to achieve this. It becomes even more difficult, if you cannot trust anyone. There is no other way than to apply reasonably and well balanced system of rewards and punishments that will make it unreasonable and unprofitable to be fraudulent.

Table of contents


Real life analogy


Before I start more technical description, I would like to give you a real life analogy to convince you that rewards and punishments or so called stick and carrot methodology in some circumstances lead to good results.

When I was in a primary school I had a Practical and technical classes. We learned there how to do many useful everyday things: sewing, cooking, sawing, reading technical drawings, etc. One day our teacher brought to class a huge amount of parts that could be used to assemble toys – cars. He gave them to us so that we could assemble them as part of our class activity. I don't know if he sold them later, or if he was paid based on the number of vehicles assembled – that's not important. The important thing about this story is that some of my colleagues used the situation as an opportunity to fool around, putting components together in various wrong ways. Alternatively, they did not fool around, but performed the entrusted task carelessly, sloppy. I tried to do it as best as I could, because I didn't want any child to get a toy that is the result of carelessness instead of a good one. The main problem, I think, was that we had none profits or reward if the toy was neatly put together. Nothing motivated us except some higher and lofty ideas like in my case. The question is therefore what motivation system can be proposed in a similar case, but concerning adults.

Imagine a toy factory and workers who manually assembly for example red toy cars. To motivate employees, or better say to force them, to keep high quality standards you may control their works by the following rules:

  1. All assembly line employees are contractors who only receive a payment dependent on "performance".
  2. Every employee may assembly as many cars as it only wants.
  3. For every assembled car an employee receives one coin as a payment.
  4. If a employee finds out that another employee assembled its car without due diligence, not maintaining high quality standards, the employee who assembled the car has to repay the payment and the one who found the problem receive that payment instead.


This simple set of rules almost guarantee you a commercial success caused by high quality of your product and satisfied both clients and employees who receives a fair payment for their work.

Why it works? Because of the following consequences:

  1. Every employee participate in this venture not because of ideology but rather because he/she has to earn money (coins) to live. They want to do this, and they expect a fair payment commensurate with the work they put in.
  2. It is fair – every employee may assembly as much cars as he/she wants.
  3. Payment rules are simple: the more you assembly the more coins you receive. There are no reasons to make unnecessary breaks from work.
  4. Every employee may check what other employee did; may verify quality of others assembly.
  5. If a worker detects deficiencies in the quality of another worker's assembly, then he/she receives their payment.
  6. Through time workers may specialize – they may focus on assembling or controlling as both offer opportunity to earn money. However to be honest, if every assemblist do their job without any complains, controllers will not get any rewards for their job.


Because of 1. employees have a strong motivation to do this job. Because of 2. and 3. employees have a strong motivation to do their job fast. Because of 4. and 5. employees have a good reason to do their job with high quality standards. Because of 4. and 5. employees have a good reason to control other employees.

There is one flaw in this picture of the ideal company that you need to know about: everything will stop working if ALL employees make a deal with each other and decide to act dishonestly by making defective products. Fortunately this option is highly unlikely, because this way employees will lead to significant losses in the factory due to the loss of quality of manufactured products, which will significantly reduce the interest of customers and, consequently, the loss of jobs, which, of course, they want to avoid at all costs, in accordance with point 1 above. You may say that customers are the next level of motivation system which is far behind employees control.

Blockchain rules


I hope this analogy allows you to grasp the key concepts behind the system you can trust. It requires:

  • validation rules for any kind of data it processed,
  • payment rules for rewarding honest workers,
  • punishment rules,
  • control rules,
  • competition rules.


Now I will discuss all of them in the context of blockchain.

Validation rules


Validation rules are mainly focus on formal aspects of processed data. You should check if all required data structures are correct, if all data fields are in correct form and contains correct values calculated or prepared with required algorithm.

Reward rules


As you know from previous chapter, solving the hash puzzle is absolutely indispensable so that you could effectively place data in a blockchain. Creating valid blocks costs time, energy, and thus money. The only way to convince participants of the system to carry this burden is to offer them something in reward for their work.

Simply speaking, you have to pay a miner for placing your data in a blockchain.

Punishment rules


The blockchain also needs a way to punish those who wants to act dishonestly. The simplest possible approach is to reclaim the reward for blocks that were accepted in the past but were identified as invalid or useless later on.

Let's stop for a while here and think who the blockchain punishment is addressed to. I would say that not for people with bad intentions but rather for people hoping for easy money and adds a block with insufficient care which later turns out to be identified as invalid or useless. For those who intentionally want to make one of block to be forged this type of penalty is an expected and accepted cost. They agree with the fact that to place poisonous data they have to pay for it. The penalty for them is that whatever they do, no matter how hard they try, all these attempts are in vain because the fake block will be easily identified and quickly removed.

There is also one more punish which is not intended to reduce dishonesty but rather intended to reduce inefficiency. Your way of thinking can be as follow: I don't want to enrich much mining data block, I just want to earn some extra money for everyday expenses. Because of this I run an low-priority process in my system and if my system will be idle I will try to solve the hash puzzle. It will take me a long time but it is not a problem for me.

One "detail" of payment rules which so far was not clearly expressed by me is worth you to note: reward is only for the first miner who solve the puzzle. This results in a kind of competition or rather race among miners like the ancient Olympic Games – only the winner receives the prize. If you are to slow, if other participant solve the puzzle before you will not receive any reward even if you also independently solve the puzzle. You must be the first otherwise you will not get any money for your effort. This way nodes, whether they want or not, participate in a speed competition. Not getting rewarded for creating a block implies that the costs for creating it cannot be covered. And this is a kind of punishment for being inefficient.

Why such a design decision? It prevents a deadlocks in blockchain. Because of this race you can be sure that your data will be included in the structure sooner rather than later. All those who try to slow down this process will not only fail to achieve this goal, but will also not receive a reward for their efforts.

Punishment rules in combination with payment rules force you to do your job carefully and efficiently.

Control rules


Even the best rewarding and punishment rules are useless if no one follows them.

The Germans have this saying: "Vertrauen ist gut, Kontrolle ist besser" (eng. "Trust is good, control is better") which you should understand as "Trust does not rule out control" or "Trust, but verify" [quodisc].

There must be some control rules enforcing fulfillment of all foundations and requirements behind blockchain. If not to prevent intentional fraud, then to protect users from accidental "bugs" which may happen as they happen naturally in our everyday life.

By design blockchain is a purely distributed peer to peer system without a central point of control or coordination that could supervise the adherence to the rules and enforce their implementation. Hence all nodes of the system are at the same time miners and supervisors of all other involved participants.

You need a clever algorithm of reaching a decision on what is true and what is false, which form of the chain is considered correct by the majority and which ones are rejected. This algorithm is known under the consensus algorithm name and would be a topic of the next chapter.

Competition rules – the heartbeat that synchronizes all nodes


I left the description of this rule at the very end due to its extensive nature.

On one side a system to be a purely distributed system may not work according to any central clock or other general control subsystem. On the other side, total freedom what node does and when is not impossible but makes even more difficult development of concept of how the system works as a coherent whole. Very common idea in such a case is auto-synchronization dependent on message passing from node to node. If nothing happens, there is no message flow, so there is no need for nodes to change their state. If one node change its state, it immediately sends message to all nodes it knows and in result this message is propagated to all nodes (see : chapter 7: Exchanging informations and data). This way, all nodes may change their state in reaction to the message they receive.

At any given point in time, all nodes of the system are in either of the two states:
  • Try to be the next node that creates a new block.
  • Evaluate a new block that was created and submitted by one of the node.


Initially every node accept incoming data, verify each and focus on creating a new block (solving PoW).

Of course, every node wants to be the first to do it (as it was explained above) and thus become the winner of the speed competition and the only one who will be rewarded for this effort.

The node which first complete this task sends to other nodes it knows message: "I did it! This is my block. You can check it if you don't believe me." As soon as a node receives a message that contains a new block, it break its activity and switches to the evaluation state. This is how the quality competition begins.

Each node has to act as a referee and validate the new block based on the validation rules for data and block headers. If the block is found valid, the node that submitted the new block receives the reward and this phase finishes. If the block is found to be invalid, it is thrown away, the node that reveal this receives the reward and this phase also finishes.

As soon as the evaluation phase finishes, the nodes switches back to work on preparing new block (possibly continuing postponed computations).

Implementing competition rules




Summary


In this chapter you have learned about rules governed existence and operation of blockchain. All of them are important, but the last one – competition rules – affects all nodes, almost at the same time, because it defines the identical rhythm of their life in highly distributed and unsynchronized environment.

The identical rhythm of life helps to define and next to ensure that all nodes maintain an identical "core of history" of data. As you will see soon in next chapter, in a purely distributed system it is difficult to ensure that a whole history on every node is exactly the same. Rather, all nodes keep informations about blocks that must be the same in all other nodes (they form "core" or "main trunk" of chain of blocks) but also allow the possibility of existence of some deviations in the newest history of block. So every node keeps not a chain of blocks but rather a tree of blocks with very long trunk and many branches at the top. These branches are next cut off as impossible as new branches come and only the core trunk remains in their place. How this happens is the subject of the next chapter.