Internal Working of Fabric Composer - hyperledger-fabric

I want to know how Fabric Composer works internally by transforming .bna file to chaincode and how key-value pairs are actually stored in the couch db/state db for the given assets, participants and transactions.
Thanks

see the links here.
Composer Architecture: https://www.slideshare.net/SimonStone8/hyperledger-composer-architecture
This architecture deep dive shows the internal workings, in terms of runtime architecture -> https://www.slideshare.net/dselman/hyperleger-composer-architecure-deep-dive
This article will also be useful to see a side-by-side comparison:
https://blog.selman.org/2017/07/08/getting-started-with-blockchain-development/#more-901
On key/value - see here -> What is the relationship between assets created in a composer network to the assets in fabric chaincode?
Finally, do note its now called Hyperledger Composer and no longer called Fabric Composer, just FYI.

Related

Custom MSP for Hyperledger Fabric

I'm trying to use DIDs/VCs from hyperledger Indy with Hyperledger Fabric. Simply I want to replace Fabric's certificate based identity/MSP with DIDs/VCs. However, as far as I understand this is not direct. The existing code based have lots of dependencies on Fabric-CA. Could someone help me to figure out potential starting points to do this customisation?
you cant try to use this modified peen-node:
https://github.com/trustbloc/fabric-mod
https://github.com/trustbloc/trustbloc-did-method/blob/main/docs/spec/trustbloc-did-method.md
or read this research:
https://arxiv.org/pdf/2104.03277.pdf
or check other did:methods that support HLF:
https://www.w3.org/TR/did-spec-registries/
or look to this project:
https://github.com/BLOCKOTUS/blockotus-organism
Currently, the only framework that can verify DID/VCs from Hyperldeger Indy is the Hyperledger Aries. There are several projects where people are trying to integrate either some of the Indy or Aries functionalities into Fabric in order to be able to issue and verify DID/VCs.
Take a look at the following projects in the "Hyperledger Mentorship Program" community:
Hyperledger Fabric - Hyperledger Aries Integration to support Fabric as Blockchain ledger
Or an older project Extending HL Fabric for connecting with HL Indy.
However, the easiest way is to have two DLTs, one for DID/VCs issue and verification (Indy), and one for transactions, etc.

How to access the underlying Fabric code in hyperledger composer?

I am developing a business network with hyperledger composer. I have followed the tutorial on composer web site at composer playground and have made the tutorial-network as well. Now I am facing one issue. after finishing defining your business network, how is it possible to get the underlying Fabric code that is generated? I can't think of a reason why it should be necessary to have it directly, but lets say if for any reason, like having to give Fabric code to your customer for whom you have developed a poc, you need to have that. Is Fabric code being saved somewhere? I have looked into the business network folder; there are only subfolders for models, test, the business network itself, and after you generate the archive file there is only one file with .bna extension. Nothing related to Fabric there!
I appreciate your help.
As part of the deployment of your business network, an associated Composer runtime is included that can parse model files, query file and acl files, it is also capable of executing your transaction processor functions. In 0.16.x this was achieved by including a JavaScript VM implementation using Go Chaincode to execute the Composer runtime (written in JavaScript) and the transaction processor functions. In Fabric 1.1, chaincode can be written natively as it now supports Node.js chaincode so with Composer beyond 0.16.x (currently 0.19.x at the time of writing) Composer utilizes this and all Go chaincode it used to contain was removed, along with the Javascript VM. It's the composer runtime that parses the model, query and acl files, and the transaction processor functions run natively inside the node.js fabric chaincode container. Nothing is ever compiled to Go.
The smart contract will be saved in different manner in fabric, as composer is just an abstraction over it. You need to search for the location where the chaincode is present inside the peer. There are some chaincode related commands which can help you in finding out where the chain code is installed. And to the client you can give the .bna file if you are using composer for the development because I am not sure whether the code will be easily readable at fabric level if you are using composer.

Chaincode using GO or Composer

I understand that chaincode(smart contracts) on hyperledger-fabric can be written using golang. But the other thing I see as of fabric 1.0 is the composer - where I could write the 'transactions' part using JS.
Is the difference that go APIs give me more lower level controls like access to MSP and CA and others? Or is it that the newer version would want you to write all your code using JS?
I am looking for some clarification on specific uses of each approach.
This tutorial -> https://blog.selman.org/2017/07/08/getting-started-with-blockchain-development/ should help you with the side-by-side comparison and the approaches using either toolset.
Updated answer (as promised in previous post): Hyperledger Composer v0.19.0 (time of writing - Apr 1st 2018) is the default release for building your blockchain business networks using Composer. So when you pull HL/Composer eg via npm install etc) - this uses the current GA edition of Hyperledger Fabric v1.1, the underlying blockchain network infrastructure. This 0.19.0 release includes a fundamental change in the way that Composer business networks are deployed (vis-a-vis previous releases eg 0.16.x - 0.18.x). Business networks are now deployed within Hyperledger Fabric 'as chaincode' - meaning that the business network (rather than Composer runtime) can be agreed by all parties (to the blockchain network) and signed, using a similar management model to non-Composer chaincode. In a later edition, the plan is to add JS requires so that these can be exploited in NodeJS and include other JS functions you've developed - of course, you can already call native Fabric APIs/chaincode functions already, from Composer transaction processors - introduced prior to 0.19.x release). See more info here in the release notes -> https://github.com/hyperledger/composer/releases/tag/v0.19.0

How to get chaincode to read from api's outside of the Hyperledger fabric blockchain

I'm wondering how you can get a hyperledger fabric smart contract to read from external API's ?
A service called oraclize (http://www.oraclize.it/) is used to do this operation in Ethereum blockchains - Is there anything similar for hyperledger fabric smart contracts or any workarounds?
In Hyperledger Fabric - smart contracts (the chaincode), could be implemented at the moment with either golang or Java, both of which are Turing complete and provides you with reach set of libraries and frameworks. Among which you can you any network library to get connected with external services, while you need to be extra cautious doing this to make sure your chaincode is deterministic (e.g. two independent executions of the same chaincode calling same external API will get same result back).
Riccardo from Oraclize here.
We are actually working on a Oraclize integration with Hyperledger.

What are the functional differences between Fabric Javascript SDK and Hyperledger Composer?

Other than the fact that Composer makes deployment and testing of prototype business networks easier and the fact that we don't have to know golang to develop chaincode, what is the difference in the functionalities that these interfaces provide that may lead one to choose one over the other?
This article can probably provide you with the answers you need:
https://blog.selman.org/2017/07/08/getting-started-with-blockchain-development/
Hyperledger Composer is both an application development framework and set of powerful tools which simplifies and expedites the creation of blockchain applications and smart contracts that are ultimately executed on the Hyperledger Fabric blockchain. Composer has its own runtime, that is generic chaincode and hosts and interprets the business network deployed - so your smart contract need only use Javascript, not chaincode in Go a (which is Fabric's domain) s you mentioned. It also has a modeling facility to create your business network model and to define such controls as Access Control lists and queries to be executed.
This architecture link should help you with further understanding -> https://www.slideshare.net/SimonStone8/hyperledger-composer-architecture
Furthermore see the Hyperledger Composer docs, see here:
https://hyperledger.github.io/composer/
TO see the Hyperledger Fabric docs - see here:
https://hyperledger-fabric.readthedocs.io/en/latest/

Resources