Current solution:
1. I have a single node running on Hyperledger.
2. I have deployed my car-auction application on it.
Solution looking for:
I want my car-auction application to deploy on the second node and both nodes should be synced on the same channel.
Any suggestion.
Thanks
This basically boils down to the network configuration that you define in Hyperledger Fabric.
This configuration is defined in two files:
crypto-config.yaml: Contains network topology
configtx.yaml: Defines genesis info and channel consortium
Considering your case, I assume your setup to be:
Single Organization
2 peer nodes within this organization
1 Orderer node
A single channel
So, you need to define network topology with an orderer and a single organization containing two peer nodes. You can find references for this complete setup at build your first network docs on fabric documentation.
Once you have that fabric setup ready, you take references from the Composer Docs. Over here, pay close attention to "connection-profile" file that you create. Since you want both these nodes to execute the car-auction chaincode, you'll need to define both of your peers as "endorsing peers" by setting "endorsingPeers" section to be "true" in the connection profile json file.
Follow the same compose reference to generate the PeerAdmin card. Now, when you install the car-auction bna file, it'll be installed on both the peers. Next, when you start the network, both the peer nodes will have their own chaincode container started up.
This way, you'll have two peer nodes connected on the same channel. And since they're on the same channel, they'll be in sync (regardless a peer is endorsing peer or not).
The same kind of setup goes for the multi-org setup.
Related
what are the containers which are associated with each peer in Hyperledger Fabric (HLF)?
For example: Endorsing peers most have one chaincode container to execute chaincode.
I'm not sure if I understand your question very well, but I still would like to give it a try.
The docker containers associated with a peer are:
Peer container, which manages you peer node. It's the peer container to which you send the transaction proposal either using CLI or through SDK. Every peer container embodies a copy of the ledger. The ledger is segregated using a channel.
Couchdb container, which persists the world state. It saves every key-value pair which you query or invoke using chaincode. The name of the container is usually in the form couchdb.
Chaincode container, where the chaincode is actually deployed. All the modules/packages that your chaincode requires are first installed when you instantiate your chaincode. The chaincode container usually have its name in the form dev-peer0.org1.example.com-fabcar-1.0.1, where dev refers to the environment in which the chaincode is instantiated. peer0.org1.example.com refers to the peer which instantiated it. fabcar here is the name of your chaincode and 1.0.1 is its version, which is changed every time you upgrade your chaincode.
A peer might not have a chaincode container if it's only acting as a validating or committing peer.
CLI container, this container is required for managing peers. At a time, CLI container can only manage a single peer. You can change the peer it's managing by adding/changing the environment variable CORE_PEER_ADDRESS, e.g. CORE_PEER_ADDRESS=peer0.org1.example.com:7051.
I'm new at HyperLedger Fabric and trying to customize the test-network provided in the demo https://github.com/hyperledger/fabric-samples/tree/master/test-network.
I can't find a way to 1. add new users and peers to the docker network and 2. create private channels using the CLI or Java SDK.
Could someone please help me ? A good tutorial to start would also be great. Thanks.
To extend Test Network with new orderer and peer, we need to extend fabric key with cryptogen, update system-channel definition, compose orderer nodes, compose peer nodes, join application channel and deploy the chaincode.
I created an article about how to extend test-network (in more details) with new peers and orderers https://dev.to/bukhorimuhammad/extending-fabric-2-test-network-50ll hope that helps
I am trying to set up the BYFN Hyperledger Fabric (v1.4.1) network by manually executing the commands, as opposed to running the script byfn.sh, given here: https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html#start-the-network
I observed that the command docker-compose -f docker-compose-cli.yaml up -d
spins up one container per peer and orderer node. But it also spins up a container for a CLI, through which all subsequent commands are run. By examining the docker-compose-cli.yaml file it is also evident that the filesystem of the CLI container contains the crypto material for all the peers and the orderer. This leads me to the following two questions:
Can one not run the subsequent commands for network setup (such channel creation, joining a channel, chaincode installation etc.) by 'exec'-ing into the Docker container of the corresponding peers?
Is it a good practice to spin up a single container which has the crypto material of all network components in one location, as is the case with the CLI container? Won't such a design, when adopted in production, compromise the private keys of the organisations involved?
Yes, you can definitely setup your network without using a cli container. That's just for a shortcut to access multiple peers using a single container. It's basically just a container in which you pass certificates of all the peers or orderers to access to the network. So whatever you are doing from cli you can do seperately from other containers. Now coming back to your questions:
Can one not run the subsequent commands for network setup (such channel creation, joining a channel, chaincode installation etc.) by 'exec'-ing into the Docker container of the corresponding peers?
Yes, you can definitely do that the only requirement is you must set the environment variables accordingly.
Is it a good practice to spin up a single container which has the crypto material of all network components in one location, as is the case with the CLI container? Won't such a design, when adopted in production, compromise the private keys of the organisations involved?
Yes, it will surely be a problem for a production setup. You can't be having a single cli for your peers and orderers. As I have already told you can do everything without a cli container but if you still want a cli then you can have different cli for your orderer container and your peer container.
I have application that uses fabric-sdk-java to join new peers to the existing fabric network. When joining peer I want to install chaincode on the peer and instantiate it (in case it had not been instantiated on the channel).
Is there any way to check using sdk if a specific chaincode is instantiated on the channel?
I am working upon a basic Blockchain POC and I have been able to do following:
Installed and started the Hyperledger fabric v1.0 successfully
I have list of Docker images running on Fabric
hyperledger/fabric-ca, hyperledger/fabric-orderer, hyperledger/fabric-peer, hyperledger/fabric-ccenv , hyperledger/fabric-couchdb
I have written Chaincode in go to read and update the ledger and compiled successfully
Next - What do I need to do and not able to do and Where I am confused?
Register my Chaincode to a peer – How do I find which Peer I need to register
I tried to follow this video but it uses YAML and I do not have it and it gives error-
https://www.youtube.com/watch?v=76WIJjKNekY&list=PLz3iwtnWFin-yUUgn-zP7KJp0iW0IFas9&index=2
Also followed few more tutorials but still confused what to do
https://hyperledger-fabric.readthedocs.io/en/release-1.2/build_network.html
Instantiate my Chaincode
Query my Chaincode - I will be able to do it once Chaincode is registered and deployed
Invoke my Chaincode to update the ledger - Same as above
Please help in above step or let me know if there is any good source of clear steps to perform registration and instantiation of chaincode.