์•ˆ๋…•ํ•˜์„ธ์š”?

๊ทธ ๋™์•ˆ “๋จผ์ € ์‹œ์ž‘ํ•ด ๋ณด๋Š” ๋ธ”๋ก์ฒด์ธ” ์‹œ๋ฆฌ์ฆˆ๋ฅผ ํ†ตํ•ด์„œ ์˜คํ”ˆ์†Œ์Šค ๋ธ”๋ก์ฒด์ธ ํ”„๋กœ์ ํŠธ์ธ Hyperledger Fabric ์˜ v0.6.x ๋ฒ„์ „์„ ์ด์šฉํ•˜์—ฌ ์ดˆ๊ธฐ ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ณ  ์ฒด์ธ์ฝ”๋“œ๋ฅผ ๋””ํ”Œ๋กœ์ดํ•˜๋ฉฐ, ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค.

์ด๋ฒˆ ๊ธ€ ๋ถ€ํ„ฐ๋Š” Hyperledger Fabric์˜ ์ •์‹๋ฒ„์ „์ด ๋  v1.0์„ ๊ธฐ์ค€์œผ๋กœ ์„ค๋ช…์„ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
Fabric v1.0์€ ์ด์ „ ๋ฒ„์ „์— ๋Œ€๋น„ํ•ด ์•„ํ‚คํ…์ฒ˜์— ๋งŽ์€ ๋ณ€ํ™”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด์ „ ๋ฒ„์ „์—์„œ๋Š” Validating Peer๊ฐ€ ํ•˜๋˜ ์—ญํ• ์„ Endorser, Orderer ๋“ฑ์ด ๋‚˜๋ˆ ์„œ ํ•˜๊ฒŒ ๋˜๋ฉฐ, REST API ๊ฐ€ ์—†์–ด์ง€๊ณ  grpc๋ฅผ ํ†ตํ•ด ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ์™€ ์ธํ„ฐํŽ˜์ด์Šค ํ•ด์•ผ ํ•˜๋Š” ๋“ฑ ๋งŽ์€ ๋ถ€๋ถ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์ƒˆ๋กœ์šด ๋ฒ„์ „์—์„œ์˜ ๋Œ€ํ‘œ์ ์ธ ์žฅ์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • Chaincode trust flexibility
  • Scalability
  • Confidentiality
  • Consensus modularity

์ด ๋ฌธ์„œ์—์„œ๋Š” ๋ณ€ํ™”๋œ ์•„ํ‚คํ…์ณ์— ๋Œ€ํ•ด์„œ๋Š” ์„ค๋ช…ํ•˜์ง€ ์•Š๊ณ  ๋ฐ”๋กœ ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ตฌ์„ฑ์„ ์œ„ํ•œ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ๋งŒ ๊ฐ„๋‹จํžˆ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

Fabric v1.0 ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด์„œ๋Š” ๋‹ค์Œ์— ๋‹ค์‹œ ๋‹ค๋ฃจ๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.
๋ณ€ํ™”๋œ ์•„ํ‚คํ…์ฒ˜์™€ ๋™์ž‘์— ๋Œ€ํ•ด์„œ๋Š” ๋‹ค์Œ์˜ ๋งํฌ์—์„œ ํ™•์ธ ๋ฐ”๋ž๋‹ˆ๋‹ค. Fabric v1.0 ์•„ํ‚คํ…์ฒ˜ ์„ค๋ช…

1. ๊ธฐ๋ณธ ํ™˜๊ฒฝ ์ค€๋น„

  • Go – ์ตœ์‹ ๋ฒ„์ „
  • Docker – v1.13 ์ด์ƒ
  • Docker Compose – v1.8 ์ด์ƒ
  • Node.js + NPM – node v6.9.5, npm v3.10.10
  • xcode – Mac ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ xcode ํ•„์š”
  • nvm – nodejs ๊ฐ€ ์ด๋ฏธ ์„ค์น˜๋˜์–ด ์žˆ์–ด์„œ ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ํ•„์š”ํ•  ๊ฒฝ์šฐ ํ•„์š”(Mac ์—์„œ ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ node v6.9.5 ๋ฒ„์ „์ผ ๊ฒฝ์šฐ ๋ชจ๋“  ๊ณผ์ •์ด ์ •์ƒ์ ์ด์—ˆ์Šต๋‹ˆ๋‹ค.)

1.1 nodejs, npm ๋ฒ„์ „ํ™•์ธ

node ๋ฒ„์ „์€ 6.9.5 ์ด์ƒ์ด ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
node -v
npm ๋ฒ„์ „์€ 3.10.10 ์ด์ƒ์ด ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
npm -v

1.2 nvm ์„ ์ด์šฉํ•œ node v6.9.5 ์„ค์น˜

๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

nvm install v6.9.5

2. Hyperledger Fabric v1.0 ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ

์ ๋‹นํ•œ ์œ„์น˜์—์„œ ๊ฐœ๋ฐœํ™˜๊ฒฝ ์…‹ํŒ…์„ ์œ„ํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋‹ค์Œ์˜ ๋ช…๋ น์„ ํ†ตํ•ด์„œ Fabric ์•„ํ‹ฐํŒฉํŠธ ๋ฐ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ฝ”๋“œ๋“ค์„ ๋‹ค์šด ๋ฐ›์Šต๋‹ˆ๋‹ค.

mkdir -p < ๋กœ์ปฌ ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ฒฝ๋กœ >/hackfest
cd < ๋กœ์ปฌ ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ฒฝ๋กœ >/hackfest
curl -L https://raw.githubusercontent.com/hyperledger/fabric/master/examples/sfhackfest/sfhackfest.tar.gz -o sfhackfest.tar.gz 2> /dev/null;  tar -xvf sfhackfest.tar.gz

์œ„์˜ ๋ช…๋ น์ด ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ด€๋ จ ํŒŒ์ผ๋“ค์ด ์••์ถ•์ด ํ’€์–ด์ง„ ํ˜•ํƒœ๋กœ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ์œผ๋กœ hyperledger/fabric-ccenv ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•ฉ๋‹ˆ๋‹ค.
(ํ•„์š”ํ•œ ๋„์ปค ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ ๋ฐ ๋นŒ๋“œ ์ž‘์—…์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์•ฝ๊ฐ„์˜ ์‹œ๊ฐ„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.)

docker-compose -f docker-compose-gettingstarted.yml build

์œ„์˜ ์ด๋ฏธ์ง€ ๋นŒ๋“œ ์ž‘์—…์ด ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฉด ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
(๋นŒ๋“œ์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํ•„์š”ํ•œ ๋„์ปค ์ด๋ฏธ์ง€๋“ค์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„์„œ ์ปจํ…Œ์ด์„œ ์ƒ์„ฑํ›„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.)

docker-compose -f docker-compose-gettingstarted.yml up -d

์ด์ œ, ์ •์ƒ์ ์œผ๋กœ ๋นŒ๋“œ๋˜์–ด ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰์ด ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด 6๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ƒ์„ฑ๋˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

docker ps

๋‹ค์Œ์œผ๋กœ๋Š” ์ฑ„๋„์ด ์ƒ์„ฑ๊ณผ ํ”ผ์–ด ์—ฐ๊ฒฐ์ด ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์˜ ๋ช…๋ น๊ณผ ๊ฐ™์ด cli ์ปจํ…Œ์ด๋„ˆ๋กœ ์ ‘์†ํ•˜์—ฌ์„œ “results.txt” ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

์ฑ„๋„๊ณผ ํ”ผ์–ด ๋“ฑ์— ๋Œ€ํ•œ ์„ค๋ช…์€ ๋‹ค์Œ Fabric v1.0 ์•„ํ‚คํ…์ณ ์„ค๋ช… ๋•Œ ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

docker exec -it cli bash

cli ์ปจํ…Œ์ด๋„ˆ๋กœ ์ ‘์†๋˜์—ˆ์œผ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ„ฐ๋ฏธ๋„์— ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋–จ์–ด์ง‘๋‹ˆ๋‹ค.

/opt/gopath/src/github.com/hyperledger/fabric/peer #

“results.txt” ํŒŒ์ผ์„ ํ™•์ธํ•ด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฉ”์„ธ์ง€๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

more results.txt

์ •์ƒ ์ฒ˜๋ฆฌ๋˜์—ˆ์œผ๋ฉด ์•„๋ž˜์˜ ๋ฉ”์„ธ์ง€๊ฐ€ ๋ณด์ž…๋‹ˆ๋‹ค.
SUCCESSFUL CHANNEL CREATION
SUCCESSFUL JOIN CHANNEL on PEER0
SUCCESSFUL JOIN CHANNEL on PEER1
SUCCESSFUL JOIN CHANNEL on PEER2

Genesis block์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜์˜ ํŒŒ์ผ์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

more myc1.block

3. SDK ๋ฅผ ์ด์šฉํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ ํ…Œ์ŠคํŠธ

Fabric v1.0์„ ์ด์šฉํ•˜์—ฌ ๊ธฐ๋ณธ์ ์ธ ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ๊ฐ€ ์‹คํ–‰ ๋˜์—ˆ์œผ๋ฉด ๋‹ค์Œ์œผ๋กœ SDK๋ฅผ ์ด์šฉํ•˜์—ฌ ์ฒด์ธ์ฝ”๋“œ deploy, invoke, query ๊ฐ€ ์ •์ƒ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
๋จผ์ €, ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ nodejs ์†Œ์Šค๋ฅผ ๋‹ค์šด๋ฐ›์Šต๋‹ˆ๋‹ค.

curl -OOOOOO https://raw.githubusercontent.com/hyperledger/fabric-sdk-node/master/examples/balance-transfer/{config.json,deploy.js,helper.js,invoke.js,query.js,package.json}

์†Œ์Šค ๋‹ค์šด๋กœ๋“œ ์™„๋ฃŒ๊ฐ€ ๋˜์—ˆ์œผ๋ฉด ๋‹ค์Œ์˜ ๋ช…๋ น์„ ํ†ตํ•ด์„œ ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋“ค์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

npm install

3.1 ์ฒด์ธ์ฝ”๋“œ deploy, invoke, query ํ…Œ์ŠคํŠธ

SDK ๋ฐ ํด๋ผ์ด์–ธํŠธ ์†Œ์Šค๊ฐ€ ์ค€๋น„๊ฐ€ ๋˜์—ˆ์œผ๋ฉด ์ฒด์ธ์ฝ”๋“œ๋ฅผ ๋””ํ”Œ๋กœ์ดํ•˜์—ฌ ์ •์ƒ์ ์ธ ๋™์ž‘์„ ํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
ํ…Œ์ŠคํŠธ์˜ ๋‚ด์šฉ์€ “๋จผ์ € ์‹œ์ž‘ํ•˜๋Š” ๋ธ”๋ก์ฒด์ธ” ์˜ ์ฒด์ธ์ฝ”๋“œ ํ…Œ์ŠคํŠธ์™€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค.
๋‹ค๋งŒ, Fabric v1.0์—์„œ๋Š” REST API ๊ฐ€ ์—†์–ด์กŒ์œผ๋ฏ€๋กœ SDK๋ฅผ ํ†ตํ•ด์„œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ž‘์„ฑํ•˜์—ฌ์•ผํ•ฉ๋‹ˆ๋‹ค.

3.1.1 Deploy

์ฒด์ธ์ฝ”๋“œ๋ฅผ ๋””ํ”Œ๋กœ์ดํ•˜๋Š” ๊ณผ์ •์—์„œ argument๋ฅผ ๋„˜๊ธฐ๋Š”๋ฐ a = 100, b = 200 ์„ ์ดˆ๊ธฐ๊ฐ’์œผ๋กœ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

  • Mac
GOPATH=$PWD node deploy.js
  • Windows
SET GOPATH=%cd%
node deploy.js

3.1.2 Invoke

Invoke ์—์„œ๋Š” a ์˜ ๊ฐ’ 100์„ b๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

node invoke.js

3.1.3 Qeury

b์˜ ๊ฐ’์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.

node query.js

๋ชจ๋‘ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜์‹œ๋‚˜์š”?
์ด์ „ ๋ฒ„์ „์— ๋น„ํ•ด์„œ๋Š” ์ƒ๋‹นํžˆ ํŽธํ•˜๊ฒŒ ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก Fabric ์•„ํ‹ฐํŒฉํŠธ ๋“ค์„ ๋ฐฐํฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
๋ฌผ๋ก , ์‹ค์ œ ์ ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ๋ชฉ์ ์— ๋งž๋Š” ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ƒ์„ธํ•œ ์„ค์ • ๋ฐฉ๋ฒ•์„ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•˜๊ฒ ์ง€๋งŒ, ๋กœ์ปฌ ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ ์œ„ํ•ด์„œ๋Š” ํฌ๊ฒŒ ๋ฌด๋ฆฌ๊ฐ€ ์—†์–ด ๋ณด์ž…๋‹ˆ๋‹ค.
Fabric v1.0์ด ์•„ํ‚คํ…์ฒ˜์™€ ํŠธ๋žœ์žญ์…˜์˜ ์ ˆ์ฐจ ๋“ฑ์ด ๋ชจ๋‘ ๋ณ€๊ฒฝ๋˜์–ด์„œ ๋งŽ์€ ๋ถ€๋ถ„์—์„œ ์„ค๋ช…์„ ํ•ด์•ผ ํ•  ํ•„์š”์„ฑ์ด ์žˆ์–ด๋ณด์ž…๋‹ˆ๋‹ค.
์ฐจ๊ทผ์ฐจ๊ทผ ๋ฌธ์„œ๋ฅผ ์˜ฌ๋ฆด ์˜ˆ์ •์ด๋‹ˆ ๋งŽ์€ ๊ธฐ๋Œ€ ๋ฐ”๋ž๋‹ˆ๋‹ค.