GetState query via chaincode always returns empty value

0 votes

I built a blockchain network following this doc: 

Every time I query the ledger via chaincode in which query is implemented by GetState (key), it always returns empty value, even if I can get the key/value pair by invoking GetStateByRange("","") which returns all the key/value pairs. 

These are the logs I inspected from the peer where the chaincode was installed on:

 2018-01-17 09:01:26.670 UTC [chaincode] processStream -> DEBU 961 [43697748]Received message GET_STATE from shim
    2018-01-17 09:01:26.670 UTC [chaincode] handleMessage -> DEBU 962 [43697748]Fabric side Handling ChaincodeMessage of type: GET_STATE in state rea
    2018-01-17 09:01:26.670 UTC [chaincode] afterGetState -> DEBU 963 [43697748]Received GET_STATE, invoking get state from ledger
    2018-01-17 09:01:26.670 UTC [chaincode] filterError -> DEBU 964 Ignoring NoTransitionError: no transition
    2018-01-17 09:01:26.670 UTC [chaincode] func1 -> DEBU 965 [43697748] getting state for chaincode test, key , channel chainplaza
    2018-01-17 09:01:26.671 UTC [stateleveldb] GetState -> DEBU 966 GetState(). ns=test, key=
    2018-01-17 09:01:26.671 UTC [chaincode] func1 -> DEBU 967 [43697748]No state associated with key: a. Sending RESPONSE with an empty payload
    2018-01-17 09:01:26.671 UTC [chaincode] 1 -> DEBU 968 [43697748]handleGetState serial send RESPONSE
    2018-01-17 09:01:26.671 UTC [chaincode] processStream -> DEBU 969 [43697748]Received message COMPLETED from shim
    2018-01-17 09:01:26.671 UTC [chaincode] handleMessage -> DEBU 96a [43697748]Fabric side Handling ChaincodeMessage of type: COMPLETED in state rea
    2018-01-17 09:01:26.671 UTC [chaincode] handleMessage -> DEBU 96b [43697748e1ea4c6f0f6af336f6c413583716c8ec1d59c10118ecfd49bf581509]HandleMessage
    2018-01-17 09:01:26.671 UTC [chaincode] notify -> DEBU 96c notifying Txid:43697748e1ea4c6f0f6af336f6c413583716c8ec1d59c10118ecfd49bf581509
    2018-01-17 09:01:26.671 UTC [chaincode] Execute -> DEBU 96d Exit

Here, [stateleveldb] GetState -> DEBU 966 GetState(). ns=test, key=, the key part is empty. If I am not wrong, in a blockchain working properly, the value of the key should be the parameter of GetState(key).

The chaincode I used is this :

Jul 17, 2018 in Blockchain by sabby
• 4,390 points

1 answer to this question.

0 votes

fabric uses an ccenv image to build the chaincode when you instantiate your chaincode. This images has a specified version of fabric source code in it's GOPATH to build the chaincode. I guess the version of fabric source code in the image should be the same with the source code used to build/compile fabric(including peer/order etc.). And there is a dependency project( in the vendor of the fabric source code in the image. This project is responsible for crypto stuffs. If you vendored in other chaincodes but with a different commit version, it seems it will cause conflicts. Remove it and all the problem will disapppear.

answered Jul 17, 2018 by Christine
• 15,790 points

Related Questions In Blockchain

+16 votes
4 answers
+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,100 points
0 votes
1 answer

Web3j Transfer.sendFunds() returns Error “insufficient funds for gas * price + value”

DISCLAIMER. This may not necessarily be an answer to your ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,720 points
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
+1 vote
1 answer

What happened on deploy, invoke and query in Hyperledger chaincode?

1. Deploy: During Deploy the chaincode is written onto ...READ MORE

answered Apr 26, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer

Unknown MSP DEFAULT error query chaincode

./ -m up After running the above command, ...READ MORE

answered Jun 8, 2018 in Blockchain by Christine
• 15,790 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP