catalogue
Delete Docker container of marbles private data link code
Start Fabric test network using CouchDB
Install and define a chain code with a collection
Interact with the test network as an Org1 administrator
Setting the Org1 identity environment variable
Private data link code of packed marbles
Interact with the test network as an Org2 administrator
Setting the Org2 identity environment variable
Set an environment variable for the chain code package
Org1 approval chain code definition
Setting the Org1 identity environment variable
Org1 approval chain code definition
Org2 approval chain code definition
Setting the Org2 identity environment variable
Org2 approval chain code definition
Submit chain code definition to channel
Setting the Org1 identity environment variable
Setting the Org2 identity environment variable
Query Org2 authorized private data
Query Org2 unauthorized private data
Setting the Org1 identity environment variable
View private data log on Org1 node
Query private price data of marble1 (data exists)
Create a new marble2 (first block)
View the private data log on the Org1 node (increase the height by 1)
Query private price data of marble1 (data exists)
Transfer marble2 to "joe" (second block)
View the private data log on the Org1 node (increase the height by 1)
Query private price data of marble1 (data exists)
Transfer marble2 to "tom" (the third block)
View the private data log on the Org1 node (increase the height by 1)
Query private price data of marble1 (data exists)
Transfer marble2 to "jerry" (the fourth block)
View the private data log on the Org1 node (increase the height by 1)
Query private price data of marble1 (data cleared)
The following is a demonstration of private data of marbles on the official website. Please refer to the official website for scenarios and details.
Clear network
[root@localhost fabric-samples]# cd test-network #Enter test network directory [root@localhost test-network]# ./network.sh down #Execute the clear network command Stopping network Removing network fabric_test WARNING: Network fabric_test not found. Removing volume docker_orderer.example.com WARNING: Volume docker_orderer.example.com not found. Removing volume docker_peer0.org1.example.com WARNING: Volume docker_peer0.org1.example.com not found. Removing volume docker_peer0.org2.example.com WARNING: Volume docker_peer0.org2.example.com not found. WARNING: The DOCKER_SOCK variable is not set. Defaulting to a blank string. Removing network fabric_test WARNING: Network fabric_test not found. Removing volume docker_peer0.org3.example.com WARNING: Volume docker_peer0.org3.example.com not found. Removing remaining containers Removing generated chaincode docker images
Install go dependency
[root@localhost test-network]# cd ../chaincode/marbles02_private//go # enter the pinball chain code directory [root@localhost go]# go mod vendor #Installation dependency go: downloading golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 go: downloading golang.org/x/sys v0.0.0-20210510120138-977fb7262007 go: downloading golang.org/x/text v0.3.3 [root@localhost go]# cd ../../../test-network #Return to test network directory
After the dependency is installed, a vendor folder will be generated in the directory
Delete Docker container of marbles private data link code
If it has been run before, execute the following command, otherwise skip
[root@localhost test-network]# docker rm -f $(docker ps -a | awk '($2 ~ /dev-peer.*.marblesp.*/) {print $1}') "docker rm" requires at least 1 argument. See 'docker rm --help'. Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers [root@localhost test-network]# docker rmi -f $(docker images | awk '($1 ~ /dev-peer.*.marblesp.*/) {print $3}') "docker rmi" requires at least 1 argument. See 'docker rmi --help'. Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] Remove one or more images
Start Fabric test network using CouchDB
[root@localhost test-network]# ./network.sh up createChannel -s couchdb ...... [root@localhost test-network]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5fc8c1b201ed hyperledger/fabric-tools:latest "/bin/bash" 37 seconds ago Up 37 seconds cli 48f80f076dd5 hyperledger/fabric-peer:latest "peer node start" 39 seconds ago Up 37 seconds 0.0.0.0:9051->9051/tcp, :::9051->9051/tcp, 7051/tcp, 0.0.0.0:19051->19051/tcp, :::19051->19051/tcp peer0.org2.example.com ed1c9d2d2522 hyperledger/fabric-peer:latest "peer node start" 39 seconds ago Up 37 seconds 0.0.0.0:7051->7051/tcp, :::7051->7051/tcp, 0.0.0.0:17051->17051/tcp, :::17051->17051/tcp peer0.org1.example.com aa7a6b3cf931 couchdb:3.1.1 "tini -- /docker-ent..." 40 seconds ago Up 39 seconds 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp, :::7984->5984/tcp couchdb1 e8b3d17a0043 couchdb:3.1.1 "tini -- /docker-ent..." 40 seconds ago Up 39 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp, :::5984->5984/tcp couchdb0 4576d37c82f4 hyperledger/fabric-orderer:latest "orderer" 40 seconds ago Up 39 seconds 0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:17050->17050/tcp, :::17050->17050/tcp orderer.example.com
This command will deploy a Fabric network, including a channel named mychannel, two organizations (each has a Peer node). The Peer node will use CouchDB as the status database and a sorting node
Install and define a chain code with a collection
Interact with the test network as an Org1 administrator
Setting the Org1 identity environment variable
[root@localhost test-network]# export PATH=${PWD}/../bin:$PATH [root@localhost test-network]# export FABRIC_CFG_PATH=$PWD/../config/ [root@localhost test-network]# export CORE_PEER_TLS_ENABLED=true [root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org1MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:7051
Private data link code of packed marbles
[root@localhost test-network]# peer lifecycle chaincode package marblesp.tar.gz --path ../chaincode/marbles02_private/go/ --lang golang --label marblespv1
After packaging, the chain code package will be generated in the test network directory
Installation chain code
The chain code will be installed on the peer0.org1.example.com node
[root@localhost test-network]# peer lifecycle chaincode install marblesp.tar.gz 2021-11-07 01:31:25.074 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nKmarblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d\022\nmarblespv1" > 2021-11-07 01:31:25.074 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d
Interact with the test network as an Org2 administrator
Setting the Org2 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org2MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:9051
Installation chain code
The chain code will be installed on the peer0.org2.example.com node
[root@localhost test-network]# peer lifecycle chaincode install marblesp.tar.gz 2021-11-07 01:35:13.044 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nKmarblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d\022\nmarblespv1" > 2021-11-07 01:35:13.044 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d
View chain code Package ID
[root@localhost test-network]# peer lifecycle chaincode queryinstalled Installed chaincodes on peer: Package ID: marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d, Label: marblespv1
Set an environment variable for the chain code package
The chain code package ID is the chain code package ID found above, which can be obtained by copying and pasting
[root@localhost test-network]# export CC_PACKAGE_ID=marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d
Org1 approval chain code definition
Setting the Org1 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org1MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:7051
Org1 approval chain code definition
[root@localhost test-network]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem [root@localhost test-network]# peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name marblesp --version 1.0 --collections-config ../chaincode/marbles02_private/collections_config.json --signature-policy "OR('Org1MSP.member','Org2MSP.member')" --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile $ORDERER_CA 2021-11-07 01:46:58.451 CST [chaincodeCmd] ClientWait -> INFO 001 txid [c66404cd6be5022f8c94f1228312982e1d2862b4ab3cfaf17df0b040dcfcc528] committed with status (VALID) at localhost:7051
Org2 approval chain code definition
Setting the Org2 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org2MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:9051
Org2 approval chain code definition
[root@localhost test-network]# peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name marblesp --version 1.0 --collections-config ../chaincode/marbles02_private/collections_config.json --signature-policy "OR('Org1MSP.member','Org2MSP.member')" --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile $ORDERER_CA 2021-11-07 01:49:59.980 CST [chaincodeCmd] ClientWait -> INFO 001 txid [106791c8c46927911a62abf6a2f34d6d390a0a8c3b9b5239c0a0ac63851a0315] committed with status (VALID) at localhost:9051
Submit chain code definition to channel
When most members of an organization approve the chain code definition, the organization can submit the chain code definition to the channel.
[root@localhost test-network]# export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem [root@localhost test-network]# export ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt [root@localhost test-network]# export ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt [root@localhost test-network]# peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name marblesp --version 1.0 --sequence 1 --collections-config ../chaincode/marbles02_private/collections_config.json --signature-policy "OR('Org1MSP.member','Org2MSP.member')" --tls --cafile $ORDERER_CA --peerAddresses localhost:7051 --tlsRootCertFiles $ORG1_CA --peerAddresses localhost:9051 --tlsRootCertFiles $ORG2_CA 2021-11-07 01:52:27.811 CST [chaincodeCmd] ClientWait -> INFO 001 txid [1663d4659df3a510aeb81806e8828e9036ec70cc6d9ff8a0a18957ef5852bc37] committed with status (VALID) at localhost:9051 2021-11-07 01:52:27.926 CST [chaincodeCmd] ClientWait -> INFO 002 txid [1663d4659df3a510aeb81806e8828e9036ec70cc6d9ff8a0a18957ef5852bc37] committed with status (VALID) at localhost:7051
Store private data
Switch to Org1 identity
Setting the Org1 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org1MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:7051
Store private data
[root@localhost test-network]# export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64 | tr -d \\n) s/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["InitMarble"]}' --transient "{\"marble\":\"$MARBLE\"}"[root@locarer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["InitMarble"]}' --transient "{\"marble\":\"$MARBLE\"}" 2021-11-07 02:10:35.326 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
Query private data
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarble","marble1"]}' {"docType":"Marble","name":"marble1","color":"blue","size":35,"owner":"tom"}
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99}
Switch to Org2 identity
Setting the Org2 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org2MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:9051
Query Org2 authorized private data
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarble","marble1"]}' {"docType":"Marble","name":"marble1","color":"blue","size":35,"owner":"tom"}
Query Org2 unauthorized private data
An error will be reported
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' Error: endorsement failure during query. response: status:500 message:"failed to read from marble details GET_STATE failed: transaction ID: 28023bee3887eed57267ab51587cda564eec503146a99e7ba7398596fd1224b2: tx creator does not have read access permission on privatedata in chaincodeName:marblesp collectionName: collectionMarblePrivateDetails"
Clear private data
See the official website for scene description
Switch to Org1 identity
Setting the Org1 identity environment variable
[root@localhost test-network]# export CORE_PEER_LOCALMSPID="Org1MSP" [root@localhost test-network]# export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt [root@localhost test-network]# export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp [root@localhost test-network]# export CORE_PEER_ADDRESS=localhost:7051
View private data log on Org1 node
Open a new terminal window
[root@localhost ~]# docker logs peer0.org1.example.com 2>&1 | grep -i -a -E 'private|pvt|privdata' 2021-11-06 17:14:03.089 UTC [kvledger] commit -> INFO 026 [mychannel] Committed block [0] with 1 transaction(s) in 33ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=31ms) commitHash=[] 2021-11-06 17:14:06.619 UTC [gossip.privdata] StoreBlock -> INFO 031 Received block [1] from buffer channel=mychannel 2021-11-06 17:14:06.645 UTC [kvledger] commit -> INFO 03b [mychannel] Committed block [1] with 1 transaction(s) in 19ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=16ms) commitHash=[47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254] 2021-11-06 17:14:06.913 UTC [gossip.privdata] StoreBlock -> INFO 03d Received block [2] from buffer channel=mychannel 2021-11-06 17:14:06.942 UTC [kvledger] commit -> INFO 047 [mychannel] Committed block [2] with 1 transaction(s) in 20ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=18ms) commitHash=[5f88b61407b149a48413433f4670c46531e5c4a8febdc339a9536ff8716a559e] 2021-11-06 17:46:56.398 UTC [lifecycle] ApproveChaincodeDefinitionForOrg -> INFO 04f Successfully endorsed chaincode approval with name 'marblesp', package ID 'marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d', on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:46:58.405 UTC [gossip.privdata] StoreBlock -> INFO 052 Received block [3] from buffer channel=mychannel 2021-11-06 17:46:58.406 UTC [gossip.privdata] RetrievePvtdata -> INFO 054 Successfully fetched all 1 eligible collection private write sets for block [3] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 17:46:58.450 UTC [kvledger] commit -> INFO 055 [mychannel] Committed block [3] with 1 transaction(s) in 43ms (state_validation=4ms block_and_pvtdata_commit=1ms state_commit=37ms) commitHash=[0f032d62813838d70175bc2b327c5e0635899c3da5660d16fba0a6531f17af4f] 2021-11-06 17:49:59.928 UTC [gossip.privdata] StoreBlock -> INFO 057 Received block [4] from buffer channel=mychannel 2021-11-06 17:50:00.023 UTC [kvledger] commit -> INFO 05a [mychannel] Committed block [4] with 1 transaction(s) in 92ms (state_validation=69ms block_and_pvtdata_commit=1ms state_commit=20ms) commitHash=[0c0a6bd1169b70de40935b59785c26040fd8936e8b8130019f5a64da47dd3bb9] 2021-11-06 17:52:25.439 UTC [lifecycle] CheckCommitReadiness -> INFO 05b Successfully checked commit readiness of chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:25.440 UTC [lifecycle] CommitChaincodeDefinition -> INFO 05c Successfully endorsed commit for chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:27.476 UTC [gossip.privdata] StoreBlock -> INFO 05f Received block [5] from buffer channel=mychannel 2021-11-06 17:52:27.923 UTC [kvledger] commit -> INFO 067 [mychannel] Committed block [5] with 1 transaction(s) in 445ms (state_validation=401ms block_and_pvtdata_commit=15ms state_commit=29ms) commitHash=[bec41e198c6f92a1b10e3926cde239da79234ba4fdc10ad0cd8bc92edcd35847] 2021-11-06 18:10:37.331 UTC [gossip.privdata] StoreBlock -> INFO 06c Received block [6] from buffer channel=mychannel 2021-11-06 18:10:37.332 UTC [gossip.privdata] RetrievePvtdata -> INFO 06e Successfully fetched all 2 eligible collection private write sets for block [6] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:10:37.366 UTC [couchdb] createDatabaseIfNotExist -> INFO 06f Created state database mychannel_marblesp$$hcollection$marble$private$details 2021-11-06 18:10:37.392 UTC [couchdb] createDatabaseIfNotExist -> INFO 070 Created state database mychannel_marblesp$$pcollection$marble$private$details 2021-11-06 18:10:37.447 UTC [kvledger] commit -> INFO 071 [mychannel] Committed block [6] with 1 transaction(s) in 114ms (state_validation=1ms block_and_pvtdata_commit=1ms state_commit=109ms) commitHash=[c07191cc2bb565dea385c864c5a673265a1ff5f1cbe2fffc8a1d8c99c319123c]
View that the block height is 6
Query private price data of marble1 (data exists)
Back to the node container
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99}
At present, the price data exists in the private database
Create a new marble2 (first block)
[root@localhost test-network]# export MARBLE=$(echo -n "{\"name\":\"marble2\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64 | tr -d \\n) s/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["InitMarble"]}' --transient "{\"marble\":\"$MARBLE\"}"[root@locarer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["InitMarble"]}' --transient "{\"marble\":\"$MARBLE\"}" 2021-11-07 02:35:55.032 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
View the private data log on the Org1 node (increase the height by 1)
Switch to the view private data log terminal window
[root@localhost ~]# docker logs peer0.org1.example.com 2>&1 | grep -i -a -E 'private|pvt|privdata' 2021-11-06 17:14:03.089 UTC [kvledger] commit -> INFO 026 [mychannel] Committed block [0] with 1 transaction(s) in 33ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=31ms) commitHash=[] 2021-11-06 17:14:06.619 UTC [gossip.privdata] StoreBlock -> INFO 031 Received block [1] from buffer channel=mychannel 2021-11-06 17:14:06.645 UTC [kvledger] commit -> INFO 03b [mychannel] Committed block [1] with 1 transaction(s) in 19ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=16ms) commitHash=[47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254] 2021-11-06 17:14:06.913 UTC [gossip.privdata] StoreBlock -> INFO 03d Received block [2] from buffer channel=mychannel 2021-11-06 17:14:06.942 UTC [kvledger] commit -> INFO 047 [mychannel] Committed block [2] with 1 transaction(s) in 20ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=18ms) commitHash=[5f88b61407b149a48413433f4670c46531e5c4a8febdc339a9536ff8716a559e] 2021-11-06 17:46:56.398 UTC [lifecycle] ApproveChaincodeDefinitionForOrg -> INFO 04f Successfully endorsed chaincode approval with name 'marblesp', package ID 'marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d', on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:46:58.405 UTC [gossip.privdata] StoreBlock -> INFO 052 Received block [3] from buffer channel=mychannel 2021-11-06 17:46:58.406 UTC [gossip.privdata] RetrievePvtdata -> INFO 054 Successfully fetched all 1 eligible collection private write sets for block [3] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 17:46:58.450 UTC [kvledger] commit -> INFO 055 [mychannel] Committed block [3] with 1 transaction(s) in 43ms (state_validation=4ms block_and_pvtdata_commit=1ms state_commit=37ms) commitHash=[0f032d62813838d70175bc2b327c5e0635899c3da5660d16fba0a6531f17af4f] 2021-11-06 17:49:59.928 UTC [gossip.privdata] StoreBlock -> INFO 057 Received block [4] from buffer channel=mychannel 2021-11-06 17:50:00.023 UTC [kvledger] commit -> INFO 05a [mychannel] Committed block [4] with 1 transaction(s) in 92ms (state_validation=69ms block_and_pvtdata_commit=1ms state_commit=20ms) commitHash=[0c0a6bd1169b70de40935b59785c26040fd8936e8b8130019f5a64da47dd3bb9] 2021-11-06 17:52:25.439 UTC [lifecycle] CheckCommitReadiness -> INFO 05b Successfully checked commit readiness of chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:25.440 UTC [lifecycle] CommitChaincodeDefinition -> INFO 05c Successfully endorsed commit for chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:27.476 UTC [gossip.privdata] StoreBlock -> INFO 05f Received block [5] from buffer channel=mychannel 2021-11-06 17:52:27.923 UTC [kvledger] commit -> INFO 067 [mychannel] Committed block [5] with 1 transaction(s) in 445ms (state_validation=401ms block_and_pvtdata_commit=15ms state_commit=29ms) commitHash=[bec41e198c6f92a1b10e3926cde239da79234ba4fdc10ad0cd8bc92edcd35847] 2021-11-06 18:10:37.331 UTC [gossip.privdata] StoreBlock -> INFO 06c Received block [6] from buffer channel=mychannel 2021-11-06 18:10:37.332 UTC [gossip.privdata] RetrievePvtdata -> INFO 06e Successfully fetched all 2 eligible collection private write sets for block [6] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:10:37.366 UTC [couchdb] createDatabaseIfNotExist -> INFO 06f Created state database mychannel_marblesp$$hcollection$marble$private$details 2021-11-06 18:10:37.392 UTC [couchdb] createDatabaseIfNotExist -> INFO 070 Created state database mychannel_marblesp$$pcollection$marble$private$details 2021-11-06 18:10:37.447 UTC [kvledger] commit -> INFO 071 [mychannel] Committed block [6] with 1 transaction(s) in 114ms (state_validation=1ms block_and_pvtdata_commit=1ms state_commit=109ms) commitHash=[c07191cc2bb565dea385c864c5a673265a1ff5f1cbe2fffc8a1d8c99c319123c] 2021-11-06 18:35:57.040 UTC [gossip.privdata] StoreBlock -> INFO 07a Received block [7] from buffer channel=mychannel 2021-11-06 18:35:57.045 UTC [gossip.privdata] RetrievePvtdata -> INFO 07c Successfully fetched all 2 eligible collection private write sets for block [7] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:35:57.131 UTC [kvledger] commit -> INFO 07d [mychannel] Committed block [7] with 1 transaction(s) in 86ms (state_validation=9ms block_and_pvtdata_commit=3ms state_commit=72ms) commitHash=[954438a7a6f0c24e5c9159706f4b6cf6fe48283a806ec43d8515ca96f9c2f35b]
It is found that the height of the block is 7, and 1 height is added
Query private price data of marble1 (data exists)
Return to the container node terminal window
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99}
Transfer marble2 to "joe" (second block)
[root@localhost test-network]# export MARBLE_OWNER=$(echo -n "{\"name\":\"marble2\",\"owner\":\"joe\"}" | base64 | tr -d \\n) erers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}"[root@localhost test-network]# prer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}" 2021-11-07 02:45:07.529 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
View the private data log on the Org1 node (increase the height by 1)
Switch to the view private data log terminal window
[root@localhost ~]# docker logs peer0.org1.example.com 2>&1 | grep -i -a -E 'private|pvt|privdata' 2021-11-06 17:14:03.089 UTC [kvledger] commit -> INFO 026 [mychannel] Committed block [0] with 1 transaction(s) in 33ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=31ms) commitHash=[] 2021-11-06 17:14:06.619 UTC [gossip.privdata] StoreBlock -> INFO 031 Received block [1] from buffer channel=mychannel 2021-11-06 17:14:06.645 UTC [kvledger] commit -> INFO 03b [mychannel] Committed block [1] with 1 transaction(s) in 19ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=16ms) commitHash=[47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254] 2021-11-06 17:14:06.913 UTC [gossip.privdata] StoreBlock -> INFO 03d Received block [2] from buffer channel=mychannel 2021-11-06 17:14:06.942 UTC [kvledger] commit -> INFO 047 [mychannel] Committed block [2] with 1 transaction(s) in 20ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=18ms) commitHash=[5f88b61407b149a48413433f4670c46531e5c4a8febdc339a9536ff8716a559e] 2021-11-06 17:46:56.398 UTC [lifecycle] ApproveChaincodeDefinitionForOrg -> INFO 04f Successfully endorsed chaincode approval with name 'marblesp', package ID 'marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d', on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:46:58.405 UTC [gossip.privdata] StoreBlock -> INFO 052 Received block [3] from buffer channel=mychannel 2021-11-06 17:46:58.406 UTC [gossip.privdata] RetrievePvtdata -> INFO 054 Successfully fetched all 1 eligible collection private write sets for block [3] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 17:46:58.450 UTC [kvledger] commit -> INFO 055 [mychannel] Committed block [3] with 1 transaction(s) in 43ms (state_validation=4ms block_and_pvtdata_commit=1ms state_commit=37ms) commitHash=[0f032d62813838d70175bc2b327c5e0635899c3da5660d16fba0a6531f17af4f] 2021-11-06 17:49:59.928 UTC [gossip.privdata] StoreBlock -> INFO 057 Received block [4] from buffer channel=mychannel 2021-11-06 17:50:00.023 UTC [kvledger] commit -> INFO 05a [mychannel] Committed block [4] with 1 transaction(s) in 92ms (state_validation=69ms block_and_pvtdata_commit=1ms state_commit=20ms) commitHash=[0c0a6bd1169b70de40935b59785c26040fd8936e8b8130019f5a64da47dd3bb9] 2021-11-06 17:52:25.439 UTC [lifecycle] CheckCommitReadiness -> INFO 05b Successfully checked commit readiness of chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:25.440 UTC [lifecycle] CommitChaincodeDefinition -> INFO 05c Successfully endorsed commit for chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:27.476 UTC [gossip.privdata] StoreBlock -> INFO 05f Received block [5] from buffer channel=mychannel 2021-11-06 17:52:27.923 UTC [kvledger] commit -> INFO 067 [mychannel] Committed block [5] with 1 transaction(s) in 445ms (state_validation=401ms block_and_pvtdata_commit=15ms state_commit=29ms) commitHash=[bec41e198c6f92a1b10e3926cde239da79234ba4fdc10ad0cd8bc92edcd35847] 2021-11-06 18:10:37.331 UTC [gossip.privdata] StoreBlock -> INFO 06c Received block [6] from buffer channel=mychannel 2021-11-06 18:10:37.332 UTC [gossip.privdata] RetrievePvtdata -> INFO 06e Successfully fetched all 2 eligible collection private write sets for block [6] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:10:37.366 UTC [couchdb] createDatabaseIfNotExist -> INFO 06f Created state database mychannel_marblesp$$hcollection$marble$private$details 2021-11-06 18:10:37.392 UTC [couchdb] createDatabaseIfNotExist -> INFO 070 Created state database mychannel_marblesp$$pcollection$marble$private$details 2021-11-06 18:10:37.447 UTC [kvledger] commit -> INFO 071 [mychannel] Committed block [6] with 1 transaction(s) in 114ms (state_validation=1ms block_and_pvtdata_commit=1ms state_commit=109ms) commitHash=[c07191cc2bb565dea385c864c5a673265a1ff5f1cbe2fffc8a1d8c99c319123c] 2021-11-06 18:35:57.040 UTC [gossip.privdata] StoreBlock -> INFO 07a Received block [7] from buffer channel=mychannel 2021-11-06 18:35:57.045 UTC [gossip.privdata] RetrievePvtdata -> INFO 07c Successfully fetched all 2 eligible collection private write sets for block [7] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:35:57.131 UTC [kvledger] commit -> INFO 07d [mychannel] Committed block [7] with 1 transaction(s) in 86ms (state_validation=9ms block_and_pvtdata_commit=3ms state_commit=72ms) commitHash=[954438a7a6f0c24e5c9159706f4b6cf6fe48283a806ec43d8515ca96f9c2f35b] 2021-11-06 18:45:09.541 UTC [gossip.privdata] StoreBlock -> INFO 082 Received block [8] from buffer channel=mychannel 2021-11-06 18:45:09.544 UTC [gossip.privdata] RetrievePvtdata -> INFO 084 Successfully fetched all 1 eligible collection private write sets for block [8] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:45:09.575 UTC [kvledger] commit -> INFO 085 [mychannel] Committed block [8] with 1 transaction(s) in 30ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=28ms) commitHash=[57e3c33dbb4133920a306a672aa325d72fa7ab68aaca504d2f475f45ba77640e]
It is found that the height of the block is 8, and 1 height is added
Query private price data of marble1 (data exists)
Return to the container node terminal window
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99}
Transfer marble2 to "tom" (the third block)
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99} [root@localhost test-network]# export MARBLE_OWNER=$(echo -n "{\"name\":\"marble2\",\"owner\":\"tom\"}" | base64 | tr -d \\n) erers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}"[root@localhost test-network]# prer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}" 2021-11-07 02:49:12.155 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
View the private data log on the Org1 node (increase the height by 1)
Switch to the view private data log terminal window
[root@localhost ~]# docker logs peer0.org1.example.com 2>&1 | grep -i -a -E 'private|pvt|privdata' 2021-11-06 17:14:03.089 UTC [kvledger] commit -> INFO 026 [mychannel] Committed block [0] with 1 transaction(s) in 33ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=31ms) commitHash=[] 2021-11-06 17:14:06.619 UTC [gossip.privdata] StoreBlock -> INFO 031 Received block [1] from buffer channel=mychannel 2021-11-06 17:14:06.645 UTC [kvledger] commit -> INFO 03b [mychannel] Committed block [1] with 1 transaction(s) in 19ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=16ms) commitHash=[47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254] 2021-11-06 17:14:06.913 UTC [gossip.privdata] StoreBlock -> INFO 03d Received block [2] from buffer channel=mychannel 2021-11-06 17:14:06.942 UTC [kvledger] commit -> INFO 047 [mychannel] Committed block [2] with 1 transaction(s) in 20ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=18ms) commitHash=[5f88b61407b149a48413433f4670c46531e5c4a8febdc339a9536ff8716a559e] 2021-11-06 17:46:56.398 UTC [lifecycle] ApproveChaincodeDefinitionForOrg -> INFO 04f Successfully endorsed chaincode approval with name 'marblesp', package ID 'marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d', on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:46:58.405 UTC [gossip.privdata] StoreBlock -> INFO 052 Received block [3] from buffer channel=mychannel 2021-11-06 17:46:58.406 UTC [gossip.privdata] RetrievePvtdata -> INFO 054 Successfully fetched all 1 eligible collection private write sets for block [3] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 17:46:58.450 UTC [kvledger] commit -> INFO 055 [mychannel] Committed block [3] with 1 transaction(s) in 43ms (state_validation=4ms block_and_pvtdata_commit=1ms state_commit=37ms) commitHash=[0f032d62813838d70175bc2b327c5e0635899c3da5660d16fba0a6531f17af4f] 2021-11-06 17:49:59.928 UTC [gossip.privdata] StoreBlock -> INFO 057 Received block [4] from buffer channel=mychannel 2021-11-06 17:50:00.023 UTC [kvledger] commit -> INFO 05a [mychannel] Committed block [4] with 1 transaction(s) in 92ms (state_validation=69ms block_and_pvtdata_commit=1ms state_commit=20ms) commitHash=[0c0a6bd1169b70de40935b59785c26040fd8936e8b8130019f5a64da47dd3bb9] 2021-11-06 17:52:25.439 UTC [lifecycle] CheckCommitReadiness -> INFO 05b Successfully checked commit readiness of chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:25.440 UTC [lifecycle] CommitChaincodeDefinition -> INFO 05c Successfully endorsed commit for chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:27.476 UTC [gossip.privdata] StoreBlock -> INFO 05f Received block [5] from buffer channel=mychannel 2021-11-06 17:52:27.923 UTC [kvledger] commit -> INFO 067 [mychannel] Committed block [5] with 1 transaction(s) in 445ms (state_validation=401ms block_and_pvtdata_commit=15ms state_commit=29ms) commitHash=[bec41e198c6f92a1b10e3926cde239da79234ba4fdc10ad0cd8bc92edcd35847] 2021-11-06 18:10:37.331 UTC [gossip.privdata] StoreBlock -> INFO 06c Received block [6] from buffer channel=mychannel 2021-11-06 18:10:37.332 UTC [gossip.privdata] RetrievePvtdata -> INFO 06e Successfully fetched all 2 eligible collection private write sets for block [6] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:10:37.366 UTC [couchdb] createDatabaseIfNotExist -> INFO 06f Created state database mychannel_marblesp$$hcollection$marble$private$details 2021-11-06 18:10:37.392 UTC [couchdb] createDatabaseIfNotExist -> INFO 070 Created state database mychannel_marblesp$$pcollection$marble$private$details 2021-11-06 18:10:37.447 UTC [kvledger] commit -> INFO 071 [mychannel] Committed block [6] with 1 transaction(s) in 114ms (state_validation=1ms block_and_pvtdata_commit=1ms state_commit=109ms) commitHash=[c07191cc2bb565dea385c864c5a673265a1ff5f1cbe2fffc8a1d8c99c319123c] 2021-11-06 18:35:57.040 UTC [gossip.privdata] StoreBlock -> INFO 07a Received block [7] from buffer channel=mychannel 2021-11-06 18:35:57.045 UTC [gossip.privdata] RetrievePvtdata -> INFO 07c Successfully fetched all 2 eligible collection private write sets for block [7] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:35:57.131 UTC [kvledger] commit -> INFO 07d [mychannel] Committed block [7] with 1 transaction(s) in 86ms (state_validation=9ms block_and_pvtdata_commit=3ms state_commit=72ms) commitHash=[954438a7a6f0c24e5c9159706f4b6cf6fe48283a806ec43d8515ca96f9c2f35b] 2021-11-06 18:45:09.541 UTC [gossip.privdata] StoreBlock -> INFO 082 Received block [8] from buffer channel=mychannel 2021-11-06 18:45:09.544 UTC [gossip.privdata] RetrievePvtdata -> INFO 084 Successfully fetched all 1 eligible collection private write sets for block [8] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:45:09.575 UTC [kvledger] commit -> INFO 085 [mychannel] Committed block [8] with 1 transaction(s) in 30ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=28ms) commitHash=[57e3c33dbb4133920a306a672aa325d72fa7ab68aaca504d2f475f45ba77640e] 2021-11-06 18:49:14.162 UTC [gossip.privdata] StoreBlock -> INFO 08a Received block [9] from buffer channel=mychannel 2021-11-06 18:49:14.165 UTC [gossip.privdata] RetrievePvtdata -> INFO 08c Successfully fetched all 1 eligible collection private write sets for block [9] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:49:14.212 UTC [kvledger] commit -> INFO 08d [mychannel] Committed block [9] with 1 transaction(s) in 47ms (state_validation=1ms block_and_pvtdata_commit=6ms state_commit=37ms) commitHash=[5e6ce96e8a9cdfc6c270039528a887c68cb30ae0ace7b764dee0b74df4c49b4e]
It is found that the height of the block is 9, and 1 height is added
Query private price data of marble1 (data exists)
Return to the container node terminal window
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' {"docType":"MarblePrivateDetails","name":"marble1","price":99}
Transfer marble2 to "jerry" (the fourth block)
[root@localhost test-network]# export MARBLE_OWNER=$(echo -n "{\"name\":\"marble2\",\"owner\":\"jerry\"}" | base64 | tr -d \\n) rderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}"[root@localhost test-network]#rer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["TransferMarble"]}' --transient "{\"marble_owner\":\"$MARBLE_OWNER\"}" 2021-11-07 02:55:43.723 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
View the private data log on the Org1 node (increase the height by 1)
Switch to the view private data log terminal window
[root@localhost ~]# docker logs peer0.org1.example.com 2>&1 | grep -i -a -E 'private|pvt|privdata' 2021-11-06 17:14:03.089 UTC [kvledger] commit -> INFO 026 [mychannel] Committed block [0] with 1 transaction(s) in 33ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=31ms) commitHash=[] 2021-11-06 17:14:06.619 UTC [gossip.privdata] StoreBlock -> INFO 031 Received block [1] from buffer channel=mychannel 2021-11-06 17:14:06.645 UTC [kvledger] commit -> INFO 03b [mychannel] Committed block [1] with 1 transaction(s) in 19ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=16ms) commitHash=[47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254] 2021-11-06 17:14:06.913 UTC [gossip.privdata] StoreBlock -> INFO 03d Received block [2] from buffer channel=mychannel 2021-11-06 17:14:06.942 UTC [kvledger] commit -> INFO 047 [mychannel] Committed block [2] with 1 transaction(s) in 20ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=18ms) commitHash=[5f88b61407b149a48413433f4670c46531e5c4a8febdc339a9536ff8716a559e] 2021-11-06 17:46:56.398 UTC [lifecycle] ApproveChaincodeDefinitionForOrg -> INFO 04f Successfully endorsed chaincode approval with name 'marblesp', package ID 'marblespv1:e8c33426e02c5397914aa0cee6b3220d7fc519845b5d9e55ad50271d7c87859d', on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:46:58.405 UTC [gossip.privdata] StoreBlock -> INFO 052 Received block [3] from buffer channel=mychannel 2021-11-06 17:46:58.406 UTC [gossip.privdata] RetrievePvtdata -> INFO 054 Successfully fetched all 1 eligible collection private write sets for block [3] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 17:46:58.450 UTC [kvledger] commit -> INFO 055 [mychannel] Committed block [3] with 1 transaction(s) in 43ms (state_validation=4ms block_and_pvtdata_commit=1ms state_commit=37ms) commitHash=[0f032d62813838d70175bc2b327c5e0635899c3da5660d16fba0a6531f17af4f] 2021-11-06 17:49:59.928 UTC [gossip.privdata] StoreBlock -> INFO 057 Received block [4] from buffer channel=mychannel 2021-11-06 17:50:00.023 UTC [kvledger] commit -> INFO 05a [mychannel] Committed block [4] with 1 transaction(s) in 92ms (state_validation=69ms block_and_pvtdata_commit=1ms state_commit=20ms) commitHash=[0c0a6bd1169b70de40935b59785c26040fd8936e8b8130019f5a64da47dd3bb9] 2021-11-06 17:52:25.439 UTC [lifecycle] CheckCommitReadiness -> INFO 05b Successfully checked commit readiness of chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:25.440 UTC [lifecycle] CommitChaincodeDefinition -> INFO 05c Successfully endorsed commit for chaincode name 'marblesp' on channel 'mychannel' with definition {sequence: 1, endorsement info: (version: '1.0', plugin: 'escc', init required: false), validation info: (plugin: 'vscc', policy: '0a28120c120a080112020800120208011a0b12090a074f7267314d53501a0b12090a074f7267324d5350'), collections: (config:<static_collection_config:<name:"collectionMarbles" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > rules:<signed_by:1 > > > identities:<principal:"\n\007Org1MSP" > identities:<principal:"\n\007Org2MSP" > > > maximum_peer_count:3 block_to_live:1000000 member_only_read:true > > config:<static_collection_config:<name:"collectionMarblePrivateDetails" member_orgs_policy:<signature_policy:<rule:<n_out_of:<n:1 rules:<signed_by:0 > > > identities:<principal:"\n\007Org1MSP" > > > maximum_peer_count:3 block_to_live:3 member_only_read:true > > )} 2021-11-06 17:52:27.476 UTC [gossip.privdata] StoreBlock -> INFO 05f Received block [5] from buffer channel=mychannel 2021-11-06 17:52:27.923 UTC [kvledger] commit -> INFO 067 [mychannel] Committed block [5] with 1 transaction(s) in 445ms (state_validation=401ms block_and_pvtdata_commit=15ms state_commit=29ms) commitHash=[bec41e198c6f92a1b10e3926cde239da79234ba4fdc10ad0cd8bc92edcd35847] 2021-11-06 18:10:37.331 UTC [gossip.privdata] StoreBlock -> INFO 06c Received block [6] from buffer channel=mychannel 2021-11-06 18:10:37.332 UTC [gossip.privdata] RetrievePvtdata -> INFO 06e Successfully fetched all 2 eligible collection private write sets for block [6] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:10:37.366 UTC [couchdb] createDatabaseIfNotExist -> INFO 06f Created state database mychannel_marblesp$$hcollection$marble$private$details 2021-11-06 18:10:37.392 UTC [couchdb] createDatabaseIfNotExist -> INFO 070 Created state database mychannel_marblesp$$pcollection$marble$private$details 2021-11-06 18:10:37.447 UTC [kvledger] commit -> INFO 071 [mychannel] Committed block [6] with 1 transaction(s) in 114ms (state_validation=1ms block_and_pvtdata_commit=1ms state_commit=109ms) commitHash=[c07191cc2bb565dea385c864c5a673265a1ff5f1cbe2fffc8a1d8c99c319123c] 2021-11-06 18:35:57.040 UTC [gossip.privdata] StoreBlock -> INFO 07a Received block [7] from buffer channel=mychannel 2021-11-06 18:35:57.045 UTC [gossip.privdata] RetrievePvtdata -> INFO 07c Successfully fetched all 2 eligible collection private write sets for block [7] (0 from local cache, 2 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:35:57.131 UTC [kvledger] commit -> INFO 07d [mychannel] Committed block [7] with 1 transaction(s) in 86ms (state_validation=9ms block_and_pvtdata_commit=3ms state_commit=72ms) commitHash=[954438a7a6f0c24e5c9159706f4b6cf6fe48283a806ec43d8515ca96f9c2f35b] 2021-11-06 18:45:09.541 UTC [gossip.privdata] StoreBlock -> INFO 082 Received block [8] from buffer channel=mychannel 2021-11-06 18:45:09.544 UTC [gossip.privdata] RetrievePvtdata -> INFO 084 Successfully fetched all 1 eligible collection private write sets for block [8] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:45:09.575 UTC [kvledger] commit -> INFO 085 [mychannel] Committed block [8] with 1 transaction(s) in 30ms (state_validation=0ms block_and_pvtdata_commit=1ms state_commit=28ms) commitHash=[57e3c33dbb4133920a306a672aa325d72fa7ab68aaca504d2f475f45ba77640e] 2021-11-06 18:49:14.162 UTC [gossip.privdata] StoreBlock -> INFO 08a Received block [9] from buffer channel=mychannel 2021-11-06 18:49:14.165 UTC [gossip.privdata] RetrievePvtdata -> INFO 08c Successfully fetched all 1 eligible collection private write sets for block [9] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:49:14.212 UTC [kvledger] commit -> INFO 08d [mychannel] Committed block [9] with 1 transaction(s) in 47ms (state_validation=1ms block_and_pvtdata_commit=6ms state_commit=37ms) commitHash=[5e6ce96e8a9cdfc6c270039528a887c68cb30ae0ace7b764dee0b74df4c49b4e] 2021-11-06 18:55:45.727 UTC [gossip.privdata] StoreBlock -> INFO 090 Received block [10] from buffer channel=mychannel 2021-11-06 18:55:45.727 UTC [gossip.privdata] RetrievePvtdata -> INFO 092 Successfully fetched all 1 eligible collection private write sets for block [10] (0 from local cache, 1 from transient store, 0 from other peers) channel=mychannel 2021-11-06 18:55:45.788 UTC [kvledger] commit -> INFO 093 [mychannel] Committed block [10] with 1 transaction(s) in 60ms (state_validation=0ms block_and_pvtdata_commit=2ms state_commit=57ms) commitHash=[95c6683728dbf68cf6019425a755a0ded702e2000634184d34750be1b035824c]
It is found that the height of the block is 10, and 1 height is added
Query private price data of marble1 (data cleared)
Return to the container node terminal window
[root@localhost test-network]# peer chaincode query -C mychannel -n marblesp -c '{"Args":["ReadMarblePrivateDetails","marble1"]}' Error: endorsement failure during query. response: status:500 message:"marble1 does not exist"
Reference documents:
Official website: Using private data in Fabric - hyperledger fabricdocs master document