# Hyperledger Korea UserGroup Meetup
# 2020๋ 04์ 23์ผ
# ์ฃผ์
- Hyperledger Fabric v2.0: What's New?
# ์๋ฃ
- 2020 Q1Hyperledger Update - https://docs.google.com/presentation/d/1-7Zu1CrekZcbLS1GyxyPQGChb3FZZxn5sY8HjIQx6o4/edit#slide=id.g59475fd5ec_0_115
- Hyperledger Fabric v2.0: What's New? - https://www.slideshare.net/hlkug/hyperledger-fabric-v20
- ํธ์ฆ์จ ๋ฉ (opens new window)
# Hyperledger Fabric v2.0: What's New?
# BYFN ๊ตฌ๋ ๋ฐ SACC ์ค์ต
# ์ฒด์ธ์ฝ๋ ํจํค์ง
```shell
# ์ฒด์ธ์ฝ๋ ๋น๋
$ cd ~/fabric-samples/chaincode/sacc
$ GO111MODULE=on go mod vendor
# ์ฒด์ธ์ฝ๋ ํจํค์ง ์์ฑ
$ docker exec cli peer lifecycle chaincode package sacc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/sacc/ --label sacc_1
```
# ์ฒด์ธ์ฝ๋ ์ค์น
```shell
# peer0.org1
$ docker exec cli peer lifecycle chaincode install sacc.tar.gz
2020-04-19 14:30:44.051 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nGsacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514\022\006sacc_1" >
2020-04-19 14:30:44.052 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: sacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514
## ํจํค์ง ID - sacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514
# peer0.org2
$ docker exec \
-e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp \
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051 \
-e CORE_PEER_LOCALMSPID="Org2MSP" \
-e CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt \
cli peer lifecycle chaincode install sacc.tar.gz
2020-04-19 14:31:17.137 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nGsacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514\022\006sacc_1" >
2020-04-19 14:31:17.138 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: sacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514
## ํจํค์ง ID - sacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514
# Peer์ ์ค์น๋ Chaincode ํ์ธํ๊ธฐ
$ docker exec cli peer lifecycle chaincode queryinstalled
Installed chaincodes on peer:
Package ID: sacc_1:1bfe84738f826868c2a15b7165faafe9172204bc447b0d8e0ac5ae925264a514, Label: sacc_1
```
# ์ฒด์ธ์ฝ๋ Approve
์ฒด์ธ์ฝ๋๋ฅผ ์ฑ๋์์ ์ฌ์ฉํ๊ธฐ ์ํด์๋ ์ฑ๋์ ํฌํจ๋ Org์ ์น์ธ์ด ํ์ํจ.
์น์ธ์ ํ์ํ ์ ์กฑ์๋ MAJORITY์ ๊ณผ๋ฐ์ ์ด์ (ex. 2๊ฐ์ Org์ธ ๊ฒฝ์ฐ 2๊ฐ์ Org์ ์น์ธ ํ์) ```shell
# peer0.org1
$ docker exec cli peer lifecycle chaincode approveformyorg \
--tls \
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \
--channelID mychannel \
--name mycc --version 1 \
--init-required --sequence 1 --waitForEvent \
--package-id ${PACKAGE_ID}
# peer0.org2
$ docker exec \
-e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp \
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051 \
-e CORE_PEER_LOCALMSPID="Org2MSP" \
-e CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt \
cli peer lifecycle chaincode approveformyorg \
--tls \
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \
--channelID mychannel --name mycc --version 1 \
--init-required --sequence 1 --waitForEvent \
--package-id ${PACKAGE_ID}
```
# ์ฒด์ธ์ฝ๋ Commit
์ฒด์ธ์ฝ๋๋ฅผ ํ์ฑํํ๊ธฐ ์ํด ์ฑ๋์ ์ฐธ์ฌํ๊ณ ์๋ Peer ์ค ํ๊ฐ์ Peer์์ ์ปค๋ฐ
```shell
# ์น์ธ ์ํ ํ์ธ
$ docker exec cli peer lifecycle chaincode checkcommitreadiness
--channelID mychannel --name mycc
--init-required --version 1 --sequence 1
--output json
{
"approvals": {
"Org1MSP": true,
"Org2MSP": true
}
}
# ์ฒด์ธ์ฝ๋ ์ปค๋ฐ(instantiate)
$ docker exec cli peer lifecycle chaincode commit \
-o orderer.example.com:7050 \
--tls \
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \
--peerAddresses peer0.org1.example.com:7051 \
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt \
--peerAddresses peer0.org2.example.com:9051 \
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt \
--channelID mychannel --name mycc --version 1 --sequence 1 \
--init-required
2020-04-19 14:58:25.807 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [e98348e2febd3cccc76ce30a1a47d58d5b4b0a28ab47f6b0b4804852a64a71db] committed with status (VALID) at peer0.org2.example.com:9051
2020-04-19 14:58:25.820 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [e98348e2febd3cccc76ce30a1a47d58d5b4b0a28ab47f6b0b4804852a64a71db] committed with status (VALID) at peer0.org1.example.com:7051
# ์ฒด์ธ์ฝ๋ ์ปค๋ฐ ์ํ ํ์ธ
$ docker exec cli peer lifecycle chaincode querycommitted \
--channelID mychannel --name mycc
Committed chaincode definition for chaincode 'mycc' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
```