1
votes

I am trying to instantiate chaincode in Hyperledger Fabric peer 1.1.0. I have downloaded 1.1.0 version fabric samples and docker containers. The fabcar application got instantiated successfully.

However when I instantiate my chaincode, the peer quits with the following error.

2019-06-29 12:01:47.916 UTC [kvledger] CommitWithPvtData -> INFO 042 Channel [mychannel]: Committed block [3] with 1 transaction(s)
panic: assignment to entry in nil map

goroutine 569 [running]:
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.createCouchdbDocJSON(0xc422170890, 0x6, 0x0, 0x0, 0xc422170898, 0x4, 0x4, 0xc422170ae0, 0xc42001e000, 0xc42001e070, ...)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:984 +0x1d8
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).processUpdateBatch(0xc4215691d0, 0xc4217c7df0, 0x0, 0x0, 0x0, 0xc422170898, 0x4)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:669 +0x550
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).ApplyUpdates.func1(0xc422170eb0, 0xc42000eb68, 0xc4215691d0, 0xc422197140, 0xc422170870, 0x7)
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:577 +0x8a5
created by github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*VersionedDB).ApplyUpdates
        /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:509 +0x11d

As I can see above, it is not taking go code from $GOPATH which is /home/ubuntu/software/golang.

I have installed the fabric and samples using the command.

as mentioned in

https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html

passing arguments "1.1.0 1.1.0 0.4.15"

I could see that the chaincode init method gets executed from the application logs.

func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
        fmt.Println("Init firing.")

    // Initialize the collection of commercial paper keys
    fmt.Println("Initializing user accounts")
    //t.createUser(stub, []string{"importerBank", "importerBank", "Importer Bank"})
    //t.createUser(stub, []string{"customs", "customs", "Customs"})
    //t.createUser(stub, []string{"exporterBank", "exporterBank", "Exporter Bank"})
    //t.createUser(stub, []string{"exporter", "exporter", "Exporter"})

    fmt.Println("Initializing LC keys collection if not present")
    valAsbytes, err := stub.GetState("LCKeys")
    if err == nil {
            var keys []string
            err = json.Unmarshal(valAsbytes, &keys)
            fmt.Println("Existing LC : %v", keys);
            if len(keys) > 0 {
                    for _, key := range keys {
                            valAsbytes, err := stub.GetState(key)
                            if err == nil {
                                    var lc LC
                                    err = json.Unmarshal(valAsbytes, &lc)
                                    if err == nil {
                                            if lc.CurrentStatus == "" {
                                                    lc.CurrentStatus = "Created"
                                                    keysBytesToWrite, _ := json.Marshal(lc)
                                                    if err == nil {
                                                            err = stub.PutState(key, keysBytesToWrite)
                                                            if err != nil {
                                                                    fmt.Println("Error writing LC to chain" + err.Error())
                                                            }
                                                    }
                                            }
                                    }
                            }
                    }
            }
    }

    fmt.Println("Initialization complete")
  1. I would like to know why the peer quits? orderer.example.com: container_name: orderer.example.com image: hyperledger/fabric-orderer environment:
    • ORDERER_GENERAL_LOGLEVEL=debug
    • ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
    • ORDERER_GENERAL_GENESISMETHOD=file
    • ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
    • ORDERER_GENERAL_LOCALMSPID=OrdererMSP
    • ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
    • GODEBUG=netdns=go working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer command: orderer ports:
    • 7050:7050 volumes:
      • ./config/:/etc/hyperledger/configtx
      • ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer
      • ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1 networks:
    • basic
1
Cant you show whats there in your docker compose file. - Risabh Sharma

1 Answers

1
votes

Try adding - GODEBUG=netdns=go in the environment section of the docker compose file for every peer and orderer.