1

I am running the Fabric network on the docker swarm. I am able to perform transactions and queries through CLI but facing this issue when invoking the transaction from the NodeJS SDK. I am using the test-network provided in the fabric sample with some additions to it. I am using the default endorsement policies

{
"message": "DiscoveryService: basic error: failed constructing descriptor for chaincodes:<name:\"basic\" > ",
"stack": "Error: DiscoveryService: basic error: failed constructing descriptor for chaincodes:<name:\"basic\" > \n    at DiscoveryService.send (/usr/src/app/node_modules/fabric-common/lib/DiscoveryService.js:363:11)\n    at async ContractImpl.getDiscoveryHandler (/usr/src/app/node_modules/fabric-network/lib/contract.js:231:13)\n    at async Transaction.submit (/usr/src/app/node_modules/fabric-network/lib/transaction.js:190:43)\n    at async tx (/usr/src/app/tx.js:21:16)\n    at async /usr/src/app/app.js:34:18"}

and the peer logs are

2021-01-08 16:46:44.687 UTC [comm.grpc.server] 1 -> INFO 0a0 unary call completed grpc.service=discovery.Discovery grpc.method=Discover grpc.peer_address=10.0.1.211:40120 grpc.peer_subject="CN=fabric-common" grpc.code=OK grpc.call_duration=549.379µs
2021-01-08 16:46:44.731 UTC [discovery] chaincodeQuery -> ERRO 0a1 Failed constructing descriptor for chaincode chaincodes:<name:"basic" > ,: no peer combination can satisfy the endorsement policy

This is my connection profile:

{
"name": "test-network-org1",
"version": "1.0.0",
"client": {
    "organization": "Org1",
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300"
            }
        }
    }
},
"organizations": {
    "Org1MSP": {
        "mspid": "Org1MSP",
        "peers": [
            "peer0.org1.example.com"
        ],
        "certificateAuthorities": [
            "ca.org1.example.com"
        ]
    }
},
"peers": {
    "peer0.org1.example.com": {
        "url": "grpcs://peer0.org1.example.com:7051",
        "tlsCACerts": {
            "pem": "-----BEGIN CERTIFICATE-----\nMIICJjCCAc2gAwIBAgIUTVUhB44O0shRtEQRrWwSONwBVLswCgYIKoZIzj0EAwIw\ncDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH\nEwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMjEwMTA4MTAyNzAwWhcNMzYwMTA1MTAyNzAw\nWjBwMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExDzANBgNV\nBAcTBkR1cmhhbTEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMT\nY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBfr\nnYwHd4KPh6A5VC7rEy/PBxGX/yb/MQe6S7JXCL1ceLRUa7JOsEaFRnqoVP0hGjWv\nnfRpu60xHEb5ypkRtGOjRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG\nAQH/AgEBMB0GA1UdDgQWBBQuKfHt6oR9p2LQzzjPZE673W+FmDAKBggqhkjOPQQD\nAgNHADBEAiBMhPVZCDZ1oeGf5XFKBngc80Tt+MsPYIUzc7gzcttq2AIgQZsHm8dP\n2cWNHIeoLdNcJ3yZB6eem80QQj08GFzepjA=\n-----END CERTIFICATE-----\n"
        },
        "grpcOptions": {
            "ssl-target-name-override": "peer0.org1.example.com",
            "hostnameOverride": "peer0.org1.example.com"
        }
    }
},
"certificateAuthorities": {
    "ca.org1.example.com": {
        "url": "https://ca.org1.example.com:7054",
        "caName": "ca-org1",
        "tlsCACerts": {
            "pem": [
                "-----BEGIN CERTIFICATE-----\nMIICJjCCAc2gAwIBAgIUTVUhB44O0shRtEQRrWwSONwBVLswCgYIKoZIzj0EAwIw\ncDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH\nEwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMjEwMTA4MTAyNzAwWhcNMzYwMTA1MTAyNzAw\nWjBwMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExDzANBgNV\nBAcTBkR1cmhhbTEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMT\nY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBfr\nnYwHd4KPh6A5VC7rEy/PBxGX/yb/MQe6S7JXCL1ceLRUa7JOsEaFRnqoVP0hGjWv\nnfRpu60xHEb5ypkRtGOjRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG\nAQH/AgEBMB0GA1UdDgQWBBQuKfHt6oR9p2LQzzjPZE673W+FmDAKBggqhkjOPQQD\nAgNHADBEAiBMhPVZCDZ1oeGf5XFKBngc80Tt+MsPYIUzc7gzcttq2AIgQZsHm8dP\n2cWNHIeoLdNcJ3yZB6eem80QQj08GFzepjA=\n-----END CERTIFICATE-----\n"
            ]
        },
        "httpOptions": {
            "verify": false
        }
    }
}

}

my docker-compose file

enter image description here

This the Nodejs code

const ccp = buildCCPOrg1();

const wallet = await buildWallet(Wallets, walletPath);
const gateway = new Gateway();

await gateway.connect(ccp, {
    wallet,
    identity: request.org1UserId,
    discovery: { enabled: true, asLocalhost: false },
});
console.log(gateway);
const network = await gateway.getNetwork(request.channelName);

const contract = network.getContract(request.chaincodeName);

var result = await contract.submitTransaction(
    "CreateAsset",
    Date.now().toString(),
    "yellow",
    "5",
    "Tom",
    "1300"
);
Aditya Joshi
  • 1,033
  • 7
  • 20

1 Answers1

0

I found the solution to this error. In my case, the error was due to anchor peers. When I created the channel and joined the channel, I forgot to update the anchor peers. Since my chaincode was using default endorsement policies(i was having 3 ORGs network) which is AND policy. That's why I was getting this error.

Anchor peers are used for cross-organization communications and my anchor peers were not having the information of other organizations as they were not updated after the channel join.

Aditya Joshi
  • 1,033
  • 7
  • 20