Subsequent transactions do not update the ledger in Hyperledger Fabric, yield iconsistent state

ⅰ亾dé卋堺 提交于 2019-12-24 02:21:50

问题


I am working on a small project to get myself familiar with the Hyperledger Fabric.

Currently, I have a small network, consisting of single peer, orderer and ca nodes (plus cli, chaincode and explorer), defined in docker-compose.yml

I have installed sample chaincode, chaincode_example02 to be more specific The initial state of a ledger is A:100, B:200, defined by

peer chaincode instantiate -n mycc -v 0 -c '{"Args":["init","a","100","b","200"]}' -C myc

When I execute the transfer everything works as expected

peer chaincode invoke -n mycc -c '{"Args":["invoke","a","b","10"]}' -C myc

That is 10 units gets transfered from A to B

BUT when I run let's say 3 transactions,

for i in {1..3}
do
    peer chaincode invoke -n mycc -c '{"Args":["invoke","a","b","10"]}' -C myc
done

as a result I have three transactions in one block, but each of them identical, and as a result of those three transactions I have only 10 units transferred, whereas I would expect 30.

Do my question is: do I need to resort to the high throughoutput solution to have deterministic transactions? Or there is another way to achieve it (using events for example)?


回答1:


Having this three transactions in the same block would mean that only one is successful, since all three of them writing into same key. The transaction to succeed is the first one, while two remaining will be considered as concurrent and hence invalidated.

The result of chaincode simulation/invocation is the Read-Write set, where it contains keys, values and modification version. Transactions trying to modify key with same or outdated version fails the MVCC (Multi Value Concurrency Control) check during block commit.



来源:https://stackoverflow.com/questions/50238893/subsequent-transactions-do-not-update-the-ledger-in-hyperledger-fabric-yield-ic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!