Uploaded image for project: 'Fabric'
  1. Fabric
  2. FAB-18166

Missing golang dependencies when using peer chaincode package

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Medium
    • Resolution: Done
    • v2.2.0, v1.4.8
    • None
    • fabric-peer, fabric-quality
    • None

    Description

      `peer chaincode package` misses some dependencies in the `vendor` folder. In my simple chaincode project: https://github.com/aldredb/chaincode1-with-shim
      I simply did:

      • go mod init
      • add "require github.com/hyperledge/fabric v1.4.8" in the go.mod file
      • go mod tidy
      • go mod vendor

      Examining the vendor folder, I have
      $ ls -al vendor/github.com
      total 0
      drwxr-xr-x 26 aldred staff 832 14 Aug 19:36 .
      drwxr-xr-x 8 aldred staff 256 14 Aug 19:36 ..
      drwxr-xr-x 3 aldred staff 96 14 Aug 19:36 Azure
      drwxr-xr-x 4 aldred staff 128 14 Aug 19:36 Microsoft
      drwxr-xr-x 4 aldred staff 128 14 Aug 19:36 containerd
      drwxr-xr-x 6 aldred staff 192 14 Aug 19:36 docker
      drwxr-xr-x 3 aldred staff 96 14 Aug 19:36 fsnotify
      drwxr-xr-x 3 aldred staff 96 14 Aug 19:36 fsouza
      ...
      then i did a peer chaincode package -n chaincode1 -v v1 -p chaincode1-with-shim chaincode1@v1.cds

      i extracted the cds file using cdstool  and examine the contents of the vendor folder inside the cds package
      ls -al src/chaincode1-with-shim/vendor/github.com
      total 0
      drwxr-xr-x 22 aldred staff 704 Aug 14 19:37 .
      drwxr-xr-x 7 aldred staff 224 Aug 14 19:37 ..
      drwxr-xr-x 3 aldred staff 96 Aug 14 19:37 containerd
      drwxr-xr-x 6 aldred staff 192 Aug 14 19:37 docker
      drwxr-xr-x 3 aldred staff 96 Aug 14 19:37 fsnotify
      drwxr-xr-x 3 aldred staff 96 Aug 14 19:37 fsouza
      ...
      as seen above, some dependency folders are missing, which results in failure in chaincode instantiation
      Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg failed to execute transaction fd549e47b4d3a1bfb1615d9028c30aae79437c9b4cd25e18d7cdc04f678a3447: error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/chaincode1-with-shim/vendor/github.com/docker/docker/pkg/archive/archive_linux.go:12:2: cannot find package "github.com/containerd/continuity/fs" in any of:
      /chaincode/input/src/chaincode1-with-shim/vendor/github.com/containerd/continuity/fs (vendor tree)
      /opt/go/src/github.com/containerd/continuity/fs (from $GOROOT)
      /chaincode/input/src/github.com/containerd/continuity/fs (from $GOPATH)
      /opt/gopath/src/github.com/containerd/continuity/fs
       
      I also see a difference between peer chaincode package using 2.2.0 binary and 1.4.8 binary.Using 1.4.8 binary:
      ls -al src/chaincode1-with-shim/vendor/github.com/containerd
      total 0
      drwxr-xr-x 3 aldred staff 96 Aug 14 19:57 .
      drwxr-xr-x 22 aldred staff 704 Aug 14 19:57 ..
      drwxr-xr-x 3 aldred staff 96 Aug 14 19:57 containerd
      Using 2.2.0 binary:
      ls -al src/chaincode1-with-shim/vendor/github.com/containerd
      total 0
      drwxr-xr-x 4 aldred staff 128 Jan 1 1970 .
      drwxr-xr-x 22 aldred staff 704 Jan 1 1970 ..
      drwxr-xr-x 3 aldred staff 96 Jan 1 1970 containerd
      drwxr-xr-x 5 aldred staff 160 Jan 1 1970 continuity

      Using the 2.2.0 binary, the missing dependency that caused instantiation error was included:
      github.com/containerd/continuity/fs so the instantiation works ok

       

      This issue does not occur if i package the chaincode using IBP VSCode extension

      Attachments

        Activity

          People

            Unassigned Unassigned
            caveman7 Aldred Benedict
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: