@@ -170,7 +170,24 @@ cp ~/admin-msp/signcerts/* ~/admin-msp/admincerts/
170
170
cd ~/non-profit-blockchain/ngo-fabric
171
171
```
172
172
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
174
191
On the Fabric client node.
175
192
176
193
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:
271
288
2018-11-26 21:41:41.022 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
272
289
```
273
290
274
- ## Step 8 - Install chaincode on your peer node
291
+ ## Step 8 - Install Vendor Dependencies
275
292
On the Fabric client node.
276
293
277
294
Install chaincode on Fabric peer.
278
295
279
296
Execute the following script:
280
297
281
298
```
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
285
304
```
286
305
287
- You should see:
306
+ ## Step 9 - Create the Chaincode Package
307
+ Run the following command to create the example chaincode package.
288
308
289
309
```
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
293
315
```
294
316
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
300
318
301
319
Execute the following script:
302
320
303
321
```
304
322
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
305
323
-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
308
325
```
309
326
310
327
You should see:
311
328
312
329
```
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
315
333
```
316
334
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
321
336
322
337
Execute the following script:
323
338
324
339
```
325
340
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
326
341
-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
328
343
```
329
344
330
345
You should see:
331
346
332
347
```
333
- 100
348
+ Installed chaincodes on peer:
349
+ Package ID: MyPackageID, Label: abstore_1
334
350
```
335
351
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
340
354
341
355
Execute the following script:
342
356
343
357
```
358
+ export CC_PACKAGE_ID=MyPackageID
344
359
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
345
360
-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
348
375
```
349
376
350
377
You should see:
351
378
352
379
```
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
354
382
```
355
383
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
358
386
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
+ ```
362
394
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.
364
397
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
+ ```
370
404
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:
373
406
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.
375
414
376
415
```
377
416
docker exec -e "CORE_PEER_TLS_ENABLED=true" -e "CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem" \
378
417
-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"]}'
380
422
```
381
423
382
424
You should see:
383
425
384
426
```
385
- 90
427
+ 2021-12-20 19:23:05.434 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 0ad Chaincode invoke successful. result: status:200
386
428
```
387
429
388
430
## Move on to Part 2
0 commit comments