Hyperledger Consensus PBFT - PhyrexTsai/docker-compose-files GitHub Wiki

PBFT on docker

PBFT docker reference : https://github.com/yeasy/docker-compose-files/tree/master/hyperledger/pbft

build via docker-compose

cd {path}/pbft; docker-compose -f docker-compose-with-membersrvc.yml up

run 5 containers

  • member service : handle members permission
  • vp0 : Validating peer
  • vp1 : Validating peer
  • vp2 : Validating peer
  • vp3 : Validating peer

after deploy chaincode

start 4 container handle consensus

  • dev-vp0-{chaincode_name}
  • dev-vp1-{chaincode_name}
  • dev-vp2-{chaincode_name}
  • dev-vp3-{chaincode_name}

PBFT failed reason before

δΉ‹ε‰ε€±ζ•—εŽŸε›  chaincode 執葌同ζ­₯ηš„ζ™‚ε€™ε„ε€‹ node ζœƒθΌ‰ε…₯另倖一個 image, 10/11 fix 了這個 bug

chaincode command

login

peer network login jim

peer chaincode flags

Usage:
  peer chaincode deploy [flags]

Global Flags:
  -a, --attributes string          User attributes for the chaincode in JSON format (default "[]")
  -c, --ctor string                Constructor message for the chaincode in JSON format (default "{}")
  -l, --lang string                Language the chaincode is written in (default "golang")
      --logging-level string       Default logging level and overrides, see core.yaml for full syntax
  -n, --name string                Name of the chaincode returned by the deploy transaction
  -p, --path string                Path to chaincode
      --test.coverprofile string   Done (default "coverage.cov")
  -t, --tid string                 Name of a custom ID generation algorithm (hashing and decoding) e.g. sha256base64
  -u, --username string            Username for chaincode operations when security is enabled
  -v, --version                    Display current version of fabric peer server

Deploy

peer chaincode deploy -u jim -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

Deploy response

22:57:32.911 [chaincodeCmd] getChaincodeSpecification -> INFO 001 Local user 'jim' is already logged in. Retrieving login token.
22:57:37.096 [chaincodeCmd] chaincodeDeploy -> INFO 002 Deploy result: type:GOLANG chaincodeID:<path:"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" name:"ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539" > ctorMsg:<args:"init" args:"a" args:"100" args:"b" args:"200" > 
Deploy chaincode: ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539
22:57:37.096 [main] main -> INFO 003 Exiting.....

-- chaincode name, need to record, using on invoke and query
ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539

Invoke

-- -n : {chaincode name}, -p : {chaincode path}
peer chaincode invoke -u jim -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -n ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539 -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'

Invoke response

02:22:01.022 [chaincodeCmd] getChaincodeSpecification -> INFO 001 Local user 'jim' is already logged in. Retrieving login token.
02:22:01.259 [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 002 Successfully invoked transaction: chaincodeSpec:<type:GOLANG chaincodeID:<path:"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" name:"ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539" > ctorMsg:<args:"invoke" args:"a" args:"b" args:"2" > secureContext:"jim" > (1c6583cb-75c2-43aa-95f3-63361de79981)
02:22:01.259 [main] main -> INFO 003 Exiting.....

Query

-- -n : {chaincode name}, -p : {chaincode path}
peer chaincode query -u jim -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -n ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539 -c '{"Function": "query", "Args": ["a"]}'

Query response

02:22:32.148 [chaincodeCmd] getChaincodeSpecification -> INFO 001 Local user 'jim' is already logged in. Retrieving login token.
02:22:32.425 [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 002 Successfully queried transaction: chaincodeSpec:<type:GOLANG chaincodeID:<path:"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" name:"ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd0f78539" > ctorMsg:<args:"query" args:"a" > secureContext:"jim" > 
Query Result: 67
02:22:32.425 [main] main -> INFO 003 Exiting.....