I'm using hyperleger fabric V1.4.4, I'm trying to enforce an endorsement policy including 2 organizations when upgrading, but when I do, The discovery service starts failing and the policy gets lost.
I verified that the anchor peers have been defined when joining the channel, so that doesn't seem to be the problem.
This is what I'm doing:
Initially this is the way I instantiated/upgrade my chaincode:
const gateway = new Gateway();
await gateway.connect(ccp, { wallet, identity: userId, discovery: { enabled: true, asLocalhost: false } });
const client = gateway.getClient();
const network = await gateway.getNetwork(channelName);
const channel = network.getChannel();
const peers = client.getPeersForOrg(orgName);
const txId = client.newTransactionID(true);
const deployId = txId.getTransactionID();
var request = {
targets : peers,
chaincodeId: ccName,
chaincodeType: ccType,
chaincodeVersion: ccVersion,
fcn: ccFunc,
args: ccArgs,
txId: txId
};
let upgradeResponse = await channel.sendUpgradeProposal(request, 300000);
This way the contract works the discovery service works too but I don't have the endorsement policy that I need so I changed the code this way:
var policy = {
identities: [
{ role: { name: "member", mspId: "org1" }},
{ role: { name: "member", mspId: "org2" }},
],
policy: {
"2-of": [{ "signed-by": 0 }, { "signed-by": 1 }]
}
}
var request = {
targets : peers,
chaincodeId: ccName,
chaincodeType: ccType,
chaincodeVersion: ccVersion,
fcn: ccFunc,
args: ccArgs,
txId: tx_id,
'endorsement-policy': policy
};
But then the discovery service starts failing with this error:
error: [Channel.js]: Channel:mychannel received discovery error:failed constructing descriptor for chaincodes:<name:"mycontract" >
I started looking at the discovery results using await channel.getDiscoveryResults()
and I can see that after adding the endorsement policy the endorsement gets lost.
Also I can see from the discovery results that I can only see the peers that I passed from my organization ccp, I don't see all the peers in the network but I can see all the orderers.
I think the problem is that doing the upgrade the discovery doesn't see the peers of all the orgs but I don't understand why.
I've tried removing the peers from the request but that doesn't seem to change the results. also I tried setting both peers in the request and I'm getting the next error:
Error: Peer with name "peer.xxxxxx.eastus.aksapp.io" not assigned to this channel
I've been lost with this issue for a while, is there a way for me to confirm that the anchor peers are working properly? is the way I'm doing the connection using the ccp blocking somehow the discovery process? what can I do to diagnose my problem?
this is how my ccp looks like:
{
"certificateAuthorities": {
"org1CA": {
"caName": "ca.org1",
"tlsCACerts": {},
"url": "https://ca.xxxxxxxx.eastus.aksapp.io:443"
}
},
"client": {
"connection": {
"timeout": {
"orderer": "300",
"peer": {
"endorser": "300"
}
}
},
"organization": "org1"
},
"name": "org1",
"organizations": {
"org1": {
"certificateAuthorities": [
"org1CA"
],
"mspid": "org1",
"peers": [
"peer1.org1"
]
}
},
"peers": {
"peer1.org1": {
"grpcOptions": {
"hostnameOverride": "peer1.xxxxxxxxxx.eastus.aksapp.io",
"ssl-target-name-override": "peer1.xxxxxxxxxx.eastus.aksapp.io"
},
"tlsCACerts": {},
"url": "grpcs://peer1.xxxxxxxxxx.eastus.aksapp.io:443"
}
},
"version": "1.0.0",
"wallet": "org1"
}
Thank you very much