hyperledger-fabrichyperledgercaliperhyperledger-caliper

Hyperledger Fabric/Hyperledger Caliper Benchmarking


Been learning a bit about both Hyperledger Fabric and Hyperledger Caliper recently.

Recently have been following the Hyperledger Caliper Fabric benchmarking tutorial here to learn a bit more about it.

It uses the Fabric Samples network as an example with the sample chaincode used being the asset-transfer-basic javascript.

When running caliper for creating 1000 assets for example.

I get an occasional error initializing the test during the asset creation operation, like this:

    2021-05-05T21:28:58.344Z - error: [DiscoveryHandler]: compareProposalResponseResults[undefined] - read/writes result sets do not match index=1
2021-05-05T21:28:58.344Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
    peer=undefined, status=grpc, message=Peer endorsements do not match
2021.05.05-22:28:58.344 error [caliper] [connectors/v2/FabricGateway]   Failed to perform submit transaction [CreateAsset] using arguments [0_231,blue,20,penguin,500],  with error: Error: No valid responses from any peers. Errors:
    peer=undefined, status=grpc, message=Peer endorsements do not match

The sample chaincode operation is pretty simple:

// CreateAsset issues a new asset to the world state with given details.
    async CreateAsset(ctx, id, color, size, owner, appraisedValue) {
        const asset = {
            ID: id,
            Color: color,
            Size: size,
            Owner: owner,
            AppraisedValue: appraisedValue,
        };
        ctx.stub.putState(id, Buffer.from(JSON.stringify(asset)));
        return JSON.stringify(asset);
    }

Is there any particular reason errors like this happen? Even if occasionally.


Solution

  • The tutorial in caliper explicitly checks out a specific tag in the fabric-samples. This is because there is a bug in the chaincode examples in the main branch which isn't present in the specific git commit. That bug causes the problem you are seeing You have actually included that bug in the snippet you posted. In the chaincode it's the line

    ctx.stub.putState(id, Buffer.from(JSON.stringify(asset)));
    

    which is incorrect. It should be

    await ctx.stub.putState(id, Buffer.from(JSON.stringify(asset)));