Insights

Blockchain Dojo - Episode 1, Determinism

Introducing the first of many episodes in a new educational series, focused on blockchain fundamentals and common crypto-concepts.In this article, we will explore one fundamental principle that every blockchain follows, determinism. The term determinism means that if we enact the same operational steps in a specific order, we reach exactly the same result as anybody else who follows the same process. This property makes blockchains powerful.
July 9, 2021
min read

Introduction

Many articles about blockchains talk about their benefits, such as decentralization and transparency, without mentioning one key mechanism that makes blockchains capable of doing what they do: determinism. For some, it could be too obvious even to mention, while for many it is a missing concept in the entire blockchain puzzle, preventing them from fully understanding it. This article attempts to shed some light on the workings and importance of determinism in blockchains. Let’s start with the basics.

A non-blockchain example - a chess game of two sages in ancient India

Determinism is the philosophical belief that all events are determined completely by previously existing causes. It is the concept that events within a given paradigm are bound by causality in such a way that any state (of an object or event) is completely determined by prior states.

Two wise men of ancient India measured their prowess in a game of chess. The whole empire was rife with anticipation for the game’s outcome and wanted to learn from the sages’ mastery. Therefore, a detailed record of each move made in the match was taken. Unfortunately, the game could not be finished because of a call to arms in a neighbouring land.

Now imagine a similar chessboard to the one mentioned in our story with all the pieces still in place in a museum today, along with the original record of the game. Since a game of chess has a fixed initial state and is deterministic up to the last known move, it is possible to use the record of the players’ moves to recreate the board state at any point in the game, even many centuries later and on a different chessboard.

Thanks to this, we can study the techniques of both of the sages, as well as revert the game to any point before it was interrupted, and even continue it in their stead.

Because of determinism, the location, playing field or time of the game become immaterial.

A blockchain example

The term Determinism in Computer Science refers to a system where the future state of the system is entirely determined by the prior state.

Determinism means that we reach exactly the same state as everybody else if we enact the same operational steps in the same order. This property makes a blockchain what it is. Fundamentally, a blockchain’s decentralization and censorship resistance features are possible because every node in the network validates every transaction in a deterministic fashion and all agree on the system’s current state.

When new blockchain users create blockchain-based wallets, for example, they have to wait for the application to synchronize with the current state of the blockchain. This synchronization is a required step before they can interact on the blockchain. Having a fully synchronized wallet allows them to send & receive funds with 100% certainty that they follow the rules and create a valid record of all transactions. Then, this transaction record is stored on the blockchain for anybody to validate. It also gives the users full control over their funds and no 3rd party can freeze or move them. The control over funds is assured by public/private key pair cryptography (no other party can sign a transaction other than the key owner). The process of reaching an equal state on every node thanks to determinism is the protection system against double-spending, which is the fundamental problem that the system as a whole solves. The double-spending problem will be covered in its own article called: “51% Attack.”

  • An SPV node doesn’t verify every transaction/block, instead, it only verifies the Merkle roots (will be covered in the later chapter - What is inside of a blockchain block) of each block. This approach reduces the size to 80 bytes per block instead of 1M, but it also has tradeoffs. For example, in the case of a 51% attack, an SPV node can be tricked into accepting invalid transactions from an evil full node.
  • “A full blockchain node verifies a transaction by checking the entire chain of thousands of blocks below it in order to guarantee that the UTXO is not spent, whereas an SPV node checks how deep the block is buried by a handful of blocks above it.” - Mastering Bitcoin [Book] - O’Reilly

Determinism, in the context of blockchains, refers to the fact that every node on the network will produce the same transaction order. Any difference between the nodes for the same operation would lead to a failure in consensus since storing this data on the distributed ledger would lead to an inconsistent ledger state.

For example, every new full node that joins the blockchain network has to replay all past operations and end up in the same ledger state as existing full nodes. For example, if you decide to run a full node on the RSK blockchain, you will need to synchronize all blocks in all of RSK’s history and check all smart contracts on this chain before you can operate as a node to validate and process new blocks.

To illustrate further, because of the element of determinism, the RSK blockchain does not allow calling 3rd party APIs, such as a stock price feed. Not allowing 3rd party APIs to be directly implemented at the consensus layer is necessary because one can never be sure if this API will always be reachable or running correctly. What if one or many countries terminated this API due to local internet censorship policies? How would you then run an RSK node when this API, which had already been used in some transactions, is not working for certain parties on the network? For example, the API could report that on August 30, 2019, two countries entered into a trade agreement - which would then become a part of the validation chain. However, if the API got shut down in another country, nodes located in that country would not report the trade agreement anymore and, as a result, the blockchain would not be possible to validate.

It is possible to use a 3rd party API in a smart contract by plugging in an oracle as an off-chain data source (to bring non-blockchain data to the blockchain smart contract) but 3rd party APIs are not implemented at the blockchain consensus layer. I will describe the concept of oracles and the role they play in the context of smart contracts in the later part called Blockchain contracts.

Blockchains do not rely on any factors that are unique to each end-user for consensus. For example, a consensus rule that relies on randomness created locally on a full node’s machine wouldn’t work because the result would be different on each user’s computer, causing each user to split off from the network. To reach consensus, the users must all share identical data and be able to use the data to compute the same results using the same protocol with the same consensus rules. That’s determinism in a blockchain context.

BE THE FIRST TO USE ZERO

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Conclusion

Determinism is one necessary element for fostering decentralization and enabling censorship-resistant transactions, two core features of any consensus-based blockchain. If past transactions could not produce the same result every time they are executed, regardless of where or by whom the transaction is executed, then achieving consensus would be impossible; blockchains would lose their power of constant tamper-proof data integrity.

Now you understand that our bitcoin is safe on the Bitcoin blockchain, in large part, thanks to the property of determinism. In the next part of this series, we will cover the Proof of Work consensus algorithm. This article and future articles are mirrored on the Sovryn Wiki here.

These articles are also published on Hackernoon. Find this series and more crypto-content here.

Congratulations. You made the first step in becoming a blockchain expert. Stay tuned for further episodes and as always:

#StaySovryn

Mickey Maler

socials
learn more

Take your sovereignty to the next level

The road to financial self-sovereignty is long. Take a step in the right direction.