'fabric invoke chaincode error: Failed to get endorsing peers: no endorsement combination can be satisfied
I have set up my fabric network with 3 orderers in one organization and a consortium with 5 organizaitons successfully. Each organization has only one peer node and join in the same channel. And I have installed and instantiated two chaincodes in this channel. However, when I invoke chaincode by *channel.Client, sometimes it work correctly, and sometimes I get such an error:
Failed to get endorsing peers: Discovery status Code: (11) UNKNOWN. Description: error getting endorsers: no endorsement combination can be satisfied
this's my dev environment:
# os
Darwin PANZVORHONG-MB0 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
# golang
go version go1.15.6 darwin/amd64
# docker
Engine Version: 20.10.5
The following is same the configuration of Fabric which I think may be useful: configtx.yaml
Organizations:
- &OrdererOrg
Name: OrdererMSP
ID: OrdererMSP
MSPDir: ../fabric/organizations/ordererOrganizations/food.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
OrdererEndpoints:
- orderer1.food.com:7050
- orderer2.food.com:7049
- orderer3.food.com:7048
- &Producer
Name: ProducerMSP
ID: ProducerMSP
MSPDir: ../fabric/organizations/peerOrganizations/producer.food.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('ProducerMSP.admin', 'ProducerMSP.peer', 'ProducerMSP.client')"
Writers:
Type: Signature
Rule: "OR('ProducerMSP.admin', 'ProducerMSP.client')"
Admins:
Type: Signature
Rule: "OR('ProducerMSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('ProducerMSP.peer')"
AnchorPeers:
- Host: peer0.producer.food.com
Port: 7051
- &Processor
Name: ProcessorMSP
ID: ProcessorMSP
MSPDir: ../fabric/organizations/peerOrganizations/processor.food.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('ProcessorMSP.admin', 'ProcessorMSP.peer', 'ProcessorMSP.client')"
Writers:
Type: Signature
Rule: "OR('ProcessorMSP.admin', 'ProcessorMSP.client')"
Admins:
Type: Signature
Rule: "OR('ProcessorMSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('ProcessorMSP.peer')"
AnchorPeers:
- Host: peer0.processor.food.com
Port: 7051
...Similar configuration of other nodes
docker-compose.yaml
peer0.producer.food.com:
container_name: peer0.producer.food.com
image: hyperledger/fabric-peer:latest
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=food
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_NETWORKID=food
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
# Peer specific variabes
- CORE_PEER_ID=peer0.producer.food.com
- CORE_PEER_ADDRESS=peer0.producer.food.com:7051
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer0.producer.food.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.producer.food.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.producer.food.com:7051
- CORE_PEER_LOCALMSPID=ProducerMSP
- GODEBUG=netdns=go
volumes:
- /var/run/docker.sock:/host/var/run/docker.sock
- ../fabric/organizations/peerOrganizations/producer.food.com/peers/peer0.producer.food.com/msp:/etc/hyperledger/fabric/msp
- ../fabric/organizations/peerOrganizations/producer.food.com/peers/peer0.producer.food.com/tls:/etc/hyperledger/fabric/tls
- peer0.producer.food.com:/var/hyperledger/production
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
ports:
- 7051:7051
networks:
- food
peer0.processor.food.com:
container_name: peer0.processor.food.com
image: hyperledger/fabric-peer:latest
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=food
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_NETWORKID=food
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
# Peer specific variabes
- CORE_PEER_ID=peer0.processor.food.com
- CORE_PEER_ADDRESS=peer0.processor.food.com:7051
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer0.processor.food.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.processor.food.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.processor.food.com:7051
- CORE_PEER_LOCALMSPID=ProcessorMSP
- GODEBUG=netdns=go
volumes:
- /var/run/docker.sock:/host/var/run/docker.sock
- ../fabric/organizations/peerOrganizations/processor.food.com/peers/peer0.processor.food.com/msp:/etc/hyperledger/fabric/msp
- ../fabric/organizations/peerOrganizations/processor.food.com/peers/peer0.processor.food.com/tls:/etc/hyperledger/fabric/tls
- peer0.processor.food.com:/var/hyperledger/production
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
ports:
- 9051:7051
networks:
- food
...Similar configuration of other nodes
config.yaml for fabric-sdk-go
:
channels:
food-channel:
peers:
peer0.producer.food.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer0.processor.food.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
......
policies:
queryChannelConfig:
minResponses: 1
maxTargets: 1
retryOpts:
attempts: 5
initialBackoff: 500ms
maxBackoff: 5s
backoffFactor: 2.0
discovery:
maxTargets: 1
retryOpts:
attempts: 4
initialBackoff: 500ms
maxBackoff: 5s
backoffFactor: 2.0
eventService:
resolverStrategy: PreferOrg
balancer: Random
blockHeightLagThreshold: 5
reconnectBlockHeightLagThreshold: 10
peerMonitorPeriod: 5s
......
organizations:
producer:
mspid: ProducerMSP
# This org's MSP store (absolute path or relative to client.cryptoconfig)
cryptoPath: peerOrganizations/producer.food.com/users/{username}@producer.food.com/msp
peers:
- peer0.producer.food.com
processor:
mspid: ProcessorMSP
cryptoPath: peerOrganizations/processor.food.com/users/{username}@processor.food.com/msp
peers:
- peer0.processor.food.com
transporter:
mspid: TransporterMSP
......
peers:
peer0.producer.food.com:
url: localhost:7051
grpcOptions:
ssl-target-name-override: peer0.producer.food.com
keep-alive-time: 5s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
allow-insecure: false
tlsCACerts:
path: ./fixtures/fabric/organizations/peerOrganizations/producer.food.com/tlsca/tlsca.producer.food.com-cert.pem
......
entityMatchers:
peer:
# the below matcher will allow dynamic discovery to use the anchor peer (peer0.org1.example.com)
# as a template for all org1 discovered peers config
- pattern: (\w+).producer.food.com:(\d+)
urlSubstitutionExp: localhost:7051
sslTargetOverrideUrlSubstitutionExp: ${1}.producer.food.com
mappedHost: peer0.producer.food.com
- pattern: (\w+).processor.food.com:(\d+)
urlSubstitutionExp: localhost:9051
sslTargetOverrideUrlSubstitutionExp: ${1}.processor.food.com
mappedHost: peer0.processor.food.com
- pattern: (\w+).transporter.food.com:(\d+)
urlSubstitutionExp: localhost:7061
sslTargetOverrideUrlSubstitutionExp: ${1}.transporter.food.com
mappedHost: peer0.transporter.food.com
- pattern: (\w+).seller.food.com:(\d+)
urlSubstitutionExp: localhost:7071
sslTargetOverrideUrlSubstitutionExp: ${1}.seller.food.com
mappedHost: peer0.seller.food.com
- pattern: (\w+).consumer.food.com:(\d+)
urlSubstitutionExp: localhost:7081
sslTargetOverrideUrlSubstitutionExp: ${1}.consumer.food.com
mappedHost: peer0.consumer.food.com
orderer:
- pattern: (\w+).food.com:(\d+)
urlSubstitutionExp: localhost:7050
sslTargetOverrideUrlSubstitutionExp: orderer1.food.com
mappedHost: orderer1.food.com
- pattern: (\w+).food.com:(\d+)
urlSubstitutionExp: localhost:7049
sslTargetOverrideUrlSubstitutionExp: orderer2.food.com
mappedHost: orderer2.food.com
- pattern: (\w+).food.com:(\d+)
urlSubstitutionExp: localhost:7048
sslTargetOverrideUrlSubstitutionExp: orderer3.food.com
mappedHost: orderer3.food.com
I've been troubled by this problem for a long time. Can someone help me?
I have found the reason for this problem. That's because endorsers got from channel should be contained in the peers list which got by discovery
, or it will be filtered.
And there has always been only one endorser peer got from channel or discovery
. So, unless the two are equal, the endorsement is not satisfied. As a result, it may take several retries to succeed, or an error will be returned when the channel.policies.discovery.retryOpts.attempts
or channel.policies.discovery.retryOpts.maxBackoff
is reached.
Now the question is, why can only one endorser be obtained from the channel or found by discovery
? I tried to fix it by modifying some possible configurations in yaml, but they all failed.
Solution 1:[1]
In the config.yaml in the peers
section, you specified only a single peer peer0.producer.food.com
, add peer0.processor.food.com
there as well and sdk won't ignore it anymore. To understand why it's ignored you can enable debug logs in the SDK.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vladislav Kopaygorodsky |