Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

hyperledger fabric - Facing issue "DiscoveryService: basic error: failed constructing descriptor for chaincodes" while submitting transaction through Nodejs SDK

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" > 
    at DiscoveryService.send (/usr/src/app/node_modules/fabric-common/lib/DiscoveryService.js:363:11)
    at async ContractImpl.getDiscoveryHandler (/usr/src/app/node_modules/fabric-network/lib/contract.js:231:13)
    at async Transaction.submit (/usr/src/app/node_modules/fabric-network/lib/transaction.js:190:43)
    at async tx (/usr/src/app/tx.js:21:16)
    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-----
MIICJjCCAc2gAwIBAgIUTVUhB44O0shRtEQRrWwSONwBVLswCgYIKoZIzj0EAwIw
cDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH
EwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjEwMTA4MTAyNzAwWhcNMzYwMTA1MTAyNzAw
WjBwMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExDzANBgNV
BAcTBkR1cmhhbTEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMT
Y2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBfr
nYwHd4KPh6A5VC7rEy/PBxGX/yb/MQe6S7JXCL1ceLRUa7JOsEaFRnqoVP0hGjWv
nfRpu60xHEb5ypkRtGOjRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG
AQH/AgEBMB0GA1UdDgQWBBQuKfHt6oR9p2LQzzjPZE673W+FmDAKBggqhkjOPQQD
AgNHADBEAiBMhPVZCDZ1oeGf5XFKBngc80Tt+MsPYIUzc7gzcttq2AIgQZsHm8dP
2cWNHIeoLdNcJ3yZB6eem80QQj08GFzepjA=
-----END CERTIFICATE-----
"
        },
        "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-----
MIICJjCCAc2gAwIBAgIUTVUhB44O0shRtEQRrWwSONwBVLswCgYIKoZIzj0EAwIw
cDELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMQ8wDQYDVQQH
EwZEdXJoYW0xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh
Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjEwMTA4MTAyNzAwWhcNMzYwMTA1MTAyNzAw
WjBwMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGggQ2Fyb2xpbmExDzANBgNV
BAcTBkR1cmhhbTEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMT
Y2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBfr
nYwHd4KPh6A5VC7rEy/PBxGX/yb/MQe6S7JXCL1ceLRUa7JOsEaFRnqoVP0hGjWv
nfRpu60xHEb5ypkRtGOjRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAG
AQH/AgEBMB0GA1UdDgQWBBQuKfHt6oR9p2LQzzjPZE673W+FmDAKBggqhkjOPQQD
AgNHADBEAiBMhPVZCDZ1oeGf5XFKBngc80Tt+MsPYIUzc7gzcttq2AIgQZsHm8dP
2cWNHIeoLdNcJ3yZB6eem80QQj08GFzepjA=
-----END CERTIFICATE-----
"
            ]
        },
        "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"
);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...