Ethereum and Turing Completeness (2024)

Ethereum and Turing Completeness (2)

The term refers to English mathematician Alan Turing, who is considered the father of computer science. In 1936 he created a mathematical model of a computer consisting of a state machine that manipulates symbols by reading and writing them on sequential memory (resembling an infinite-length paper tape). With this construct, Turing went on to provide a mathematical foundation to answer (in the negative) questions about universal computability, meaning whether all problems are solvable. He proved that there are classes of problems that are uncomputable. Specifically, he proved that the halting problem (whether it is possible, given an arbitrary program and its input, to determine whether the program will eventually stop running) is not solvable.

Alan Turing further defined a system to be Turing complete if it can be used to simulate any Turing machine. Such a system is called a Universal Turing machine (UTM).

Ethereum’s ability to execute a stored program, in a state machine called the Ethereum Virtual Machine, while reading and writing data to memory makes it a Turing-complete system and therefore a UTM. Ethereum can compute any algorithm that can be computed by any Turing machine, given the limitations of finite memory.

Ethereum’s groundbreaking innovation is to combine the general-purpose computing architecture of a stored-program computer with a decentralized blockchain, thereby creating a distributed single-state (singleton) world computer. Ethereum programs run “everywhere,” yet produce a common state that is secured by the rules of consensus.

Turing Completeness as a “Feature”

Hearing that Ethereum is Turing complete, you might arrive at the conclusion that this is a feature that is somehow lacking in a system that is Turing incomplete. Rather, it is the opposite. Turing completeness is very easy to achieve; in fact, the simplest Turing-complete state machine known has 4 states and uses 6 symbols, with a state definition that is only 22 instructions long. Indeed, sometimes systems are found to be “accidentally Turing complete.” A fun reference of such systems can be found at http://bit.ly/2Og1VgX.

However, Turing completeness is very dangerous, particularly in open access systems like public blockchains, because of the halting problem we touched on earlier. For example, modern printers are Turing complete and can be given files to print that send them into a frozen state. The fact that Ethereum is Turing complete means that any program of any complexity can be computed by Ethereum. But that flexibility brings some thorny security and resource management problems. An unresponsive printer can be turned off and turned back on again. That is not possible with a public blockchain.

Implications of Turing Completeness

Turing proved that you cannot predict whether a program will terminate by simulating it on a computer. In simple terms, we cannot predict the path of a program without running it. Turing-complete systems can run in “infinite loops,” a term used (in oversimplification) to describe a program that does not terminate. It is trivial to create a program that runs a loop that never ends. But unintended never-ending loops can arise without warning, due to complex interactions between the starting conditions and the code. In Ethereum, this poses a challenge: every participating node (client) must validate every transaction, running any smart contracts it calls. But as Turing proved, Ethereum can’t predict if a smart contract will terminate, or how long it will run, without actually running it (possibly running forever). Whether by accident or on purpose, a smart contract can be created such that it runs forever when a node attempts to validate it. This is effectively a DoS attack. And of course, between a program that takes a millisecond to validate and one that runs forever are an infinite range of nasty, resource-hogging, memory-bloating, CPU-overheating programs that simply waste resources. In a world computer, a program that abuses resources gets to abuse the world’s resources. How does Ethereum constrain the resources used by a smart contract if it cannot predict resource use in advance?

To answer this challenge, Ethereum introduces a metering mechanism called gas. As the EVM executes a smart contract, it carefully accounts for every instruction (computation, data access, etc.). Each instruction has a predetermined cost in units of gas. When a transaction triggers the execution of a smart contract, it must include an amount of gas that sets the upper limit of what can be consumed running the smart contract. The EVM will terminate execution if the amount of gas consumed by computation exceeds the gas available in the transaction. Gas is the mechanism Ethereum uses to allow Turing-complete computation while limiting the resources that any program can consume.

The next question is, ‘how does one get gas to pay for computation on the Ethereum world computer?’ You won’t find gas on any exchanges. It can only be purchased as part of a transaction, and can only be bought with ether. Ether needs to be sent along with a transaction and it needs to be explicitly earmarked for the purchase of gas, along with an acceptable gas price. Just like at the pump, the price of gas is not fixed. Gas is purchased for the transaction, the computation is executed, and any unused gas is refunded back to the sender of the transaction.

Ethereum and Turing Completeness (2024)

FAQs

How is Ethereum Turing complete? ›

So, is Ethereum Turing-complete? Yes, the blockchain technology platform Ethereum is a prime example of Turing completeness. Solidity, its programming language, enables developers to design complex decentralized applications (DApps) and smart contracts, transforming the field of blockchain-based applications.

Are blockchains Turing complete? ›

Blockchains meeting these criteria are regarded as Turing complete. In the blockchain context, it implies that the programming languages used to develop smart contracts can solve any computational problem. For example, Ethereum uses Solidity for its native code and smart contracts.

What makes EVM Turing complete? ›

The EVM's Turing completeness is measured by the fact it can run any program. Without the EVM, developers wouldn't be able to implement the numerous dApps (decentralized applications) for which Ethereum is known. Virtual machines aren't tied to a specific physical device and have no system interface or hardware.

Is Solidity a Turing complete language? ›

Solidity is a high-level, Turing-complete language, which means developers can write code substantially faster as many of the low-level concerns are abstracted away.

What is an example of Turing complete? ›

Most practical programming languages are Turing-complete. Writing a Turing machine simulator in most programming languages is a pretty straightforward task. Then there are “computing environments” that you would not expect to be Turing Complete, but really are. For example, Excel spreadsheets are Turing complete.

Is Python a Turing complete language? ›

Python has been Turing complete since it was created in the late 1980s.

How do you know if something is Turing complete? ›

To show that something is Turing-complete, it is enough to demonstrate that it can be used to simulate some Turing-complete system. No physical system can have infinite memory, but if the limitation of finite memory is ignored, most programming languages are otherwise Turing-complete.

Is Ai Turing complete? ›

Yes, there is a relationship between Turing completeness and AI. Turing complete systems provide the computational power required for developing and implementing AI algorithms.

Is JavaScript not Turing complete? ›

Using HTML and JavaScript together can make a Turing complete system. The standard regular expressions, which most programming languages use, are not Turing complete. This is because regular expression engines have been adapted to include back-references, and a finite automaton cannot handle back references.

What is the difference between EVM and Ethereum? ›

The Ethereum Virtual Machine (EVM) is the engine that powers the Ethereum blockchain. It's designed to run smart contracts and decentralized applications (dApps) securely and reliably. Think of the EVM as a universal computer that runs the same code exactly as intended, no matter where it is.

How does Ethereum EVM work? ›

How does the EVM work? The EVM operates as a state machine, meaning it computes a new valid state from block to block based on a set of predefined rules. These rules govern the execution of smart contracts and the updating of the Ethereum blockchain's state.

Which logic gates are Turing complete? ›

Theoretically speaking, an infinite number of NAND (inverted AND) logic gates can be used to build a Turing machine. This is because NAND and NOR are the universal logic gates. In the real world, one can never build a Turing complete machine because infinite memory does not exist.

Is Ethereum's internal code Turing complete? ›

Ethereum's smart contracts are written using the Solidity programming language, a general-purpose Turing complete language developed specifically for Ethereum. The Ethereum Virtual Machine (EVM), which executes the smart contracts according to the program, is a Turing complete machine.

What code is Ethereum written in? ›

Solidity is a programming language for implementing smart contracts on various blockchain platforms, most notably, Ethereum. Solidity is licensed under GNU General Public License v3. 0.

Is SQL language Turing complete? ›

So when it comes to the proper definition of a programming language, SQL is a domain-specific programming language that is Turing complete. Thus qualifying SQL as a programming language.

How does Ethereum have an infinite supply? ›

Unlike Bitcoin that has a limited supply, the issuance of Ethereum is capped at 18 million Ethereums per year! In theory, the number of tokens that will be released yearly will average to the number of tokens lost yearly due to misuse, accidental loss, and others, therefore it would reach an equilibrium.

How does Ethereum execute smart contracts? ›

Think of the EVM as a distributed global computer where all smart contracts are executed. (Ethereum is sometimes referred to as a “world computer.”) Ethereum lets developers program their own smart contracts to define EVM instructions. The EVM executes a contract according to the rules the developer programmed.

What is the math behind Ethereum? ›

The equation is: K = k * G, where K is the public key, k is the private key, and G is the constant point (generator point). Asymmetric or public-key cryptography is based on the concept of the discrete algorithm problem, which involves performing addition and multiplication on the points of an elliptic curve.

How does the Ethereum virtual machine work? ›

EVM interacts with the Ethereum network through nodes, which validate transactions and contribute to its Proof of Stake consensus mechanism. Nodes execute smart contracts and store the entire transaction history, contributing to the decentralized and trustless nature of the blockchain.

Top Articles
Concert at the Crypto.com Arena - Finding the Perfect Seats! - Barrystickets.com
308 Chandlers Wharf #308, Portland, ME 04101 - MLS 1582202 - Coldwell Banker
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 5918

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.