Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWSではじめるBlockchain/[DevelopersIO 2019 in OSAKA]...

maru1981
October 12, 2019

AWSではじめるBlockchain/[DevelopersIO 2019 in OSAKA]Blockchain starting with AWS

Developers.IO 2019 in 大阪での登壇資料

maru1981

October 12, 2019
Tweet

More Decks by maru1981

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ  ؙໟ ಞ࢙ʢϚϧϞΞπγʣ AWS ࣄۀຊ෦ ίϯαϧςΟϯά෦ॴଐ • ιϦϡʔγϣϯΞʔΩςΫτ •

    2018೥1݄ೖࣾ - 18೥ؒɺਆށͷ SIer ͰΠϯϑϥΤϯδχΞ • ޷͖ͳ AWS αʔϏε - Amazon CloudFront - AWS Transit Gateway - Amazon Managed Blockchain
  2. ैདྷܕͷ՝୊  wίετ w஥հίετ
 গֹܾࡁͰ͖ͳ͍ w࣌ؒతίετ w࠮ٗͳͲʹෆ࣮֬ੑʹ ର͢Δίετ ৴པͰ͖Δୈࡾऀ Alice

    Bob औҾ ѱҙͷϢʔβ ৴༻ ඞཁͳͷ͸ʮ୭ʯʹ΋ͱͮ ͘৴༻Ͱ͸ͳ͘ɺ҉߸ֶత ূ໌ʹجͮ͘ిࢠऔҾ
  3. Α͏΍͘ϒϩοΫͷొ৔  wτϥϯβΫγϣϯͷϒϩʔυΩϟετ
 ͢΂ͯͷτϥϯβΫγϣϯΛ஌Δ wλΠϜελϯϯϓʴσδλϧॺ໊
 ͋Δ࣌ࠁʹͦͷిࢠσʔλ͕ଘࡏ͍ͯͨ͜͠ͱͱɺͦΕҎ ߱վ͟Μ͞Ε͍ͯͳ͍͜ͱΛূ໌͢Δٕज़ wϒϩοΫ
 ෳ਺τϥϯβΫγϣϯʢ59ʣͷϋογϡ஋ΛϚʔΫϧϧʔ τʹ·ͱΊɺϧʔτϋογϡͷΈΛϒϩοΫϔομʔʹؚ

    ΊͯɺλΠϜελϯϓΛൃߦ
 ֤ϒϩοΫ͸ϋογϡνΣʔϯͰͭͳ͕ͬͯɺ͢΂ͯͷऔ Ҿ͕ه࿥͞Ε͍ͯΔ͜ͱ͔Β୆ாͱ͍ΘΕΔ ैདྷͷλΠϜελϯϓαʔό͸தԝूݖతͰ͋ΔͨΊɺ
 ඇதԝूݖతͳλΠϜελϯϓαʔό͕ඞཁʢ୭Λਖ਼ͱ͢Δͷ͔ʣ
  4. ϋογϡϨʔτʢ࠾۷଎౓ʣ  wϚΠχϯά͢Δࡍͷඵ͋ͨΓͷܭࢉྗ
 ɾϝΨIBTIT͸ຖඵສճͷϋογϡܭࢉ w &)ʢΤΫαϋογϡʣ
 ژճඵ w ໿ژճඵͷܭࢉ w

    ෼ͰϒϩοΫੜ੒͞ΕΔ Α͏ʹ೉қ౓ௐ੔͞ΕΔ w ϒϩοΫੜ੒͢Δͷʹ ژճYඵͷϋο γϡܭࢉΛͿΜճ͢
  5. .BOBHFE#MPDLDIBJO&EJUJPO  4UBSUFS&EJUJPO 4UBOEBSE&EUJPO ༻్ ςετ͓Αͼখن໛ͷ ຊ൪ωοτϫʔΫ ຊ൪ωοτϫʔΫ ϝϯόʔγοϓྉۚ ʢQFS)PVSʣ

      ωοτϫʔΫ͋ͨΓͷ ϝϯόʔ਺ ࠷େ̑ ࠷େ ϝϯόʔ͋ͨΓͷ ϐΞϊʔυ਺ ࠷େ̎ ࠷େ̏ ΠϯελϯελΠϓ CDUTNBMMCDUNFEJVN CDUTNBMMYMBSHF CDNDMBSHFYMBSHF τϥϯβΫγϣϯͷ εϧʔϓοτ͓ΑͼՄ༻ੑ 4UBOEBSEΑΓ௿͍ 4UBSUFSΑΓߴ͍
  6. )ZQFSMFEHFS'BCSJDͷίϯηϯαεϞσϧ  Hyperledger Fabric ೖ໳, ୈ 3 ճ ίϯηϯαε/Ordering Service/Kafka/Zookeeper

    w&OEPSTFNFOUϑΣʔζ
 
 &OEPSTJOH1FFSʹ5YΛૹ෇͠ɺ &OEPSTFNFOU1PMJDZ͕5YΛγϛϡϨʔ γϣϯͯ͠ॺ໊ΛՃ͑ɺΫϥΠΞϯτʹ ฦ৴ɻ
 
 γϛϡϨʔγϣϯͷࡍʹૹ৴ݩͷূ໌ॻ ͷݕূɺର৅νϟωϧ΁ͷΞΫηεݖͷ νΣοΫ΋ߦ͏ɻ
  7. )ZQFSMFEHFS'BCSJDͷίϯηϯαεϞσϧ  Hyperledger Fabric ೖ໳, ୈ 3 ճ ίϯηϯαε/Ordering Service/Kafka/Zookeeper

    w0SEFSJOHϑΣʔζ
 
 0SEFSJOH4FSWJDFʹ5Y ʢ&OEPSTJOH1FFSͷγϛϡ Ϩʔγϣϯ݁Ռɺॺ໊ɺνϟω ϧ*%ΛؚΉʣΛૹ෇
 
 0SEFSJOH4FSWJDF͕5YΛνϟ ωϧ͝ͱʹॱং෇͚ͯϒϩοΫ ʹ·ͱΊɺ$PNNJUUJOH1FFSʹ ϒϩοΫΛૹΔɻ
  8. )ZQFSMFEHFS'BCSJDͷίϯηϯαεϞσϧ  Hyperledger Fabric ೖ໳, ୈ 3 ճ ίϯηϯαε/Ordering Service/Kafka/Zookeeper

    w7BMJEBUJPOϑΣʔζ
 
 0SEFSJOH4FSWJDF͔Βड͚औͬͨ5YΛ $PNNJUUJOH1FFS͕ɺ&OEPSTFNFOU 1PMJDZΛຬͨͯ͠Δ͔ɺෳ਺ͷ5Y͕ಉ͡ ஋Λߋ৽ͯ͠ڝ߹͍ͯ͠ͳ͍͔ݕূ͢Δɻ
 
 ໰୊ͳ͚Ε͹$PNNJUUJOH1FFS͸
 ϒϩοΫΛ୆ாʹॻ͖ࠐΈɺεςʔτ%# Λߋ৽͢Δɻ
  9. 0SEFSJOH4FSWJDF  wτϥϯβΫγϣϯͷॱং෇͚ͱϒ ϩοΫͷ࡞੒ɺ1FFS΁ͷϒϩοΫ ૹ৴Λߦ͏ wνϟωϧͷ࠶ߏ੒ͱߏங wΫϥΠΞϯτͷΞΫηε੍ޚ w৑௕Խ͸,BGLB;PPLFFQFSͰ࣮ݱ ͍ͯ͠Δɻ,BGLB͕5YΛཷΊࠐΈɺ ϒϩοΫʹͯ͠ૹ৴͢Δɻ;PPLFFQFS

    ͕෼ࢄγεςϜΛ؅ཧ͢Δɻ
 Hyperledger Fabric ೖ໳, ୈ 3 ճ ίϯηϯαε/Ordering Service/Kafka/Zookeeper ".#͸,BGLBͰ͸ͳ͘2-%#ͷٕज़Ͱ଱ٱੑͱ৴པੑΛߴΊ͍ͯΔ
  10. .41 $"  w.41 .FNCFSTIJQ4FSWJDF1SPWJEFS 
 ɾূ໌ॻͷൃߦͱݕূɺϢʔβೝূΛߦ͏
 ɾ.41ͷΠϯελϯε͸Ұҙͳ.41*%ʢ.FNCFS*%ʣ
 ɹͱඥ෇͚ΒΕΔɻ
 ɾ.41৘ใ͕δΣωγεϒϩοΫʹ૊Έࠐ·ΕΔ͜ͱͰɺ


    ɹωοτϫʔΫࢀՃͷೝূΛߦ͍ɺνϟωϧʹࢀՃͰ͖Δɹ w$"
 ɾೝূͷͨΊʹඞཁͳূ໌ॻ΍ɺ伴Λൃߦ͢Δ
 ɾ".#Ͱ͸ηΩϡΞͳ$"αʔϏεʹ,.4Λ࢖༻ɹɹɹɹɹɹɹɹ
  11. εςοϓɿ)ZQFSMFEHFS'BCSJD$MJFOU  $ curl https://ca.m-dxguvikqg5bkbgczei5yusw3ue.n- q7tnhxnbxnaqlabhaueyck75jy.managedblockchain.us-east-1.amazonaws.com: 30002/cainfo -k {"result":{"CAName":"m- DXGUVIKQG5BKBGCZEI5YUSW3UE","CAChain":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FUR

    S0tLS0tCk1JSUNzakNDQWxtZ0F3SUJBZ0lVUCtXUjFvVWN3K0tGVVBVNW5jNFlaQ2Z kbGpRd0NnWUlLb1pJemowRUF3SXcKZ2JVeEN6QUpCZ
 (中略) WZyU0FUa3hIVlJQQWlBaWE5cVc1a2V3WVJyWgpKUG1zM2JWWitZa25KRDJZd0s5R 0ZMVE1qeHhvQUE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==","Version":" 1.2.1-snapshot-"} ,"errors":[],"messages":[],"success":true} w)'$MJFOU͔Β'BCSJD$"΁ͷ઀ଓ֬ೝ
  12. εςοϓɿ)ZQFSMFEHFS'BCSJD$MJFOU  $ go get -u github.com/hyperledger/fabric-ca/cmd/... $ cd /home/ec2-user/go/src/github.com/hyperledger/fabric-ca

    $ git fetch $ git checkout release-1.2 Branch 'release-1.2' set up to track remote branch 'release-1.2' from 'origin'. Switched to a new branch 'release-1.2' $ make fabric-ca-client Building fabric-ca-client in bin directory ... Built bin/fabric-ca-client $ cd /home/ec2-user $ git clone https://github.com/hyperledger/fabric-samples.git w$"ΫϥΠΞϯτΛߏ੒ wαϯϓϧϦϙδτϦͷෳ੡
  13. εςοϓɿ)ZQFSMFEHFS'BCSJD$MJFOU  (docker-compose-cli.yaml)
 $ cat docker-compose-cli.yaml version: '2' services: cli:

    container_name: cli image: hyperledger/fabric-tools:1.2.0 tty: true environment: - GOPATH=/opt/gopath - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - CORE_LOGGING_LEVEL=info # Set logging level to debug for more verbose logging - CORE_PEER_ID=cli - CORE_CHAINCODE_KEEPALIVE=10 working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer command: /bin/bash volumes: - /var/run/:/host/var/run/ - /home/ec2-user/fabric-samples/chaincode:/opt/gopath/src/github.com/ - /home/ec2-user:/opt/home w%PDLFS$PNQPTFΛߏ੒
  14. εςοϓɿ)ZQFSMFEHFS'BCSJD$MJFOU  $ docker-compose -f ~/docker-compose-cli.yaml up -d Creating network

    "ec2user_default" with the default driver Pulling cli (hyperledger/fabric-tools:1.2.0)... (略) Status: Downloaded newer image for hyperledger/fabric-tools:1.2.0 Creating cli ... done w)ZQFSMFEHFS'BCMJD$MJFOUىಈ
  15.  $ aws s3 cp s3://us-east-1.managedblockchain/etc/managedblockchain-tls-chain.pem /home/ ec2-user/managedblockchain-tls-chain.pem download: s3://us-east-1.managedblockchain/etc/managedblockchain-tls-chain.pem

    to ./ managedblockchain-tls-chain.pem $ openssl x509 -noout -text -in /home/ec2-user/managedblockchain-tls-chain.pem
 Certificate: Data: Version: 3 (0x2) Serial Number: 36:a8:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:3f:9b Signature Algorithm: sha256WithRSAEncryption Issuer: C=US, ST=WA, L=Seattle, O=Amazon Web Services, Inc., OU=Amazon Managed Blockchain, CN=Amazon Managed Blockchain us-east-1 Root CA Validity
 (以下、省略) wূ໌ॻϑΝΠϧΛ࡞੒ɺ಺༰ͷ֬ೝ εςοϓɿ؅ཧϢʔβͷొ࿥
  16.  $ fabric-ca-client enroll -u https://devioadmin:'ABC123!'@ca.m- dxguvikqg5bkbgczei5yusw3ue.n-q7tnhxnbxnaqlabhaueyck75jy.managedblockchain.us- east-1.amazonaws.com:30002 --tls.certfiles /home/ec2-user/managedblockchain-tls-

    chain.pem -M /home/ec2-user/admin-msp
 
 2019/09/05 22:27:18 [INFO] Created a default configuration file at /home/ec2-user/.fabric- ca-client/fabric-ca-client-config.yaml 2019/09/05 22:27:18 [INFO] TLS Enabled 2019/09/05 22:27:18 [INFO] generating key: &{A:ecdsa S:256} 2019/09/05 22:27:18 [INFO] encoded CSR 2019/09/05 22:27:18 [INFO] Stored client certificate at /home/ec2-user/admin-msp/ signcerts/cert.pem 2019/09/05 22:27:18 [INFO] Stored root CA certificate at /home/ec2-user/admin-msp/ cacerts/ca-m-dxguvikqg5bkbgczei5yusw3ue-n-q7tnhxnbxnaqlabhaueyck75jy- managedblockchain-us-east-1-amazonaws-com-30002.pem w؅ཧϢʔβΛొ࿥
 <VIUUQT"ENJO6TFSOBNF"ENJO1BTTXPSE!4BNQMF$"&OEQPJOU"OE1PSU> εςοϓɿ؅ཧϢʔβͷొ࿥
  17.  $ cat configtx.yaml Organizations: - &Org1 # DefaultOrg defines

    the organization which is used in the sampleconfig # of the fabric.git development environment Name: m-DXGUVIKQG5BKBGCZEI5YUSW3UE # ID to load the MSP definition as ID: m-DXGUVIKQG5BKBGCZEI5YUSW3UE MSPDir: /opt/home/admin-msp # AnchorPeers defines the location of peers which can be used # for cross org gossip communication. Note, this value is only # encoded in the genesis block in the Application section context
 AnchorPeers: - Host: Port: Application: &ApplicationDefaults # Organizations is the list of orgs which are defined as participants on # the application side of the network Organizations: 
 Profiles: OneOrgChannel: Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1 wνϟωϧߏ੒ϑΝΠϧʢDPOpHUYZNMʣͷ࡞੒ εςοϓɿ)ZQFSMFEHFS'BCSJDνϟωϧΛ࡞੒ Member-ID
  18.  $ docker exec cli configtxgen \
 -outputCreateChannelTx /opt/home/mychannel.pb \


    -profile OneOrgChannel -channelID mychannel \ --configPath /opt/home/ 2019-09-06 06:58:32.137 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration 2019-09-06 06:58:32.139 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx 2019-09-06 06:58:32.139 UTC [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml 2019-09-06 06:58:32.140 UTC [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the application org group m-DXGUVIKQG5BKBGCZEI5YUSW3UE in configtx.yaml 2019-09-06 06:58:32.140 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 005 Writing new channel tx wDPOpHUYϐΞϒϩοΫͷ࡞੒ εςοϓɿ)ZQFSMFEHFS'BCSJDνϟωϧΛ࡞੒ << νϟωϧ໊
  19.  # .bash_profile
 
 export MSP_PATH=/opt/home/admin-msp export MSP=m-DXGUVIKQG5BKBGCZEI5YUSW3UE export ORDERER=orderer.n-q7tnhxnbxnaqlabhaueyck75jy.managedblockchain.us-east-1.amazonaws.com:30001

    export PEER=nd-z3gz64hpmvc3no2ysx2d7bxiru.m-dxguvikqg5bkbgczei5yusw3ue.n- q7tnhxnbxnaqlabhaueyck75jy.managedblockchain.us-east-1.amazonaws.com:30003
 
 $ source ~/.bash_profile w؀ڥม਺ઃఆ εςοϓɿ)ZQFSMFEHFS'BCSJDνϟωϧΛ࡞੒
  20.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer channel create -c mychannel \ > -f /opt/home/mychannel.pb -o $ORDERER \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-06 10:28:41.260 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2019-09-06 10:28:41.397 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
 (中略)
 2019-09-06 10:28:43.555 UTC [channelCmd] InitCmdFactory -> INFO 017 Endorser and orderer connections initialized 2019-09-06 10:28:43.760 UTC [cli/common] readBlock -> INFO 018 Received block: 0 
 wνϟωϧ࡞੒ εςοϓɿ)ZQFSMFEHFS'BCSJDνϟωϧΛ࡞੒
  21.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer channel join -b mychannel.block \ > -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls
 2019-09-06 10:31:34.028 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2019-09-06 10:31:34.417 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
 wϐΞϊʔυΛνϟωϧʹࢀՃ εςοϓɿ)ZQFSMFEHFS'BCSJDνϟωϧΛ࡞੒
  22.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > cli peer chaincode install \ > -n mycc -v v0 -p github.com/chaincode_example02/go 2019-09-06 11:09:59.791 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-09-06 11:09:59.792 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2019-09-06 11:09:59.943 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > wνΣʔϯίʔυͷΠϯετʔϧ
 <QFFSDIBJODPEFJOTUBMMOνΣʔϯίʔυ໊WόʔδϣϯQύε> εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ
  23.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > cli peer chaincode instantiate \ > -o $ORDERER -C mychannel -n mycc -v v0 \ > -c '{"Args":["init","a","100","b","200"]}' \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-06 11:12:46.285 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-09-06 11:12:46.286 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc wνΣʔϯίʔυͷΠϯελϯεԽ εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ << -c Initؔ਺ʹ౉͢Ҿ਺
  24.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > cli peer chaincode list --instantiated \ > -o $ORDERER -C mychannel \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls Get instantiated chaincodes on channel mychannel: Name: mycc, Version: v0, Path: github.com/chaincode_example02/go, Escc: escc, Vscc: vscc wνΣʔϯίʔυͷΠϯελϯεԽΛ֬ೝ εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ ESCCʢEndorsement System ChainCodeʣ
 ɹɾTxͷϓϩϙʔβϧϨεϙϯεʹॺ໊͢ΔγεςϜνΣʔϯίʔυ
 VSCCʢValidation System ChainCodeʣ
 ɹɾΤϯυʔεϝϯτΛݕূ͢ΔγεςϜνΣʔϯίʔυ
  25.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode query -C mychannel \ > -n mycc -c '{"Args":["query","a"]}' 100 εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ wνΣʔϯίʔυͷΫΤϦ
  26.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode invoke -C mychannel \ > -n mycc -c '{"Args":["invoke","a","b","10"]}' \ > -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-06 11:18:33.984 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ wνΣʔϯίʔυͷݺͼग़͠ʢ*OWPLFʣ
  27.  $ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem"

    \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode query -C mychannel \ > -n mycc -c '{"Args":["query","a"]}' 90 εςοϓɿνΣʔϯίʔυͷΠϯετʔϧͱ࣮ߦ wνΣʔϯίʔυͷΫΤϦʢ*OWPLF݁Ռͷ֬ೝʣ
  28.  [ec2-user@Org1 ~]$ mkdir /home/ec2-user/org2-msp [ec2-user@Org1 ~]$ mkdir /home/ec2-user/org2-msp/admincerts [ec2-user@Org1

    ~]$ mkdir /home/ec2-user/org2-msp/cacerts 何らかの方法で、Org2から以下を取得 ・Org2のAdmin証明書(Org2 の /home/ec2-user/admin-msp/admincerts 以下) ・Org2のルートCA(Org2 の /home/ec2-user/admin-msp/cacerts 以下) [ec2-user@Org1 ~]$ cp Org2AdminCerts /home/ec2/org2-msp/admincerts [ec2-user@Org1 ~]$ cp Org2CACerts /home/ec2/org2-msp/cacerts εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒ wνϟωϧ࡞੒ऀ͸ɺࢀՃऀʢ0SHʣͷ.41ΞʔςΟϑΝΫτΛ࡞੒
  29.  $ cat configtx.yaml Organizations: - &Org1 Name: m-DXGUVIKQG5BKBGCZEI5YUSW3UE ID:

    m-DXGUVIKQG5BKBGCZEI5YUSW3UE MSPDir: /opt/home/admin-msp
 AnchorPeers: - Host: Port:
 - &Org2 Name: m-HDN2TMRMCJEHHD27SM2KZY7F2Q ID: m-HDN2TMRMCJEHHD27SM2KZY7F2Q MSPDir: /opt/home/org2-msp AnchorPeers: - Host: Port: Application: &ApplicationDefaults Organizations: 
 Profiles: TwoOrgChannel: Consortium: AWSSystemConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1
 - *Org2 wڞ༗νϟωϧͷνϟωϧߏ੒ϑΝΠϧʢDPOpHUYZNMʣͷ࡞੒ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  30.  [ec2-user@Org1 ~]$ docker exec cli configtxgen \ > -outputCreateChannelTx

    /opt/home/ourchannel.pb \ > -profile TwoOrgChannel -channelID ourchannel \ > --configPath /opt/home/ 2019-09-07 01:16:02.674 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration 2019-09-07 01:16:02.677 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx 2019-09-07 01:16:02.678 UTC [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml 2019-09-07 01:16:02.678 UTC [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the application org group m-DXGUVIKQG5BKBGCZEI5YUSW3UE in configtx.yaml 2019-09-07 01:16:02.678 UTC [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 005 Default policy emission is deprecated, please include policy specificiations for the application org group m-HDN2TMRMCJEHHD27SM2KZY7F2Q in configtx.yaml 2019-09-07 01:16:02.679 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx wDPOpHUYϐΞϒϩοΫͷ࡞੒ʢ0SHͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  31.  [ec2-user@Org1 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer channel create -c ourchannel \ > -f /opt/home/ourchannel.pb -o $ORDERER \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-07 01:27:43.173 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2019-09-07 01:27:43.284 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND} 2019-09-07 01:27:46.300 UTC [cli/common] readBlock -> INFO 01e Got status: &{NOT_FOUND} 2019-09-07 01:27:46.315 UTC [channelCmd] InitCmdFactory -> INFO 01f Endorser and orderer connections initialized 2019-09-07 01:27:46.522 UTC [cli/common] readBlock -> INFO 020 Received block: 0 wڞ༗νϟωϧΛ࡞੒ʢ0SHͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  32.  [ec2-user@Org2 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer channel fetch oldest /opt/home/ourchannel.block \ > -c ourchannel -o $ORDERER \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-07 01:34:07.914 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2019-09-07 01:34:07.919 UTC [cli/common] readBlock -> INFO 002 Received block: 0 wδΣωγεϒϩοΫͷऔಘʢ0SHͰ࣮ߦʣ
 νϟωϧʹࢀՃ͢Δϝϯόʔ͸ɺνϟωϧͷδΣωγεϒϩοΫΛऔಘ͢Δඞཁ͕͋Δ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  33.  [ec2-user@Org1 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer channel join -b /opt/home/ourchannel.block \ > -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-07 01:37:32.066 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2019-09-07 01:37:32.295 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join wϐΞϊʔυΛڞ༗νϟωϧʹࢀՃʢ0SH 0SHͷ྆ํͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  34.  [ec2-user@Org2 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > cli peer chaincode install -n mycc -v v0 \ > -p github.com/chaincode_example02/go 2019-09-07 02:05:51.527 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-09-07 02:05:51.527 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2019-09-07 02:05:51.823 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > wνΣʔϯίʔυͷΠϯετʔϧʢ0SH 0SHͷ྆ํͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  35.  [ec2-user@Org1 ~]$ docker exec -e “CORE_PEER_TLS_ENABLED=true” / > -e

    “CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem” \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > cli peer chaincode instantiate -o $ORDERER \ > -C ourchannel -n mycc -v v0 \ > -c '{"Args":["init","a","100","b","200"]}' \ > --cafile /opt/home/managedblockchain-tls-chain.pem --tls \ > -P "AND (‘m-DXGUVIKQG5BKBGCZEI5YUSW3UE.member’,'m-HDN2TMRMCJEHHD27SM2KZY7F2Q.member')" 2019-09-07 02:15:22.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2019-09-07 02:15:22.822 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc wνΣʔϯίʔυͷΠϯελϯεԽʢ0SHͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒ -P ͸Endorsment policyͷࢦఆ
 AND Λࢦఆ͍ͯ͠ΔͨΊɺ͜ͷCC͸྆ϝϯόʔͷঝೝ͕ͳ͍ͱ࣮ߦͰ͖ͳ͍
  36.  [ec2-user@Org2 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode query -C ourchannel \ > -n mycc -c '{"Args":["query","a"]}' 100 wνΣʔϯίʔυͷΫΤϦʢ0SHͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  37.  [ec2-user@Org1 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_ADDRESS2=$PEER2" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode invoke \ > -C ourchannel -n mycc -c '{"Args":["invoke","a","b","10"]}' \ > --peerAddresses $PEER \ > --tlsRootCertFiles /opt/home/managedblockchain-tls-chain.pem \ > --peerAddresses $PEER2 \ > --tlsRootCertFiles /opt/home/managedblockchain-tls-chain.pem \ > -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-07 02:30:14.176 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 wνΣʔϯίʔυͷݺͼग़͠ʢ0SHͰ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  38.  [ec2-user@Org2 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode query -C ourchannel \ > -n mycc -c '{"Args":["query","a"]}' 90 wνΣʔϯίʔυͷΫΤϦʢ0SHͰ݁Ռͷ֬ೝ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  39.  [ec2-user@Org1 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS2=$PEER2" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode invoke \ > -C ourchannel -n mycc -c '{"Args":["invoke","a","b","10"]}' \ > --peerAddresses $PEER2 \ > --tlsRootCertFiles /opt/home/managedblockchain-tls-chain.pem \ > -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls 2019-09-07 02:38:12.996 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 wνΣʔϯίʔυͷݺͼग़͠ʢ0SHͰ࣮ߦʣ
 ͭͷQFFS"EESFTTFTΛࢦఆͤͣʹνΣʔϯίʔυΛݺͼग़ͯ͠ΈΔ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  40.  [ec2-user@Org2 ~]$ docker exec -e "CORE_PEER_TLS_ENABLED=true" \ > -e

    "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \ > -e "CORE_PEER_ADDRESS=$PEER" \ > -e "CORE_PEER_LOCALMSPID=$MSP" \ > -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \ > cli peer chaincode query -C ourchannel \ > -n mycc -c '{"Args":["query","a"]}' 90�<< 変わっていない。
 
 ����AND条件のEndorsment policyであるため、
 ����一方のPeerにのみで呼び出しても台帳を更新することが出来ないことが確認できた。 wνΣʔϯίʔυͷΫΤϦʢ0SHͰ݁Ռͷ֬ೝ࣮ߦʣ εςοϓɿผͷ"84ΞΧ΢ϯτΛϝϯόʔʹট଴ͯ͠ڞಉνϟωϧ࡞੒
  41. ·ͱΊ  wͦ΋ͦ΋ϒϩοΫνΣʔϯ͕ඞཁͳͷ͔ΛΑ͘ߟ͑Δ
 ɾෆมతͳ୆ாσʔλϕʔε͕ཉ͍͠ͳΒ"NB[PO2-%#
 ɾ("ͳΓ·ͨ͠ʂ౦ژϦʔδϣϯͰ΋࢖͑·͢ wϑϨʔϜϫʔΫ
 ɾ)ZQFSMFEHFS'BCSJDɹϓϥΠϕʔτνΣʔϯ
 ɾ&UIFSFVNɹϓϥΠϕʔτPSύϒϦοΫνΣʔϯɹͨͩ͠$PNJOHTPPO wΤσΟγϣϯͷҧ͍
 ɾ4UBSUFSɺ4UBOEBSE


    ɾՁ֨ɺεέʔϧɺར༻ՄೳͳΠϯελϯελΠϓ w௿ίετɺ؆୯ʹߏங
 ɾैྔ՝ۚͳͷͰࣦ҆͘ഊͰ͖Δɻ໛ࡧ͍ͯͩ͘͠͞ɻ
 ɾ໘౗ͳ෦෼͸ϑϧϚωʔδυɻεϚʔτίϯτϥΫτ։ൃʹूதͰ͖Δɻ w"NB[PO.BOBHFE#MPDLDIBJO