Skip to content

Commit

Permalink
Update nano test network
Browse files Browse the repository at this point in the history
Fix regression in network.sh and update peer scripts to allow
chaincodeListenAddress and chaincodeAddress to be overridden if
required

Also updates the nano test network readme to describe the new
environment variables for the k8s builder

Fixes #1198

Signed-off-by: James Taylor <jamest@uk.ibm.com>
  • Loading branch information
jt-nti authored and denyeart committed Apr 29, 2024
1 parent 42b9b60 commit 0db6448
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
12 changes: 12 additions & 0 deletions test-network-nano-bash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ To deploy and invoke the chaincode, utilize the peer1 admin terminal that you ha

1. Using a chaincode container
2. Running the chaincode as a service
3. Using the k8s builder and minikube

For your convenience you can run `install&approve&commit_chaincode_peer1.sh` from peer1admin terminal to run basic chaincode as a container and activate it. The output of the script is redirected to the logs folder.

Expand Down Expand Up @@ -154,6 +155,17 @@ And start the chaincode service:
npm run start:server-nontls
```

## 3. Using the k8s builder and minikube

It is also possible to launch chaincode in kubernetes pods using the k8s builder. A simple way to do this is using [minikube](https://minikube.sigs.k8s.io/docs/), which requires the chaincodeListenAddress and chaincodeAddress settings used by the Nano test network to be overridden using the following environment variables.

```shell
export CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE=host.minikube.internal
export CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE=0.0.0.0
```

See the [fabric-builder-k8s](https://github.com/hyperledger-labs/fabric-builder-k8s) project for more details on how to configure and use the k8s builder.

## Activate the chaincode

Using the peer1 admin, approve and commit the chaincode (only a single approver is required based on the lifecycle endorsement policy of any organization):
Expand Down
8 changes: 4 additions & 4 deletions test-network-nano-bash/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ networkStart() {
fi

echo "Creating channel (peer1)..."
. peer1admin.sh && ./join_channel.sh
. ./peer1admin.sh && ./join_channel.sh

echo "Joining channel (peer2)..."
. peer2admin.sh && ./join_channel.sh
. ./peer2admin.sh && ./join_channel.sh

echo "Joining channel (peer3)..."
. peer3admin.sh && ./join_channel.sh
. ./peer3admin.sh && ./join_channel.sh

echo "Joining channel (peer4)..."
. peer4admin.sh && ./join_channel.sh
. ./peer4admin.sh && ./join_channel.sh
fi
echo "Fabric network running. Use Ctrl-C to stop."

Expand Down
4 changes: 2 additions & 2 deletions test-network-nano-bash/peer1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org1
export CORE_PEER_ID=peer0.org1.example.com
export CORE_PEER_ADDRESS=127.0.0.1:7051
export CORE_PEER_LISTENADDRESS=127.0.0.1:7051
export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7052
export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7052
export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7052
export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7052
# bootstrap peer is the other peer in the same org
export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7053
export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7051
Expand Down
4 changes: 2 additions & 2 deletions test-network-nano-bash/peer2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org1
export CORE_PEER_ID=peer1.org1.example.com
export CORE_PEER_ADDRESS=127.0.0.1:7053
export CORE_PEER_LISTENADDRESS=127.0.0.1:7053
export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7054
export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7054
export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7054
export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7054
# bootstrap peer is the other peer in the same org
export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7051
export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7053
Expand Down
4 changes: 2 additions & 2 deletions test-network-nano-bash/peer3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org2
export CORE_PEER_ID=peer0.org2.example.com
export CORE_PEER_ADDRESS=127.0.0.1:7055
export CORE_PEER_LISTENADDRESS=127.0.0.1:7055
export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7056
export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7056
export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7056
export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7056
# bootstrap peer is the other peer in the same org
export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7057
export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7055
Expand Down
4 changes: 2 additions & 2 deletions test-network-nano-bash/peer4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org2
export CORE_PEER_ID=peer1.org2.example.com
export CORE_PEER_ADDRESS=127.0.0.1:7057
export CORE_PEER_LISTENADDRESS=127.0.0.1:7057
export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7058
export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7058
export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7058
export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7058
# bootstrap peer is the other peer in the same org
export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7055
export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7057
Expand Down

0 comments on commit 0db6448

Please sign in to comment.