0
votes

I'm working on setting Hyperledger Fabric network on AWS ECS. Here's my network network and bootstrap scenarios.

Network

  • ca-org0, ca-org1, ca-org2
  • orderer-org0
  • peer1-org1, peer1-org2

Bootstrap sceanrios

  1. All nodes are successfully started, create crypto materials, peers and orderers are registered and enrolled to CA ...
  2. create 'mychannel' channel
  3. join peer1-org1, peer1-org2 to 'mychannel'
  4. update both peers as anchor peer
  5. both peers install 'abac' sample chaincode
  6. peer1-org1 instantiate 'abac' chaincode to 'mychannel'
  7. test invoke and query

ECS

each node is ECS service with 1 task with networkMode awsvpc. and every service is created with AWS Service Discovery so each service can be look up with DNS. In my case peer1-org1 can be look up in vpc using peer1-org1.ns-t2c, orderer1-org0 as orderer1-org0.ns-t2c ...

ECS cluster diagram

Problem

I have been successfully done installing chaincode (step 5 in 'Bootstrap sceanrios') and chaincode container is created in EC2

peer1-org1:$ peer chaincode instantiate -C mychannel -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR('org1MSP.member','org2MSP.member')" -o orderer1-org0.ns-test

And this instantiate command successfully done w/o error and chaincode container is created on peer1-org1's EC2

peer1-org1's EC2:$ docker ps
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS              NAMES
3f7a488475cb        dev-peer1-org1.ns-t2c-mycc-1.0    "chaincode -peer.add…"   17 seconds ago      Up 16 seconds                         dev-peer1-org1.ns-t2c-mycc-1.0
<below is peer1-org1 container info>

But when I execute peer chaincode list --instantiated -C mychannel, No chaincode listed

peer1-org1:$ peer chaincode list --instantiated -C mychannel
Get instantiated chaincodes on channel mychannel:
peer1-org1:$

When queried 'abac' chaincode

peer1-org1$: peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Error: endorsement failure during query. response: status:500 message:"make sure the chaincode mycc has been successfully instantiated and try again: getccdata mychannel/mycc responded with error: could not find chaincode with name 'mycc'"

And here's peer task definition

{
  "family": "peer1-org1",
  "networkMode": "awsvpc",
  "containerDefinitions" : [
    {
      "name": "peer1-org1",
      "image": "hyperledger/fabric-ca-peer:1.2.0",
      "essential": true,
      "memory": 128,
      "command": ["/bin/bash", "-c", "'/scripts/ecs_start-peer.sh'"],
      "environment": [
        {"name": "FABRIC_CA_CLIENT_HOME", "value": "/data/peers/peer1-org1.ns-t2c"},
        {"name": "FABRIC_CA_CLIENT_TLS_CERTFILES", "value": "/data/org1-ca-chain.pem"},
        {"name": "ENROLLMENT_URL", "value": "http://peer1-org1.ns-t2c:[email protected]:7054"},
        {"name": "PEER_NAME", "value": "peer1-org1.ns-t2c"},
        {"name": "PEER_HOME", "value": "/data/peers/peer1-org1.ns-t2c"},
        {"name": "PEER_HOST", "value": "peer1-org1.ns-t2c"},
        {"name": "PEER_NAME_PASS", "value": "peer1-org1.ns-t2c:peer1-org1.ns-t2cpw"},
        {"name": "CORE_PEER_ID", "value": "peer1-org1.ns-t2c"},
        {"name": "CORE_PEER_ADDRESS", "value": "peer1-org1.ns-t2c:7051"},
        {"name": "CORE_PEER_LOCALMSPID", "value": "org1MSP"},
        {"name": "CORE_PEER_MSPCONFIGPATH", "value": "/data/peers/peer1-org1.ns-t2c/msp"},
        {"name": "CORE_VM_ENDPOINT", "value": "unix:///host/var/run/docker.sock"},
        {"name": "CORE_LOGGING_LEVEL", "value": "DEBUG"},
        {"name": "CORE_PEER_TLS_ENABLED", "value": "true"},
        {"name": "CORE_PEER_TLS_CERT_FILE", "value": "/data/peers/peer1-org1.ns-t2c/tls/server.crt"},
        {"name": "CORE_PEER_TLS_KEY_FILE", "value": "/data/peers/peer1-org1.ns-t2c/tls/server.key"},
        {"name": "CORE_PEER_TLS_ROOTCERT_FILE", "value": "/data/org1-ca-chain.pem"},
        {"name": "CORE_PEER_TLS_CLIENTAUTHREQUIRED", "value": "true"},
        {"name": "CORE_PEER_TLS_CLIENTROOTCAS_FILES", "value": "/data/org1-ca-chain.pem"},
        {"name": "CORE_PEER_TLS_CLIENTCERT_FILE", "value": "/data/tls/peer1-org1.ns-t2c-client.crt"},
        {"name": "CORE_PEER_TLS_CLIENTKEY_FILE", "value": "/data/tls/peer1-org1.ns-t2c-client.key"},
        {"name": "CORE_PEER_GOSSIP_USELEADERELECTION", "value": "true"},
        {"name": "CORE_PEER_GOSSIP_ORGLEADER", "value": "false"},
        {"name": "CORE_PEER_GOSSIP_EXTERNALENDPOINT", "value": "peer1-org1.ns-t2c:7051"},
        {"name": "CORE_PEER_GOSSIP_SKIPHANDSHAKE", "value": "true"},
        {"name": "ORG", "value": "org1"},
        {"name": "ORG_ADMIN_CERT", "value": "/data/orgs/org1/msp/admincerts/cert.pem"},
        {"name": "CORE_PEER_ADDRESSAUTODETECT", "value": "true"},
        {"name": "CORE_PEER_CHAINCODELISTENADDRESS", "value": "0.0.0.0:7052"},
        {"name": "CORE_VM_DOCKER_ATTACHSTDOUT", "value": "true"}
      ],
      "mountPoints": [
        {
          "containerPath": "/scripts",
          "sourceVolume": "scripts"
        },
        {
          "containerPath": "/data",
          "sourceVolume" : "data"
        },
        {
          "containerPath": "/host/var/run",
          "sourceVolume": "run"
        }
      ],
      "portMappings": [
        {
          "containerPort": 7051
        },
        {
          "containerPort": 7053
        }
      ]
    }
  ],
  "volumes": [
    {
      "name": "scripts",
      "host": {
        "sourcePath":"/efs/scripts"
      }
    },
    {
      "name": "data",
      "host": {
        "sourcePath": "/efs/data"
      }
    },
    {
      "name": "run",
      "host": {
        "sourcePath": "/var/run"
      }
    }
  ]
}

I've referenced here and here to reference peer ENV variables but no worked..

1
Hello, @zeroFruit, can you please provide any link or repository to deploy hyperledger fabric on aws ecs? - ajay

1 Answers

0
votes

I had the same problem: my chaincode was successfully installed and instantiated, but I also got the error: "could not find chaincode with name 'mycc'"

The cause in my situation was: The anchor peers had a incorrect hostname configured in configtx.yaml (example: Organizations > &Org > AnchorPeers > Host)

The solution for me was to set the hostname to the correct value.

Hope this helps anyone.