GetState query via chaincode always returns empty value

0 votes

I built a blockchain network 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 : https://github.com/hyperledger/fabric-samples/tree/release/chaincode/chaincode_example02

Jul 17, 2018 in Blockchain by sabby
• 4,370 points
1,717 views

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(github.com/miekg/pkcs11) in the vendor of the fabric source code in the image. This project is responsible for crypto stuffs. If you vendored github.com/miekg/pkcs11 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
2,983 views
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
3,062 views
0 votes
1 answer

Hyperledger : Deploying chaincode successful. But, cannot query - says ResourceNotFound

The problem(from logging) is dial unix /var/run/docker.sock: connect: ...READ MORE

answered Jun 21, 2018 in Blockchain by charlie_brown
• 7,720 points
1,008 views
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,462 views
+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
1,528 views
0 votes
1 answer

Unknown MSP DEFAULT error query chaincode

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

answered Jun 8, 2018 in Blockchain by Christine
• 15,790 points
813 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP