Simulate Hyperledger Fabric network with 5000 users - hyperledger-fabric

I am new to Hyperledger Fabric.
I read its documentation and followed the test network they provided on their website, so the test-network provides a bunch of terminal commands to add a third organization and its peer. I like that everything is ready to run on terminals, but the problem is the high level of abstraction over many details.
Goal:
I would like to simulate a permissioned blockchain network with 5000 users. Each user should be able to broadcast a transaction in every 15 seconds to the channel. The orderers should package these transactions in every 15 seconds and let the connected users verify new blocks.
Questions:
Should I create a new peer for each user?
Or can I use a single peer and let each user use the app?
I could not find a single tutorial on adding more peers dynamically.
Reading the documentation, I think I should let each user have his own peer and app to broadcast transactions. However, creating 5000 peers(one-by-one) would be very time-consuming.
I know these questions may sound naive, considering my other options like creating my blockchain network simulation using socketio or grpc would be less painful at the moment. I don't really want to avoid reading the docs of HLF, but the high-level of abstraction and the learning-time make me wonder, I should better use the other options for my simulation. As Linus Torvalds puts it simply:
Talk is cheap, show me the code!
In HLF case, I don't want the already-provided terminal commands, I want to really understand and modify the source code of peers.
Thank you for any recommendation or direction.

You need 5000 users (as registered in the CA), not 5000 peers. A single peer should be enough (although some more peers can be useful to distribute the endorsements and improve performance).
So, you should:
Register 5000 users in your Fabric-CA
Enroll their cryptographic material from the Fabric-CA
Run the 5000 clients (peer command, Fabric SDK based application or whatever).
Fabric CA related stuff: https://hyperledger-fabric-ca.readthedocs.io/en/latest/deployguide/use_CA.html.
Obviously, you should prepare some kind of script to do that. Don't do it manually.
If your purpose is only testing, maybe you can use cryptogen instead of Fabric-CA.
It seems that you are trying to perform some kind of performance test. Hyperledger Caliper is designed for these kind of tests. Maybe you can configure Caliper with 5000 workers (although I'm not sure if you can configure less than 1 TPS to simulate your request every 15 seconds).
About the orderers, you can configure your ordering service with a batch time of 15 seconds, but take into account that your 5000 transactions every 15 seconds may reach the batch size before that happens, so the block is generated before.

Related

Understanding Blockchain (Hyperledger Fabric) Concept

For the past few days i am trying to learn blockchain, more specifically in using hyperledger fabric
However, while i am quite familiar building centralized app, i am so new in grasp this whole new concept, and got some question in mind i haven't found answer, yet.
If its decentralized, does the script will run as desktop background process in every machine connected to the network through internet?
Since
no way it could be "decentralized" if its hosted on 3rd party server
blockchain platform seems could seamlessly write/read local files, which certainly not possible at the case of hosted in 3rd party server
existing blockchain application (i.e bitcoin) written for desktop (c++)
If it does desktop process, in the case of creating website interface to run the application, do we need API to communicate? And if so, how the API could be made to communicate between all machine in the network?
Moreover in the case of storing sensitive data like password, since its stored locally in every machine, does it means we will rely only on encryption being used? I assume common AES256 will work? Or need multi layer encryption (as in XMR) to make it harder for people trying to decrypt those sensitive information?
Any input is greatly appreciated. Thank you in advance!
I'll answer your questions for Hyperledger Fabric since that's what you tagged this post for.
Presumably the "script" you mean is chaincode, the blockchain back-end part of the decentralized application. It runs on endorsers (part of Fabric peers), specifically all endorsers that are specified in the endorsement policy and have installed the chaincode. The endorsement policy specifies how many endorsers need to agree for chaincode transactions to go through, i.e. 3/5. These peers can be hosted by multiple organizations in different places, that's why it's decentralized.
You need to use the Hyperledger Fabric SDK to communicate with your chaincode (get data, send transactions).
Decentralized apps don't really use user-password combo for identity management. Users have public/private keypairs which they need to keep locally. Only if you want to encrypt the private key you'd need a password for the user to decrypt it locally. You use the private key to sign transactions and to authenticate with the network (which determines your access rights, i.e. user vs admin)
I can recommend the Fabric paper as a learning resource
Also check out the docs, they cover many of your questions
I would recommend first taking a step back and finding out what are the best use cases for Web3 vs Web2. There are a number of projects that seem to have been shoehorned into using Web3 when they could have been created more quickly and efficiently using
Web2 technologies.
Ask yourself these questions before jumping on board the decentralized Web3 bandwagon:
Is an Immutable Ledger the Best Fit for Your Back-end?
Does Your Back-end Work Best as Decentralized Computing?
Do You Need Scalability or High Transaction Volumes?
Only when you understand the problem you are trying to solve, can you determine the best technologies for the job.
To help answer the above questions, you can use the following article as a resource: https://www.scalablepath.com/back-end/choosing-web3-for-software-project

Correct Hyperledger Fabric E-Commerce Architecture

I've only really just started looking into Hyperledger Fabric and have been asked to create an e-commerce platform (e-bay style) that uses the platform.
However, I am stuck with defining the appropriate architecture for the Hyperledger network, or if it is even appropriate to for this scenario, mainly because I do not know the number of organisations that will be part of the network at the start. Also how would this work having a single client on the front-end that users (in this case they would be organisations) would use to login, register, etc and how would this reflect on the Hyperledger network?
Would each new user be a new node on the network?
I first thought I could create a base network with just a ETCDRAFT orderer, a Fabric CA node, CouchBase, Fabric CLI node and a main Channel, and then add new organisations as they came along, but I wouldn't have anywhere to store the chain code as far I understand it.
I also thought of having the same structure but with an additional Peer node that would essentially represent the e-commerce platform itself, and new organisations (users on the ecommerce platform) would be added as users on the network, but that kind of defeats the purpose of a network in my view.
I know this might be a noob question but I am struggling a bit to define my initial set-up so that I can start writing the chain code, API and client, so any clarity on how this should ideally look in terms of network structure would be much appreciated.
The problem statement is quite vague in itself.
I am trying to answer the question with my assumptions.
Let consider e-commerce website like Amazon.
How many participants in there of blockchain network?
The sellers and buyers consider them as identities of a single organization not "Node".
The peers would be the various department running in the amazon like dep1,dep2 etc.

Hyperledger participation without hosting a peer node

We are looking to implement a hyperledger-fabric solution and I'm stumped by this fundamental question. How is a hyperledger solution architected if not all participants are able/willing to host a peer node?
Our users are divided into 2 groups - payers and providers. Most of our providers are willing and have the IT infrastructure required to host a peer node. Many of our payers are/do not.
From the perspective of a payer participant how can I trust the system if I'm not a peer and don't have my own copy of the ledger? What options might we have in setting up a hyperledger environment that allows them to participate?
Apologies if I have missed the point or some documentation that describes this scenario but links to it would be most welcome.
The easiest "trust assumption" is for groups which don't run peers to trust a specific member who is running a peer. For submitting transactions, it really does not matter if you run a node or not ... you would likely care about the endorsement policy in effect to make sure that there is not one all powerful member with a peer, but other than that you submit to multiple peers for endorsement anyway. For querying data, as mentioned you might have affinity / trust for one particular member, you might select a random or majority set of peers and do a "strong read". A query is still an invoke so you can actually query multiple peers in the same call.

How to execute the given "js files" on the Fabric network?

I'm studying Hyperledger Fabric with the documentation(https://hyperledger-fabric.readthedocs.io/en/release-1.0/write_first_app.html)
I'm done with two samples, which is "Building Your First network" & "Writing Your First Application"
I'm also done adding 1 extra peer to each organization, by modifying certain files, as well as done trying all commands on "Writing Your Fist Application" session.
Now, I'd like to execute the same commands(e.g. Querying all cars, Adding new cars or whatever) on the first network where I have built up, not on the test Fabcar network.
The thing is that I really have no idea what to do and how to do, even though I know how to handle NodeJS program(by Writing Application webpage)
So I'd like to ask you some questions.
Should I modify some files in order to "move" all necessary things to my network? if so, which file should I modify?
By any chance, Could you please tell me the correct steps to make it? I feel like I need to install and instantiate the required smart contract on my peers. Am I right?
I really appreciate your help in advance.
To answer your question, you would need to read some documentation online that will help you understand the architecture and how you can build up the packages as hyperledger fabric provided freedom to users to create use case specific configurations.
To start with.
Make sure you have have understood the concept of peer, orderer, couchdb, ca authority. Those 4 things you need to play with most of the times.
Assuming you have installed nodejs and able to run node through terminal, Read through the following example
Tuna Fish example, it help you to understand the concept of injecting, updating, querying blockchin ledger. Also, It will help understand the usage of Nodejs backend and angularjs basic UI. or use the other examples as you have seen on the fabric-samples github repository. Fabric Samples. Balance Transfer will help you understand the channel and chaincode operations using Node JS. Build your first network will help you understand the configuration files(concentrate on docker-compose.yaml, scipt.js and byfn.js)
Then to answer your questions.
you just have to modify the mount drive config variables in docker-componse-cli.yaml. Then you can edit your startup script based on how you want to move chaincode to your peer.
you need to install chaincode on all the peers that are part of that channel. And you only need to instantiate chaincode once per channel.
Installation and instantiation combination is a powerful feature because it allows for a peer to interact with the same chaincode container across multiple channels. The only prerequisite is for the actual chaincode source files to be installed on the peer's file system. As such, if a piece of common chaincode is being used across dozens of channels, a peer would need only a single chaincode container to perform read/writes on all the channel ledgers.
To run the node js files on the fabric network.
welcome to blockchain world :)

Creating orderer node in Hyperledger Fabric

I am new to Hyperledger Fabric and am starting a new project which is to transfer asset from one person to another. Here are the steps which I think I need to follow to achieve the completion of the project, do tell me if I am wrong or I missed something:
Create an orderer node.
Create a channel.
Create peers and endorser nodes.
Connect each peer and endorser node to channel.
Write chaincode and endorsing policies.
Create transaction to update ledger state.
If I am right, can someone help me with creation of orderer node, or provide me a link which helps. Also wanted to ask that orderer node creation is possible using node SDK.
In Hyperledger Fabric there are 3 types of nodes. Each node is a process running on some machine (perhaps in a container) and communicates with other nodes in the network.
The nodes are:
- Orderer node
- Peer node
- Client node that embeds a client SDK in some language/framework (node.js, golang, java).
You can't create a node on its own. Each node, is correlated with some organization and has its own certificates and private key.
You can take a look at https://github.com/hyperledger/fabric-samples/ (read the https://hyperledger-fabric.readthedocs.io/en/latest/getting_started.html to understand how) and this would allow you to grasp better the core concepts.
After that when you'll be more certain and more knowledgeable, you could also try to deploy your own setup of Fabric on multiple machines.
You can take a look at https://github.com/yacovm/fabricDeployment to how to do so.
There are two aspects to deploying Hyperledger Fabric... the operational aspects (deploying the containers that run the orderer, peer, ca, etc runtime components) and the transactional aspects (creating channels and issuing transaction proposals etc).
Suggest that you look into the tutorials provided. Specifically, I would start with "building your first network". This example gets into the details of how to deploy the network, create a channel and issue transactions.

Resources