Skip to content

Commit

Permalink
[FAB-9318] Update docs with multi endorse policy
Browse files Browse the repository at this point in the history
Now that the CLI supports multiple endorsements, this
CR updates the documentation to use a more robust example
endorsement policy of "AND (..)" instead of "OR (...)".

Change-Id: I0239558a4e2a698d62d171ba2b62733ada7e8be9
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed May 14, 2018
1 parent d72c7a4 commit 368b151
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
20 changes: 10 additions & 10 deletions docs/source/build_network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ completion, it should report the following in your terminal window:
Query Result: 90
2017-05-16 17:08:15.158 UTC [main] main -> INFO 008 Exiting.....
===================== Query on peer1.org2 on channel 'mychannel' is successful =====================
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
===================== All GOOD, BYFN execution completed =====================
Expand Down Expand Up @@ -680,9 +680,9 @@ argument. This is our policy where we specify the required level of endorsement
for a transaction against this chaincode to be validated.

In the command below you’ll notice that we specify our policy as
``-P "OR ('Org1MSP.peer','Org2MSP.peer')"``. This means that we need
“endorsement” from a peer belonging to Org1 **OR** Org2 (i.e. only one endorsement).
If we changed the syntax to ``AND`` then we would need two endorsements.
``-P "AND ('Org1MSP.peer','Org2MSP.peer')"``. This means that we need
“endorsement” from a peer belonging to Org1 **AND** Org2 (i.e. two endorsement).
If we changed the syntax to ``OR`` then we would need only one endorsement.

**Golang**

Expand All @@ -691,7 +691,7 @@ If we changed the syntax to ``AND`` then we would need two endorsements.
# be sure to replace the $CHANNEL_NAME environment variable if you have not exported it
# if you did not install your chaincode with a name of mycc, then modify that argument as well
peer chaincode instantiate -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 -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -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 -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
**Node.js**

Expand All @@ -705,7 +705,7 @@ If we changed the syntax to ``AND`` then we would need two endorsements.
# if you did not install your chaincode with a name of mycc, then modify that argument as well
# notice that we must pass the -l flag after the chaincode name to identify the language
peer chaincode instantiate -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 -C $CHANNEL_NAME -n mycc -l node -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -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 -C $CHANNEL_NAME -n mycc -l node -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
See the `endorsement
policies <http://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html>`__
Expand Down Expand Up @@ -743,7 +743,7 @@ update the state DB. The syntax for invoke is as follows:
# be sure to set the -C and -n flags appropriately
peer chaincode invoke -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 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}'
peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc --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:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
Query
^^^^^
Expand Down Expand Up @@ -816,8 +816,8 @@ What's happening behind the scenes?

- The instantiation also passes in an argument for the endorsement
policy. The policy is defined as
``-P "OR ('Org1MSP.peer','Org2MSP.peer')"``, meaning that any
transaction must be endorsed by a peer tied to Org1 or Org2.
``-P "AND ('Org1MSP.peer','Org2MSP.peer')"``, meaning that any
transaction must be endorsed by a peer tied to Org1 and Org2.

- A query against the value of "a" is issued to ``peer0.org1.example.com``. The
chaincode was previously installed on ``peer0.org1.example.com``, so this will start
Expand Down Expand Up @@ -869,7 +869,7 @@ You should see the following output:
2017-05-16 17:08:01.367 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: E61DB37F4E8B0D32C9FE10E3936BA9B8CD278FAA1F3320B08712164248285C54
Query Result: 90
2017-05-16 17:08:15.158 UTC [main] main -> INFO 008 Exiting.....
===================== Query on peer1.org2 on channel 'mychannel' is successful =====================
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
===================== All GOOD, BYFN execution completed =====================
Expand Down
6 changes: 3 additions & 3 deletions docs/source/chaincode4noah.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ the state with ``john`` and ``0``, the command would look like the following:

.. code:: bash
peer chaincode instantiate -n sacc -v 1.0 -c '{"Args":["john","0"]}' -P "OR ('Org1.member','Org2.member')"
peer chaincode instantiate -n sacc -v 1.0 -c '{"Args":["john","0"]}' -P "AND ('Org1.member','Org2.member')"
.. note:: Note the endorsement policy (CLI uses polish notation), which requires an
endorsement from either member of Org1 or Org2 for all transactions to
**sacc**. That is, either Org1 or Org2 must sign the
endorsement from both a member of Org1 and Org2 for all transactions to
**sacc**. That is, both Org1 and Org2 must sign the
result of executing the `Invoke` on **sacc** for the transactions to
be valid.

Expand Down
23 changes: 15 additions & 8 deletions docs/source/commands/peerchaincode.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Usage:
peer chaincode install [flags]
Flags:
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-h, --help help for install
-l, --lang string Language the chaincode is written in (default "golang")
Expand Down Expand Up @@ -111,6 +112,7 @@ Usage:
Flags:
-C, --channelID string The channel on which this command should be executed
--collections-config string The file containing the configuration for the chaincode's collection
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-E, --escc string The name of the endorsement system chaincode to be used for this chaincode
-h, --help help for instantiate
Expand Down Expand Up @@ -144,6 +146,7 @@ Usage:
Flags:
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-h, --help help for invoke
-n, --name string Name of the chaincode
Expand Down Expand Up @@ -172,6 +175,7 @@ Usage:
Flags:
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-h, --help help for list
--installed Get the installed chaincodes on a peer
--instantiated Get the instantiated chaincodes on a channel
Expand Down Expand Up @@ -231,13 +235,13 @@ Usage:
Flags:
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-h, --help help for query
-x, --hex If true, output the query value byte array in hexadecimal. Incompatible with --raw
-n, --name string Name of the chaincode
--peerAddresses stringArray The addresses of the peers to connect to
-r, --raw If true, output the query value as raw bytes, otherwise format as a printable string
-t, --tid string Name of a custom ID generation algorithm (hashing and decoding) e.g. sha256base64
--tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag
Global Flags:
Expand Down Expand Up @@ -285,6 +289,7 @@ Usage:
Flags:
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-E, --escc string The name of the endorsement system chaincode to be used for this chaincode
-h, --help help for upgrade
Expand Down Expand Up @@ -322,7 +327,7 @@ instantiates the chaincode named `mycc` at version `1.0` on channel

```
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Expand All @@ -334,7 +339,7 @@ instantiates the chaincode named `mycc` at version `1.0` on channel
network with TLS disabled:

```
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
Expand All @@ -346,11 +351,13 @@ instantiates the chaincode named `mycc` at version `1.0` on channel

Here is an example of the `peer chaincode invoke` command:

* Invoke the chaincode named `mycc` at version `1.0` on channel
`mychannel`, requesting to move 10 units from variable `a` to variable `b`
* Invoke the chaincode named `mycc` at version `1.0` on channel `mychannel`
on `peer0.org1.example.com:7051` and `peer0.org2.example.com:7051` (the
peers defined by `--peerAddresses`), requesting to move 10 units from
variable `a` to variable `b`:

```
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}'
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:7051 -c '{"Args":["invoke","a","b","10"]}'
2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Expand Down Expand Up @@ -470,7 +477,7 @@ upgrades the chaincode named `mycc` at version `1.0` on channel

```
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
.
.
.
Expand All @@ -494,7 +501,7 @@ upgrades the chaincode named `mycc` at version `1.0` on channel
network with TLS disabled:

```
peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
.
.
.
Expand Down
16 changes: 9 additions & 7 deletions docs/wrappers/peer_chaincode_postscript.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ instantiates the chaincode named `mycc` at version `1.0` on channel

```
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-02-22 16:33:53.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Expand All @@ -23,7 +23,7 @@ instantiates the chaincode named `mycc` at version `1.0` on channel
network with TLS disabled:

```
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2018-02-22 16:34:09.324 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
Expand All @@ -35,11 +35,13 @@ instantiates the chaincode named `mycc` at version `1.0` on channel

Here is an example of the `peer chaincode invoke` command:

* Invoke the chaincode named `mycc` at version `1.0` on channel
`mychannel`, requesting to move 10 units from variable `a` to variable `b`
* Invoke the chaincode named `mycc` at version `1.0` on channel `mychannel`
on `peer0.org1.example.com:7051` and `peer0.org2.example.com:7051` (the
peers defined by `--peerAddresses`), requesting to move 10 units from
variable `a` to variable `b`:

```
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}'
peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:7051 -c '{"Args":["invoke","a","b","10"]}'
2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-02-22 16:34:27.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Expand Down Expand Up @@ -159,7 +161,7 @@ upgrades the chaincode named `mycc` at version `1.0` on channel

```
export ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
.
.
.
Expand All @@ -183,7 +185,7 @@ upgrades the chaincode named `mycc` at version `1.0` on channel
network with TLS disabled:

```
peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n mycc -v 1.2 -c '{"Args":["init","a","100","b","200","c","300"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
.
.
.
Expand Down

1 comment on commit 368b151

@jasperdg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i get the following error when I try to run the bash command on line 746

Error: unknown flag: --peerAddresses
Error: unknown flag: --tlsRootCertFiles

I can't find these flags in the invoke documentation either, what can I do to make this work in my build?

Please sign in to comment.