hyperledger composer deploy and start - hyperledger-fabric

I have created a Business network archive. composer deploy and composer start works fine. However, I am not understanding where is it getting deployed ?
Under which channel does it get deployed ?
How can I set endorsement policies for this Business network ?
My understanding of BNA is it is equivalent to chain code which is mentioned under Composer v0.19.0 - Breaking changes section
enter link description here

Under v0.19.0 of Composer (the 'latest' version) the composer network install command install the BNA to Peers in the folder /var/hyperledger/production/chaincodes/. The composer network start command creates a new chaincode specific container for each Peer to run the chaincode - the name of the container is made up of the name of the Network and the Version.
The channel used by composer is defined in the Connection Profile (connection.json) being used to install and start the network. In the Development Fabric the channel used is composerchannel.
The endorsement policy can be supplied to the composer network start command e.g. -o endorsementPolicyFile=my-endorsement-policy.json as described here.

Related

How to install chaincode on a different channel

I'm wondering how you can install a business network on a specific channel.
In my network I have two channels:
1) defaultchannel - chaincode installed and running on all peers connected to channel.
2) blockaviation - all peers added and certificates synced but no chaincode installed.
If I run the following command to install the chaincode:
composer network install -c admin#blockchain-network -a ./contracts/blockaviation/dist/block-aviation-network.bna
It gives me the following error:
Error: The business network is already installed on all the peers
This is true for the defaultchannel but I want to install the business network on a different channel.
Does anyone know how to specify a specific channel when running:
composer network install
composer network start
composer network upgrade
The channel is specified in the connection profile (connection.json) for the card being used. Remember that Composer cards connect to one Channel only, so you will need to create a new connection.json file, then create a card using that profile and the certificates that you already have.
Steps 2 to 7 of the Composer Multi-Org tutorial should help guide you in creating the new card. Once you have that card you should be able to install and start the Network (assuming the channel is setup ok and you have access to it.)

Hyperledger Composer v0.19.8 Error When Upgrading Business Network

I am trying to upgrade hyperledger fabric business network and I get this error
composer archive create -t dir -n . && \
composer network install -a $BNA_FILE -c PeerAdmin#hlfv1 && \
composer network upgrade -c PeerAdmin#hlfv1 -n NETWORK-NAME -V 0.1.23
The version number corresponds to that one in the package.json like the documentation says it should. I get the below error when I run the upgrade command
Error: Error trying to upgrade business network. Error: No valid responses
from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode
error (status: 500, message: could not find chaincode with name 'NETWORK-NAME')
I made sure that hyperledger fabric is running ./startFabric yet I still get this error
The error message received is saying that there is no business network called NETWORK-NAME started. In order to upgrade a business network it has to have been previously started.
What it sounds like in this case is that you have started the simple fabric development server provided by composer and initially installed and started the business network NETWORK-NAME. At some point you have restarted the fabric but this restart has actually removed the existing fabric servers and created a new fresh fabric network. Because this is a clean fabric network, there now isn't a business network on the channel and you need to start again from scratch and install and start the business network. For example the startFabric.sh script actually completely removes your existing fabric network and creates a new one and as such the business network and data is lost.
These resources may help you if you want to look into ensuring your fabric server persists it's information under various circumstances.
https://hyperledger-fabric.readthedocs.io/en/release-1.1/build_network.html#a-note-on-data-persistence
https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#fabricsetup (see section on how to retain docker state)

Hyperledger Composer - Install and join .bna on a second peer of a different organization

I'm using Hyperledger Composer v0.19.4.
I have a blockchain network that has two different organization (PartOwner and Warehouse), each with one peer. I have installed and started the .bna on the peer of the first organization, using the following commands:
composer network install -c PartOwner-PeerAdmin#channel2 -a carauction-network.bna
composer network start -c PartOwner-PeerAdmin#channel2 -n carauction-network -V 1.0.0 -A PartOwnerAdmin -C ./certs/PartOwner-BnaAdmin/admin-pub.pem
At this point i want the peer of the second organization to join the network.
Which steps must be completed?
Thanks
You should follow the official tutorial for multi organization network https://hyperledger.github.io/composer/latest/tutorials/deploy-to-fabric-multi-org. Also you need to provide certificates of network administrators for both orgs.Currently you are giving certificate of only PartOwner. Other steps are detailed in the link.

Hyperledger Composer v0.16.0 network start error

I'm trying Hyperledger Composer v0.16.0. According to this procedure, I want to Deploy BNA to Fabric network on cloud. but following error occurs.
Kindly let me know how I can solve it.
command:
composer network start --card PeerAdmin#myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file networkadmin.card
result:
tarting business network from archive: trade-network.bna
Business network definition:
Identifier: trade-network#0.1.13
Description: Commodities Trading Business Network
Processing these Network Admins:
userName: admin
✖ Starting business network definition. This may take a minute...
Error: Error trying to instantiate composer runtime. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: chaincode error (status: 500, message: chaincode instantiation policy violated(Failed to authenticate policy))
Error: No valid responses from any peers may be b/c you don't ./startFabric (in fabric-tools folder) or may be the .acl file (permissions.acl) have error (try change it to the beginning version).
The error 'Error: Error trying to instantiate composer runtime.' Suggests you have not run the composer runtime install command e.g.
composer runtime install -c PeerAdmin#fabric-network -n tutorial-network
Or that the command did not complete successfully.
The other possibility is that your fabric has stopped or is not contactable.
The runtime must be installed on fabric for the network to start.
"composer runtime install -c PeerAdmin#hlfv1 -n "
The Steps:
1) ./startFabric.sh,
2) ./createPeerAdminCard.sh,
3) composer runtime install -c PeerAdmin#hlfv1 -n ,
4) composer network start -a ./#0.0.1.bna -A admin -S adminpw -c PeerAdmin#hlfv1
there seems to be some challenges / bug with the use of composer
Composer Updates : 0.19.0 Changes:
End of March developers of Composer framework released version 0.19.0. Although there are multiple new features (mostly under the covers) in this release, it also introduced some BREAKING changes :( So what does that mean? It means that:
Some of the composer CLI commands have become obsolete or have changed
BNA Installation commands have changed ( install + start )
Following Composer CLI commands have been removed
runtime install, network deploy, network update, network undeploy
BNA upgrade requires an install of new version followed by
Composer card commands standardised to use -c or --card. Earlier some commands used -n and some used -c
Some of the Composer API have changed
That error can mean that the identity you are using to perform a network start doesn't have channel admin authority and thus is not authorised to perform a network start. I would suggest you check with whoever created your Hyperledger Fabric environment and channel to find out who the right identities are for administrative authority on the channel and build a card with the appropriate crypto material representing that identity in order to perform a network start.
1. ./stopFabric.sh
2. export FABRIC_VERSION=hlfv11
3. ./startFabric.sh
4. ./createPeerAdminCard.sh
5. install network
6. start network
Please create a new card with your business network name. Hopefully it will work:
composer network start --card PeerAdmin#myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file trade-network.card
I came up with a solution to my problem, which is similar to yours, it might be useful to you too:
I noticed that with other networks it works properly so, there is a problem with the DNS:
Edit or create /etc/docker/daemon.json in your machine and add:
{ "dns": ["your dns", "8.8.8.8"] }
Stop Fabric, restart Docker, Start Fabric
Repeat composer install and composer start
Well i was getting the similar error :-
Upgrading business network definition. This may take a minute...
Error: Error trying to upgrade business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: could not find chaincode with name 'airlinev9')
Command failed
My composer version: v0.19.4
What I was trying to do:-
I was trying the update my BNA to a newer version. But got the error which i shown you above.
What I did to solve the issue :-
I first deleted the previous card using the command :-
composer card delete -c admin#airlinev9
And then start the BNA with (already created, installed):-
composer network start -c PeerAdmin#hlfv1 -n airlinev9 -V 0.0.3 -A
admin -S adminpw
And it worked for me.
I am SUPER new to HyperLedger hence I am not sure on how it worked out me but just in case might work for you too so try it out. I did only 2 things((on fabric-tool directory) :
1) ./startFabric.sh
2) ./createPeerAdminCard.sh
Ok I agree I lied. Not 2 things but 3.
3) Retry .bna association as expected normally.
I hope it works for you too :)

Unable to modify Chaincode in hyperledger fabric

I downloaded the fabric-sample example from the command in linux,
given in the document "http://hyperledger-fabric.readthedocs.io/en/v1.0.0-beta/getting_started.html#install-prerequisites"
I followed the document to start the network, and script.sh
is running successfully.
now when I am modifying the chain code from my local system at "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
chaincode modification is not reflecting in the output.
please suggest me, how to run my own chaincode.
If your target is to run your own chaincode, the recommended way is to follow the chaincode developers guide here. Normally, the chaincode is started and maintained by peer, but this chaincode dev mode allows user to start chaincode for easier testing and development. If you are starting by modifying existing chaincode, you may omit the code-building section and concentrate on the other steps (creating proper directories, building them etc)
When you start your network, you get some Peers and an Orderer. In that step you copy the chaincode that it's in the predefined directory, i.e. a predefined chaincode is copied for you. You define that directory in the docker-compose-cli.yaml file, in the line - ./chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode So, if you want to change the chaincode that is copies to your Blockchain, you should change in that directory.
So, any change that you do in your local machine won't have any effect on the chaincode of the Peer. If you want to run your own chaincode, you have to define it previously, before starting up your network. Then, you will hava it in the corresponding docker container.
You can develope your own chaincode and pass it to the cli container by executing the following command:
docker cp yourchaincode.go cli:/opt/gopath/src/github.com/hyperledger/fabric/examples/mychaincode/yourchaincode.go

Resources