How to keep one account consistent between the two channels in fabric network - hyperledger-fabric

There are three accounts A,B and C and two channels CH1 and CH2 in fabric network. There are a transaction between A and B in CH1 and another transaction between A and C in CH2.
My problem is that how to keep the account of A consistent between the two different ledgers about CH1 and CH2.

Typically, the data within a channel is restricted to that channel. It is possible to have some state external to the channel that is managed independently of the channel's ledger.
There is a new feature of Hyperledger Fabric in v1.2 (coming real soon... RC1 is available today) called SideDB that allows you to manage such data, though I am not certain that it would make sense to manage accounts in that manner.

The new SideDB feature, referred to as Private Data, is described here:
http://hyperledger-fabric.readthedocs.io/en/latest/private-data/private-data.html
and
http://hyperledger-fabric.readthedocs.io/en/latest/private-data-arch.html

Related

How to merge two different Hyperledger Fabric Networks to a single network with two different channels

I have two different Blockchain networks with HLF 1.4.1 with two parties A and B and A and C each having its own genesis block and single channel with some data.
Is there any way to merge these two networks in to one network with A, B, C as organizations and their individual channels data between A->B and A->C in the merged network?
How the genesis block and the crypto can be configured in the case?
The process of merging channels can be viewed as two.
First, there is a method of using an existing channel and a method of creating a new channel.
1. use existing channels
This is a method of participating C organization in the channel between A<->B through configtxlator.
See for details
fabric-1.4/channel_update \
Of course, B can participate in channel A<->C.
2. create a new channel
Create a new channel for A<->B<->C to participate
This is exactly the same as the existing channel creation process.
All of the above methods require data porting.
In case 1, it is necessary to update the state of the channel between B<->C to the new channel A<->B<->C.
In case 2, it is necessary to update all existing two channel state data.
This process should be done separately according to your taste. You can do it manually, or you can develop and apply an automated script.
Genesis block?
The configtxlator result from step 1 is updated in the channel. Due to the data structure of the blockchain, the existing Genesis block (0th height) does not disappear, but new configuration(add other organization) of the channel itself is reflected in the form of a newly added update block.
In the case of step 2, a new genesis block is created because it is completely newly constructed.
Crypto?
In the case of the crypto configuration, the existing organization can be used as it is without changing separately.

Using HLF peers for off ledger communication

I would like to leverage Hyperledger Fabric Peers (specifically identities) to communicate data that does not need to be recorded as a world state.
The Private Data Collection seems a step in that direction but everything is ordered and recorded.
Is there a way to send a payload between participants that does not get persisted?
Of course, every parameter sent is recorded in the channel's chain (but not in the world state unless your chaincode specifically does it).
Maybe you can save the payload (encrypted if you need it) in a distributed storage system (IPFS, for instance), share the IPFS hash/index via Fabric and delete from IPFS when it is no longer needed. I don't know if it fits your use case.

How to handle an event raised in one channel in a different channel in Hyperledger Composer of Fabric?

I have this scenario that a single node is part of different channels. In one channel there are only traders. In the other channel there are traders and regulator. Details of the trades should not be shared with the regulator. The only thing which is being shared is aggregated value at the end of the business day. By aggregated value, we mean how much of each asset is sold, not the detail of each trade. In other words there is confidential information between two parties that cannot be shared with regulator, and there is aggregated value that is not confidential and must be shared with the regulator.
Now I have an event when there is a nomination. By nomination I mean a trade made over some asset in the first channel, the one without regulator. Is it possible to handle this trading event in the other channel where the regulator is?
As I read through the documents, channels are isolated. But how isolated are they? Are they isolated in a way that events raised in one channel cannot be seen or handled in another channel? In that case, how do you suggest to implement this scenario? I mean do you suggest any specific architecture or tools enabling implementation of this scenario? Also do you think Hyperledger Fabric or Composer are suitable for these requirements?
I appreciate any help. Thank you.
So you have two channels, two separate ledgers and two separate business networks (as you've configured it).
Your 'nomination' is, in effect, a 'transaction' as described above. (events in Composer mean, business events that are usually subscribed to by a client application FYI).
In Hyperledger Composer, you can do 'cross-channel' or 'inter business network' queries. So can allow [only] the Regulator (from the 2nd channel) to query [only] those trade 'events' (ie transactions with the fields that contain the 'trade') or indeed assets (updated by the transaction), if need be - back in the '1st' channel (and access controls) in the 2nd channel can restrict the Regulator to do only that 'query' (if that's all he/she is supposed to have jurisdiction to do). Hope this helps.
See example
https://hyperledger.github.io/composer/latest/tutorials/invoke-composer-network

How to keep a digital asset in Hyperledger Fabric?

I'm working with the BYFN example using 3 organizations, 2 channels. One channel(c12) between Org1 and Org2, another channel (c23) between Org2 and Org3. The first chaincode is an example where I'm able to transfer value between "A" and "B". When I run the code over c12, I can see I'm able to transfer an amount from A to B. But when I query the same chaincode over c23, the initialization is kept. I understand why (different ledgers) and etc.
Now I would like to introduce the following requirement. I, as an organization, need to transfer this value only if I have the amount available.
The sequence would be:
1. I'm on org2, I have 100, and I wanna transfer 60 to org1. And everything works as expected.
2. I'm on org2, I have 40 and I'll try to transfer 50 to org3 (another ledger - channel). This should fail because I have only 40.
How can I achieve this?
Where will the "shared state" be stored? MSP?
The same approach would work for a complex asset?
Extra information:
- I already have read the documentation, about the assets, account model, the examples, but usually, they are focused only one channel only. Maybe I'm losing something.
- I'm not using hyperledger composer
In fabric you have a chaincode and a ledger different for each channel. so if you want to have the business logic descripted you need to use only one channel (with 3 orgs).
You can probably use private data to make the separation you are now doing with the two channels

How to maintain provenance in a network while using channels

I am wondering of how to maintain provenance in a network while using channels. In marbles example, lets say Regulator, Manufacturer, country dealer and retailers are transacting on a blockchain network.
Regulator,Manufacturer and dealer are transacting on Channel1 whereas dealer transact with retailer1 on Channel2 and with retailer2 on Channel3, just to keep privacy on selling price for different retailers. As marble1 was originated in Channel1 by the manufacturer , How do the same marble is available in Channel2 or Channel3 for transactions without duplicating the marble and keeping its provenance to Channel1.
I don't know how works the marbles example. However, I think that not all the participants could see all the information and provenance for a marble.
The dealer is in the three channels, so he would be duplicating the info in the three channels. The dealer would has an application that links all the info.
I believe that this issue is more related to the client application.
It is related to client code. A channel cannot send data to other channel due to privacy in fabric. One can implement state of transaction in application code. One way to achieve it through the application code could be to keep id of marble same in all channnels and then run GetHistoryForKey() method on different channel and then accumulate txns in one place in client app to arrive at a solution.

Resources