Using the definitions created using fabric-composer, can one generate the chaincode and individual nodejs components i.e REST API and UI ? So that it can be later run without using fabric-composer?
If I understand the question correctly, then you can't. Hyperledger composer provides a runtime that resides inside of a Hyperledger fabric chaincode container that manages and executes the various artifacts that make up a business network definition. A business network definition is not generated into standalone chaincode.
The Rest Server that provides the rest API for a business network also relies on Hyperledger Composer APIs to interact with the runtime to be able to dynamically introspect the business network and provide access to that business network. The Rest Server provides the flexibility to create any type of UI you wish and doesn't have to be generated from the Yo generator provided by Hyperledger Composer.
Related
Can I create a service or container from another container, on Google Cloud Run or Cloud Run on GKE ?
I basically want to manage my containers/services dynamically from another container and not sure how to go about this
Adding more details:
One of my microservices needs to create new isolated containers that will run some user-land code. I would like to have full life-cycle control of these containers, run the code, and then destroy as needed.
I also looked at Cloud Run APIs but not sure how to run something like 'kubectl create ...' through the APIs? Is that the right approach?
Yes, you should be able to deploy Cloud Run services from Cloud Run services.
on Cloud Run (hosted): services by default run with Editor permissions, so this should be possible without any extra configuration
note that if you deploy apps with --allow-unauthenticated which requires setting IAM permissions, the Editor role will not be enough, as you need Owner role on the GCP project for that.
on Cloud Run on GKE: services by default run with limited scopes (as they by default inherit GKE node's permissions/scopes). You should add a service account to the Kubernetes Pod and use it to authenticate.
From there, you have several options:
Use the REST API directly: Since run.googleapis.com behaves like a Kubernetes API server, you can directly apply JSON objects of Knative Services. (You can use gcloud ... --log-http to learn how deployments are made using REST API requests).
Use gcloud: you can ship your container image with gcloud and invoke it from your process.
Use Google Cloud Client Libraries: You can use the client libraries that are available for Cloud Run (for example this Go library) to construct in-memory Service objects and send them to the API using a higher level client library (recommended approach)
I'm a beginner with Hyperledger and I have some questions about Hyperledger Composer:
What's the difference between Hyperledger Composer and Composer Playground?
From what I understand Playground is just a user interface for the configuration, deployment and testing of a business network. So, isn't there any differences between deploy a business network with Playground and with Hyperledger Composer using Yeoman? (as shown for example in this tutorial)
I installed Composer Playgroung locally with this official tutorial. After creating a new business network, where can I find the related files on my machine?
What are all the operation I need to run every time I start up my machine to continue developing?
Sometimes just running ./startFabric.sh makes Playground return “Error trying to ping. Make sure chaincode has successfully instantiated and try again”
Do I have to export my business network card from Playground every time I want to test the RESTful API’s (using composer-rest-server)?
1: Hyperledger composer is a project which helps us interact with Hyperledger fabric. It includes UI (composer-playgroud), CLI and NPM(SDK) package. Composer Playground is a testing & development tool. You can create a blockchain smart contract here and also deploy in local memory to test the code. For production deployment, I would suggest use composer-cli.
2: Composer playground keeps all the cards in ".composer" folder. Most likely this folder sits on your user folder. In Ubuntu OS it is on path "/home/user/.composer". Regarding BNA, if it is connected to your fabric then it picks BNA from there. In browser only mode, it keeps in the browser cache.
3: I would suggest first run ./stopFabric.sh and then run ./startFabric.sh. It will stop all the Docker containers. If you have installed your own BNA then just ping the network. Follow this link. In the end, you will find the ping command.
4: Once you have imported cards to your composer rest server then, I think it should be okay. You do not need to import it again until unless the service is running. You can create composer rest server stateful by adding mongo in it. follow this. You can not import a card in two application i.e. if you have imported a card into composer playground then you can not import the same card into composer rest server.
I'm having some challenges to actually understand the procedure to connect composer to fabric(not the samples).
My objective here is to configure a fabric network and then connect this configurated network with a composer.bna.
After making all the changes I want to in the network, I need to run the network with the docker composer commands correct ? just like the byfn.sh script?
After that I should generate a PeerAdmin card right? so i believe I should use the connection.json file and the composer-cli command or there is another way to do it ?
And then I can start the procedure via composer?
I'm just little confused because with fabric tools you have all those startFabric.sh and creatPeerAdmin.sh but some of them are different from de fabric-samples and well....I'm a real beginner on the subject but I just need more understanding on the procedure between a configurated network and composer.
once you've tested your personalized Fabric environment is up and running (you mention BYFN 2-Org [Fabric] blockchain network, which is a sample network provided by Hyperledger Fabric: this performs some chaincode tests, like: invokes and queries eg query the ledger after updating an asset: ie to ensure the scripted BYFN sample Fabric network is up and running OK). Hyperledger Composer, being a development framework and toolset (not a blockchain per se) is largely for writing smart contracts (ie business networks - and of course for writing client-side apps too) - and it 'consumes' that Fabric infrastructure and deploys smart contracts to it, in the form of chaincode that runs as native NodeJS chaincode.
Now to Composer: If you look at the 'Multi-Org' tutorial (how to interact with a business network / smart contract, between two Orgs, and participants from those orgs), it tells you what was needed to configure Composer to be able to interact with the blockchain network, which has TLS enabled etc etc. It includes defining Connection profiles (eg what are the nodes of the network, what ports, what config parameters, what's the defined Fabric endorsement policy for the business network etc etc), business network cards (cards provide the blockchain identities the ability to transact in that business network and know 'who' performed it), what Access Control rules, what Queries to run, What transaction logic and units of work to execute, to update the blockchain ledger. Composer is one way of developing your smart contracts, is model-driven and also aimed at taking away many of the transformatory, type-handling, validation aspects you would otherwise have to do. Your aim is to check your custom Fabric network is all running correctly (as mentioned earlier), then come to Composer, to configure the - Composer - elements, all of which are described in the Composer docs -> https://hyperledger.github.io/composer
in answer to your questions
You would need to ensure your docker-compose (not 'composer') YAML files reflect the custom Fabric network you want to spin up.
yes, you need someone with peer admin authority/capability in Fabric, to install / and someone with minimally channel admin authority/capability to start the business network on the channel (as you'll see in the multi-org tutorial, both these are done by a Composer business network card that happens to be called PeerAdmin)
correct
The tools you mention in your last paragraph, are Composer tools - the aim of those scripts is to allow a Composer developer to spin up a local, Development Fabric to test against. You won't find them in 'fabric-samples' because they are provided by Composer (composer-tools) as described here -> https://hyperledger.github.io/composer/latest/installing/development-tools.html .
Ethereum contract can deploy new contract easily, i wanna know can hyperledger fabric chaincode be able to deploy a new chaincode?
Hyperledger fabric has two types of chaincode. System chaincode which is integrated directly in the peer, and external chaincode which is deployed into a container managed by Docker. T
If you are using the recently created v0.6 release, there is just one built-in system chaincode. However, you can easily deploy multiple external chaincodes to the same network of peers.
There is currently work being done to enable multiple system chaincodes, and to manage the the life-cycle of all chaincode types. That will likely be available in master shortly, and likely in the next dot release.
I think the question is: Is it possible to instantiate a ChainCode by invoking a method of a non-system Chaincode ?
This is not possible at the moment. In the future, cross-chaincode invocation will be supported (ie an invoke generated within an invoke) but I don't think there is any plan to support a Chaincode deployment dynamically generated from an invoke.
As off Fabric Version 1.1, you can issue a read query to an already instantiated (external not system) chaincode, but not issue write query to a different (external)chaincode.
As Part of setting up continuous integration using bitten, I would like to set up some bitten-slaves on windows. However, bitten documentation lacks instructions on how to register bitten slave as a service.
Looking at Microsoft's documentation on How to create a Windows service by using Sc.exe, I've tried the following:
sc create bitten-slave binPath= "C:\Python26\Scripts\bitten-slave.exe --verbose
--log=C:\dev\bitten.log http://svn/cgi-bin/trac.cgi/builds"
The service was indeed created. But trying to start it, I get the following error:
The bitten-slave service failed to
start due to the following error: The
service did not respond to the start
or control request in a timely
fashion.
What am I doing wrong?
Any random program can't run as a service in Windows, the application needs to be specially written to talk to the service controller.
An application that wants to be a service needs to first be written in such a way that it can handle start, stop, and pause messages from the Service Control Manager.
However, Microsoft does provide a generic service wrapper, SRVANY, which can be used to run an arbitrary program as a service. I use SRVANY to run several python scripts as services, so it should work properly.
This page on the Bitten wiki describes a simple Python script that can be configured as a scheduled task to ensure the Bitten slave is kept running.