EOSIO 개발 환경 설치 및 실행

Youngbae An
RayonProtocol
Published in
13 min readJun 22, 2018

EOS 플랫폼에 실행되는 DApp 개발을 위한 환경을 구축해보자.

참고 문서는 EOSIO 공식 wiki문서로컬환경에 설치 문서를 참고하였다.

EOSIO Components

EOSIO는 3개의 component로 구성되어 있다.

  • nodeos : 블록체인을 관리하는 노드 component
  • keosd : 지갑을 관리하는 component
  • cleos : 블록체인과 지갑을 제어하기 위한 CLI

EOSIO 설치

이 문서에서는 MacOS Darwin 10.12 기준으로 설명한다.

EOSIO git에서 소스코드를 다운로드 한다.

$ git clone https://github.com/EOSIO/eos --recursive

소스코드를 빌드하기 위해서는 사전에 xcode 및 homebrew가 설치되어 있어야 한다. 아직 설치가 안되어 있는 경우 먼저 xcode와 homebrew를 설치하자.

소스코드내 포함된 빌드 스크립트를 실행하면 자동 빌드가 된다.

$ cd eos$ ./eosio_build.sh

빌드 성공하면 아래와 같은 메세지가 나온다.

[100%] Linking CXX executable unit_test[100%] Built target unit_test_______  _______  _______ _________ _______(  ____ \(  ___  )(  ____ \\__   __/(  ___  )| (    \/| (   ) || (    \/   ) (   | (   ) || (__    | |   | || (_____    | |   | |   | ||  __)   | |   | |(_____  )   | |   | |   | || (      | |   | |      ) |   | |   | |   | || (____/\| (___) |/\____) |___) (___| (___) |(_______/(_______)\_______)\_______/(_______)EOSIO has been successfully built. 00:11:21To verify your installation run the following commands:/usr/local/bin/mongod -f /usr/local/etc/mongod.conf &cd /Users/scion/git/eos/build; make testFor more information:EOSIO website: https://eos.ioEOSIO Telegram channel @ https://t.me/EOSProjectEOSIO resources: https://eos.io/resources/EOSIO Stack Exchange: https://eosio.stackexchange.comEOSIO wiki: https://github.com/EOSIO/eos/wiki

문제해결

  1. build 도중 아래와 같은 error가 발생할 경우
CMake Error at /usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindIntl.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
programs/cleos/CMakeLists.txt:29 (find_package)

이경우는 homebrew의 gettext 연결이 다른 버전으로 되어 있어서. 연결정보를 변경해주면 된다.

$ brew link gettext — force

환경변수 파일 (~/.profile)에 gettext path 추가

export PATH=”/usr/local/opt/gettext/bin:$PATH”

참고 : https://github.com/EOSIO/eos/issues/2174

  • build 도중 다음 에러 발생시
Mac OS 10.13.3 build error “path mongo-cxx-driver already exists”

다음과 같이 한다.

sudo rm -rf /tmp/mongo*
cd /path/to/eos
rm -rf build/
git pull
git submodule update — init — recursive
./eosio_build.sh

참고 : https://github.com/EOSIO/eos/issues/3197

확인

빌드가 성공적으로 완료되었는지를 검증하기 위해 테스트 스크립트를 실행해 보자.

$ /usr/local/bin/mongod -f /usr/local/etc/mongod.conf &$ cd build/$ make testRunning tests...Test project /Users/scion/git/eos/buildStart  1: test_cypher_suites1/35 Test  #1: test_cypher_suites ...................   Passed    0.04 secStart  2: validate_simple.token_abi2/35 Test  #2: validate_simple.token_abi ............   Passed    0.08 secStart  3: validate_eosio.token_abi...34/35 Test #34: restart-scenarios-test-hard_replay ...   Passed  151.83 secStart 35: validate_dirty_db_test35/35 Test #35: validate_dirty_db_test ...............   Passed    4.42 sec100% tests passed, 0 tests failed out of 35

빌드 완료된 프로그램을 설치하자.

$ cd build$ sudo make install

EOSIO 실행

EOSIO의 component들을 실행 시켜 보자. 여기서는 개발 환경을 위한 구성이기 때문에 1개의 노드로 구성을 하도록 한다.

nodeos

다음 명령어로 option을 주어 실행하면 된다

$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
  • -e : block production 실행
  • -p eosio : producer 이름 설정
  • — plugin eosio::chain_api_plugin : chain 관련 API 실행
  • — plugin eosio::history_api_plugin : history 관련 API 실행

실행 option대신 config파일에 적은 후 ‘nodeos’만 실행 해도 된다.

  • config file위치 : ‘~/Library/Application Support/eosio/nodeos/config/config.ini’
  • nodeos를 처음 실행할때 해당 파일이 자동 생성된다.
$ vi ~/Library/Application\ Support/eosio/nodeos/config/config.ini

...
# enable-stale-production = false
enable-stale-production = true
...
# producer-name =
producer-name = eosio
...
plugin = eosio::chain_api_plugin
plugin = eosio::history_api_plugin
...

nodeos 실행:

$ nodeos

정상적으로 실행되면 콘솔에 0.5초마다 block이 생성되는 메세지를 볼수 있다.

‘nodeos’가 정상적으로 동작중인지 확인하기 위해 API를 실행시켜 보자.

8888포트로 실행중인 API 서버에 HTTP Request를 실행한다.

$ curl -k -v 'http://127.0.0.1:8888/v1/chain/get_info' -X GET

Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET /v1/chain/get_info HTTP/1.1
> Host: 127.0.0.1:8888
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Length: 529
< Content-type: application/json
< Server: WebSocket++/0.7.0
<
{"server_version":"012dc012","chain_id":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f","head_block_num":363,"last_irreversible_block_num":362,"last_irreversible_block_id":"0000016ad0238cef2f6a8de2098115ba155cbbc535122912a7a62f66097adbd6","head_block_id":"0000016b8cbb9154a759f2e61968fc1069fcf0ef9468886614d0538a97d96c61","head_block_time":"2018-06-12T07:10:59","head_block_producer":"eosio","virtual_block_cpu_limit":287075,"virtual_block_net_limit":1506023,"block_cpu_limit":199900,"block_net_limit":1048576}

또는 ‘cleos’ 명령어를 이용하여 실행한다.

$ cleos get info
{
"server_version": "012dc012",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 580,
"last_irreversible_block_num": 579,
"last_irreversible_block_id": "000002436a1baaeb366b55995ddad7de0822f177d60a8c6e336e3f5fcb18ecc5",
"head_block_id": "00000244e6923239c0649ddada0dd47a2df80df13fa825275df9ddac975e6162",
"head_block_time": "2018-06-12T07:12:48",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 356561,
"virtual_block_net_limit": 1871085,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}

keosd

다음 명령어로 option을 주어 실행하면 된다:

$ keosd — http-server-address=127.0.0.1:8900
  • — http-server-address : REST API 주소
    nodeos의 default port가 8888이므로 겹치지 않게 8900을 지정하자.
    8900을 사용해야 ‘cleos’ 에서 default port로 인식해서 URL 지정없이 사용 가능하다.

실행 option대신 config파일에 적은후 ‘keosd’만 실행 해도 된다.

  • config file 위치 : ~/eosio-wallet/config.ini
  • ‘keosd’를 처음 실행할때 해당 파일이 자동 생성된다.
$ vi ~/eosio-wallet/config.ini

# http-server-address = 127.0.0.1:8888
http-server-address = 127.0.0.1:8900

keosd 실행:

$ keosd

8900포트로 실행중인 API 서버에 HTTP Request를 실행한다:

$ curl -k -v ‘http://127.0.0.1:8900/v1/wallet/list_wallets' -X GETNote: Unnecessary use of -X or — request, GET is already inferred.
* Trying 127.0.0.1…
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8900 (#0)
> GET /v1/wallet/list_wallets HTTP/1.1
> Host: 127.0.0.1:8900
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Length: 2
< Content-type: application/json
< Server: WebSocket++/0.7.0
<
[]

또는 ‘cleos’ 명령어를 이용하여 실행한다:

$ cleos wallet list
Wallets:
[]

nodeos와 keosd가 정상적으로 동작하면 EOSIO 서비스를 이용 할 수 있다.

--

--