Reporting without chaincode on hyperledger fabric peer - hyperledger-fabric

Can we implement a channel between two peers and initiate a transaction just to store data without any chaincode or smartcontract? If yes any example

No. The only way to put/get state is via chaincode.

Related

Is it possible to list endorsing peers of a chaincode in the application?

In Hyperledger ledger, how could I list endorsing peers of a specific chaincode?
I have a channel with 5 peers but I need that only three of them endorse a transaction while the other two need only to access to same ledger.
You can use the discovery service to get the endorsing peer. Here you can find some information:
https://hyperledger-fabric.readthedocs.io/en/latest/discovery-overview.html
Hyperledger fabric has a CLI tool to query the discovery service:
https://hyperledger-fabric.readthedocs.io/en/latest/discovery-cli.html
For node.js applications, you can follow the tutorial here:
https://hyperledger.github.io/fabric-sdk-node/release-1.4/tutorial-discovery.html
With the latest Fabric Client SDKs (personally using GO client), you don't need to deal with endorsement policies. Client SDK already does this dirty work for you. It extracts:
Which organizations' endorsements are required for this chaincode, key (key level endorsement policy can be defined as well), etc.
Which peers currently exist in the system and what are their MSPs (from discovery service).
According to these information, client SDK builds a set of necessary peers then sends your transaction request to all. It waits response from requested endorsers. Once it collects all responses, it sends to orderer and so on.
If you have a special case which you need to manually set endorsing peers of your choice (I had one use case about private collections so I had to use this approach) check out discovery service API of your client SDK.

Can I query Hyperledger Fabric ledger or update ledger without chaincode in peer?

I have simple question about Hyperledger Fabric. so here is my question:
I know that for committing peers (ordinary peers) it's not 100% necessary to have chaincode installed, but every peer should have ledger and that's 100% necessary.
so suppose I am committing peer and I have not chaincode installed, but I have ledger of course. Now new block arrives from ordering peer.
1) I should check blocks validity, so I need to query ledger
2) I should add this block, so I need to update ledger.
So how can I do this two above without chaincode? Isn't chaincode necessary for above operations? (query and update)
To check the transaction/block's validity, the peer does not need to have the chaincode, the readwrite set available in the transaction is compared against the ledger (available in all peer) to decide the validity.
And adding the block to the ledger is not dependent upon the validity check. If it was found invalid, it will still be added to the ledger but with an invalid tag.
You cannot query a peer without having a chaincode. Must need chaincode installed in the peer in order to query | invoke.
Hyperledger Fabric has two types of peers
1) Endorsing peers
2) Committing Peers
Endorsing peers must need a chaincode which means you need to install chaincode on endorsing peers because its duty is to make sure the transaction owner has sufficient rights and it simulates that transaction against the ledger for that it needs a chaincode interface in order to complete simulation.
Once the simulation is done it sends back the R/W sets and simulation result to client and client will send this to the orderer
Orderer then distributes to committing peers ( No need to install chaincode)
Whole: Applications generate a transaction proposal which they send to each of the required set of peers for endorsement. Each of these endorsing peers then independently executes a chaincode using the transaction proposal to generate a transaction proposal response. It does not apply this update to the ledger, but rather simply signs it and returns it to the application.

Difference between Endorsing Peer and Committing peer in Hyperledger Fabric?

I am quit confused with these two peers since I am new to Fabric. If any body help me with this.
Endorsing peers are basically approvers.
A transaction has to be proposed and then endorsed before it can be submitted successfully to the blockchain.
Endorsing peer is the peer that will "endorse"/provide the seal of approval to a transaction when it is proposed. After the transaction is endorsed, the transaction(plus the endorsement) will be submitted to blockchain.
Once the Transaction is submitted, it will make way to the peers that are supposed to get that transaction. These peers will then "commit"/save the transaction in their Ledger, and these are the committer peers.
The committing peers and endorsing peers can be the same peers sometimes.
To understand the difference among those Peers, I thinks that it is important to know where takes part its Peer in the flow of a transaction of Hyperledger Fabric.
A proposal is send to the Endorser Peers. These Peers verify the proposal, execute it and send the reply signed to the client.
The client inspect those replies. If they result is succesfull, it generates a new transaction with the replies of the Endorser Peers and sends it to the Ordering Service.
The Ordering Service executes its operations and sends the block to the corresponding Peers, i.e. the Commiters.
The Commiters append each block to the corresponding ledger.
As #adnan.c said:
"The committing peers and endorsing peers can be the same peers
sometimes."

Chaincode should only be installed on endorsing peer nodes?

According to hyperledger fabric documentation, the chaincode should only be deployed in endorsing peers, and it says still the non endorsing peers can validate and update the ledger. Now I am bit confused if non endorsing peers don't have a chaincode, how can they generate R/W sets. How the non endorsing peers will be able to create new state for the asset, if they aren't aware of the logic (chaincode) behind it ?
If you look at https://hyperledger-fabric.readthedocs.io/en/release-1.1/txflow.html#, you'll find a section that states:
The blocks of transactions are “delivered” to all peers on the channel. The transactions within the block are validated to ensure endorsement policy is fulfilled and to ensure that there have been no changes to ledger state for read set variables since the read set was generated by the transaction execution. Transactions in the block are tagged as being valid or invalid.
A block is an ordered set of transactions and transactions include the state transitions in the form of read/write sets. The output of endorsement is actually the read/write set and these are what are ordered and delivered to all peers in the channel.
In order to validate a transaction, a peer needs to check the following:
Is the transaction well-formed
Was the endorsement policy met (the
endorsement policy is distributed to all peers in a channel when
chaincode is instantiated even if the peer does not have the
chaincode bytes)
MVCC check
In order to do the above, peers do not need to execute the chaincode itself.

how to know all peers who have joined channel

From hyperledger fabric, peer channel join -b helloch.block command which peer join channel does not generate block which will send to all peers.
So, when other organization peer have joined the channel, we do not know.
I consider it should generate a block to notify any other peer. Is there other ideas?
There is no way of listing all peers which joined the channel in current version of Hyperledger Fabric, however there is a work in progress FAB-5451 to implement service discovery so peer will be able to expose these type of information to the clients.

Resources