Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 9de360b

Browse files
committed
Update README.md for 2.2; update configtx.yaml to include 2.2 policy definitions
1 parent 27bbf60 commit 9de360b

File tree

2 files changed

+165
-67
lines changed

2 files changed

+165
-67
lines changed

ngo-fabric/README.md

+89-47
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,24 @@ cp ~/admin-msp/signcerts/* ~/admin-msp/admincerts/
170170
cd ~/non-profit-blockchain/ngo-fabric
171171
```
172172

173-
## Step 5 - Update the configtx channel configuration
173+
## Step 5 - Upgrade the Peer CLI from 1.2 to 2.2
174+
175+
```
176+
cd
177+
sed -i "s|1.2|2.2|g" ~/docker-compose-cli.yaml
178+
docker-compose -f docker-compose-cli.yaml up -d
179+
cd ~/fabric-samples
180+
git checkout release-2.2
181+
```
182+
183+
Upgrade go version to latest
184+
```
185+
sudo rm -rf /usr/local/go
186+
curl -L https://go.dev/dl/go1.19.3.linux-amd64.tar.gz -o go1.19.3.linux-amd64.tar.gz
187+
sudo tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz
188+
```
189+
190+
## Step 6 - Update the configtx channel configuration
174191
On the Fabric client node.
175192

176193
Update the configtx channel configuration. The Name and ID fields should be updated with the member ID from Managed Blockchain.
@@ -271,118 +288,143 @@ You should see:
271288
2018-11-26 21:41:41.022 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
272289
```
273290

274-
## Step 8 - Install chaincode on your peer node
291+
## Step 8 - Install Vendor Dependencies
275292
On the Fabric client node.
276293

277294
Install chaincode on Fabric peer.
278295

279296
Execute the following script:
280297

281298
```
282-
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
283-
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
284-
cli peer chaincode install -n $CHAINCODENAME -v $CHAINCODEVERSION -p $CHAINCODEDIR
299+
cd ~
300+
sudo chown -R ec2-user:ec2-user fabric-samples/
301+
cd fabric-samples/chaincode/abstore/go/
302+
GO111MODULE=on go mod vendor
303+
cd
285304
```
286305

287-
You should see:
306+
## Step 9 - Create the Chaincode Package
307+
Run the following command to create the example chaincode package.
288308

289309
```
290-
2018-11-26 21:41:46.585 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
291-
2018-11-26 21:41:46.585 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
292-
2018-11-26 21:41:48.004 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
310+
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
311+
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
312+
cli peer lifecycle chaincode package ./abstore.tar.gz \
313+
--path /opt/home/fabric-samples/chaincode/abstore/go/ \
314+
--label abstore_1
293315
```
294316

295-
## Step 9 - Instantiate the chaincode on the channel
296-
On the Fabric client node.
297-
298-
Instantiate chaincode on Fabric channel. This statement may take around 30 seconds, and you
299-
won't see a specific success response.
317+
## Step 10 - Install the Package
300318

301319
Execute the following script:
302320

303321
```
304322
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
305323
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
306-
cli peer chaincode instantiate -o $ORDERER -C $CHANNEL -n $CHAINCODENAME -v $CHAINCODEVERSION \
307-
-c '{"Args":["init","a","100","b","200"]}' --cafile $CAFILE --tls
324+
cli peer lifecycle chaincode install abstore.tar.gz
308325
```
309326

310327
You should see:
311328

312329
```
313-
2018-11-26 21:41:53.738 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
314-
2018-11-26 21:41:53.738 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
330+
2022-11-22 17:12:57.054 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 003 Installed remotely: response:<status:200 payload:"\nJabstore_1:3918d0438fd2ebe48ed1bde01533513a14f788846fd2d72ef054482760e73409\022\tabstore_1" >
331+
2022-11-22 17:12:57.054 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 004 Chaincode code package identifier: abstore_1:3918d0438fd2ebe48ed1bde01533513a14f788846fd2d72ef054482760e73409
332+
[ec2-user@ip-10-0-7-183 go]$ export CC_PACKAGE_ID=abstore_1:3918d0438fd2ebe48ed1bde01533513a14f788846fd2d72ef054482760e73409
315333
```
316334

317-
## Step 10 - Query the chaincode
318-
On the Fabric client node.
319-
320-
Query the chaincode on Fabric peer.
335+
## Step 11 - Verify the Package
321336

322337
Execute the following script:
323338

324339
```
325340
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
326341
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
327-
cli peer chaincode query -C $CHANNEL -n $CHAINCODENAME -c '{"Args":["query","a"]}'
342+
cli peer lifecycle chaincode queryinstalled
328343
```
329344

330345
You should see:
331346

332347
```
333-
100
348+
Installed chaincodes on peer:
349+
Package ID: MyPackageID, Label: abstore_1
334350
```
335351

336-
## Step 11 - Invoke a transaction
337-
On the Fabric client node.
338-
339-
Invoke a Fabric transaction.
352+
## Step 12 - Approve the Chaincode
353+
Run the following commands to approve the chaincode definition for your organization. Replace `MyPackageID` with the Package ID value returned in the previous step
340354

341355
Execute the following script:
342356

343357
```
358+
export CC_PACKAGE_ID=MyPackageID
344359
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
345360
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
346-
cli peer chaincode invoke -o $ORDERER -C $CHANNEL -n $CHAINCODENAME \
347-
-c '{"Args":["invoke","a","b","10"]}' --cafile $CAFILE --tls
361+
cli peer lifecycle chaincode approveformyorg \
362+
--orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \
363+
--channelID $CHANNEL --name abstore --version v0 --sequence 1 --package-id $CC_PACKAGE_ID
364+
```
365+
366+
## Step 13 - Check Commit Readiness
367+
Run the following command to check whether the chaincode definition is ready to be committed on the channel.
368+
369+
```
370+
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
371+
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
372+
cli peer lifecycle chaincode checkcommitreadiness \
373+
--orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \
374+
--channelID $CHANNEL --name abstore --version v0 --sequence 1
348375
```
349376

350377
You should see:
351378

352379
```
353-
2018-11-26 21:45:20.935 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
380+
Chaincode definition for chaincode 'mycc', version 'v0', sequence '1' on channel 'mychannel' approval status by org:
381+
m-LVQMIJ75CNCUZATGHLDP24HUHM: true
354382
```
355383

356-
## Step 12 - Query the chaincode again and check the change in value
357-
On the Fabric client node.
384+
## Step 14 - Commit the Chaincode
385+
Commit the Chaincode
358386

359-
Query the chaincode on the Fabric peer and check the change in value. This proves the success of the invoke
360-
transaction. If you execute the query immediately after the invoke, you may notice that the data hasn't changed.
361-
Any idea why? There should be a gap of (roughly) 2 seconds between the invoke and query.
387+
```
388+
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
389+
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
390+
cli peer lifecycle chaincode commit \
391+
--orderer $ORDERER --tls --cafile /opt/home/managedblockchain-tls-chain.pem \
392+
--channelID $CHANNEL --name abstore --version v0 --sequence 1
393+
```
362394

363-
Invoking a transaction in Fabric involves a number of steps, including:
395+
## Step 15 - Verify the Chaincode
396+
You might have to wait a minute or two for the commit to propagate to the peer node. Run the following command to verify that the chaincode is committed.
364397

365-
* Sending the transaction to the endorsing peers for simulation and endorsement
366-
* Packaging the endorsements from the peers
367-
* Sending the packaged endorsements to the ordering service for ordering
368-
* The ordering service grouping the transactions into blocks (which are created every 2 seconds, by default)
369-
* The ordering service sending the blocks to all peer nodes for validating and committing to the ledger
398+
```
399+
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
400+
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
401+
cli peer lifecycle chaincode querycommitted \
402+
--channelID $CHANNEL
403+
```
370404

371-
Only after the transactions in the block have been committed to the ledger can you read the
372-
new value from the ledger (or more specifically, from the world state key-value store).
405+
You should see:
373406

374-
Execute the following script:
407+
```
408+
Committed chaincode definitions on channel 'mychannel':
409+
Name: mycc, Version: v0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc
410+
```
411+
412+
## Step 16 - Initialize the Chaincode
413+
Run the following command to initialize the chaincode.
375414

376415
```
377416
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
378417
-e "CORE_PEER_ADDRESS=$PEER" -e "CORE_PEER_LOCALMSPID=$MSP" -e "CORE_PEER_MSPCONFIGPATH=$MSP_PATH" \
379-
cli peer chaincode query -C $CHANNEL -n $CHAINCODENAME -c '{"Args":["query","a"]}'
418+
cli peer chaincode invoke \
419+
--tls --cafile /opt/home/managedblockchain-tls-chain.pem \
420+
--channelID $CHANNEL \
421+
--name mycc -c '{"Args":["init", "a", "100", "b", "200"]}'
380422
```
381423

382424
You should see:
383425

384426
```
385-
90
427+
2021-12-20 19:23:05.434 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 0ad Chaincode invoke successful. result: status:200
386428
```
387429

388430
## Move on to Part 2

ngo-fabric/configtx.yaml

+76-20
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
#
2+
#
33
# Licensed under the Apache License, Version 2.0 (the "License").
44
# You may not use this file except in compliance with the License.
55
# A copy of the License is located at
6-
#
6+
#
77
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# or in the "license" file accompanying this file. This file is distributed
10-
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
# express or implied. See the License for the specific language governing
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

1414
################################################################################
@@ -34,23 +34,79 @@ Organizations:
3434
Policies:
3535
Readers:
3636
Type: Signature
37-
Rule: "OR('SimbaMSP.admin', 'SimbaMSP.peer', 'SimbaMSP.client')"
37+
Rule: "OR('Org1.admin', 'Org1.peer', 'Org1.client')"
3838
Writers:
3939
Type: Signature
40-
Rule: "OR('SimbaMSP.admin', 'SimbaMSP.client')"
40+
Rule: "OR('Org1.admin', 'Org1.client')"
4141
Admins:
4242
Type: Signature
43-
Rule: "OR('SimbaMSP.admin')"
44-
Endorsement:
45-
Type: Signature
46-
Rule: "OR('SimbaMSP.peer')"
43+
Rule: "OR('Org1.admin')"
44+
# Endorsement:
45+
#Type: Signature
46+
#Rule: "OR('m-BAW63UNV2NHORLLE7GXQ6BVI4Q.peer')"
4747

4848
AnchorPeers:
4949
# AnchorPeers defines the location of peers which can be used
5050
# for cross org gossip communication. Note, this value is only
5151
# encoded in the genesis block in the Application section context
52-
- Host:
53-
Port:
52+
- Host:
53+
Port:
54+
55+
################################################################################
56+
#
57+
# SECTION: Capabilities
58+
#
59+
# - This section defines the capabilities of fabric network. This is a new
60+
# concept as of v1.1.0 and should not be utilized in mixed networks with
61+
# v1.0.x peers and orderers. Capabilities define features which must be
62+
# present in a fabric binary for that binary to safely participate in the
63+
# fabric network. For instance, if a new MSP type is added, newer binaries
64+
# might recognize and validate the signatures from this type, while older
65+
# binaries without this support would be unable to validate those
66+
# transactions. This could lead to different versions of the fabric binaries
67+
# having different world states. Instead, defining a capability for a channel
68+
# informs those binaries without this capability that they must cease
69+
# processing transactions until they have been upgraded. For v1.0.x if any
70+
# capabilities are defined (including a map with all capabilities turned off)
71+
# then the v1.0.x peer will deliberately crash.
72+
#
73+
################################################################################
74+
Capabilities:
75+
# Channel capabilities apply to both the orderers and the peers and must be
76+
# supported by both.
77+
# Set the value of the capability to true to require it.
78+
Channel: &ChannelCapabilities
79+
# V2_0 capability ensures that orderers and peers behave according
80+
# to v2.0 channel capabilities. Orderers and peers from
81+
# prior releases would behave in an incompatible way, and are therefore
82+
# not able to participate in channels at v2.0 capability.
83+
# Prior to enabling V2.0 channel capabilities, ensure that all
84+
# orderers and peers on a channel are at v2.0.0 or later.
85+
V2_0: true
86+
87+
# Orderer capabilities apply only to the orderers, and may be safely
88+
# used with prior release peers.
89+
# Set the value of the capability to true to require it.
90+
Orderer: &OrdererCapabilities
91+
# V2_0 orderer capability ensures that orderers behave according
92+
# to v2.0 orderer capabilities. Orderers from
93+
# prior releases would behave in an incompatible way, and are therefore
94+
# not able to participate in channels at v2.0 orderer capability.
95+
# Prior to enabling V2.0 orderer capabilities, ensure that all
96+
# orderers on channel are at v2.0.0 or later.
97+
V2_0: true
98+
99+
# Application capabilities apply only to the peer network, and may be safely
100+
# used with prior release orderers.
101+
# Set the value of the capability to true to require it.
102+
Application: &ApplicationCapabilities
103+
# V2_0 application capability ensures that peers behave according
104+
# to v2.0 application capabilities. Peers from
105+
# prior releases would behave in an incompatible way, and are therefore
106+
# not able to participate in channels at v2.0 application capability.
107+
# Prior to enabling V2.0 application capabilities, ensure that all
108+
# peers on channel are at v2.0.0 or later.
109+
V2_0: true
54110

55111
################################################################################
56112
#
@@ -81,13 +137,13 @@ Application: &ApplicationDefaults
81137
Rule: "MAJORITY Admins"
82138
LifecycleEndorsement:
83139
Type: ImplicitMeta
84-
Rule: "MAJORITY Endorsement"
140+
Rule: "ANY Readers"
85141
Endorsement:
86142
Type: ImplicitMeta
87-
Rule: "MAJORITY Endorsement"
143+
Rule: "ANY Readers"
88144

89-
#Capabilities:
90-
# <<: *ApplicationCapabilities
145+
Capabilities:
146+
<<: *ApplicationCapabilities
91147

92148
################################################################################
93149
#
@@ -118,8 +174,8 @@ Channel: &ChannelDefaults
118174
# Capabilities describes the channel level capabilities, see the
119175
# dedicated Capabilities section elsewhere in this file for a full
120176
# description
121-
# Capabilities:
122-
# <<: *ChannelCapabilities
177+
Capabilities:
178+
<<: *ChannelCapabilities
123179

124180

125181
################################################################################

0 commit comments

Comments
 (0)