Post
Topic
Board Development & Technical Discussion
Re: Smart Contracts in Blockchain
by
Cryddit
on 24/06/2016, 00:17:55 UTC
Bitcoin's first-cut code had several script instructions enabled, which were disabled by the time it launched.

Hal Finney was mostly responsible for that; he pointed out numerous ways in which the lack of ability to 'lock' resources before doing a transaction could result in legit-looking scripts that could later be attacked, or could result in a denial of service.  Satoshi and Hal disabled backward-branching instructions from Bitcoin's scripting language (which means it's no longer turing-complete) for security's sake.  That more-or-less forces multi-step transactions to wait several blocks between steps, during which interval people can verify that the previous step did happen and is now part of the chain, before going on.

No backward branching means that flow-of-control in a bitcoin script can jump forward over part of the script (in an 'if' branch for example) but can't jump backward to something it's done before (in a 'while' or 'until' loop, or in a recursion for example). 

ETH lifted this restriction among others.  That means contracts in ETH are more flexible and scripts can do more - but it also means they are trickier and enables people to make smart contracts that can be attacked in more unexpected ways - particularly with 'locking' of resources.  An ETH script can do many steps immediately based on balances that existed before the script ran - and then the whole sequence can be invalidated by a very shallow blockchain fork.  When more than one blockchain-recorded transaction is required to complete an interaction, this results in a relatively cheaper attack - if the two tx get into different blocks, and then one but not the other is invalidated by a fork.