์•„๋‹ˆ ๊ทธ๋ž˜์„œ ํŠธ๋žœ์žญ์…˜์ด ์–ด๋–ป๊ฒŒ ์ผ์–ด๋‚œ๋‹ค๊ตฌ์š”?

๋ธ”๋ก์ฒด์ธ์—์„œ ํ•œ ๋ธ”๋Ÿญ์ด ๋”ํ•ด์ง€๋Š” ์ „ ๊ณผ์ •์— ๋Œ€ํ•ด์„œ ์‚ดํŽด๋ด…๋‹ˆ๋‹ค. ํŠธ๋žœ์žญ์…˜ ํ๋ฆ„์„ ์‚ดํŽด๋ณด๋ฉด์„œ, ๋ณธ ์‹œ๋ฆฌ์ฆˆ์˜ ํ–ฅํ›„ ํฌ์ŠคํŒ…์—์„œ ์ƒ์„ธํžˆ ๋‹ค๋ฃฐ ์ด๋ฒคํŠธ/๋ฉ”์‹œ์ง€ ์ฒด๊ณ„์™€ ํ•ฉ์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ด์ง ๋ง›๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ๋ˆˆ์—ฌ๊ฒจ ๋ณด์…”์•ผ ํ•  ๋ถ€๋ถ„์€ Execute-Order-Validate ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ”Œ๋žซํผ์€ Order-Execute ๊ตฌ์กฐ์ธ ๊ฒƒ๊ณผ๋Š” ์ƒ๋ฐ˜๋ฉ๋‹ˆ๋‹ค.

์•„๋ž˜ ํฌ์ŠคํŒ…์€ HLF ๊ณต์‹ ๋ฌธ์„œ Transaction Flow ํŽ˜์ด์ง€๋ฅผ ์ฐธ๊ณ ๋กœ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ถœ์ฒ˜: https://hyperledger-fabric.readthedocs.io/en/release-1.2/arch-deep-dive.html

Phase 1: Client A๊ฐ€ ํŠธ๋žœ์žญ์…˜ ์š”์ฒญ(transaction proposal)

Client A๊ฐ€ ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ์— ํŠธ๋žœ์žญ์…˜์„ ์š”์ฒญํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ค‘๊ณ ์ฐจ๋ฅผ ์‚ฌ๊ณ  ์‹ถ์–ด์š”!๋ผ๊ณ  ์š”์ฒญ์„ ๋ณด๋‚ธ๊ฑฐ์ฃ . ๊ทธ ๊ฑฐ๋ž˜์— ๋Œ€ํ•ด์„œ ์Šน์ธํ•ด์•ผ ํ•˜๋Š” ํ”ผ์–ด๊ฐ€ endorsement policy๋กœ ์ •์˜๋˜์–ด ์žˆ๋Š”๋ฐ, ์ด ๋‹จ๊ณ„์—์„œ ๊ทธ ํ”ผ์–ด๋“ค์—๊ฒŒ ํ•ด๋‹น ์š”์ฒญ์„ ์ „์†กํ•ฉ๋‹ˆ๋‹ค. ์ด ํ”ผ์–ด๋“ค์—๊ฒŒ transaction proposal์ด๋ผ๋Š” ํ˜•ํƒœ๋กœ ์ „์†ก๋˜๋Š”๋ฐ, ํด๋ผ์ด์–ธํŠธ์˜ SDK๋Š” ์ด๋ฅผ gRPC ํ”„๋กœํ† ์ฝœ๋กœ ์ „์†กํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋กœํ† ์ฝœ ๋ฒ„ํผ ํ˜•ํƒœ๋กœ ๋ณ€ํ˜•ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ์‚ฌ์šฉ์ž์˜ ์‹ ์› ์ •๋ณด๋ฅผ ์„œ๋ช… ํ˜•ํƒœ๋กœ proposal์— ์‚ฝ์ž…ํ•ฉ๋‹ˆ๋‹ค.

์ด ๊ณผ์ •์—์„œ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋ฉด, ํ”ผ์–ด๋“ค์ด ๋ฆฌ์Šจํ•˜๊ณ  ์žˆ๋‹ค๊ฐ€ ์ด์ œ ๊ทธ ๋‹ค์Œ ์•ก์…˜์„ ์ทจํ•˜๋Š” ๊ฒ๋‹ˆ๋‹ค. ์ฆ‰ ์ผ๋ฐ˜์ ์ธ pub-sub ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค๋งŒ, ์ด ์ด๋ฒคํŠธ๋ž€ ๋น„์ฆˆ๋‹ˆ์Šค ๋„คํŠธ์›Œํฌ ๋ชจ๋ธ ํŒŒ์ผ(.cto)์—์„œ ์‚ฌ์ „์— ์ •์˜๋˜์–ด์•ผ ํ•˜๋ฉฐ, ํŠน์ •๋œ ํŠธ๋žœ์žญ์…˜์—์„œ๋งŒ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ์•„๋ž˜ Hyperledger composer documentation์˜ ์˜ˆ์‹œ๋ฅผ ํ•œ ๋ฒˆ ์‚ดํŽด๋ณด์‹œ์ฃ .

Phase 2: Endorsing peers ๊ฐ€ ์„œ๋ช…์„ ํ™•์ธํ•˜๊ณ  ํŠธ๋žœ์žญ์…˜ ์‹คํ–‰

Endorsing peer๋Š” ์ผ๋‹จ ํŠธ๋žœ์žญ์…˜์„ ์ „๋‹ฌ ๋ฐ›์œผ๋ฉด, 1) ํŠธ๋žœ์žญ์…˜์˜ ํ˜•์‹์— ๋งž๊ฒŒ ๋‚ด์šฉ์ด ์ž˜ ์ฑ„์›Œ์ ธ์žˆ๋Š”์ง€ 2) ์ด์ „์— ์ œ์ถœ๋œ ์  ์žˆ์—ˆ๋˜ ํŠธ๋žœ์žญ์…˜์€ ์•„๋‹Œ์ง€ 3) ์„œ๋ช…์ด ์œ ํšจํ•œ์ง€(MSP๋ฅผ ํ†ตํ•จ) 4) ํŠธ๋žœ์žญ์…˜์„ ์ œ์ถœํ•œ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๊ทธ๋Ÿด ๊ถŒํ•œ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒŒ ํ™•์ธ์ด ๋˜๋ฉด, Endorsing peer๋Š” Transaction proposal์„ ์ธ์ž๋กœ ๋ฐ›์•„์„œ ์ฒด์ธ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. State DB์˜ ๊ฐ’์— ์ฒด์ธ์ฝ”๋“œ๊ฐ€ ์‹ค์ œ๋กœ ์‹คํ–‰๋˜๋ฉฐ ๊ฒฐ๊ณผ๊ฐ’, read/write set์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ด ์‹œ์ ์—๋Š” ์›์žฅ ์—…๋ฐ์ดํŠธ๋Š” ํ•˜์ง€ ์•Š๊ณ , ๋ฐ˜ํ™˜๋œ ๊ฒฐ๊ณผ๊ฐ’์„ proposal response๋กœ ํด๋ผ์ด์–ธํŠธ SDK๋กœ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.

Phase 3: Proposal responses ๊ฒ€ํ† 

๊ทธํ›„ ํด๋ผ์ด์–ธํŠธ SDK๊ฐ€ Endorsing peer์˜ ์„œ๋ช…์„ ํ™•์ธํ•œ ๋’ค ๊ฐ ํ”ผ์–ด๋กœ๋ถ€ํ„ฐ์˜ proposal response๋ฅผ ๋น„๊ตํ•˜๋Š” ์ž‘์—…์„ ๊ฑฐ์นฉ๋‹ˆ๋‹ค. ๋‹จ์ˆœํ•œ ์ฟผ๋ฆฌ ๊ฐ™์ด Ordering service๊ฐ€ ํ•„์š” ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” ์ฟผ๋ฆฌ ๊ฒฐ๊ณผ๊ฐ’์„ ์–ป๊ณ  ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค. ์›์žฅ ์—…๋ฐ์ดํŠธ์™€ ๊ฐ™์€ ๊ฒฝ์šฐ, ํด๋ผ์ด์–ธํŠธ ์ฐจ์›์—์„œ Endorsement policy์— ์ค€ํ•˜๋Š” proposal response๊ฐ€ ์™”๋Š”์ง€(A, B๊ฐ€ ๋ชจ๋‘ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ƒˆ๋Š”์ง€) ๊ฒ€ํ† ํ•ฉ๋‹ˆ๋‹ค.

๋‹จ, ์ด ๋‹จ๊ณ„์—์„œ ํด๋ผ์ด์–ธํŠธ๊ฐ€ endorsement policy๋ฅผ ๊ฒ€ํ† ํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•ด๋„, committing ๋‹จ๊ณ„์—์„œ ๊ฐ ํ”ผ์–ด๊ฐ€ ๋ณ„๋„๋กœ ๊ฒ€ํ† ๋ฅผ ํ•ฉ๋‹ˆ๋‹ค.

Phase 4: ํด๋ผ์ด์–ธํŠธ๊ฐ€ Transaction ์ „๋‹ฌ

๊ฒ€ํ† ๊ฐ€ ์™„๋ฃŒ๋˜๊ณ  ๋‚˜๋ฉด ํด๋ผ์ด์–ธํŠธ๊ฐ€ Transaction message์— proposal๊ณผ proposal response๋ฅผ ๋‹ด์•„์„œ Ordering service์— ๋ณด๋ƒ…๋‹ˆ๋‹ค. ํŠธ๋žœ์žญ์…˜์—๋Š” read/write set์ด ๋“ค์–ด๊ฐ€ ์žˆ์„ ๊ฒƒ์ด๊ณ , Endorsing peer์˜ ์„œ๋ช…๊ณผ ์ฑ„๋„ ID๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. Orderer๋Š” ํŠธ๋žœ์žญ์…˜ ๋‚ด์šฉ์— ๊ด€๊ณ„ ์—†์ด, ๋ชจ๋“  ์ฑ„๋„์—์„œ ๋ฐœ์ƒํ•˜๋Š” ํŠธ๋žœ์žญ์…˜์„ ๋ฐ›์•„์„œ ์‹œ๊ฐ„ ์ˆœ์„œ๋Œ€๋กœ ์ •๋ ฌํ•˜์—ฌ ๋ธ”๋Ÿญ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

Orderer๊ฐ€ ํ•ฉ์˜ํ•˜๋Š” ๋ฐฉ์‹์€ ๊ธฐ๋ณธ์ ์œผ๋กœ pluggableํ•˜๋‚˜, ์ง€๊ธˆ ์‹œ์ (2018๋…„ 8์›” ๋ง) ๊ธฐ์ค€์œผ๋กœ๋Š” SOLO์™€ Kafka ๋‘ ๊ฐ€์ง€ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. SOLO๋Š” ๊ฐœ๋ฐœ์šฉ์ด๋‹ˆ ์ฐจ์น˜ํ•˜๊ณ , Kafka๋Š” ๊ฐ„๋‹จํžˆ ์ด์•ผ๊ธฐํ•˜๋ฉด in-out order์— ํŠนํ™”๋œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค. ์ด์— ๋Œ€ํ•ด์„œ๋Š” ํ–ฅํ›„ ํฌ์ŠคํŒ…์—์„œ ์กฐ๊ธˆ ๋” ์ž์„ธํžˆ ์•Œ์•„๋ด…์‹œ๋‹ค. 2018๋…„ 8์›” Hyperledger Seoul Meetup์—์„œ๋„ ๊ฐ„๋‹จํžˆ ๋‹ค๋ฃจ์—ˆ๋Š”๋ฐ, ๊ถ๊ธˆํ•˜์‹œ๋‹ค๋ฉด ์ด ํฌ์ŠคํŒ…์˜ ํ•˜๋‹จ๋ถ€๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

Phase 5: Committing Peer์—์„œ ํŠธ๋žœ์žญ์…˜์„ ๊ฒ€์ฆํ•˜๊ณ  ์ปค๋ฐ‹

ํŠธ๋žœ์žญ์…˜ ๋ธ”๋Ÿญ์ด ํ•ด๋‹น ์ฑ„๋„์˜ ๋ชจ๋“  Committing Peer์—๊ฒŒ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค. ๊ฐ๊ฐ์˜ committing peer๋Š” ๋ธ”๋Ÿญ ๋‚ด์˜ ๋ชจ๋“  ํŠธ๋žœ์žญ์…˜์ด ๊ฐ๊ฐ์˜ Endorsement policy๋ฅผ ์ค€์ˆ˜ํ•˜๋Š”์ง€, world state ๊ฐ’์˜ read-set ๋ฒ„์ „์ด ๋งž๋Š”์ง€(read-set ๋ฒ„์ „์€ ํŠธ๋žœ์žญ์…˜ ์ดํ›„์—๋งŒ ๋ณ€๊ฒฝ๋จ) ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ๊ฒ€์‚ฌ ๊ณผ์ •์ด ๋๋‚˜๋ฉด ํ•ด๋‹น ๋ธ”๋Ÿญ ๋‚ด์˜ ํŠธ๋žœ์žญ์…˜์—๋Š” valid/invalid ๊ฐ’์ด ํƒœ๊ทธ๋ฉ๋‹ˆ๋‹ค.

Phase 6: Ledger updated

์ถœ์ฒ˜: https://hyperledger-fabric.readthedocs.io/en/release-1.2/txflow.html

๊ฐ ํ”ผ์–ด๋Š” ์ตœ์ข… ๊ฒ€์ฆ์„ ๋งˆ์นœ ๋ธ”๋Ÿญ์„ ์ฑ„๋„ ๋‚ด ์ฒด์ธ์— ๋ถ™์ž…๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์œ ํšจํ•œ ํŠธ๋žœ์žญ์…˜์˜ ๊ฒฝ์šฐ write-set์ด state DB์— ์ž…๋ ฅ๋ฉ๋‹ˆ๋‹ค. ์ผ๋ จ์˜ ๊ณผ์ •์ด ๋งˆ๋ฌด๋ฆฌ๋˜๋ฉด ์ด๋ฒคํŠธ๋ฅผ ๋ฐœ์ƒ์‹œ์ผœ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ž‘์—… ๊ฒฐ๊ณผ์— ๋Œ€ํ•ด ์•Œ๋ฆฝ๋‹ˆ๋‹ค.

ํ† ๋ก  ์ฐธ๊ฐ€

์ด๋ฉ”์ผ์€ ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ์ž…๋ ฅ์ฐฝ์€ * ๋กœ ํ‘œ์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.