[basic] 이더리움 맛보기 <2> Ethereum

captaink.eth | 강선장
6 min readJul 29, 2022

--

지난 챕터를 통해 비트코인은 상태 변환 시스템으로, 스마트 콘트랙트와 이를 수행하는 Virtual Machine을 갖춘 시스템인 것을 알게 되었습니다. 이러한 비트코인의 구조를 계승하되, 한계를 개선해서 나온 것이 이더리움입니다.

비트코인의 한계로 지적되는 것은 크게 두 가지입니다.

Lack of Turing-completeness

출처: Ethereum Whitepaper

… The main category that is missing is loops. This is done to avoid infinite loops during transaction verification; theoretically it is a surmountable obstacle for script programmers, since any loop can be simulated by simply repeating the underlying code many times with an if statement, but it does lead to scripts that are very space-inefficient…

비트코인은 튜링 불완전(Lack of Turing-completeness)하다고 말합니다. 복잡한 설명은 차치하고, 코드에 반복문(loop)을 담을 수 없다는 얘기입니다.

반복문은 이런 예시를 들어서 설명이 가능합니다:

  • 반복문인 경우: 바구니에 사과가 10개가 될 때 까지 1개 씩 넣어라
  • 반복문이 아닌 경우: 바구니에 사과를 1개 넣어라, 바구니에 사과를 1개 넣어라 … (10번 반복)

비트코인에서 반복문을 허용하게 된다면 코드를 수행하는 노드들은 자칫하면 무한 반복 구조에 빠질 수 있고, 트랜잭션 검증이 안 되니 블록 생성이 아예 멈춰버릴 수도 있죠. 반복문은 필요하지도 않고, 있어서도 안되는 기능인 겁니다.

이러한 구조적인 한계 때문에, 비트코인은 복잡한 코드를 수행할 수 없습니다. 어찌어찌 시도는 해 볼 수 있겠지만 스크립트 최대 용량 한계가 있기 때문에 구현도 어렵고, 비효율적입니다.

Lack of state

출처: Ethereum Whitepaper

UTXO can either be spent or unspent; there is no opportunity for multi-stage contracts or scripts which keep any other internal state beyond that…

비트코인엔 스테이트가 부족(lack of state)하다고 합니다. 스테이트라는 것은, 어떤 작업을 수행할 때 참조할 수 있는 이전 값들 내지는 그런 값들의 집합체를 의미합니다. 이런 의미에서 비트코인의 스테이트는 UTXO들이고, UTXO들의 값은 1과 0으로 존재하겠죠.

비트코인에서 ‘작업’은 트랜잭션에 해당됩니다. 트랜잭션을 수행할 때, 참조할 수 있는 스테이트가 UTXO의 값만 있기 때문에, 송금 이상의 기능을 수행할 수 가 없습니다.

예를 들어 비트코인의 스테이트만으론 ‘A의 계좌의 apple 코인 100개와 B 계좌의 tree 코인 10개를 교환하라’ 라는 작업을 수행할 수 없습니다. 해당 작업을 수행하려면 A 계좌와 B 계좌의 잔고가 포함되어 있다는 정보, 즉 스테이트가 필요한데, 비트코인의 스테이트는 이런 정보를 담지 못하기 때문입니다.

Ethereum

출처: Ethereum Whitepaper

The intent of Ethereum is to create an alternative protocol for building decentralized applications, providing a different set of tradeoffs that we believe will be very useful for a large class of decentralized applications, … Ethereum does this by building what is essentially the ultimate abstract foundational layer: a blockchain with a built-in Turing-complete programming language, allowing anyone to write smart contracts and decentralized applications where they can create their own arbitrary rules for ownership, transaction formats and state transition functions. … Smart contracts, cryptographic “boxes” that contain value and only unlock it if certain conditions are met, can also be built on top of the platform, with vastly more power than that offered by Bitcoin scripting because of the added powers of Turing-completeness, value-awareness, blockchain-awareness and state.

이러한 비트코인의 한계를 개선하고자 이더리움은 튜링 완전 언어(Turing-complete programming language)를 채택했습니다. 이를 통해 복잡한 스크립트를 비교적 간단하게 구현할 수 있게 되었고, 다양한 기능들이 포함된 스마트 콘트랙트(smart contracts)를 구현할 수 있게 되었죠.

또한, 스테이트 구성에 있어서 거래 기록 뿐만 아니라, 스마트 콘트랙트, 스마트 콘랙트의 결과 값까지 저장되어, 스테이트의 다양한 값들을 활용하여 다양하고 복잡한 상호작용을 할 수 있게 되었습니다.

이더리움 관련 챕터인데 이제서야 비트코인에서 벗어났네요. 다음 챕터부터는 본격적으로 이더리움에 대해 얘기해보도록 하겠습니다.

👈🏻 이전 게시물: <1> Bitcoin As A State Transition System
👉🏻 다음 게시물: <3> Ethereum Accounts

저는 다음 두 채널에서 활동하고 있습니다. 언제든 편하게 와서 소통해주세요.

Treasure Hunt: https://t.me/look4treasure
고로치 같이투자 소통방: https://t.me/gachi2job1

--

--