create account

What are Smart Contracts and why they have nothing to do with Turing Completeness and Scriptability by chainsquad

View this thread on: hive.blogpeakd.comecency.com
· @chainsquad ·
$1.24
What are Smart Contracts and why they have nothing to do with Turing Completeness and Scriptability
Recently, I had a great conversation with Nathan Hourt, a brilliant backend
developer that I love working with. We are on the same wave length. So it
shouldn't surprise you that we came to similar conclusions on an item that is
often presented misleadingly in the public: The different aspects of *smart
contracts*, *Turing completeness* and *scriptability*.

Before I start, let's setup a glossary πŸ“– and clarify these terms.

## Turing Completeness

This is a term used in computer-science and is called after Alan Turing - the
guy that broke Enigma encryption in WW2. From
[wikipedia](https://en.wikipedia.org/wiki/Turing_completeness) we get this

<blockquote>
In computability theory, a system of data-manipulation rules [...] is
said to be <strong>Turing-complete</strong> [..] if it can be used to
simulate any Turing machine. This means that this system is able to recognize
or decide other data-manipulation rule sets. Turing completeness is used as a
way to express the power of such a data-manipulation rule set.
</blockquote>

To break this down, it means that Turing-Complete languages can be used to do
**anything** that is in the reach of a computer. Not surprising, pretty much any
programming language is Turing-complete, including
[LaTex](https://stackoverflow.com/questions/2968411/ive-heard-that-latex-is-turing-complete-are-there-any-programs-written-in-late),
[Minecraft](https://gaming.stackexchange.com/questions/20219/is-minecraft-turing-complete), [Magic: The Gathering](https://arxiv.org/abs/1904.09828),
[CSS3](https://github.com/elitheeli/stupid-machines/tree/master/rule110), and
even Super Mario World
([more](https://beza1e1.tuxen.de/articles/accidentally_turing_complete.html)).

Interestingly, Bitcoin's [Script](https://en.bitcoin.it/wiki/Script) language
is capable of building a [dual stack push down
automata](https://en.wikipedia.org/wiki/Pushdown_automaton) and is thus capable
of computing values in a system compatible with that of Godel’s logic system.
While it is not a Turing machine, it is as powerful.

## Scriptability

Scriptability - I am not sure this is a real English word - describes the
ability to get a script installed on the blockchain easily. In essence, all
major Smart-Contract platforms these days allow any user to deploy any contract
onto their blockchain. 

Ethereum contracts are written in Solidity, EOS contracts in Webassambly, and
other blockchains use NodeJS or even Python to allow users to get *their own
scripts* installed on the blockchain.

In fact, even Bitcoin allows scripting - in fact, their stack-based language
for this is called [Script](https://en.bitcoin.it/wiki/Script).

Other blockchain systems do not provide Scripting capabilities, such as
[Hive](https://hive.io) yet they provide features that add just enough
flexibility to have a growing smart-contract community there as well. In a
sense, scripts would run off-chain and are fed with information that is stored
(and ordered) by the blockchain.

## Smart Contracts

Personally, I don't like this term. It's difficult to grasp what it really
means and no concise definition exists. In short, everyone thinks about
something else when they hear smart contracts.

To try to bring some meaning to this term that many would agree on, a smart
contract provides means to take some sort of action on participants according
to the terms set forth on deployment of said contract.

Usually, smart contracts are written in software language (Solidity, C++, ...)
and quite technical but they all have in common that the terms (**what is
executed under which conditions**) is provided to the parties prior to them
**approving** them.

What makes smart contracts (in particular in combination with Scriptablity)
particularly dangerous are *bugs* and *misunderstandings*. For that reason,
millions have been *hacked* or where lost as contracts apparently didn't
*behave* as *expected*. In fact, there are dozens of arguments about whether
*code is law* or not. Just a primer on the scope of this issue:

* [The DAO Hack](https://medium.com/@ogucluturk/the-dao-hack-explained-unfortunate-take-off-of-smart-contracts-2bd8c8db3562)
* [Incident with non-standard ERC20 deflationary tokens](https://medium.com/balancer-protocol/incident-with-non-standard-erc20-deflationary-tokens-95a0f6d46dea)
* [Uniswap/Lendf.Me Hacks: Root Cause and Loss Analysis](https://medium.com/@peckshield/uniswap-lendf-me-hacks-root-cause-and-loss-analysis-50f3263dcc09)
* [Ether Collateral Bug Disclosure](https://blog.synthetix.io/bug-disclosure/)
* [Parity Multi-Sig Library Self-Destruct](https://www.parity.io/a-postmortem-on-the-parity-multi-sig-library-self-destruct/)
* [The biggest smart contract hacks in history or how to endanger up to US $2.2 billion](https://medium.com/solidified/the-biggest-smart-contract-hacks-in-history-or-how-to-endanger-up-to-us-2-2-billion-d5a72961d15d)
* ...

To make matters worse, most smart contracts are not meant of ordinary people.
That's because they are written in a non-natural language that obfuscates or at
least disconnects the intend from the written.

## Ricardian Contracts

In order to make smart contracts *easier* to understand, Ian Grigg developed
[Ricardian Contracts](https://en.wikipedia.org/wiki/Ricardian_contract).
Basically, these are standard smart contracts, written in computer slang, but
extended by a legal document crafted by a lawyer. Unfortunately, not much is
known about the applicability as they are only rarely used.

I am not a lawyer, but I can think of a practical problem with these: Source of
Truth. In case of a disagreement of code and legal word, how would one tell
this to the blockchain?  A curt may rule that the software is wrong and needs
fixing, but the software may already have executed and the funds are gone. Go
after people in the real world? what was the advantage of using a blockchain
then?

## Room for innovation

As with all things in tech, there is some room left for innovations. In this
case, I would be interested to see why people consider it a given that smart
contracts are executed by the blockchain and not the user.

If you think of a smart contract like a *state-machine* that eats data and
poops some outcome while going to some other state, why do we need the state
and the outcome to be on the blockchain? A **deterministic** state-machine
would always return identical outcome and undergo the same state transitions
when provided the same input data again.
πŸ‘  , , , , , , , , , , , ,
properties (23)
authorchainsquad
permlinkwhat-are-smart-contracts-and-why-they-have-nothing-to-do-with-turing-completeness-and-scriptability
categorychainsquad
json_metadata{"tags":["chainsquad","blockchain","smart","contract","turing"],"links":["https://en.wikipedia.org/wiki/Turing_completeness","https://stackoverflow.com/questions/2968411/ive-heard-that-latex-is-turing-complete-are-there-any-programs-written-in-late","https://gaming.stackexchange.com/questions/20219/is-minecraft-turing-complete","https://arxiv.org/abs/1904.09828","https://github.com/elitheeli/stupid-machines/tree/master/rule110","https://beza1e1.tuxen.de/articles/accidentally_turing_complete.html","https://en.bitcoin.it/wiki/Script","https://en.wikipedia.org/wiki/Pushdown_automaton","https://hive.io","https://medium.com/@ogucluturk/the-dao-hack-explained-unfortunate-take-off-of-smart-contracts-2bd8c8db3562","https://medium.com/balancer-protocol/incident-with-non-standard-erc20-deflationary-tokens-95a0f6d46dea","https://medium.com/@peckshield/uniswap-lendf-me-hacks-root-cause-and-loss-analysis-50f3263dcc09","https://blog.synthetix.io/bug-disclosure/","https://www.parity.io/a-postmortem-on-the-parity-multi-sig-library-self-destruct/","https://medium.com/solidified/the-biggest-smart-contract-hacks-in-history-or-how-to-endanger-up-to-us-2-2-billion-d5a72961d15d","https://en.wikipedia.org/wiki/Ricardian_contract"],"app":"hiveblog/0.1","format":"markdown"}
created2020-08-27 07:40:45
last_update2020-08-27 07:40:45
depth0
children2
last_payout2020-09-03 07:40:45
cashout_time1969-12-31 23:59:59
total_payout_value0.676 HBD
curator_payout_value0.566 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,474
author_reputation42,383,038,531,003
root_title"What are Smart Contracts and why they have nothing to do with Turing Completeness and Scriptability"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id99,299,163
net_rshares4,347,078,036,956
author_curate_reward""
vote details (13)
@good-karma ·
$0.09
Interesting read, in some sense it is being executed by user regardless. Good to see you on chain again!
πŸ‘  ,
πŸ‘Ž  
properties (23)
authorgood-karma
permlinkre-chainsquad-2020827t131150447z
categorychainsquad
json_metadata{"tags":["chainsquad","blockchain","smart","contract","turing"],"app":"esteem/2.2.7-surfer","format":"markdown+html","community":"esteem.app"}
created2020-08-27 10:11:51
last_update2020-08-27 10:11:51
depth1
children1
last_payout2020-09-03 10:11:51
cashout_time1969-12-31 23:59:59
total_payout_value0.046 HBD
curator_payout_value0.047 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length104
author_reputation656,214,797,217,320
root_title"What are Smart Contracts and why they have nothing to do with Turing Completeness and Scriptability"
beneficiaries
0.
accountesteemapp
weight300
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,300,607
net_rshares397,785,192,170
author_curate_reward""
vote details (3)
@chainsquad ·
Feels good to be back!
properties (22)
authorchainsquad
permlinkqfq0yi
categorychainsquad
json_metadata{"app":"hiveblog/0.1"}
created2020-08-27 11:51:54
last_update2020-08-27 11:51:54
depth2
children0
last_payout2020-09-03 11:51:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation42,383,038,531,003
root_title"What are Smart Contracts and why they have nothing to do with Turing Completeness and Scriptability"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,301,972
net_rshares0